sapientpro / ebay-inventory-sdk-php
Ebay Inventory API 的 PHP SDK
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:21:42 UTC
README
库存 API 用于创建和管理库存,然后在 eBay 市场上发布和管理此库存。此 API 中还有将符合条件的、活跃的 eBay 列表转换为库存 API 模型的方法。
此 PHP 包由 Swagger Codegen 项目自动生成(Swagger Codegen)
- API 版本:1.16.2
- 构建包:io.swagger.codegen.v3.generators.php.PhpClientCodegen
要求
- PHP 8.1 及更高版本
- 启用 ext-curl 和 ext-json 扩展
安装与使用
使用 composer 安装此包
composer require sapientpro/ebay-account-sdk-php
入门指南
请按照安装过程进行操作,然后运行以下命令
<?php use SapientPro\EbayInventorySDK\Configuration; use SapientPro\EbayInventorySDK\Api\InventoryItemApi; use SapientPro\EbayInventorySDK\Models\BulkInventoryItem; // Configure OAuth2 access token for authorization: api_auth $config = Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN'); $apiInstance = new InventoryItemApi( 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 = BulkInventoryItem::fromArray([]); try { $result = $apiInstance->bulkCreateOrReplaceInventoryItem($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling InventoryItemApi->bulkCreateOrReplaceInventoryItem: ', $e->getMessage(), PHP_EOL; }
注意:某些方法需要 $contentLanguage
参数。它的值应该是字符串类型,并对应于 LocaleEnum 案例值,但应该是短横线分隔的格式:LocaleEnum::en_US -> 'en-US'
创建模型
某些 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/inventory/v1
模型文档
- 地址
- 金额
- 可用性
- 可用性分布
- 所有可用性
- 基本响应
- 最佳出价
- 批量 eBay 出价详情
- 批量获取库存项
- 批量获取库存项响应
- 批量库存项
- 批量库存项响应
- 批量迁移列表
- 批量迁移列表响应
- 批量出价
- 批量出价响应
- 批量价格数量
- 批量价格数量响应
- 批量发布响应
- 慈善机构
- 兼容性
- 兼容产品
- 尺寸
- EbayOfferDetailsWithAll
- EbayOfferDetailsWithId
- EbayOfferDetailsWithKeys
- 错误
- 错误参数
- 扩展生产者责任
- 费用
- 费用摘要
- 费用摘要响应
- 格式分配
- 地理坐标
- 获取库存项
- 获取库存项响应
- 间隔
- 库存项
- 库存项组
- 库存项列表
- 库存项响应
- 库存项与 SKU 区域
- 库存项与 SKU 区域组键
- 库存项与 SKU 区域组 ID
- 库存项列表
- 库存位置
- 库存位置完整
- 库存位置响应
- 列表详情
- 列表政策
- 位置
- 位置详情
- 位置响应
- 迁移列表
- 迁移列表响应
- 名称值列表
- 出价键与 ID
- 出价键与 ID 列表
- 出价价格数量
- 出价响应
- 出价响应与列表 ID
- 出价 SKU 响应
- 出价列表
- 营业时间
- 包装重量和尺寸
- 在指定地点取货的可用性
- 价格和数量
- 价格和数量响应
- 定价摘要
- 产品
- 产品系列属性
- 产品标识符
- 按库存项目组发布请求
- 发布响应
- 发货到指定地点的可用性
- 包含所有内容的发货到指定地点的可用性
- 覆盖运费
- 特殊营业时间
- 规格
- 税费
- 时间长度
- 根据...变化
- 版本
- 重量
- 按库存项目组撤回请求
- 撤回响应
授权
api_auth
- 类型: OAuth
- 流程: accessCode
- 授权URL: https://auth.ebay.com/oauth2/authorize
- 作用域:
- https://api.ebay.com/oauth/api_scope/sell.inventory: 查看和管理您的库存和报价
- https://api.ebay.com/oauth/api_scope/sell.inventory.readonly: 查看您的库存和报价