oxy-coach/aliexpress-api-client-local 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

oxy-coach/aliexpress-api-client-local

最新稳定版本:v2.0.1

Composer 安装命令:

composer require oxy-coach/aliexpress-api-client-local

包简介

API client implementation for new AliExpress API version.

README 文档

README

Build Status Latest stable PHP from Packagist

AliExpress API client for new API version

API client implementation for AliExpress local API.

Usage

  1. This library uses php-http/httplug under the hood. If you don't want to bother with details, just install library and it's dependencies via Composer:
composer require php-http/curl-client nyholm/psr7 php-http/message retailcrm/aliexpress-top-client

Details about those third-party libraries and why you need to install them can be found here.

  1. Instantiate client using ClientFactory:
use Simla\Component\AppData;
use Simla\Factory\ClientFactory;

$client = ClientFactory::createClient(
    AppData::ENDPOINT,
    'your jwt token'
);
  1. Create and fill request data. All requests and responses use the same naming. Requests live under RetailCrm\Model\Request namespace, and responses can be found in the RetailCrm\Model\Response namespace. For example, you can instantiate an order list request with this code:
use Simla\Model\Request\GetOrderListRequest;

$request = new GetOrderListRequest();
  1. Send request using Client::sendRequest like this:
/** @var \Simla\Model\Response\GetOrderListResponse $response */
$response = $client->sendRequest(new GetOrderListRequest());

Each request uses provided jwt token for authorization.

Friendly note. Use response type annotations. Both client methods which returns responses actually returns ResponseInterface (not the PSR one). Actual response type will be determined by the request model. Your IDE will not recognize any response options unless you put a proper type annotation for the response variable.

Customization

This library uses Container pattern under the hood. You can pass additional dependencies using ContainerBuilder. For example:

use Http\Client\Curl\Client;
use Simla\Component\AppData;
use Simla\Component\Environment;
use Nyholm\Psr7\Factory\Psr17Factory;
use Simla\Builder\ClientBuilder;
use Simla\Builder\ContainerBuilder;
use Simla\Component\Logger\StdoutLogger;

$client = new Client();
$logger = new StdoutLogger();
$factory = new Psr17Factory();
$appData = new AppData(AppData::ENDPOINT, 'jwt token');
$container = ContainerBuilder::create()
            ->setEnv(Environment::TEST)
            ->setClient($client)
            ->setLogger($logger)
            ->setStreamFactory($factory)
            ->setRequestFactory($factory)
            ->setUriFactory($factory)
            ->build();
$client = ClientBuilder::create()
            ->setContainer($container)
            ->setAppData($appData)
            ->build();

Logger should implement Psr\Log\LoggerInterface (PSR-3), HTTP client should implement Psr\Http\TopClient\TopClientInterface (PSR-18), HTTP objects must be compliant to PSR-7. You can use your own container if you want to - it must be compliant to PSR-11. This is strongly discouraged because it'll be much easier to just integrate library with your own application, and your own DI system.

The simplest example of client initialization without using ClientFactory looks like this:

use Simla\Component\AppData;
use Simla\Builder\ClientBuilder;
use Simla\Builder\ContainerBuilder;

$appData = new AppData(AppData::ENDPOINT, 'jwt token');
$client = ClientBuilder::create()
            ->setContainer(ContainerBuilder::create()->build())
            ->setAppData($appData)
            ->build();

In fact, ClientFactory works just like this under the hood.

统计信息

  • 总下载量: 44
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固