An unofficial PHP SDK for the Vend POS API.
You can install this package via composer:
composer require simplesquid/vend-sdk
To setup, get the instance of the SDK and set the desired user agent and settings:
$vend = Vend::getInstance();
/* Optional configuration. */
$vend->userAgent('Vend SDK')
->requestTimeout(2)
->confirmationTimeout(30);
It is advisable that you use the client object as a singleton, however, there is no explicit restriction for this.
This outlines a typical sequence of instructions, but is not a complete list of all the functionality of the SDK. Please review the code for more advanced usages. It is also suggested you read the Vend API documentation.
Alternatively, you can see a working authorisation implementation in our Laravel Vend SDK package.
You have two options for authorisation with the Vend API, a Personal Access Token or OAuth 2.0.
When using the Personal Access Token, simply setup the Vend client like so:
$vend->domainPrefix($domain_prefix)
->personalAccessToken($access_token);
Setup the Vend client with the OAuth identifiers:
$vend->clientId($client_id)
->clientSecret($client_secret)
->redirectUri($redirect);
Send the user to the OAuth URL generated by:
$vend->getAuthorisationUrl($previous_url);
Use the domain prefix and authorisation code returned from the OAuth process:
/** @var \SimpleSquid\Vend\Resources\OneDotZero\Token */
$token = $vend->domainPrefix($domain_prefix)
->oAuthAuthorisationCode($code);
Make sure you store the returned Token object and the domain prefix.
Once you have received the initial authorisation, you may setup the Vend client using the Token object received during the authorisation process:
$vend->authorisationToken($token);
If a request throws a \SimpleSquid\Vend\Exceptions\TokenExpiredException
, you can refresh the token like so:
/** @var \SimpleSquid\Vend\Resources\OneDotZero\Token */
$token = $vend->refreshOAuthAuthorisationToken();
Again, make sure you store the returned Token object.
To see all the available requests, take a look at traits located in the Actions
folder. As an example, Products can be managed using the following requests:
/**
* List products.
* Returns a paginated list of products.
*
* @param int|null $page_size The maximum number of items to be returned in the response.
* @param int|null $after The lower limit for the version numbers to be included in the response.
* @param int|null $before The upper limit for the version numbers to be included in the response.
* @param bool|null $deleted Indicates whether deleted items should be included in the response.
*
* @return \SimpleSquid\Vend\Resources\TwoDotZero\ProductCollection
*/
$products = $vend->product->get($page_size, $after, $before, $deleted);
/**
* Get a single product.
* Returns a single product object with a given ID.
*
* @param string $id Valid product ID.
*
* @return \SimpleSquid\Vend\Resources\TwoDotZero\Product
*/
$product = $vend->product->find($id);
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Package skeleton based on spatie/skeleton-php.
SimpleSquid is a small web development and design company based in Cape Town, South Africa.
The MIT License (MIT). Please see License File for more information.