simplesquid/laravel-vend-sdk

A Laravel package for our PHP SDK for Vend POS.

v0.3.1 2020-11-13 07:32 UTC

This package is auto-updated.

Last update: 2024-04-08 21:03:06 UTC


README

Latest Version on Packagist MIT License Total Downloads

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.