grena / oxatis-api-php-client
Oxatis API 客户端
v1.0.0
2021-06-24 10:19 UTC
Requires
- php: >=7.1
- goetas-webservices/xsd2php-runtime: v0.2.15
- jms/serializer: ^3.12
- php-http/client-common: ^2.1
- php-http/discovery: ^1.7
- php-http/httplug: ^2.1
- php-http/message: ^1.8
- php-http/message-factory: ^1.0
- php-http/multipart-stream-builder: ^1.0
- phpro/soap-client: ^1.6
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0
- psr/http-message-implementation: ^1.0
Requires (Dev)
- donatj/mock-webserver: ^2.0
- friendsofphp/php-cs-fixer: ^2.14
- goetas-webservices/xsd2php: 0.4.3
- http-interop/http-factory-guzzle: ^1.0
- laminas/laminas-code: ^3.1.0
- php-http/guzzle6-adapter: ^2.0
- phpspec/phpspec: ^7.1.0
- phpunit/phpunit: ^9.5.5
- symfony/yaml: ^4.2
Suggests
- php-http/guzzle6-adapter: In order to use Guzzle v6 as the HTTP client
This package is auto-updated.
Last update: 2024-09-19 10:48:15 UTC
README
这是一个适用于任何 Oxatis SaaS 实例的 PHP API 客户端。
要求
- PHP >= 7.4
- Composer
安装
composer require grena/oxatis-api-php-client
如何使用
在你的项目中,导入 OxatisClientBuilder
并使用你的 Oxatis AppID 和 token 构建客户端
use Heavymind\Oxatis\ApiClient\OxatisClientBuilder; // Build the Oxatis client with your AppID and Token $clientBuilder = new OxatisClientBuilder(); $oxatisClient = $clientBuilder->buildAuthenticatedByToken( "OXATIS_APP_ID", "OXATIS_TOKEN" );
现在你可以使用 OxatisClient
来发送请求,例如这里,检索每个税率对应的“国家名称”
use Heavymind\Oxatis\ApiClient\Type\TaxRateGetList; use Heavymind\Oxatis\ApiClient\Type\TaxRateEntity; $response = $oxatisClient->getTaxRateServices()->taxRateGetList( new TaxRateGetList($oxatisClient->getWSIdentitySoap()) ); foreach ($response->getDataResultService()->getData()->getTaxRateList()->getTaxRateIDs() as $taxRateID) { /** @var TaxRateEntity $taxRateID */ var_dump($taxRateID->getCountryName()); }
重新生成 API
此 API 主要通过 phpro/soap-client
自动生成。
如果 Oxatis 端的在线 Soap WSDL 文件已更改,则此 API 客户端 需要通过运行以下命令重新生成
docker-compose run php_74 php generate-soap-api.php
这将
- 在
config/
文件夹中生成phpro/soap-client
需要的配置文件 - 在
src/Type
中为每个服务生成每个类型类 - 在
src/Services/
中为每个服务生成客户端和客户端工厂
贡献
克隆此项目,然后
cp docker-compose.yml.dist docker-compose.yml docker-compose up --build docker-compose run php_74 ./composer.phar install