bricre/amazon-selling-partner-sdk-vendor-direct-fulfillment-shipping

由亚马逊卖家伙伴API直接配送运输的OpenAPI定义生成的API客户端

v1 2021-09-23 22:34 UTC

This package is auto-updated.

Last update: 2024-09-23 23:32:37 UTC


README

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

生成的代码具有良好的自文档,带有适当的PHPDoc注释。

请参阅亚马逊的文档以了解API行为的详细说明。

安装

composer require bricre/amazon-selling-partner-sdk-vendor-direct-fulfillment-shipping

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

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

composer require guzzlehttp/guzzle

Symfony HTTP客户端

composer require symfony/http-client

版本控制

此项目与亚马逊的API版本控制相匹配。

由于Composer的限制,版本号如'2021-01-01'将更改为'2021.01.01'。

如果您发现没有提供匹配的版本,请联系作者以生成针对正确版本。

用法

首先,您需要使用所需凭据和预定义的响应类型配置OpenAPI\RunTime\Client。您只需要这样做一次(或创建一个依赖注入中的服务)。

您还可能想查看亚马逊关于如何授权您的请求的文档。

<?php
use Amz\VendorDirectFulfillmentShipping\ResponseTypes;
use OpenAPI\Runtime\Client;
use OpenAPI\Runtime\SimplePsrResponseHandlerStack;

Client::configure(
    new \GuzzleHttp\Client([
        'base_uri' => 'https://sellingpartnerapi-na.amazon.com/',
        'headers'=>[
            'Authorization'=> 'Bearer <accessToken>'
        ]
    ]),
    new SimplePsrResponseHandlerStack(new ResponseTypes())
);

然后,在您的业务逻辑中,您可以直接调用API操作

<?php
use Amz\AplusContent\Api\AplusContent;
use Ebay\Sell\Account\Api\Program;

$api = new AplusContent();

$docs = $api->searchContentDocuments(['marketplaceId'=>'xxxxxx']);

作者