simplesquid / vend-sdk
An unoffical PHP SDK for Vend POS
Installs: 1 207
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 4
Open Issues: 5
Requires
- php: ^7.3
- ext-json: *
- guzzlehttp/guzzle: ^6.3
- nesbot/carbon: ^2.23
- spatie/data-transfer-object: ~1.11.0
Requires (Dev)
- filp/whoops: ^2.5
- mockery/mockery: ^1.0
- phpunit/phpunit: ^8.2
- symfony/var-dumper: ^4.3
- dev-main
- 1.x-dev
- v0.5.21
- v0.5.20
- v0.5.19
- v0.5.18
- v0.5.17
- v0.5.16
- v0.5.15
- v0.5.14
- v0.5.13
- v0.5.12
- v0.5.11
- v0.5.10
- v0.5.9
- v0.5.8
- v0.5.7
- v0.5.6
- v0.5.5
- v0.5.4
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.17
- v0.4.16
- v0.4.15
- v0.4.14
- v0.4.13
- v0.4.12
- v0.4.11
- v0.4.10
- v0.4.9
- v0.4.8
- v0.4.7
- v0.4.6
- v0.4.5
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.1
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
- dev-analysis-vQG0Gl
- dev-analysis-XaZjjV
This package is auto-updated.
Last update: 2024-11-13 14:29:33 UTC
README
An unofficial PHP SDK for the Vend POS API.
Installation
You can install this package via composer:
composer require simplesquid/vend-sdk
Setup
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.
Usage
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.
Authorisation
You have two options for authorisation with the Vend API, a Personal Access Token or OAuth 2.0.
Personal Access Token
When using the Personal Access Token, simply setup the Vend client like so:
$vend->domainPrefix($domain_prefix) ->personalAccessToken($access_token);
OAuth 2.0
Setup the Vend client with the OAuth identifiers:
$vend->clientId($client_id) ->clientSecret($client_secret) ->redirectUri($redirect);
Initial authorisation procedure
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.
Subsequent setup procedure
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.
Requests
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);
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email security@simplesquid.co.za instead of using the issue tracker.
Credits
Package skeleton based on spatie/skeleton-php.
About us
SimpleSquid is a small web development and design company based in Cape Town, South Africa.
License
The MIT License (MIT). Please see License File for more information.