mallgroup / mpapi-client
PHP Client for Mall marketplace API
Installs: 114 041
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 6
Forks: 19
Open Issues: 9
Requires
- php-64bit: ^7.4 || ^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- codeception/codeception: ^4.1
- codeception/module-asserts: ^1.0.0
- codeception/module-phpbrowser: ^1.0.0
- phpmd/phpmd: ^2.10
- phpstan/phpstan: ^0.12.88
- slevomat/coding-standard: ^7.0
- squizlabs/php_codesniffer: ^3.5
- vimeo/psalm: ^4.7
- vlucas/phpdotenv: ^5.3
- dev-master
- v5.0.0
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.0
- v4.0.0
- v4.0.0-beta.4
- v4.0.0-beta
- v3.x-dev
- 3.14.0
- 3.13.0
- 3.12.2
- 3.12.1
- 3.12.0
- 3.11.6
- 3.11.5
- 3.11.4
- 3.11.3
- 3.11.1
- 3.11.0
- 3.10.1
- 3.10.0
- 3.9.3
- 3.9.2
- 3.9.1
- 3.9.0
- 3.8.3
- 3.8.2
- 3.8.0
- 3.7.1
- 3.7.0
- 3.6.0
- 3.5.1
- 3.5.0
- 3.4.0
- 3.3.2
- 3.3.1
- 3.2.0
- 3.1.0
- 3.0.0
- 2.16.2
- 2.15.0
- 2.14.2
- 2.14.1
- 2.14.0
- 2.13.0
- 2.12.2
- 2.12.1
- 2.12.0
- 2.11.6
- 2.11.5
- 2.11.4
- 2.11.3
- 2.11.2
- 2.11.1
- 2.11.0
- 2.10.2
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.1
- 2.6.0
- 2.5.1
- 2.4.0
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.0
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.9
- 2.0.8
- 2.0.7
- 2.0.6
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.9.7
- 1.9.5
- 1.9.4
- 1.9.3
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8
- 1.7.1
- 1.6.3
- 1.6.2
- 1.6.1
- v1.6
- 1.5.0
- 1.4.1
- v1.4
- 1.3.1
- 1.3.0
- v1.2
- dev-dependabot/composer/guzzlehttp/psr7-2.5.0
- dev-dependabot/composer/guzzlehttp/guzzle-7.4.5
- dev-client-v4-ci
This package is auto-updated.
Last update: 2024-11-19 21:53:27 UTC
README
Mall Marketplace API Client
Description
MPAPI client is a tool created to help Internet Mall, a. s. partners easily manage article catalogue, deliveries, orders etc. using Mall Marketplace API.
Requirements
64bit
version ofPHP 7.4
orPHP 8
- Guzzle 7
Installation
To install the client using Composer run following command in your repository
composer require mallgroup/mpapi-client
Implementation
Info
Client consists of one main client and multiple, separate, domain clients.
The main client groups all domain clients under one object, for easier implementation, but every domain client can be initialized and used by itself.
Every client provides an interface that SHOULD be used as parameter types in code, instead of client classes themselves (i.e., use MpApiClientInterface $client
or BrandsClientInterface $client
instead of MpApiClient $client
or BrandsClient $client
).
When initializing the client, you MUST provide
- an authenticator implementing AuthMiddlewareInterface
- currently, only ClientIdAuthenticator, which accepts
my-client-id
, is provided - in the future, new authenticators will be released (i.e., OAuth)
- currently, only ClientIdAuthenticator, which accepts
- name of the app using the API
- it is sent with every request to Mall API for easier request identification and debugging of reported issues
- please provide a simple, yet meaningful name, i.e.,
MyAppName CRM
orMyAppName Order sync
instead of a random string
Examples
There are 2 main ways to initialize the client
1. Using MpApiClient with default config
<?php declare(strict_types=1); use MpApiClient\Common\Authenticators\ClientIdAuthenticator; use MpApiClient\MpApiClient; use MpApiClient\MpApiClientOptions; require 'vendor/autoload.php'; // 1. Initialize client options with request authenticator $options = new MpApiClientOptions( new ClientIdAuthenticator('my-client-id') ); // 2. Initialize MP API Client $client = MpApiClient::createFromOptions('my-app-name', $options); // 3. Get brand client $brandClient = $client->brand();
2. Using MpApiClient (or any other domain client) with custom http client
- every domain client can be initialized this way as a standalone client
- when initializing a custom http client,
handler
stack withAuthMiddlewareInterface
MUST be provided!
<?php declare(strict_types=1); use GuzzleHttp\Client; use GuzzleHttp\Handler\CurlHandler; use GuzzleHttp\HandlerStack; use MpApiClient\Brand\BrandClient; use MpApiClient\Common\Authenticators\ClientIdAuthenticator; use MpApiClient\MpApiClient; use MpApiClient\MpApiClientOptions; require 'vendor/autoload.php'; // 1. Initialize request authenticator $authenticator = new ClientIdAuthenticator('my-client-id'); // 2. Create custom Guzzle http client with authenticator middleware // 2.1 Create CurlHandler stack and Guzzle http client manually $handler = new CurlHandler(); $handlerStack = HandlerStack::create($handler); $handlerStack->push($authenticator->getHandler()); $httpClient = new Client( [ 'base_uri' => 'https://mpapi.mallgroup.com/v1/', 'timeout' => 10, 'allow_redirects' => true, 'handler' => $handlerStack, ] ); // 2.2. Create Guzzle client using MpApiClientOptions object $options = new MpApiClientOptions($authenticator); $options->setTimeout(30); $httpClient = new Client($options->getGuzzleOptionsArray()); // 3. Create MpApiClient and BrandClient using custom Guzzle client $client = new MpApiClient($httpClient, 'my-app-name') $brandClient = new BrandClient($httpClient, 'my-app-name')
Examples for all client domains
List of custom Exceptions thrown in this client can be found here
⚠ Warning
- client does not include support for deprecated endpoints that will be changed, replaced or removed in the future (i.e.,
/v1/deliveries
or/v1/gifts
)
ℹ Known missing or incomplete features
- Support for
/v2/transports
endpoints