simplesquid / laravel-vend-sdk
A Laravel package for our PHP SDK for Vend POS.
Requires
- php: ^7.3
- illuminate/support: ^6.0
- simplesquid/vend-sdk: ^0.5
Requires (Dev)
- mockery/mockery: ^1.0
- orchestra/testbench: ^4.0
- phpunit/phpunit: ^8.2
- symfony/var-dumper: ^4.3
This package is auto-updated.
Last update: 2024-10-08 21:59:04 UTC
README
A Laravel package for our PHP SDK for Vend POS.
Installation
You can install this package via composer:
composer require simplesquid/laravel-vend-sdk
The package will automatically register itself with the Laravel service container.
To publish the config file to config/vend.php
run:
php artisan vendor:publish --provider="SimpleSquid\LaravelVend\VendServiceProvider"
OAuth Setup
Should you wish to make use of the OAuth authorisation method, you will need to register your application on the Vend Developer page and set the redirect URI to the named route url, vend.oauth.request
.
Then, copy the client ID and secret to your environment variables. You will also need to create an implementation of \SimpleSquid\LaravelVend\VendTokenManager
to store and retrieve the access token (it is recommended to be saved in your database).
Finally, direct your user to the named route, vend.oauth.request
, in order to request access. The access token will be saved upon the user's successful return to your application, and they will be redirected to the previous page.
Usage
An example use case is shown below. The VendRequestJob
handles both rate limiting and refreshes of the OAuth token.
use SimpleSquid\LaravelVend\Facades\Vend; use SimpleSquid\LaravelVend\Jobs\VendRequestJob; /* Get the list of products. */ public function getProducts() { return VendRequestJob::dispatchNow(function () { return Vend::product()->get(); }); } /* Create a new product. */ public function createProduct($product) { VendRequestJob::dispatch(function () use $product { return Vend::product()->create($product); }); }
For more examples, feel free to dive into the code.
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.