Skip to content

Commit

Permalink
Updated README.md with Call API examples
Browse files Browse the repository at this point in the history
  • Loading branch information
pashamesh committed Jan 30, 2017
1 parent a431c8b commit cee144e
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# CoMagic API php client
CoMagic API php client for https://www.comagic.ru/support/api/
CoMagic php client for:
- Rest API https://www.comagic.ru/support/api/
- Call API

## Installation
To get started, install package via the Composer package manager:
Expand All @@ -8,17 +10,39 @@ To get started, install package via the Composer package manager:

## Usage

### Init RestAPI client
### Configuring
Array is using to configure Rest API and Call API clients.
```php
$config = [
// required for Rest API and optional for Call API
'login' => 'put_login_here',
'password' => 'put_password_here',
// required for Call API if login and password not specified
'access_token' => 'put_access_token_here',
];

```
Do not foreget to add `Call API` permissions to user if you wand to use login and password authorization for Call API


### Rest API
```php
use CoMagic\RestApiClient;

$restClient = new RestApiClient([
'login' => 'put_login_here',
'password' => 'put_password_here'
]);
$restApi = new RestApiClient($config);
var_dump(
$restApi->call(['date_from' => '2017-01-10', 'date_till' => '2017-01-13'])
);
```
### Do RestAPI request
Example how to get calls info:

### Call API
API Methods names need to bespecified in CamelCase
```php
$data = $restClient->call(['date_from' => '2017-01-10', 'date_till' => '2017-01-13']);
$callApi = new CallApiClient($config);
var_dump($callApi->listCalls());
```

It's possible to get response metadata after API request is made
```php
var_dump($callApi->metadata());
```

0 comments on commit cee144e

Please sign in to comment.