h4kuna / ares
通过从捷克共和国的 ARES 数据库(按识别号)提供主题信息。
v3.0.9
2024-09-10 13:29 UTC
Requires
- php: >=8.0
- ext-curl: *
- ext-json: *
- ext-simplexml: *
- nette/utils: ^2.0 || ^3.0 || ^4.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0.1 || ^2.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.5
- nette/tester: ^2.4
- phpstan/phpstan: ^1.8
- phpstan/phpstan-strict-rules: ^1.4
- tracy/tracy: ^2.9
Suggests
- guzzlehttp/guzzle: As default implementation for PSR-7, PSR-17 and PSR-18 standards.
- dev-master
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.0.5
- v2.0.4
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v1.4.14
- v1.4.13
- v1.4.12
- v1.4.11
- v1.4.10
- v1.4.9
- v1.4.8
- v1.4.7
- v1.4.6
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-address-fallback
This package is auto-updated.
Last update: 2024-09-16 06:45:37 UTC
README
关于版本的其他信息请见 变更日志。
通过二维码支持开发
在 revolut 的链接位置使用二维码或赞助按钮。
谢谢 :)
项目安装
安装 h4kuna/ares 的最佳方式是使用 Composer
composer require h4kuna/ares
# optional and default support
composer require guzzlehttp/guzzle
通过客户的 IN 下载客户信息。
ARES
开发者主页 文档。
按一个识别号加载数据。
use h4kuna\Ares; $ares = (new Ares\AresFactory())->create(); try { $response = $ares->loadBasic('87744473'); /* @var $response Ares\Ares\Core\Data */ var_dump($response); } catch (Ares\Exceptions\IdentificationNumberNotFoundException $e) { // log identification number, why is bad? Or make nothing. } catch (Ares\Exceptions\AdisResponseException $e) { // if validation by adis failed, but data from ares returned /* @var $response Ares\Ares\Core\Data */ $response = $e->data; $response->adis === null; // true var_dump($e->getMessage()); } catch (Ares\Exceptions\ServerResponseException $e) { // no response from server or broken json }
按多个识别号加载数据。ARES 服务的限制设置为 100 项,但库将其分块并检查重复项。
use h4kuna\Ares; /** @var Ares\Ares $ares */ $numbers = ['one' => '25596641', 'two' => '26713250', 'three' => '27082440', 'four' => '11111111']; try { foreach ($ares->loadBasicMulti($numbers) as $name => $r) { var_dump($name, $r->company); } } catch (Ares\Exceptions\ServerResponseException $e) { // no response from server or broken json }
其他端点
从类 Sources 选择端点。
- SERVICE_* - 可用的其他端点
- CORE - 是主要端点,在方法
$ares->loadBasic()
中使用 - DIAL - 如果你想列出值,例如
PravniForma
- SER_NO_* 不存在
use h4kuna\Ares; /** @var Ares\Ares $ares */ $result = $ares->getAresClient()->useEndpoint(Ares\Ares\Sources::SERVICE_VR, '27082440'); var_dump($result);
拨号
参数 kodCiselniku
和 zdrojCiselniku
你可以在本页面的 json 文件中找到,如 AresRestApi-verejne_v*.json,例如 ciselnikKod: PravniForma, zdroj: res
。
use h4kuna\Ares; /** @var Ares\Ares $ares */ $result = $ares->getAresClient()->searchEndpoint(Ares\Ares\Sources::DIAL, [ 'kodCiselniku' => 'PravniForma', 'zdrojCiselniku' => 'res', ])->ciselniky[0]->polozkyCiselniku; foreach ($result as $item) { var_dump($item); }
数据盒(datová schánka)
use h4kuna\Ares; /** @var Ares\Ares $ares */ try { $response = $ares->loadDataBox('87744473'); var_dump($response->ISDS); } catch (h4kuna\Ares\Exceptions\ServerResponseException $e) { // catch error }
VIES
支持 基本检查。
use h4kuna\Ares; /** @var Ares\Ares $ares */ try { $response = $ares->checkVatVies($vatNumber); var_dump($response->valid); // true / false } catch (Ares\Exceptions\ServerResponseException $e) { // invalid VAT }