bricre/ebay-api-sell-inventory

此包已被 弃用 并不再维护。作者建议使用 bricre/ebay-sdk-sell-inventory 包。

由 eBay 的 OpenAPI 定义生成的 API 客户端

1.14.0.1 2021-09-02 00:40 UTC

This package is auto-updated.

Last update: 2022-05-04 16:08:34 UTC


README

使用 allansun/openapi-code-generator 从 eBay 的 Swagger 文件生成的代码。

生成的代码有良好的自文档,并带有正确的 PHPDoc 注释。

请参阅 eBay 的文档 了解 API 行为的详细解释。

安装

composer require bricre/ebay-api-sell-inventory

您还需要一个基于 PSR-7 的客户端或 Symfony 的 HTTP Foundation 基于客户端

因此,您可以使用 Guzzle(或其他任何 PSR-7 兼容客户端)

composer require guzzlehttp/guzzle

Symfony HTTP 客户端

composer require symfony/http-client

版本控制

从版本 1.14.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/inventory/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');

作者