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-generated. |
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
|
|
|
/** |
70
|
|
|
* @deprecated getEndpoint function is deprecated |
71
|
|
|
*/ |
72
|
|
|
protected function getEndpoint() { |
73
|
|
|
return 'campaigns'; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return CampaignFields |
78
|
|
|
*/ |
79
|
|
|
public static function getFieldsEnum() { |
80
|
|
|
return CampaignFields::getInstance(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
protected static function getReferencedEnums() { |
84
|
|
|
$ref_enums = array(); |
85
|
|
|
$ref_enums['ConfiguredStatus'] = CampaignConfiguredStatusValues::getInstance()->getValues(); |
86
|
|
|
$ref_enums['EffectiveStatus'] = CampaignEffectiveStatusValues::getInstance()->getValues(); |
87
|
|
|
$ref_enums['Status'] = CampaignStatusValues::getInstance()->getValues(); |
88
|
|
|
$ref_enums['DatePreset'] = CampaignDatePresetValues::getInstance()->getValues(); |
89
|
|
|
$ref_enums['DeleteStrategy'] = CampaignDeleteStrategyValues::getInstance()->getValues(); |
90
|
|
|
$ref_enums['ExecutionOptions'] = CampaignExecutionOptionsValues::getInstance()->getValues(); |
91
|
|
|
$ref_enums['Objective'] = CampaignObjectiveValues::getInstance()->getValues(); |
92
|
|
|
$ref_enums['Operator'] = CampaignOperatorValues::getInstance()->getValues(); |
93
|
|
|
return $ref_enums; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
|
97
|
|
|
public function deleteAdLabels(array $fields = array(), array $params = array(), $pending = false) { |
98
|
|
|
$this->assureId(); |
99
|
|
|
|
100
|
|
|
$param_types = array( |
101
|
|
|
'adlabels' => 'list<Object>', |
102
|
|
|
'execution_options' => 'list<execution_options_enum>', |
103
|
|
|
); |
104
|
|
|
$enums = array( |
105
|
|
|
'execution_options_enum' => AdLabelExecutionOptionsValues::getInstance()->getValues(), |
106
|
|
|
); |
107
|
|
|
|
108
|
|
|
$request = new ApiRequest( |
109
|
|
|
$this->api, |
110
|
|
|
$this->data['id'], |
111
|
|
|
RequestInterface::METHOD_DELETE, |
112
|
|
|
'/adlabels', |
113
|
|
|
new AbstractCrudObject(), |
114
|
|
|
'EDGE', |
115
|
|
|
array(), |
116
|
|
|
new TypeChecker($param_types, $enums) |
117
|
|
|
); |
118
|
|
|
$request->addParams($params); |
119
|
|
|
$request->addFields($fields); |
120
|
|
|
return $pending ? $request : $request->execute(); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
public function createAdLabel(array $fields = array(), array $params = array(), $pending = false) { |
124
|
|
|
$this->assureId(); |
125
|
|
|
|
126
|
|
|
$param_types = array( |
127
|
|
|
'adlabels' => 'list<Object>', |
128
|
|
|
'execution_options' => 'list<execution_options_enum>', |
129
|
|
|
); |
130
|
|
|
$enums = array( |
131
|
|
|
'execution_options_enum' => AdLabelExecutionOptionsValues::getInstance()->getValues(), |
132
|
|
|
); |
133
|
|
|
|
134
|
|
|
$request = new ApiRequest( |
135
|
|
|
$this->api, |
136
|
|
|
$this->data['id'], |
137
|
|
|
RequestInterface::METHOD_POST, |
138
|
|
|
'/adlabels', |
139
|
|
|
new AdLabel(), |
140
|
|
|
'EDGE', |
141
|
|
|
AdLabel::getFieldsEnum()->getValues(), |
142
|
|
|
new TypeChecker($param_types, $enums) |
143
|
|
|
); |
144
|
|
|
$request->addParams($params); |
145
|
|
|
$request->addFields($fields); |
146
|
|
|
return $pending ? $request : $request->execute(); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
public function getAds(array $fields = array(), array $params = array(), $pending = false) { |
150
|
|
|
$this->assureId(); |
151
|
|
|
|
152
|
|
|
$param_types = array( |
153
|
|
|
'ad_draft_id' => 'string', |
154
|
|
|
'date_preset' => 'date_preset_enum', |
155
|
|
|
'effective_status' => 'list<string>', |
156
|
|
|
'include_deleted' => 'bool', |
157
|
|
|
'time_range' => 'Object', |
158
|
|
|
'updated_since' => 'int', |
159
|
|
|
); |
160
|
|
|
$enums = array( |
161
|
|
|
'date_preset_enum' => AdDatePresetValues::getInstance()->getValues(), |
162
|
|
|
); |
163
|
|
|
|
164
|
|
|
$request = new ApiRequest( |
165
|
|
|
$this->api, |
166
|
|
|
$this->data['id'], |
167
|
|
|
RequestInterface::METHOD_GET, |
168
|
|
|
'/ads', |
169
|
|
|
new Ad(), |
170
|
|
|
'EDGE', |
171
|
|
|
Ad::getFieldsEnum()->getValues(), |
172
|
|
|
new TypeChecker($param_types, $enums) |
173
|
|
|
); |
174
|
|
|
$request->addParams($params); |
175
|
|
|
$request->addFields($fields); |
176
|
|
|
return $pending ? $request : $request->execute(); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
public function getAdSets(array $fields = array(), array $params = array(), $pending = false) { |
180
|
|
|
$this->assureId(); |
181
|
|
|
|
182
|
|
|
$param_types = array( |
183
|
|
|
'ad_draft_id' => 'string', |
184
|
|
|
'date_preset' => 'date_preset_enum', |
185
|
|
|
'effective_status' => 'list<effective_status_enum>', |
186
|
|
|
'is_completed' => 'bool', |
187
|
|
|
'time_range' => 'Object', |
188
|
|
|
); |
189
|
|
|
$enums = array( |
190
|
|
|
'date_preset_enum' => AdSetDatePresetValues::getInstance()->getValues(), |
191
|
|
|
'effective_status_enum' => AdSetEffectiveStatusValues::getInstance()->getValues(), |
192
|
|
|
); |
193
|
|
|
|
194
|
|
|
$request = new ApiRequest( |
195
|
|
|
$this->api, |
196
|
|
|
$this->data['id'], |
197
|
|
|
RequestInterface::METHOD_GET, |
198
|
|
|
'/adsets', |
199
|
|
|
new AdSet(), |
200
|
|
|
'EDGE', |
201
|
|
|
AdSet::getFieldsEnum()->getValues(), |
202
|
|
|
new TypeChecker($param_types, $enums) |
203
|
|
|
); |
204
|
|
|
$request->addParams($params); |
205
|
|
|
$request->addFields($fields); |
206
|
|
|
return $pending ? $request : $request->execute(); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
public function getCopies(array $fields = array(), array $params = array(), $pending = false) { |
210
|
|
|
$this->assureId(); |
211
|
|
|
|
212
|
|
|
$param_types = array( |
213
|
|
|
'date_preset' => 'date_preset_enum', |
214
|
|
|
'effective_status' => 'list<effective_status_enum>', |
215
|
|
|
'is_completed' => 'bool', |
216
|
|
|
'time_range' => 'Object', |
217
|
|
|
); |
218
|
|
|
$enums = array( |
219
|
|
|
'date_preset_enum' => CampaignDatePresetValues::getInstance()->getValues(), |
220
|
|
|
'effective_status_enum' => CampaignEffectiveStatusValues::getInstance()->getValues(), |
221
|
|
|
); |
222
|
|
|
|
223
|
|
|
$request = new ApiRequest( |
224
|
|
|
$this->api, |
225
|
|
|
$this->data['id'], |
226
|
|
|
RequestInterface::METHOD_GET, |
227
|
|
|
'/copies', |
228
|
|
|
new Campaign(), |
229
|
|
|
'EDGE', |
230
|
|
|
Campaign::getFieldsEnum()->getValues(), |
231
|
|
|
new TypeChecker($param_types, $enums) |
232
|
|
|
); |
233
|
|
|
$request->addParams($params); |
234
|
|
|
$request->addFields($fields); |
235
|
|
|
return $pending ? $request : $request->execute(); |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
public function getInsights(array $fields = array(), array $params = array(), $pending = false) { |
239
|
|
|
$this->assureId(); |
240
|
|
|
|
241
|
|
|
$param_types = array( |
242
|
|
|
'action_attribution_windows' => 'list<action_attribution_windows_enum>', |
243
|
|
|
'action_breakdowns' => 'list<action_breakdowns_enum>', |
244
|
|
|
'action_report_time' => 'action_report_time_enum', |
245
|
|
|
'breakdowns' => 'list<breakdowns_enum>', |
246
|
|
|
'date_preset' => 'date_preset_enum', |
247
|
|
|
'default_summary' => 'bool', |
248
|
|
|
'export_columns' => 'list<string>', |
249
|
|
|
'export_format' => 'string', |
250
|
|
|
'export_name' => 'string', |
251
|
|
|
'fields' => 'list<fields_enum>', |
252
|
|
|
'filtering' => 'list<Object>', |
253
|
|
|
'level' => 'level_enum', |
254
|
|
|
'product_id_limit' => 'int', |
255
|
|
|
'sort' => 'list<string>', |
256
|
|
|
'summary' => 'list<summary_enum>', |
257
|
|
|
'summary_action_breakdowns' => 'list<summary_action_breakdowns_enum>', |
258
|
|
|
'time_increment' => 'string', |
259
|
|
|
'time_range' => 'Object', |
260
|
|
|
'time_ranges' => 'list<Object>', |
261
|
|
|
'use_account_attribution_setting' => 'bool', |
262
|
|
|
); |
263
|
|
|
$enums = array( |
264
|
|
|
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(), |
265
|
|
|
'action_breakdowns_enum' => AdsInsightsActionBreakdownsValues::getInstance()->getValues(), |
266
|
|
|
'action_report_time_enum' => AdsInsightsActionReportTimeValues::getInstance()->getValues(), |
267
|
|
|
'breakdowns_enum' => AdsInsightsBreakdownsValues::getInstance()->getValues(), |
268
|
|
|
'date_preset_enum' => AdsInsightsDatePresetValues::getInstance()->getValues(), |
269
|
|
|
'summary_enum' => AdsInsightsSummaryValues::getInstance()->getValues(), |
270
|
|
|
'level_enum' => AdsInsightsLevelValues::getInstance()->getValues(), |
271
|
|
|
'summary_action_breakdowns_enum' => AdsInsightsSummaryActionBreakdownsValues::getInstance()->getValues(), |
272
|
|
|
); |
273
|
|
|
|
274
|
|
|
$request = new ApiRequest( |
275
|
|
|
$this->api, |
276
|
|
|
$this->data['id'], |
277
|
|
|
RequestInterface::METHOD_GET, |
278
|
|
|
'/insights', |
279
|
|
|
new AdsInsights(), |
280
|
|
|
'EDGE', |
281
|
|
|
AdsInsights::getFieldsEnum()->getValues(), |
282
|
|
|
new TypeChecker($param_types, $enums) |
283
|
|
|
); |
284
|
|
|
$request->addParams($params); |
285
|
|
|
$request->addFields($fields); |
286
|
|
|
return $pending ? $request : $request->execute(); |
287
|
|
|
} |
288
|
|
|
|
289
|
|
|
public function getInsightsAsync(array $fields = array(), array $params = array(), $pending = false) { |
290
|
|
|
$this->assureId(); |
291
|
|
|
|
292
|
|
|
$param_types = array( |
293
|
|
|
'action_attribution_windows' => 'list<action_attribution_windows_enum>', |
294
|
|
|
'action_breakdowns' => 'list<action_breakdowns_enum>', |
295
|
|
|
'action_report_time' => 'action_report_time_enum', |
296
|
|
|
'breakdowns' => 'list<breakdowns_enum>', |
297
|
|
|
'date_preset' => 'date_preset_enum', |
298
|
|
|
'default_summary' => 'bool', |
299
|
|
|
'export_columns' => 'list<string>', |
300
|
|
|
'export_format' => 'string', |
301
|
|
|
'export_name' => 'string', |
302
|
|
|
'fields' => 'list<fields_enum>', |
303
|
|
|
'filtering' => 'list<Object>', |
304
|
|
|
'level' => 'level_enum', |
305
|
|
|
'product_id_limit' => 'int', |
306
|
|
|
'sort' => 'list<string>', |
307
|
|
|
'summary' => 'list<summary_enum>', |
308
|
|
|
'summary_action_breakdowns' => 'list<summary_action_breakdowns_enum>', |
309
|
|
|
'time_increment' => 'string', |
310
|
|
|
'time_range' => 'Object', |
311
|
|
|
'time_ranges' => 'list<Object>', |
312
|
|
|
'use_account_attribution_setting' => 'bool', |
313
|
|
|
); |
314
|
|
|
$enums = array( |
315
|
|
|
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(), |
316
|
|
|
'action_breakdowns_enum' => AdsInsightsActionBreakdownsValues::getInstance()->getValues(), |
317
|
|
|
'action_report_time_enum' => AdsInsightsActionReportTimeValues::getInstance()->getValues(), |
318
|
|
|
'breakdowns_enum' => AdsInsightsBreakdownsValues::getInstance()->getValues(), |
319
|
|
|
'date_preset_enum' => AdsInsightsDatePresetValues::getInstance()->getValues(), |
320
|
|
|
'summary_enum' => AdsInsightsSummaryValues::getInstance()->getValues(), |
321
|
|
|
'level_enum' => AdsInsightsLevelValues::getInstance()->getValues(), |
322
|
|
|
'summary_action_breakdowns_enum' => AdsInsightsSummaryActionBreakdownsValues::getInstance()->getValues(), |
323
|
|
|
); |
324
|
|
|
|
325
|
|
|
$request = new ApiRequest( |
326
|
|
|
$this->api, |
327
|
|
|
$this->data['id'], |
328
|
|
|
RequestInterface::METHOD_POST, |
329
|
|
|
'/insights', |
330
|
|
|
new AdReportRun(), |
331
|
|
|
'EDGE', |
332
|
|
|
AdReportRun::getFieldsEnum()->getValues(), |
333
|
|
|
new TypeChecker($param_types, $enums) |
334
|
|
|
); |
335
|
|
|
$request->addParams($params); |
336
|
|
|
$request->addFields($fields); |
337
|
|
|
return $pending ? $request : $request->execute(); |
338
|
|
|
} |
339
|
|
|
|
340
|
|
|
public function deleteSelf(array $fields = array(), array $params = array(), $pending = false) { |
341
|
|
|
$this->assureId(); |
342
|
|
|
|
343
|
|
|
$param_types = array( |
344
|
|
|
); |
345
|
|
|
$enums = array( |
346
|
|
|
); |
347
|
|
|
|
348
|
|
|
$request = new ApiRequest( |
349
|
|
|
$this->api, |
350
|
|
|
$this->data['id'], |
351
|
|
|
RequestInterface::METHOD_DELETE, |
352
|
|
|
'/', |
353
|
|
|
new AbstractCrudObject(), |
354
|
|
|
'NODE', |
355
|
|
|
array(), |
356
|
|
|
new TypeChecker($param_types, $enums) |
357
|
|
|
); |
358
|
|
|
$request->addParams($params); |
359
|
|
|
$request->addFields($fields); |
360
|
|
|
return $pending ? $request : $request->execute(); |
361
|
|
|
} |
362
|
|
|
|
363
|
|
|
public function getSelf(array $fields = array(), array $params = array(), $pending = false) { |
364
|
|
|
$this->assureId(); |
365
|
|
|
|
366
|
|
|
$param_types = array( |
367
|
|
|
); |
368
|
|
|
$enums = array( |
369
|
|
|
); |
370
|
|
|
|
371
|
|
|
$request = new ApiRequest( |
372
|
|
|
$this->api, |
373
|
|
|
$this->data['id'], |
374
|
|
|
RequestInterface::METHOD_GET, |
375
|
|
|
'/', |
376
|
|
|
new Campaign(), |
377
|
|
|
'NODE', |
378
|
|
|
Campaign::getFieldsEnum()->getValues(), |
379
|
|
|
new TypeChecker($param_types, $enums) |
380
|
|
|
); |
381
|
|
|
$request->addParams($params); |
382
|
|
|
$request->addFields($fields); |
383
|
|
|
return $pending ? $request : $request->execute(); |
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
public function updateSelf(array $fields = array(), array $params = array(), $pending = false) { |
387
|
|
|
$this->assureId(); |
388
|
|
|
|
389
|
|
|
$param_types = array( |
390
|
|
|
'adlabels' => 'list<Object>', |
391
|
|
|
'budget_rebalance_flag' => 'bool', |
392
|
|
|
'execution_options' => 'list<execution_options_enum>', |
393
|
|
|
'name' => 'string', |
394
|
|
|
'objective' => 'objective_enum', |
395
|
|
|
'promoted_object' => 'Object', |
396
|
|
|
'spend_cap' => 'unsigned int', |
397
|
|
|
'status' => 'status_enum', |
398
|
|
|
); |
399
|
|
|
$enums = array( |
400
|
|
|
'execution_options_enum' => CampaignExecutionOptionsValues::getInstance()->getValues(), |
401
|
|
|
'objective_enum' => CampaignObjectiveValues::getInstance()->getValues(), |
402
|
|
|
'status_enum' => CampaignStatusValues::getInstance()->getValues(), |
403
|
|
|
); |
404
|
|
|
|
405
|
|
|
$request = new ApiRequest( |
406
|
|
|
$this->api, |
407
|
|
|
$this->data['id'], |
408
|
|
|
RequestInterface::METHOD_POST, |
409
|
|
|
'/', |
410
|
|
|
new Campaign(), |
411
|
|
|
'NODE', |
412
|
|
|
Campaign::getFieldsEnum()->getValues(), |
413
|
|
|
new TypeChecker($param_types, $enums) |
414
|
|
|
); |
415
|
|
|
$request->addParams($params); |
416
|
|
|
$request->addFields($fields); |
417
|
|
|
return $pending ? $request : $request->execute(); |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
} |
421
|
|
|
|