Skip to content

Latest commit

 

History

History
119 lines (78 loc) · 2.93 KB

README.md

File metadata and controls

119 lines (78 loc) · 2.93 KB

Apparel21 PHP SDK

This SDK provides simple access to the Apparel21 API. It handles most Apparel21 associated complexities including authentication, entity abstraction, errors and more.

Contents

Getting started

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

Prerequisites

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.

Creating a client

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.

Integrating with Laravel

This package ships with a Laravel specific service provider which allows you to set your credentials from your configuration file and environment.

Registering the provider

Add the following to the providers array in your config/app.php file.

Omneo\Apparel21\LaravelServiceProvider::class

Adding config keys

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'),
]

Adding environment keys

In your .env file, add the following keys.

APPAREL21_BASE_URL=
APPAREL21_USERNAME=
APPAREL21_PASSWORD=

Resolving a client

To resolve a fully authenticated client, you simply pull it from the service container. This can be done in a few ways.

Type hinting

use Omneo\Apparel21;

public function yourControllerMethod(Apparel21\Client $client) {
    // Call methods on $client
}

Using the app() helper

use Omneo\Apparel21;

public function anyMethod() {
    $client = app(Apparel21\Client::class);
    // Call methods on $client
}

Available methods

Coming soon.

Contributing

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.

Testing

./vendor/bin/phpunit