1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2015-present, Facebook, Inc. All rights reserved. |
4
|
|
|
* |
5
|
|
|
* You are hereby granted a non-exclusive, worldwide, royalty-free license to |
6
|
|
|
* use, copy, modify, and distribute this software in source code or binary |
7
|
|
|
* form for use in connection with the web services and APIs provided by |
8
|
|
|
* Facebook. |
9
|
|
|
* |
10
|
|
|
* As with any software that integrates with the Facebook platform, your use |
11
|
|
|
* of this software is subject to the Facebook Developer Principles and |
12
|
|
|
* Policies [http://developers.facebook.com/policy/]. This copyright notice |
13
|
|
|
* shall be included in all copies or substantial portions of the software. |
14
|
|
|
* |
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
18
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
19
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
20
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
21
|
|
|
* DEALINGS IN THE SOFTWARE. |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
namespace FacebookAds\Object; |
26
|
|
|
|
27
|
|
|
use FacebookAds\ApiRequest; |
28
|
|
|
use FacebookAds\Cursor; |
29
|
|
|
use FacebookAds\Http\RequestInterface; |
30
|
|
|
use FacebookAds\TypeChecker; |
31
|
|
|
use FacebookAds\Object\Fields\CampaignFields; |
32
|
|
|
use FacebookAds\Object\Values\AdDatePresetValues; |
33
|
|
|
use FacebookAds\Object\Values\AdLabelExecutionOptionsValues; |
34
|
|
|
use FacebookAds\Object\Values\AdSetDatePresetValues; |
35
|
|
|
use FacebookAds\Object\Values\AdSetEffectiveStatusValues; |
36
|
|
|
use FacebookAds\Object\Values\AdsInsightsActionAttributionWindowsValues; |
37
|
|
|
use FacebookAds\Object\Values\AdsInsightsActionBreakdownsValues; |
38
|
|
|
use FacebookAds\Object\Values\AdsInsightsActionReportTimeValues; |
39
|
|
|
use FacebookAds\Object\Values\AdsInsightsBreakdownsValues; |
40
|
|
|
use FacebookAds\Object\Values\AdsInsightsDatePresetValues; |
41
|
|
|
use FacebookAds\Object\Values\AdsInsightsLevelValues; |
42
|
|
|
use FacebookAds\Object\Values\AdsInsightsSummaryActionBreakdownsValues; |
43
|
|
|
use FacebookAds\Object\Values\AdsInsightsSummaryValues; |
44
|
|
|
use FacebookAds\Object\Values\CampaignConfiguredStatusValues; |
45
|
|
|
use FacebookAds\Object\Values\CampaignDatePresetValues; |
46
|
|
|
use FacebookAds\Object\Values\CampaignDeleteStrategyValues; |
47
|
|
|
use FacebookAds\Object\Values\CampaignEffectiveStatusValues; |
48
|
|
|
use FacebookAds\Object\Values\CampaignExecutionOptionsValues; |
49
|
|
|
use FacebookAds\Object\Values\CampaignObjectiveValues; |
50
|
|
|
use FacebookAds\Object\Values\CampaignOperatorValues; |
51
|
|
|
use FacebookAds\Object\Values\CampaignStatusValues; |
52
|
|
|
use FacebookAds\Object\Traits\AdLabelAwareCrudObjectTrait; |
53
|
|
|
use FacebookAds\Object\Traits\ObjectValidation; |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* This class is auto-genereated. |
57
|
|
|
* |
58
|
|
|
* For any issues or feature requests related to this class, please let us know |
59
|
|
|
* on github and we'll fix in our codegen framework. We'll not be able to accept |
60
|
|
|
* pull request for this class. |
61
|
|
|
* |
62
|
|
|
*/ |
63
|
|
|
|
64
|
|
|
class Campaign extends AbstractArchivableCrudObject { |
65
|
|
|
|
66
|
|
|
use AdLabelAwareCrudObjectTrait; |
67
|
|
|
use ObjectValidation; |
68
|
|
|
|
69
|
|
|
protected function getEndpoint() { |
70
|
|
|
return 'campaigns'; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return CampaignFields |
75
|
|
|
*/ |
76
|
|
|
public static function getFieldsEnum() { |
77
|
|
|
return CampaignFields::getInstance(); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
protected static function getReferencedEnums() { |
81
|
|
|
$ref_enums = array(); |
82
|
|
|
$ref_enums['ConfiguredStatus'] = CampaignConfiguredStatusValues::getInstance()->getValues(); |
83
|
|
|
$ref_enums['EffectiveStatus'] = CampaignEffectiveStatusValues::getInstance()->getValues(); |
84
|
|
|
$ref_enums['Status'] = CampaignStatusValues::getInstance()->getValues(); |
85
|
|
|
$ref_enums['DatePreset'] = CampaignDatePresetValues::getInstance()->getValues(); |
86
|
|
|
$ref_enums['DeleteStrategy'] = CampaignDeleteStrategyValues::getInstance()->getValues(); |
87
|
|
|
$ref_enums['ExecutionOptions'] = CampaignExecutionOptionsValues::getInstance()->getValues(); |
88
|
|
|
$ref_enums['Objective'] = CampaignObjectiveValues::getInstance()->getValues(); |
89
|
|
|
$ref_enums['Operator'] = CampaignOperatorValues::getInstance()->getValues(); |
90
|
|
|
return $ref_enums; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
|
94
|
|
|
public function deleteAdLabels(array $fields = array(), array $params = array(), $pending = false) { |
95
|
|
|
$this->assureId(); |
96
|
|
|
|
97
|
|
|
$param_types = array( |
98
|
|
|
'adlabels' => 'list<Object>', |
99
|
|
|
'execution_options' => 'list<execution_options_enum>', |
100
|
|
|
'id' => 'string', |
101
|
|
|
); |
102
|
|
|
$enums = array( |
103
|
|
|
'execution_options_enum' => AdLabelExecutionOptionsValues::getInstance()->getValues(), |
104
|
|
|
); |
105
|
|
|
|
106
|
|
|
$request = new ApiRequest( |
107
|
|
|
$this->api, |
108
|
|
|
$this->data['id'], |
109
|
|
|
RequestInterface::METHOD_DELETE, |
110
|
|
|
'/adlabels', |
111
|
|
|
new AbstractCrudObject(), |
112
|
|
|
'EDGE', |
113
|
|
|
array(), |
114
|
|
|
new TypeChecker($param_types, $enums) |
115
|
|
|
); |
116
|
|
|
$request->addParams($params); |
117
|
|
|
$request->addFields($fields); |
118
|
|
|
return $pending ? $request : $request->execute(); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
public function createAdLabel(array $fields = array(), array $params = array(), $pending = false) { |
122
|
|
|
$this->assureId(); |
123
|
|
|
|
124
|
|
|
$param_types = array( |
125
|
|
|
'adlabels' => 'list<Object>', |
126
|
|
|
'execution_options' => 'list<execution_options_enum>', |
127
|
|
|
'id' => 'string', |
128
|
|
|
); |
129
|
|
|
$enums = array( |
130
|
|
|
'execution_options_enum' => AdLabelExecutionOptionsValues::getInstance()->getValues(), |
131
|
|
|
); |
132
|
|
|
|
133
|
|
|
$request = new ApiRequest( |
134
|
|
|
$this->api, |
135
|
|
|
$this->data['id'], |
136
|
|
|
RequestInterface::METHOD_POST, |
137
|
|
|
'/adlabels', |
138
|
|
|
new AbstractCrudObject(), |
139
|
|
|
'EDGE', |
140
|
|
|
array(), |
141
|
|
|
new TypeChecker($param_types, $enums) |
142
|
|
|
); |
143
|
|
|
$request->addParams($params); |
144
|
|
|
$request->addFields($fields); |
145
|
|
|
return $pending ? $request : $request->execute(); |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
public function getAds(array $fields = array(), array $params = array(), $pending = false) { |
149
|
|
|
$this->assureId(); |
150
|
|
|
|
151
|
|
|
$param_types = array( |
152
|
|
|
'ad_draft_id' => 'string', |
153
|
|
|
'date_preset' => 'date_preset_enum', |
154
|
|
|
'effective_status' => 'list<string>', |
155
|
|
|
'include_deleted' => 'bool', |
156
|
|
|
'time_range' => 'map', |
157
|
|
|
'updated_since' => 'int', |
158
|
|
|
); |
159
|
|
|
$enums = array( |
160
|
|
|
'date_preset_enum' => AdDatePresetValues::getInstance()->getValues(), |
161
|
|
|
); |
162
|
|
|
|
163
|
|
|
$request = new ApiRequest( |
164
|
|
|
$this->api, |
165
|
|
|
$this->data['id'], |
166
|
|
|
RequestInterface::METHOD_GET, |
167
|
|
|
'/ads', |
168
|
|
|
new Ad(), |
169
|
|
|
'EDGE', |
170
|
|
|
Ad::getFieldsEnum()->getValues(), |
171
|
|
|
new TypeChecker($param_types, $enums) |
172
|
|
|
); |
173
|
|
|
$request->addParams($params); |
174
|
|
|
$request->addFields($fields); |
175
|
|
|
return $pending ? $request : $request->execute(); |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
public function getAdSets(array $fields = array(), array $params = array(), $pending = false) { |
179
|
|
|
$this->assureId(); |
180
|
|
|
|
181
|
|
|
$param_types = array( |
182
|
|
|
'ad_draft_id' => 'string', |
183
|
|
|
'date_preset' => 'date_preset_enum', |
184
|
|
|
'effective_status' => 'list<effective_status_enum>', |
185
|
|
|
'is_completed' => 'bool', |
186
|
|
|
'time_range' => 'map', |
187
|
|
|
); |
188
|
|
|
$enums = array( |
189
|
|
|
'date_preset_enum' => AdSetDatePresetValues::getInstance()->getValues(), |
190
|
|
|
'effective_status_enum' => AdSetEffectiveStatusValues::getInstance()->getValues(), |
191
|
|
|
); |
192
|
|
|
|
193
|
|
|
$request = new ApiRequest( |
194
|
|
|
$this->api, |
195
|
|
|
$this->data['id'], |
196
|
|
|
RequestInterface::METHOD_GET, |
197
|
|
|
'/adsets', |
198
|
|
|
new AdSet(), |
199
|
|
|
'EDGE', |
200
|
|
|
AdSet::getFieldsEnum()->getValues(), |
201
|
|
|
new TypeChecker($param_types, $enums) |
202
|
|
|
); |
203
|
|
|
$request->addParams($params); |
204
|
|
|
$request->addFields($fields); |
205
|
|
|
return $pending ? $request : $request->execute(); |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
public function getInsights(array $fields = array(), array $params = array(), $pending = false) { |
209
|
|
|
$this->assureId(); |
210
|
|
|
|
211
|
|
|
$param_types = array( |
212
|
|
|
'action_attribution_windows' => 'list<action_attribution_windows_enum>', |
213
|
|
|
'action_breakdowns' => 'list<action_breakdowns_enum>', |
214
|
|
|
'action_report_time' => 'action_report_time_enum', |
215
|
|
|
'breakdowns' => 'list<breakdowns_enum>', |
216
|
|
|
'date_preset' => 'date_preset_enum', |
217
|
|
|
'default_summary' => 'bool', |
218
|
|
|
'fields' => 'list<fields_enum>', |
219
|
|
|
'filtering' => 'list<Object>', |
220
|
|
|
'level' => 'level_enum', |
221
|
|
|
'product_id_limit' => 'int', |
222
|
|
|
'sort' => 'list<string>', |
223
|
|
|
'summary' => 'list<summary_enum>', |
224
|
|
|
'summary_action_breakdowns' => 'list<summary_action_breakdowns_enum>', |
225
|
|
|
'time_increment' => 'string', |
226
|
|
|
'time_range' => 'map', |
227
|
|
|
'time_ranges' => 'list<map>', |
228
|
|
|
); |
229
|
|
|
$enums = array( |
230
|
|
|
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(), |
231
|
|
|
'action_breakdowns_enum' => AdsInsightsActionBreakdownsValues::getInstance()->getValues(), |
232
|
|
|
'action_report_time_enum' => AdsInsightsActionReportTimeValues::getInstance()->getValues(), |
233
|
|
|
'breakdowns_enum' => AdsInsightsBreakdownsValues::getInstance()->getValues(), |
234
|
|
|
'date_preset_enum' => AdsInsightsDatePresetValues::getInstance()->getValues(), |
235
|
|
|
'summary_enum' => AdsInsightsSummaryValues::getInstance()->getValues(), |
236
|
|
|
'level_enum' => AdsInsightsLevelValues::getInstance()->getValues(), |
237
|
|
|
'summary_action_breakdowns_enum' => AdsInsightsSummaryActionBreakdownsValues::getInstance()->getValues(), |
238
|
|
|
); |
239
|
|
|
|
240
|
|
|
$request = new ApiRequest( |
241
|
|
|
$this->api, |
242
|
|
|
$this->data['id'], |
243
|
|
|
RequestInterface::METHOD_GET, |
244
|
|
|
'/insights', |
245
|
|
|
new AdsInsights(), |
246
|
|
|
'EDGE', |
247
|
|
|
AdsInsights::getFieldsEnum()->getValues(), |
248
|
|
|
new TypeChecker($param_types, $enums) |
249
|
|
|
); |
250
|
|
|
$request->addParams($params); |
251
|
|
|
$request->addFields($fields); |
252
|
|
|
return $pending ? $request : $request->execute(); |
253
|
|
|
} |
254
|
|
|
|
255
|
|
|
public function getInsightsAsync(array $fields = array(), array $params = array(), $pending = false) { |
256
|
|
|
$this->assureId(); |
257
|
|
|
|
258
|
|
|
$param_types = array( |
259
|
|
|
'action_attribution_windows' => 'list<action_attribution_windows_enum>', |
260
|
|
|
'action_breakdowns' => 'list<action_breakdowns_enum>', |
261
|
|
|
'action_report_time' => 'action_report_time_enum', |
262
|
|
|
'breakdowns' => 'list<breakdowns_enum>', |
263
|
|
|
'date_preset' => 'date_preset_enum', |
264
|
|
|
'default_summary' => 'bool', |
265
|
|
|
'fields' => 'list<fields_enum>', |
266
|
|
|
'filtering' => 'list<Object>', |
267
|
|
|
'level' => 'level_enum', |
268
|
|
|
'product_id_limit' => 'int', |
269
|
|
|
'sort' => 'list<string>', |
270
|
|
|
'summary' => 'list<summary_enum>', |
271
|
|
|
'summary_action_breakdowns' => 'list<summary_action_breakdowns_enum>', |
272
|
|
|
'time_increment' => 'string', |
273
|
|
|
'time_range' => 'map', |
274
|
|
|
'time_ranges' => 'list<map>', |
275
|
|
|
); |
276
|
|
|
$enums = array( |
277
|
|
|
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(), |
278
|
|
|
'action_breakdowns_enum' => AdsInsightsActionBreakdownsValues::getInstance()->getValues(), |
279
|
|
|
'action_report_time_enum' => AdsInsightsActionReportTimeValues::getInstance()->getValues(), |
280
|
|
|
'breakdowns_enum' => AdsInsightsBreakdownsValues::getInstance()->getValues(), |
281
|
|
|
'date_preset_enum' => AdsInsightsDatePresetValues::getInstance()->getValues(), |
282
|
|
|
'summary_enum' => AdsInsightsSummaryValues::getInstance()->getValues(), |
283
|
|
|
'level_enum' => AdsInsightsLevelValues::getInstance()->getValues(), |
284
|
|
|
'summary_action_breakdowns_enum' => AdsInsightsSummaryActionBreakdownsValues::getInstance()->getValues(), |
285
|
|
|
); |
286
|
|
|
|
287
|
|
|
$request = new ApiRequest( |
288
|
|
|
$this->api, |
289
|
|
|
$this->data['id'], |
290
|
|
|
RequestInterface::METHOD_POST, |
291
|
|
|
'/insights', |
292
|
|
|
new AdReportRun(), |
293
|
|
|
'EDGE', |
294
|
|
|
AdReportRun::getFieldsEnum()->getValues(), |
295
|
|
|
new TypeChecker($param_types, $enums) |
296
|
|
|
); |
297
|
|
|
$request->addParams($params); |
298
|
|
|
$request->addFields($fields); |
299
|
|
|
return $pending ? $request : $request->execute(); |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
public function deleteSelf(array $fields = array(), array $params = array(), $pending = false) { |
303
|
|
|
$this->assureId(); |
304
|
|
|
|
305
|
|
|
$param_types = array( |
306
|
|
|
'id' => 'string', |
307
|
|
|
); |
308
|
|
|
$enums = array( |
309
|
|
|
); |
310
|
|
|
|
311
|
|
|
$request = new ApiRequest( |
312
|
|
|
$this->api, |
313
|
|
|
$this->data['id'], |
314
|
|
|
RequestInterface::METHOD_DELETE, |
315
|
|
|
'/', |
316
|
|
|
new AbstractCrudObject(), |
317
|
|
|
'NODE', |
318
|
|
|
array(), |
319
|
|
|
new TypeChecker($param_types, $enums) |
320
|
|
|
); |
321
|
|
|
$request->addParams($params); |
322
|
|
|
$request->addFields($fields); |
323
|
|
|
return $pending ? $request : $request->execute(); |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
public function getSelf(array $fields = array(), array $params = array(), $pending = false) { |
327
|
|
|
$this->assureId(); |
328
|
|
|
|
329
|
|
|
$param_types = array( |
330
|
|
|
); |
331
|
|
|
$enums = array( |
332
|
|
|
); |
333
|
|
|
|
334
|
|
|
$request = new ApiRequest( |
335
|
|
|
$this->api, |
336
|
|
|
$this->data['id'], |
337
|
|
|
RequestInterface::METHOD_GET, |
338
|
|
|
'/', |
339
|
|
|
new Campaign(), |
340
|
|
|
'NODE', |
341
|
|
|
Campaign::getFieldsEnum()->getValues(), |
342
|
|
|
new TypeChecker($param_types, $enums) |
343
|
|
|
); |
344
|
|
|
$request->addParams($params); |
345
|
|
|
$request->addFields($fields); |
346
|
|
|
return $pending ? $request : $request->execute(); |
347
|
|
|
} |
348
|
|
|
|
349
|
|
|
public function updateSelf(array $fields = array(), array $params = array(), $pending = false) { |
350
|
|
|
$this->assureId(); |
351
|
|
|
|
352
|
|
|
$param_types = array( |
353
|
|
|
'adlabels' => 'list<Object>', |
354
|
|
|
'execution_options' => 'list<execution_options_enum>', |
355
|
|
|
'name' => 'string', |
356
|
|
|
'objective' => 'objective_enum', |
357
|
|
|
'promoted_object' => 'Object', |
358
|
|
|
'spend_cap' => 'unsigned int', |
359
|
|
|
'status' => 'status_enum', |
360
|
|
|
); |
361
|
|
|
$enums = array( |
362
|
|
|
'execution_options_enum' => CampaignExecutionOptionsValues::getInstance()->getValues(), |
363
|
|
|
'objective_enum' => CampaignObjectiveValues::getInstance()->getValues(), |
364
|
|
|
'status_enum' => CampaignStatusValues::getInstance()->getValues(), |
365
|
|
|
); |
366
|
|
|
|
367
|
|
|
$request = new ApiRequest( |
368
|
|
|
$this->api, |
369
|
|
|
$this->data['id'], |
370
|
|
|
RequestInterface::METHOD_POST, |
371
|
|
|
'/', |
372
|
|
|
new AbstractCrudObject(), |
373
|
|
|
'NODE', |
374
|
|
|
array(), |
375
|
|
|
new TypeChecker($param_types, $enums) |
376
|
|
|
); |
377
|
|
|
$request->addParams($params); |
378
|
|
|
$request->addFields($fields); |
379
|
|
|
return $pending ? $request : $request->execute(); |
380
|
|
|
} |
381
|
|
|
|
382
|
|
|
} |
383
|
|
|
|