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