Download the PHP package ferjul17/sellsy-api without Composer
On this page you can find all versions of the php package ferjul17/sellsy-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package sellsy-api
Sellsy API Client Library
PHP library which helps to call Sellsy's API
How to install
First of all you need Composer:
php -r "readfile('https://getcomposer.org/installer');" | php
Then add Sellsy API as a dependency of your project:
php composer.phar require ferjul17/sellsy-api
How to use
Setup the library
The library provide you a class called Service
which represent a part of the Sellsy's API.
The service allows you to call api associated to this module.
For instance, the service Accountdatas
allows to call all method which start with Accountdatas in Sellsy's API, like Accountdatas.getTaxe or Accountdatas.updateUnit
The Services are created by a factory called Client
. So you first need to create a Client
before having a Service
.
To create a client just call its constructor. Its first argument is an array which contains the configuration.
You must provide the credentials to call the API which include the user token and secret, and the consumer token and secret that you can find in Sellsy interface.
Call APIs
Once you have you client, you can retreive a Service
by calling the method getService($serviceName)
:
Finally, you can call an API with the method call($methodName, $params)
:
There's another method callAsync($methodName, $params)
which send an asynchronous request and return a Promise
:
You can find more information about Promise
here.
Handle errors
In order to handle errors, you should use retryable version of the previous methodes: retryableCall($callable)
and
retryableCallAsync($callable)
. In case of an error which is handle by the library, this one will try to send again the
requests by calling $callable
.
$callable
must be a function which return the parameters to give to the call()
and callAsync()
methods.
$callable
takes 3 arguments:
- The instance of the
ServiceInterface
used to send the call - The retry number. The first time this value is 0.
- The error received
How to run tests
If you want to test this library, you can run the test suite clone this repository:
git clone https://github.com/ferjul17/Sellsy-api.git
then install dependencies:
composer update
than run the tests:
vendor/phpunit/phpunit/phpunit
License
Sellsy API is an open-source project released under the MIT license. See the LICENSE
file for more information.