merch-one / php-api-sdk
SDK for MerchOne API integration
1.0.4
2023-04-14 15:35 UTC
Requires
- php: >=7.4
- ext-ctype: *
- ext-json: *
- guzzlehttp/guzzle: ^6|^7
- tightenco/collect: ^8.83
Requires (Dev)
- phpunit/phpunit: ^9.0
README
PHP SDK for MerchOne API integration
This package provide a set of tools that allow developers to easily integrate with MerchOne API.
Installation
composer require merch-one/php-api-sdk
Overview
Introduction
Client provide 3 different API's to interact with.
- Catalog API
- Orders API
- Shipping API
To get the list of available endpoints, please check MerchOne API Documentation
Basic Usage
Create an instance of MerchOne\PhpApiSdk\Http\Client
use MerchOne\PhpApiSdk\Http\Client; class MyService { private Client $httpClient; public function __construct() { $this->httpClient = new Client(); } public function doSomething(): void { // authenticate client using credentials $this->httpClient->auth( 'your-store-user', 'your-store-key' ); // or authenticate client using base64 encoded credentials $this->httpClient->basicAuth( base64_encode('your-store-user:your-store-key'), ); /* Interact with Catalog API */ /** @var \MerchOne\PhpApiSdk\Contracts\Clients\CatalogApi $catalogApi */ $catalogApi = $this->httpClient->catalog(); /* Interact with Orders API */ /** @var \MerchOne\PhpApiSdk\Contracts\Clients\OrdersApi $ordersApi */ $ordersApi = $this->httpClient->orders(); /* Interact with Shipping API */ /** @var \MerchOne\PhpApiSdk\Contracts\Clients\ShippingApi $shippingApi */ $shippingApi = $this->httpClient->shipping(); // switch API version you interact with $this->httpClient->setVersion($version); // get current API version $this->httpClient->getVersion(); } }
- The
Client
class accepts two parameters:$version
- API version to interact with. Default value isbeta
.- See Helpers for available versions.
$clientOptions
- Custom options to use with request.- See Guzzle Documentation for available options.
- The
User-Agent
,Accept
andContent-Type
headers, as well ashttp_error
properties CAN NOT be overwritten !
Helpers
use MerchOne\PhpApiSdk\Util\MerchOneApi; // get the list of all available API versions MerchOneApi::getVersions();
- Class
MerchOne\PhpSdk\Util\OrderStatus
provides a full list of Order statuses.
Check more in MerchOne API Documentation
Exceptions
The package can throw the following exceptions:
Tests
Package comes with a set of tests to ensure that everything works as expected. To run tests, execute the following command:
./vendor/bin/phpunit