Skip to content

Commit

Permalink
fix Improve README.md #3
Browse files Browse the repository at this point in the history
  • Loading branch information
ferjul17 committed Dec 27, 2015
1 parent c379dde commit 99eb7a7
Showing 1 changed file with 71 additions and 2 deletions.
73 changes: 71 additions & 2 deletions README.md
@@ -1,5 +1,5 @@
Sellsy Client Library
=======================
Sellsy API Client Library
=========================

[![Build Status](https://travis-ci.org/ferjul17/Sellsy-api.svg?branch=master)](https://travis-ci.org/ferjul17/Sellsy-api)
[![Coverage Status](https://coveralls.io/repos/ferjul17/Sellsy-api/badge.svg?branch=master&service=github)](https://coveralls.io/github/ferjul17/Sellsy-api?branch=master)
Expand All @@ -18,3 +18,72 @@ $promise = $client->getService('Infos')->callAsync('getInfos', [])->then(functio
});
$promise->wait();
```

How to install
--------------

First of all you need [Composer](https://getcomposer.org/doc/00-intro.md "Introduction - 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
----------

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.

```php
$client = new Client(['userToken' => 'xxx', 'userSecret' => 'xxx',
'consumerToken' => 'xxx', 'consumerSecret' => 'xxx',
]);
```

Once you have you client, you can retreive a `Service` by calling the method `getService($serviceName)`:

```php
$service = $client->getService('Accountdatas');
```

Finally, you can call an API with the method `call($methodName, $params)`:

```php
$response = $service->call('createUnit', ['unit' => ['value' => 'Kg']);
```

There's another method `callAsync($methodName, $params)` which send an asynchronous request and return a `Promise`:

```php
$promise = $service->callAsync('createUnit', ['unit' => ['value' => 'Kg']);
$response = $promise->wait();
```

You can find more information about `Promise` [here](https://github.com/guzzle/promises "Github of Guzzle Promises").

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.

0 comments on commit 99eb7a7

Please sign in to comment.