mmierzynski / gus-api-bundle
Symfony 扩展包,允许在 GUS 数据库中搜索数据
0.2
2022-10-29 13:38 UTC
Requires
- php: >=7.1
- ext-json: *
- ext-simplexml: *
- ext-soap: *
- symfony/framework-bundle: ^6.0
- symfony/serializer: ^6.0
- symfony/validator: ^6.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.12
- phpmd/phpmd: ^2.13
- phpunit/phpunit: ^7.0 | ^8.0 | ^9.0
This package is auto-updated.
Last update: 2024-09-29 06:03:24 UTC
README
描述
Symfony 6 扩展包,允许从 REGON GUS API 获取信息
安装
composer require mmierzynski/gus-api-bundle
使用
配置
# config/packages/gus_api.yaml gus_api: regon: env: test api_key: 'abcde12345abcde12345'
- env - [必需] GUS API 环境。接受值:test,prod
- api_key - [必需] 您的 API 密钥。对于测试环境,您可以使用:abcde12345abcde12345
使用
登录用户
use MMierzynski\GusApi\Client\RegonApiClient; use MMierzynski\GusApi\Exception\InvalidUserCredentialsException; public function index(RegonApiClient $client): JsonResponse { if (!$client->isUserLogged()){ try{ $accessKey = $client->login(); } catch (InvalidUserCredentialsException $credentialsException) { // do something } } ... }
搜索公司
use MMierzynski\GusApi\Client\RegonApiClient; use MMierzynski\GusApi\Model\DTO\Request\SearchCompanyParams; public function index(RegonApiClient $client): JsonResponse { ... $searchParams = new SearchCompanyParams(Nip:'8992689516'); $company = $client->searchForCompany($accessKey, $searchParams); ... }
获取完整报告
use MMierzynski\GusApi\Client\RegonApiClient; public function index(RegonApiClient $client): JsonResponse { ... $fullReport = $client->getFullReport( $accessKey, '000331501', 'BIR11OsPrawna' ); ... }
获取摘要报告
use MMierzynski\GusApi\Client\RegonApiClient; public function index(RegonApiClient $client): JsonResponse { ... $reportDate = (new DateTimeImmutable())->setDate(2014, 11, 7); $summaryReport = $client->getSummaryReport( $accessKey, 'BIR11NowePodmiotyPrawneOrazDzialalnosciOsFizycznych', $reportDate ); ... }