This SDK provides simple access to the Apparel21 API. It handles most Apparel21 associated complexities including authentication, entity abstraction, errors and more.
- Getting started
- Prerequisites
- Creating a client
- Integrating with Laravel
- Available methods
- Contributing
Install the SDK into your project using Composer.
composer config repositories.apparel21-sdk git [email protected]:omneo/apparel21-sdk.git
composer require omneo/apparel21-sdk
To begin sending requests to Apparel21, you will need a few pieces of information.
- Base URL This is the base URL where the Apparel21 API is accessible from.
- Username This is provided by Apparel21.
- Password This is provided by Apparel21.
If you are using Laravel, skip to the Integrating with Laravel section
To begin using the SDK, you will first need to create an authenticated client with the information you have obtained above.
use Omneo\Apparel21;
$client = (new Apparel21\Client('http://api.example.com/RetailAPI/'))
->setCredentials('username', 'password');
If you create a client without setting credentials, all your requests will be sent without appropriate authentication headers and will most likely result in an unauthorised response.
This package ships with a Laravel specific service provider which allows you to set your credentials from your configuration file and environment.
Add the following to the providers
array in your config/app.php
file.
Omneo\Apparel21\LaravelServiceProvider::class
In your config/services.php
file, add the following to the array.
'apparel21' => [
'base_url' => env('APPAREL21_BASE_URL'),
'username' => env('APPAREL21_USERNAME'),
'password' => env('APPAREL21_PASSWORD'),
]
In your .env
file, add the following keys.
APPAREL21_BASE_URL=
APPAREL21_USERNAME=
APPAREL21_PASSWORD=
To resolve a fully authenticated client, you simply pull it from the service container. This can be done in a few ways.
use Omneo\Apparel21;
public function yourControllerMethod(Apparel21\Client $client) {
// Call methods on $client
}
use Omneo\Apparel21;
public function anyMethod() {
$client = app(Apparel21\Client::class);
// Call methods on $client
}
Coming soon.
If you wish to contribute to this library, please submit a pull request and assign to a member of Capcom for review.
All public methods should be accompanied with unit tests.
./vendor/bin/phpunit