bricre / ebay-api-sell-recommendation
1.1.0.1
2021-09-02 00:40 UTC
Requires
- allansun/openapi-runtime: ^2.1
Requires (Dev)
- allansun/openapi-code-generator: ^0.2.5
- allansun/openapi-parser: ^2.1.4
This package is auto-updated.
Last update: 2022-05-04 16:07:47 UTC
README
使用allansun/openapi-code-generator从eBay的Swagger文件生成的代码。
生成的代码具有良好的自文档,带有适当的PHPDoc注释。
请参阅eBay的文档以获取详细的API行为说明。
安装
composer require bricre/ebay-api-sell-recommendation
您还需要一个基于 PSR-7 的客户端或 Symfony的HTTP Foundation基于的客户端
因此,您可以使用Guzzle(或任何其他PSR-7兼容客户端)
composer require guzzlehttp/guzzle
或 Symfony HTTP客户端
composer require symfony/http-client
版本控制
从版本1.1.0开始,此项目将匹配eBay API的版本。如果您发现没有提供匹配的版本,请联系作者以生成正确的版本。
使用方法
首先,您需要使用所需凭据和预定义的响应类型配置 OpenAPI\RunTime\Client。您只需这样做一次(或在您的依赖注入中创建一个服务)。
<?php use Ebay\Sell\Account\ResponseTypes; use OpenAPI\Runtime\DefaultResponseHandlerStack; use OpenAPI\Runtime\Client; use OpenAPI\Runtime\SimplePsrResponseHandlerStack; Client::configure( new \GuzzleHttp\Client([ 'base_uri' => 'https://api.ebay.com/sell/recommendation/v1/', 'headers'=>[ 'Authorization'=> 'Bearer <accessToken>' ] ]), new SimplePsrResponseHandlerStack(new ResponseTypes()) );
然后,在您的业务逻辑中,您可以直接调用API操作
<?php use Ebay\Sell\Account\Api\PaymentsProgram; use Ebay\Sell\Account\Api\Program; $programAPI = new Program(); $programs = $programAPI->getOptedIns(); $paymentsProgramAPI = new PaymentsProgram(); $response = $paymentsProgramAPI->get('marketplace_id','payments_programe_type');
作者
- Allan Sun - 初始工作