bricre/ebay-api-buy-deal

该包已被放弃,不再维护。作者建议使用bricre/ebay-sdk-buy-deal包。

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

1.3.0.1 2021-09-02 00:40 UTC

This package is auto-updated.

Last update: 2022-05-04 16:10:40 UTC


README

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

生成的代码具有完善的PHPDoc注释,便于自文档化。

请参考eBay的文档以了解详细的API行为说明。

安装

composer require bricre/ebay-api-sell-account

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

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

composer require guzzlehttp/guzzle

Symfony HTTP 客户端

composer require symfony/http-client

版本

从版本1.3.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/buy/deal/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');

作者