Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 35 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# [Uiscom](https://www.uiscom.ru/) & [CoMagic](https://main.comagic.ru/) API PHP client
CoMagic php client for:
- Rest API https://www.comagic.ru/support/api/
- Call API
# [UIScom](https://www.uiscom.ru/) (formerly [CoMagic](https://main.comagic.ru/)) API PHP client
UIS and CoMagic PHP client for the following APIs:
- [Call API](https://www.uiscom.ru/academiya/spravochnyj-centr/dokumentatsiya-api/call_api/)
- [Data API](https://www.uiscom.ru/academiya/spravochnyj-centr/dokumentatsiya-api/data_api/)

## Requirements
This package requires PHP 7.4 or above.

## Installation
To get started, install package via the Composer package manager:

`composer require pashamesh/comagic-api`
`composer require pashamesh/uiscom-api-client`

## Usage

Expand All @@ -27,39 +27,22 @@ $config = [
```

You also need to change domain if you client of Uiscom by specifying `endpoint`:

```php
$config = [
// required for Rest API and optional for Call API
'login' => 'put_login_here',
'password' => 'put_password_here',
'endpoint' => [
'rest_api' => 'https://api.uiscom.ru/api/'
],
// required for Call API if login and password not specified
'access_token' => 'put_access_token_here',
];
use Uiscom\CallApiConfig;

$config = new CallApiConfig('login', 'password', 'access_token')
```

Do not forget to add `Call API` permissions to user if you want to use login and
password authorization for Call API.


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

$restApi = new RestApiClient($config);
var_dump(
$restApi->call(['date_from' => '2025-01-10', 'date_till' => '2025-01-13'])
);
```

### Call API
API Methods names need to be specified in CamelCase

```php
use CoMagic\CallApiConfig;
use CoMagic\CallApiClient;
use Uiscom\CallApiConfig;
use Uiscom\CallApiClient;

$config = new CallApiConfig('login', 'password', 'access_token');
$callApi = new CallApiClient($config);
Expand All @@ -70,3 +53,27 @@ It's possible to get response metadata after API request is made
```php
var_dump($callApi->metadata());
```

### Data API

API Methods names need to be specified in CamelCase

```php
use Uiscom\DataApiConfig;
use Uiscom\DataApiClient;

$config = new DataApiConfig('access_token');
$dataApi = new DataApiClient($config);
var_dump(
$dataApi->getCallsReport([
'date_from' => '2025-01-10 00:00:00',
'date_till' => '2025-01-13 23:59:59'
])
);
```

It's possible to get response metadata after API request is made

```php
var_dump($dataApi->metadata());
```
21 changes: 18 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
{
"name": "pashamesh/comagic-api",
"description": "php binding for UIScom and CoMagic API",
"name": "pashamesh/uiscom-api-client",
"description": "PHP binding for UIScom (formerly CoMagic) API",
"type": "library",
"license": "MIT",
"keywords": [
"uis",
"uiscom",
"comagic",
"sdk",
"php",
"api",
"package",
"uiscom sdk",
"uiscom api",
"uiscom dataapi",
"uiscom callapi",
"uiscom package"
],
"require": {
"php": ">=7.4",
"ext-json": "*",
"guzzlehttp/guzzle": "^6.2|^7.0"
},
"autoload": {
"psr-4": {
"CoMagic\\": "src/CoMagic/"
"Uiscom\\": "src/Uiscom/"
}
},
"authors": [
Expand Down
183 changes: 0 additions & 183 deletions src/CoMagic/RestApiClient.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace CoMagic;
namespace Uiscom;

use GuzzleHttp\Client;
use GuzzleHttp\Exception\TransferException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace CoMagic;
namespace Uiscom;

use InvalidArgumentException;

Expand Down
Loading