/loyverse-sdk

A simple to use PHP class to work with the Loyverse API.

Primary LanguagePHPMIT LicenseMIT

Loyverse SDK

Build Status Total Downloads Latest Stable Version License

To work with this package, firstly you must have a Loyverse account, and secondly you must create an API token through Loyverse itself.

Documentation

Installation

To install the SDK in your project you need to require the package via composer:

composer require pashkevich/loyverse-sdk

Basic Usage

You can create an instance of the SDK like so:

$loyverse = new Pashkevich\Loyverse\Loyverse(PERSONAL_ACCESS_TOKEN_HERE);

Using the Loyverse instance you may perform multiple actions as well as retrieve the different resources Loyverse's API provides:

$categories = $loyverse->categories();

This will give you an array of categories that you have access to, where each category is represented by an instance of Pashkevich\Loyverse\Resources\Category, this instance has multiple public properties like $id, $name, $color , and others.

You may also retrieve a single category using:

$category = $loyverse->category(CATEGORY_ID_HERE);

On multiple actions supported by this SDK you may need to pass some parameters, for example when creating a new category:

$category = $loyverse->createCategory([
    'name' => 'Fruits',
    'color' => 'ORANGE',
]);

These parameters will be used in the POST request sent to Loyverse servers, you can find more information about the parameters needed for each action on Loyverse's official API documentation.

You can also set the desired timeout value:

$loyverse->setTimeout(120)->createCategory(array $data);

Managing Categories

$loyverse->categories(array $parameters);
$loyverse->category(string $categoryId);
$loyverse->createCategory(array $data);
$loyverse->deleteCategory(string $categoryId);

On a Category instance you may also call:

$category->update(array $data);
$category->delete();

Managing Customers

$loyverse->customers(array $parameters);
$loyverse->customer(string $customerId);
$loyverse->createCustomer(array $data);
$loyverse->deleteCustomer(string $customerId);

On a Customer instance you may also call:

$customer->update(array $data);
$customer->delete();

Managing Discounts

$loyverse->discounts(array $parameters);
$loyverse->discount(string $discountId);
$loyverse->createDiscount(array $data);
$loyverse->deleteDiscount(string $discountId);

On a Discount instance you may also call:

$discount->update(array $data);
$discount->delete();

Managing Employees

$loyverse->employees(array $parameters);
$loyverse->employee(string $employeeId);

Managing Inventory

$loyverse->inventory(array $parameters);
$loyverse->updateInventory(array $data);

Managing Items

$loyverse->items(array $parameters);
$loyverse->item(string $itemId);
$loyverse->createItem(array $data);
$loyverse->deleteItem(string $itemId);

On a Item instance you may also call:

$item->update(array $data);
$item->delete();

Managing Merchants

$loyverse->merchant();

Managing Modifiers

$loyverse->modifiers(array $parameters);
$loyverse->modifier(string $modifierId);
$loyverse->createModifier(array $data);
$loyverse->deleteModifier(string $modifierId);

On a Modifier instance you may also call:

$modifier->update(array $data);
$modifier->delete();

Managing Payment Types

$loyverse->paymentTypes(array $parameters);
$loyverse->paymentType(string $paymentTypeId);

Managing Pos Devices

$loyverse->posDevices(array $parameters);
$loyverse->posDevice(string $posDeviceId);
$loyverse->createPosDevice(array $data);
$loyverse->deletePosDevice(string $posDeviceId);

On a PosDevice instance you may also call:

$posDevice->update(array $data);
$posDevice->delete();

Managing Receipts

$loyverse->receipts(array $parameters);
$loyverse->receipt(string $receiptNumber);
$loyverse->createReceipt(array $data);
$loyverse->createReceiptRefund(string $receiptNumber, array $data);

On a Receipt instance you may also call:

$receipt->refund(array $data);

Managing Shifts

$loyverse->shifts(array $parameters);
$loyverse->shift(string $shiftId);

Managing Stores

$loyverse->stores(array $parameters);
$loyverse->store(string $storeId);

Managing Suppliers

$loyverse->suppliers(array $parameters);
$loyverse->supplier(string $supplierId);
$loyverse->createSupplier(array $data);
$loyverse->deleteSupplier(string $supplierId);

On a Supplier instance you may also call:

$supplier->update(array $data);
$supplier->delete();

Managing Taxes

$loyverse->taxes(array $parameters);
$loyverse->tax(string $taxId);
$loyverse->createTax(array $data);
$loyverse->deleteTax(string $taxId);

On a Tax instance you may also call:

$tax->update(array $data);
$tax->delete();

Managing Variants

$loyverse->variants(array $parameters);
$loyverse->variant(string $variantId);
$loyverse->createVariant(array $data);
$loyverse->deleteVariant(string $variantId);

On a Variant instance you may also call:

$variant->update(array $data);
$variant->delete();

Managing Webhooks

$loyverse->webhooks(array $parameters);
$loyverse->webhook(string $webhookId);
$loyverse->createWebhook(array $data);
$loyverse->deleteWebhook(string $webhookId);

On a Webhook instance you may also call:

$webhook->update(array $data);
$webhook->delete();

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email siarheipashkveich@gmail.com instead of using the issue tracker.

Credits

License

Loyverse SDK is open-sourced software licensed under the MIT license.