1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Dmitry Gladyshev <[email protected]> |
4
|
|
|
* @date 26/08/2016 13:51 |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Yandex\Direct\Service; |
8
|
|
|
|
9
|
|
|
use Yandex\Direct\Exception\Exception; |
10
|
|
|
use Yandex\Direct\Service; |
11
|
|
|
use function Yandex\Direct\get_param_names; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class Ads |
15
|
|
|
* @package Yandex\Direct\Service |
16
|
|
|
*/ |
17
|
|
|
final class Ads extends Service |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @param $Ads |
21
|
|
|
* @return array |
22
|
|
|
* @throws Exception |
23
|
|
|
* |
24
|
|
|
* @see https://tech.yandex.ru/direct/doc/ref-v5/ads/add-docpage/ |
25
|
|
|
*/ |
26
|
|
|
public function add($Ads) |
27
|
|
|
{ |
28
|
|
|
return $this->request([ |
29
|
|
|
'method' => 'add', |
30
|
|
|
'params' => [ |
31
|
|
|
'Ads' => $Ads |
32
|
|
|
] |
33
|
|
|
]); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param $Ads |
38
|
|
|
* @return array |
39
|
|
|
* @throws Exception |
40
|
|
|
* |
41
|
|
|
* @see https://tech.yandex.ru/direct/doc/ref-v5/ads/update-docpage/ |
42
|
|
|
*/ |
43
|
|
|
public function update($Ads) |
44
|
|
|
{ |
45
|
|
|
return $this->request([ |
46
|
|
|
'method' => 'update', |
47
|
|
|
'params' => [ |
48
|
|
|
'Ads' => $Ads |
49
|
|
|
] |
50
|
|
|
]); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @param $SelectionCriteria |
55
|
|
|
* @return array |
56
|
|
|
* @throws Exception |
57
|
|
|
* |
58
|
|
|
* @see https://tech.yandex.ru/direct/doc/ref-v5/ads/delete-docpage/ |
59
|
|
|
*/ |
60
|
|
|
public function delete($SelectionCriteria) |
61
|
|
|
{ |
62
|
|
|
return $this->request([ |
63
|
|
|
'method' => 'delete', |
64
|
|
|
'params' => [ |
65
|
|
|
'SelectionCriteria' => $SelectionCriteria |
66
|
|
|
] |
67
|
|
|
]); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @param $SelectionCriteria |
72
|
|
|
* @return array |
73
|
|
|
* @throws Exception |
74
|
|
|
* |
75
|
|
|
* https://tech.yandex.ru/direct/doc/ref-v5/ads/suspend-docpage/ |
76
|
|
|
*/ |
77
|
|
|
public function suspend($SelectionCriteria) |
78
|
|
|
{ |
79
|
|
|
return $this->request([ |
80
|
|
|
'method' => 'suspend', |
81
|
|
|
'params' => [ |
82
|
|
|
'SelectionCriteria' => $SelectionCriteria |
83
|
|
|
] |
84
|
|
|
]); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @param $SelectionCriteria |
89
|
|
|
* @return array |
90
|
|
|
* @throws Exception |
91
|
|
|
* |
92
|
|
|
* https://tech.yandex.ru/direct/doc/ref-v5/ads/resume-docpage/ |
93
|
|
|
*/ |
94
|
|
|
public function resume($SelectionCriteria) |
95
|
|
|
{ |
96
|
|
|
return $this->request([ |
97
|
|
|
'method' => 'resume', |
98
|
|
|
'params' => [ |
99
|
|
|
'SelectionCriteria' => $SelectionCriteria |
100
|
|
|
] |
101
|
|
|
]); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @param $SelectionCriteria |
106
|
|
|
* @return array |
107
|
|
|
* @throws Exception |
108
|
|
|
* |
109
|
|
|
* https://tech.yandex.ru/direct/doc/ref-v5/ads/archive-docpage/ |
110
|
|
|
*/ |
111
|
|
|
public function archive($SelectionCriteria) |
112
|
|
|
{ |
113
|
|
|
return $this->request([ |
114
|
|
|
'method' => 'archive', |
115
|
|
|
'params' => [ |
116
|
|
|
'SelectionCriteria' => $SelectionCriteria |
117
|
|
|
] |
118
|
|
|
]); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param $SelectionCriteria |
123
|
|
|
* @return array |
124
|
|
|
* @throws Exception |
125
|
|
|
* |
126
|
|
|
* https://tech.yandex.ru/direct/doc/ref-v5/ads/unarchive-docpage/ |
127
|
|
|
*/ |
128
|
|
|
public function unarchive($SelectionCriteria) |
129
|
|
|
{ |
130
|
|
|
return $this->request([ |
131
|
|
|
'method' => 'unarchive', |
132
|
|
|
'params' => [ |
133
|
|
|
'SelectionCriteria' => $SelectionCriteria |
134
|
|
|
] |
135
|
|
|
]); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @param $SelectionCriteria |
140
|
|
|
* @return array |
141
|
|
|
* @throws Exception |
142
|
|
|
* |
143
|
|
|
* https://tech.yandex.ru/direct/doc/ref-v5/ads/moderate-docpage/ |
144
|
|
|
*/ |
145
|
|
|
public function moderate($SelectionCriteria) |
146
|
|
|
{ |
147
|
|
|
return $this->request([ |
148
|
|
|
'method' => 'moderate', |
149
|
|
|
'params' => [ |
150
|
|
|
'SelectionCriteria' => $SelectionCriteria |
151
|
|
|
] |
152
|
|
|
]); |
153
|
|
|
} |
154
|
|
|
|
155
|
|
|
|
156
|
|
|
/** |
157
|
|
|
* Возвращает параметры объявлений, отвечающих заданным критериям. |
158
|
|
|
* |
159
|
|
|
* @param $SelectionCriteria |
160
|
|
|
* @param $FieldNames |
161
|
|
|
* @param $TextAdFieldNames |
162
|
|
|
* @param $MobileAppAdFieldNames |
163
|
|
|
* @param $DynamicTextAdFieldNames |
164
|
|
|
* @param $TextImageAdFieldNames |
165
|
|
|
* @param $MobileAppImageAdFieldNames |
166
|
|
|
* @param $TextAdBuilderAdFieldNames |
167
|
|
|
* @param $MobileAppAdBuilderAdFieldNames |
168
|
|
|
* @param $CpcVideoAdBuilderAdFieldNames |
169
|
|
|
* @param $CpmBannerAdBuilderAdFieldNames |
170
|
|
|
* @param $CpmVideoAdBuilderAdFieldNames |
171
|
|
|
* @param $Page |
172
|
|
|
* @return array |
173
|
|
|
* @throws Exception |
174
|
|
|
* @throws \ReflectionException |
175
|
|
|
* |
176
|
|
|
* @see https://tech.yandex.ru/direct/doc/ref-v5/ads/get-docpage/ |
177
|
|
|
*/ |
178
|
|
|
public function get( |
179
|
|
|
$SelectionCriteria, |
180
|
|
|
$FieldNames, |
181
|
|
|
$TextAdFieldNames = null, |
182
|
|
|
$MobileAppAdFieldNames = null, |
183
|
|
|
$DynamicTextAdFieldNames = null, |
184
|
|
|
$TextImageAdFieldNames = null, |
185
|
|
|
$MobileAppImageAdFieldNames = null, |
186
|
|
|
$TextAdBuilderAdFieldNames = null, |
187
|
|
|
$MobileAppAdBuilderAdFieldNames = null, |
188
|
|
|
$CpcVideoAdBuilderAdFieldNames = null, |
189
|
|
|
$CpmBannerAdBuilderAdFieldNames = null, |
190
|
|
|
$CpmVideoAdBuilderAdFieldNames = null, |
191
|
|
|
$Page = null |
192
|
|
|
) { |
193
|
|
|
$params = compact(get_param_names(__METHOD__)); |
194
|
|
|
|
195
|
|
|
return $this->request([ |
196
|
|
|
'method' => 'get', |
197
|
|
|
'params' => $params |
198
|
|
|
]); |
199
|
|
|
} |
200
|
|
|
} |
201
|
|
|
|