Widgets   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 66
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A apiList() 0 6 2
A apiInstall() 0 12 2
A apiUninstall() 0 12 2
1
<?php
2
3
namespace AmoCRM\Models;
4
5
/**
6
 * Class Widgets
7
 *
8
 * Класс модель для работы с Виджетами
9
 *
10
 * @package AmoCRM\Models
11
 * @author dotzero <[email protected]>
12
 * @link http://www.dotzero.ru/
13
 * @link https://github.com/dotzero/amocrm-php
14
 *
15
 * For the full copyright and license information, please view the LICENSE
16
 * file that was distributed with this source code.
17
 */
18
class Widgets extends AbstractModel
19
{
20
    /**
21
     * Список виджетов
22
     *
23
     * Метод для получения списка доступных для установки виджетов.
24
     *
25
     * @link https://developers.amocrm.ru/rest_api/widgets/list.php
26
     * @param array $parameters Массив параметров к amoCRM API
27
     * @return array Ответ amoCRM API
28
     */
29 1
    public function apiList($parameters = [])
30
    {
31 1
        $response = $this->getRequest('/private/api/v2/json/widgets/list', $parameters);
32
33 1
        return isset($response['widgets']) ? $response['widgets'] : [];
34
    }
35
36
    /**
37
     * Включение виджетов
38
     *
39
     * Метод позволяет включать виджеты по одному или пакетно,
40
     * а также обновлять данные включённых и выключенных виджетов.
41
     *
42
     * @link https://developers.amocrm.ru/rest_api/widgets/set.php
43
     * @param array $parameters Массив параметров к amoCRM API
44
     * @return array Ответ amoCRM API
45
     * @throws \AmoCRM\Exception
46
     */
47 1
    public function apiInstall($parameters)
48
    {
49
        $parameters = [
50
            'widgets' => [
51 1
                'install' => $parameters,
52 1
            ],
53 1
        ];
54
55 1
        $response = $this->postRequest('/private/api/v2/json/widgets/set', $parameters);
56
57 1
        return isset($response['widgets']['install']) ? $response['widgets']['install'] : [];
58
    }
59
60
    /**
61
     * Выключение виджетов
62
     *
63
     * Метод позволяет выключать виджеты по одному или пакетно,
64
     * а также обновлять данные включённых и выключенных виджетов.
65
     *
66
     * @link https://developers.amocrm.ru/rest_api/widgets/set.php
67
     * @param array $parameters Массив параметров к amoCRM API
68
     * @return array Ответ amoCRM API
69
     * @throws \AmoCRM\Exception
70
     */
71 1
    public function apiUninstall($parameters)
72
    {
73
        $parameters = [
74
            'widgets' => [
75 1
                'uninstall' => $parameters,
76 1
            ],
77 1
        ];
78
79 1
        $response = $this->postRequest('/private/api/v2/json/widgets/set', $parameters);
80
81 1
        return isset($response['widgets']['uninstall']) ? $response['widgets']['uninstall'] : [];
82
    }
83
}