1
0
mirror of synced 2024-11-21 20:36:03 +03:00
AliExpress TOP client
Go to file
2020-10-01 16:29:49 +03:00
src authorization URI builder, slightly different authenticator usage, fail tests if mocks weren't used 2020-10-01 16:29:49 +03:00
tests authorization URI builder, slightly different authenticator usage, fail tests if mocks weren't used 2020-10-01 16:29:49 +03:00
.editorconfig initial 2020-09-25 18:06:41 +03:00
.env.dist authorization URI builder, slightly different authenticator usage, fail tests if mocks weren't used 2020-10-01 16:29:49 +03:00
.gitignore pre-commit hook with auto install 2020-09-29 16:54:10 +03:00
.travis.yml authorization URI builder, slightly different authenticator usage, fail tests if mocks weren't used 2020-10-01 16:29:49 +03:00
composer.json restructurized models list, ExpressionLanguage for property exclusion, tests for excluded properties and inline JSON 2020-10-01 12:43:07 +03:00
LICENSE initial 2020-09-25 18:06:41 +03:00
phpcs.xml.dist phpcs & code quality fixes 2020-09-29 16:40:35 +03:00
phpmd.xml restructurized models list, ExpressionLanguage for property exclusion, tests for excluded properties and inline JSON 2020-10-01 12:43:07 +03:00
phpunit.xml.dist php 7.3 support, better architecture 2020-09-28 13:27:19 +03:00
README.md WIP: Hacks for inline JSON string inside another JSON or inside XML (some responses actually look like that) 2020-09-30 17:50:44 +03:00

Build Status Covarage Latest stable PHP from Packagist

AliExpress TOP API client

API client implementation for AliExpress TOP.

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 through 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 like that:
use RetailCrm\Component\AppData;
use RetailCrm\Builder\ClientBuilder;
use RetailCrm\Builder\ContainerBuilder;

$appData = new AppData(AppData::OVERSEAS_ENDPOINT, 'appKey', 'appSecret');
$client = ClientBuilder::create()
            ->setContainer(ContainerBuilder::create()->build())
            ->setAppData($appData)
            ->build();

Details

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

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

$client = new Client();
$logger = new StdoutLogger();
$factory = new Psr17Factory();
$authenticator = new TokenAuthenticator('appKey', 'token');
$appData = new AppData(AppData::OVERSEAS_ENDPOINT, 'appKey', 'appSecret');
$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\Client\ClientInterface (PSR-18), HTTP objects must be compliant to PSR-7.

You can use your own container - it must be compliant to PSR-11. But this is strongly discouraged because it'll be much easier to just integrate library with your own application, and your own DI system.