Skip to content

Commit 2e80637

Browse files
authored
Merge pull request #9 from pashamesh/feat/replace_rest_api
feat: Replace RestAPI client by DataAPI client
2 parents 18df4b9 + 791b485 commit 2e80637

File tree

12 files changed

+480
-235
lines changed

12 files changed

+480
-235
lines changed

README.md

Lines changed: 35 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# [Uiscom](https://www.uiscom.ru/) & [CoMagic](https://main.comagic.ru/) API PHP client
2-
CoMagic php client for:
3-
- Rest API https://www.comagic.ru/support/api/
4-
- Call API
1+
# [UIScom](https://www.uiscom.ru/) (formerly [CoMagic](https://main.comagic.ru/)) API PHP client
2+
UIS and CoMagic PHP client for the following APIs:
3+
- [Call API](https://www.uiscom.ru/academiya/spravochnyj-centr/dokumentatsiya-api/call_api/)
4+
- [Data API](https://www.uiscom.ru/academiya/spravochnyj-centr/dokumentatsiya-api/data_api/)
55

66
## Requirements
77
This package requires PHP 7.4 or above.
88

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

12-
`composer require pashamesh/comagic-api`
12+
`composer require pashamesh/uiscom-api-client`
1313

1414
## Usage
1515

@@ -27,39 +27,22 @@ $config = [
2727
```
2828

2929
You also need to change domain if you client of Uiscom by specifying `endpoint`:
30+
3031
```php
31-
$config = [
32-
// required for Rest API and optional for Call API
33-
'login' => 'put_login_here',
34-
'password' => 'put_password_here',
35-
'endpoint' => [
36-
'rest_api' => 'https://api.uiscom.ru/api/'
37-
],
38-
// required for Call API if login and password not specified
39-
'access_token' => 'put_access_token_here',
40-
];
32+
use Uiscom\CallApiConfig;
4133

34+
$config = new CallApiConfig('login', 'password', 'access_token')
4235
```
4336

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

47-
48-
### Rest API
49-
```php
50-
use CoMagic\RestApiClient;
51-
52-
$restApi = new RestApiClient($config);
53-
var_dump(
54-
$restApi->call(['date_from' => '2025-01-10', 'date_till' => '2025-01-13'])
55-
);
56-
```
57-
5840
### Call API
5941
API Methods names need to be specified in CamelCase
42+
6043
```php
61-
use CoMagic\CallApiConfig;
62-
use CoMagic\CallApiClient;
44+
use Uiscom\CallApiConfig;
45+
use Uiscom\CallApiClient;
6346

6447
$config = new CallApiConfig('login', 'password', 'access_token');
6548
$callApi = new CallApiClient($config);
@@ -70,3 +53,27 @@ It's possible to get response metadata after API request is made
7053
```php
7154
var_dump($callApi->metadata());
7255
```
56+
57+
### Data API
58+
59+
API Methods names need to be specified in CamelCase
60+
61+
```php
62+
use Uiscom\DataApiConfig;
63+
use Uiscom\DataApiClient;
64+
65+
$config = new DataApiConfig('access_token');
66+
$dataApi = new DataApiClient($config);
67+
var_dump(
68+
$dataApi->getCallsReport([
69+
'date_from' => '2025-01-10 00:00:00',
70+
'date_till' => '2025-01-13 23:59:59'
71+
])
72+
);
73+
```
74+
75+
It's possible to get response metadata after API request is made
76+
77+
```php
78+
var_dump($dataApi->metadata());
79+
```

composer.json

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
{
2-
"name": "pashamesh/comagic-api",
3-
"description": "php binding for UIScom and CoMagic API",
2+
"name": "pashamesh/uiscom-api-client",
3+
"description": "PHP binding for UIScom (formerly CoMagic) API",
44
"type": "library",
5+
"license": "MIT",
6+
"keywords": [
7+
"uis",
8+
"uiscom",
9+
"comagic",
10+
"sdk",
11+
"php",
12+
"api",
13+
"package",
14+
"uiscom sdk",
15+
"uiscom api",
16+
"uiscom dataapi",
17+
"uiscom callapi",
18+
"uiscom package"
19+
],
520
"require": {
621
"php": ">=7.4",
722
"ext-json": "*",
823
"guzzlehttp/guzzle": "^6.2|^7.0"
924
},
1025
"autoload": {
1126
"psr-4": {
12-
"CoMagic\\": "src/CoMagic/"
27+
"Uiscom\\": "src/Uiscom/"
1328
}
1429
},
1530
"authors": [

src/CoMagic/RestApiClient.php

Lines changed: 0 additions & 183 deletions
This file was deleted.

src/CoMagic/CallApiClient.php renamed to src/Uiscom/CallApiClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace CoMagic;
5+
namespace Uiscom;
66

77
use GuzzleHttp\Client;
88
use GuzzleHttp\Exception\TransferException;

src/CoMagic/CallApiConfig.php renamed to src/Uiscom/CallApiConfig.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace CoMagic;
5+
namespace Uiscom;
66

77
use InvalidArgumentException;
88

0 commit comments

Comments
 (0)