sapientpro / ebay-account-sdk-php
eBay 账户 API
v1.0.0
2023-06-27 14:50 UTC
Requires
- php: ^8.1
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- phpdocumentor/reflection-docblock: ^5.3
- symfony/property-access: ^6.2
- symfony/serializer: ^6.2
- symfony/validator: ^6.3
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.2
- squizlabs/php_codesniffer: ^3.6
This package is not auto-updated.
Last update: 2024-09-23 16:53:52 UTC
README
账户 API 使卖家能够配置他们的 eBay 卖家账户,包括卖家的政策(eBay 商业政策和卖家定义的自定义政策)、选择加入或退出 eBay 卖家计划、配置销售税表和获取账户信息。
关于此 API 中方法可用性的详细信息,请参阅 <a href="/api-docs/sell/account/overview.html#requirements">账户 API 要求和限制。
此 PHP 包由 Swagger Codegen 项目自动生成
- API 版本:v1.9.0
- 打包构建:io.swagger.codegen.v3.generators.php.PhpClientCodegen
要求
- PHP 8.1 或更高版本
- 启用 ext-json 和 ext-curl 扩展
安装和用法
使用 composer 安装此包
composer require sapientpro/ebay-account-sdk-php
示例用法
请遵循 安装程序,然后运行以下命令
<?php use SapientPro\EbayAccountSDK\Configuration; use SapientPro\EbayAccountSDK\Api\CustomPolicyApi; use SapientPro\EbayAccountSDK\Models\CustomPolicyCreateRequest; use SapientPro\EbayAccountSDK\Enums\MarketplaceIdEnum; use SapientPro\EbayAccountSDK\Enums\CustomPolicyTypeEnum; // Configure OAuth2 access token for authorization: api_auth $config = Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new CustomPolicyApi( // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. // This is optional, `GuzzleHttp\Client` will be used as default. ebayClient: GuzzleHttp\Client(), config: $config ); // you can create and fill a Model class that implements EbayModelInterface using fromArray() method // exception will be thrown if a property does not exist in the model class $body = CustomPolicyCreateRequest::fromArray([ 'description' => 'description_example', 'name' => 'name_example', 'label' => 'label_example', 'custom_policy_type_enum' => CustomPolicyTypeEnum::PRODUCT_COMPLIANCE, ]); try { $result = $apiInstance->createCustomPolicy($body, MarketplaceIdEnum::EBAY_US); print_r($result); // there is also a custom ApiException for non 2xx responses } catch (Exception $e) { echo 'Exception when calling CustomPolicyApi->createCustomPolicy: ', $e->getMessage(), PHP_EOL; }
创建模型
一些 SDK 方法需要 $body
变量作为参数。它指的是实现了 EbayModelInterface 的模型类。有几种方法可以创建模型类
fromArray()
您可以使用 fromArray() 方法创建模型类。如果模型类中不存在该属性,则会抛出异常。
如果模型具有实现了 EbayModelInterface 的类型的属性,则必须使用 fromArray() 方法创建该类的实例。在此示例中,price
属性的类型为 ConvertedAmount
,也实现了 EbayModelInterface。
Item::fromArray([ 'price' => ConvertedAmount::fromArray([ 'value' => '6.90', 'currency' => CurrencyCodeEnum::USD )] ])
fromPlainArray()
也可以从普通关联数组创建模型。前面的示例可以重写如下
Item::fromPlainArray([ 'price' => [ 'value' => '6.90', 'currency' => CurrencyCodeEnum::USD ] ])
fromJson()
也可以从 JSON 字符串创建模型。
Item::fromJson('{"price": {"value": "6.90", "currency": "USD"}}')
API 端点文档
所有 URI 都是相对于 https://api.ebay.com/sell/account/v1
模型文档
- 金额
- 类别类型
- CompactCustomPolicyResponse
- CustomPolicy
- CustomPolicyCreateRequest
- CustomPolicyRequest
- CustomPolicyResponse
- 存款
- 错误
- ErrorParameter
- 履行政策
- 履行政策请求
- 履行政策响应
- 国际退货覆盖类型
- KycCheck
- KycResponse
- 付款方式
- 付款政策
- 付款政策请求
- 付款政策响应
- 付款计划入门响应
- 付款计划入门步骤
- 付款计划响应
- 项目
- 项目列表
- 利率表
- 利率表响应
- 收件人账户参考
- 地区
- 地区集
- 退货政策
- 退货政策请求
- 退货政策响应
- 销售税
- 销售税基数
- 销售税
- 销售限制
- 销售权限
- 设置履行政策响应
- 设置付款政策响应
- 设置退货政策响应
- 运输选项
- 运输服务
- 时间段
授权文档
api_auth
- 类型:OAuth
- 流程:accessCode
- 授权 URL:https://auth.ebay.com/oauth2/authorize
- 范围:
- https://api.ebay.com/oauth/api_scope/sell.account.readonly:查看您的账户设置
- https://api.ebay.com/oauth/api_scope/sell.account:查看和管理您的账户设置