Completed
Branch v4.x (712f3d)
by Dmitry
04:56
created

AdGroups   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 95
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 9 1
A delete() 0 9 1
A get() 0 16 1
A update() 0 9 1
1
<?php
2
3
namespace Gladyshev\Yandex\Direct\Service;
4
5
use ReflectionException;
6
use Gladyshev\Yandex\Direct\Exception\ErrorResponseException;
7
use Gladyshev\Yandex\Direct\AbstractService;
8
9
use function Gladyshev\Yandex\Direct\get_param_names;
10
11
/**
12
 * Class AdGroups
13
 * @package Gladyshev\Yandex\Direct\Service
14
 */
15
final class AdGroups extends AbstractService
16
{
17
    /**
18
     * Создает группы объявлений.
19
     *
20
     * @param $AdGroups
21
     * @return array
22
     * @throws \Throwable
23
     *
24
     * @see https://tech.yandex.ru/direct/doc/ref-v5/adgroups/add-docpage/
25
     */
26
    public function add($AdGroups)
27
    {
28
        return $this->call([
29
            'method' => 'add',
30
            'params' => [
31
                'AdGroups' => $AdGroups
32
            ]
33
        ]);
34
    }
35
36
    /**
37
     * Удаляет группы объявлений.
38
     *
39
     * @param $SelectionCriteria
40
     * @return array
41
     * @throws \Throwable
42
     *
43
     * @see https://tech.yandex.ru/direct/doc/ref-v5/adgroups/delete-docpage/
44
     */
45
    public function delete($SelectionCriteria)
46
    {
47
        return $this->call([
48
            'method' => 'delete',
49
            'params' => [
50
                'SelectionCriteria' => $SelectionCriteria
51
            ]
52
        ]);
53
    }
54
55
    /**
56
     * Возвращает параметры групп, отвечающих заданным критериям.
57
     *
58
     * @param array $SelectionCriteria
59
     * @param array $FieldNames
60
     * @param array $MobileAppAdGroupFieldNames
61
     * @param array $DynamicTextAdGroupFieldNames
62
     * @param array $DynamicTextFeedAdGroupFieldNames
63
     * @param array $SmartAdGroupFieldNames
64
     * @param array $Page
65
     *
66
     * @return array
67
     *
68
     * @throws \Throwable
69
     * @throws ReflectionException
70
     * @throws ErrorResponseException
71
     *
72
     * @see https://tech.yandex.ru/direct/doc/ref-v5/adgroups/delete-docpage/
73
     */
74
    public function get(
75
        $SelectionCriteria,
76
        $FieldNames,
77
        $MobileAppAdGroupFieldNames = null,
78
        $DynamicTextAdGroupFieldNames = null,
79
        $DynamicTextFeedAdGroupFieldNames = null,
80
        $SmartAdGroupFieldNames = null,
81
        $Page = null
82
    ) {
83
        $params = compact(get_param_names(__METHOD__));
84
85
        return $this->call([
86
            'method' => 'get',
87
            'params' => $params
88
        ]);
89
    }
90
91
    /**
92
     * Изменяет параметры групп объявлений.
93
     *
94
     * @param $AdGroups
95
     * @return array
96
     * @throws \Throwable
97
     *
98
     * @see https://tech.yandex.ru/direct/doc/ref-v5/adgroups/update-docpage/
99
     */
100
    public function update($AdGroups)
101
    {
102
        return $this->call([
103
            'method' => 'update',
104
            'params' => [
105
                'AdGroups' => $AdGroups
106
            ]
107
        ]);
108
    }
109
}
110