amorvan / ebay-inventory-sdk-php
PHP SDK for Ebay Inventory API
v1.0.0
2024-03-10 21:23 UTC
Requires
- php: ^8.0
- ext-mbstring: *
- guzzlehttp/guzzle: ^7.3
- phpdocumentor/reflection-docblock: ^5.3
- symfony/property-access: ^5.4
- symfony/serializer: ^5.4
- symfony/validator: ^5.4
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-09-10 22:33:13 UTC
README
库存API用于创建和管理库存,然后在eBay市场上发布和管理此库存。此API中还有一些方法可以将有资格的、活动的eBay列表转换为库存API模型。
此PHP包由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的Model类。创建Model类有几种方法
fromArray()
您可以使用fromArray()方法创建Model类。如果模型类中不存在属性,它将抛出异常。
如果模型有实现EbayModelInterface类型的属性,您必须使用fromArray()方法创建该类的实例。在此示例中,属性price
是类型为ConvertedAmount
的,它也实现了EbayModelInterface。
Item::fromArray([ 'price' => ConvertedAmount::fromArray([ 'value' => '6.90', 'currency' => CurrencyCodeEnum::USD )] ])
fromPlainArray()
也可以从纯关联数组创建Model。前面的示例可以重写如下
Item::fromPlainArray([ 'price' => [ 'value' => '6.90', 'currency' => CurrencyCodeEnum::USD ] ])
fromJson()
还可以从JSON字符串创建Model。
Item::fromJson('{"price": {"value": "6.90", "currency": "USD"}}')
API端点文档
所有URI相对于https://api.ebay.com/sell/inventory/v1
模型文档
- 地址
- 金额
- 可用性
- 可用性分布
- 全部可用性
- 基本响应
- 最佳出价
- 批量Ebay出价详情
- 批量获取库存项
- 批量获取库存项响应
- 批量库存项
- 批量库存项响应
- 批量迁移列表
- 批量迁移列表响应
- 批量出价
- 批量出价响应
- 批量价格数量
- 批量价格数量响应
- 批量发布响应
- 慈善机构
- 兼容性
- 兼容产品
- 尺寸
- Ebay出价详情
- Ebay出价详情
- Ebay出价详情
- 错误
- 错误参数
- 扩展生产者责任
- 费用
- 费用摘要
- 费用摘要响应
- 格式分配
- 地理坐标
- 获取库存项
- 获取库存项响应
- 间隔
- 库存项
- 库存项组
- 库存项列表
- 库存项响应
- 库存项
- 库存项
- 库存项
- 库存项
- 库存位置
- 库存位置
- 库存位置响应
- 列表详情
- 列表政策
- 位置
- 位置详情
- 位置响应
- 迁移列表
- 迁移列表响应
- 名称值列表
- 出价键
- 出价键
- 出价价格数量
- 出价响应
- 出价响应
- 出价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: 查看您的库存和报价