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