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\AdFields; |
32
|
|
|
use FacebookAds\Object\Values\AdBidTypeValues; |
33
|
|
|
use FacebookAds\Object\Values\AdConfiguredStatusValues; |
34
|
|
|
use FacebookAds\Object\Values\AdDatePresetValues; |
35
|
|
|
use FacebookAds\Object\Values\AdEffectiveStatusValues; |
36
|
|
|
use FacebookAds\Object\Values\AdExecutionOptionsValues; |
37
|
|
|
use FacebookAds\Object\Values\AdLabelExecutionOptionsValues; |
38
|
|
|
use FacebookAds\Object\Values\AdOperatorValues; |
39
|
|
|
use FacebookAds\Object\Values\AdPreviewAdFormatValues; |
40
|
|
|
use FacebookAds\Object\Values\AdStatusValues; |
41
|
|
|
use FacebookAds\Object\Values\AdsInsightsActionAttributionWindowsValues; |
42
|
|
|
use FacebookAds\Object\Values\AdsInsightsActionBreakdownsValues; |
43
|
|
|
use FacebookAds\Object\Values\AdsInsightsActionReportTimeValues; |
44
|
|
|
use FacebookAds\Object\Values\AdsInsightsBreakdownsValues; |
45
|
|
|
use FacebookAds\Object\Values\AdsInsightsDatePresetValues; |
46
|
|
|
use FacebookAds\Object\Values\AdsInsightsLevelValues; |
47
|
|
|
use FacebookAds\Object\Values\AdsInsightsSummaryActionBreakdownsValues; |
48
|
|
|
use FacebookAds\Object\Values\AdsInsightsSummaryValues; |
49
|
|
|
use FacebookAds\Object\Traits\AdLabelAwareCrudObjectTrait; |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* This class is auto-generated. |
53
|
|
|
* |
54
|
|
|
* For any issues or feature requests related to this class, please let us know |
55
|
|
|
* on github and we'll fix in our codegen framework. We'll not be able to accept |
56
|
|
|
* pull request for this class. |
57
|
|
|
* |
58
|
|
|
*/ |
59
|
|
|
|
60
|
|
|
class Ad extends AbstractArchivableCrudObject |
61
|
|
|
implements CanRedownloadInterface { |
62
|
|
|
|
63
|
|
|
use AdLabelAwareCrudObjectTrait; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @deprecated getEndpoint function is deprecated |
67
|
|
|
*/ |
68
|
|
|
protected function getEndpoint() { |
69
|
|
|
return 'ads'; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return AdFields |
74
|
|
|
*/ |
75
|
|
|
public static function getFieldsEnum() { |
76
|
|
|
return AdFields::getInstance(); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
protected static function getReferencedEnums() { |
80
|
|
|
$ref_enums = array(); |
81
|
|
|
$ref_enums['BidType'] = AdBidTypeValues::getInstance()->getValues(); |
82
|
|
|
$ref_enums['ConfiguredStatus'] = AdConfiguredStatusValues::getInstance()->getValues(); |
83
|
|
|
$ref_enums['EffectiveStatus'] = AdEffectiveStatusValues::getInstance()->getValues(); |
84
|
|
|
$ref_enums['Status'] = AdStatusValues::getInstance()->getValues(); |
85
|
|
|
$ref_enums['DatePreset'] = AdDatePresetValues::getInstance()->getValues(); |
86
|
|
|
$ref_enums['ExecutionOptions'] = AdExecutionOptionsValues::getInstance()->getValues(); |
87
|
|
|
$ref_enums['Operator'] = AdOperatorValues::getInstance()->getValues(); |
88
|
|
|
return $ref_enums; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
public function getAdCreatives(array $fields = array(), array $params = array(), $pending = false) { |
93
|
|
|
$this->assureId(); |
94
|
|
|
|
95
|
|
|
$param_types = array( |
96
|
|
|
); |
97
|
|
|
$enums = array( |
98
|
|
|
); |
99
|
|
|
|
100
|
|
|
$request = new ApiRequest( |
101
|
|
|
$this->api, |
102
|
|
|
$this->data['id'], |
103
|
|
|
RequestInterface::METHOD_GET, |
104
|
|
|
'/adcreatives', |
105
|
|
|
new AdCreative(), |
106
|
|
|
'EDGE', |
107
|
|
|
AdCreative::getFieldsEnum()->getValues(), |
108
|
|
|
new TypeChecker($param_types, $enums) |
109
|
|
|
); |
110
|
|
|
$request->addParams($params); |
111
|
|
|
$request->addFields($fields); |
112
|
|
|
return $pending ? $request : $request->execute(); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
public function deleteAdLabels(array $fields = array(), array $params = array(), $pending = false) { |
116
|
|
|
$this->assureId(); |
117
|
|
|
|
118
|
|
|
$param_types = array( |
119
|
|
|
'adlabels' => 'list<Object>', |
120
|
|
|
'execution_options' => 'list<execution_options_enum>', |
121
|
|
|
); |
122
|
|
|
$enums = array( |
123
|
|
|
'execution_options_enum' => AdLabelExecutionOptionsValues::getInstance()->getValues(), |
124
|
|
|
); |
125
|
|
|
|
126
|
|
|
$request = new ApiRequest( |
127
|
|
|
$this->api, |
128
|
|
|
$this->data['id'], |
129
|
|
|
RequestInterface::METHOD_DELETE, |
130
|
|
|
'/adlabels', |
131
|
|
|
new AbstractCrudObject(), |
132
|
|
|
'EDGE', |
133
|
|
|
array(), |
134
|
|
|
new TypeChecker($param_types, $enums) |
135
|
|
|
); |
136
|
|
|
$request->addParams($params); |
137
|
|
|
$request->addFields($fields); |
138
|
|
|
return $pending ? $request : $request->execute(); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function createAdLabel(array $fields = array(), array $params = array(), $pending = false) { |
142
|
|
|
$this->assureId(); |
143
|
|
|
|
144
|
|
|
$param_types = array( |
145
|
|
|
'adlabels' => 'list<Object>', |
146
|
|
|
'execution_options' => 'list<execution_options_enum>', |
147
|
|
|
); |
148
|
|
|
$enums = array( |
149
|
|
|
'execution_options_enum' => AdLabelExecutionOptionsValues::getInstance()->getValues(), |
150
|
|
|
); |
151
|
|
|
|
152
|
|
|
$request = new ApiRequest( |
153
|
|
|
$this->api, |
154
|
|
|
$this->data['id'], |
155
|
|
|
RequestInterface::METHOD_POST, |
156
|
|
|
'/adlabels', |
157
|
|
|
new AdLabel(), |
158
|
|
|
'EDGE', |
159
|
|
|
AdLabel::getFieldsEnum()->getValues(), |
160
|
|
|
new TypeChecker($param_types, $enums) |
161
|
|
|
); |
162
|
|
|
$request->addParams($params); |
163
|
|
|
$request->addFields($fields); |
164
|
|
|
return $pending ? $request : $request->execute(); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
public function getInsights(array $fields = array(), array $params = array(), $pending = false) { |
168
|
|
|
$this->assureId(); |
169
|
|
|
|
170
|
|
|
$param_types = array( |
171
|
|
|
'action_attribution_windows' => 'list<action_attribution_windows_enum>', |
172
|
|
|
'action_breakdowns' => 'list<action_breakdowns_enum>', |
173
|
|
|
'action_report_time' => 'action_report_time_enum', |
174
|
|
|
'breakdowns' => 'list<breakdowns_enum>', |
175
|
|
|
'date_preset' => 'date_preset_enum', |
176
|
|
|
'default_summary' => 'bool', |
177
|
|
|
'export_columns' => 'list<string>', |
178
|
|
|
'export_format' => 'string', |
179
|
|
|
'export_name' => 'string', |
180
|
|
|
'fields' => 'list<fields_enum>', |
181
|
|
|
'filtering' => 'list<Object>', |
182
|
|
|
'level' => 'level_enum', |
183
|
|
|
'product_id_limit' => 'int', |
184
|
|
|
'sort' => 'list<string>', |
185
|
|
|
'summary' => 'list<summary_enum>', |
186
|
|
|
'summary_action_breakdowns' => 'list<summary_action_breakdowns_enum>', |
187
|
|
|
'time_increment' => 'string', |
188
|
|
|
'time_range' => 'Object', |
189
|
|
|
'time_ranges' => 'list<Object>', |
190
|
|
|
'use_account_attribution_setting' => 'bool', |
191
|
|
|
); |
192
|
|
|
$enums = array( |
193
|
|
|
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(), |
194
|
|
|
'action_breakdowns_enum' => AdsInsightsActionBreakdownsValues::getInstance()->getValues(), |
195
|
|
|
'action_report_time_enum' => AdsInsightsActionReportTimeValues::getInstance()->getValues(), |
196
|
|
|
'breakdowns_enum' => AdsInsightsBreakdownsValues::getInstance()->getValues(), |
197
|
|
|
'date_preset_enum' => AdsInsightsDatePresetValues::getInstance()->getValues(), |
198
|
|
|
'summary_enum' => AdsInsightsSummaryValues::getInstance()->getValues(), |
199
|
|
|
'level_enum' => AdsInsightsLevelValues::getInstance()->getValues(), |
200
|
|
|
'summary_action_breakdowns_enum' => AdsInsightsSummaryActionBreakdownsValues::getInstance()->getValues(), |
201
|
|
|
); |
202
|
|
|
|
203
|
|
|
$request = new ApiRequest( |
204
|
|
|
$this->api, |
205
|
|
|
$this->data['id'], |
206
|
|
|
RequestInterface::METHOD_GET, |
207
|
|
|
'/insights', |
208
|
|
|
new AdsInsights(), |
209
|
|
|
'EDGE', |
210
|
|
|
AdsInsights::getFieldsEnum()->getValues(), |
211
|
|
|
new TypeChecker($param_types, $enums) |
212
|
|
|
); |
213
|
|
|
$request->addParams($params); |
214
|
|
|
$request->addFields($fields); |
215
|
|
|
return $pending ? $request : $request->execute(); |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
public function getInsightsAsync(array $fields = array(), array $params = array(), $pending = false) { |
219
|
|
|
$this->assureId(); |
220
|
|
|
|
221
|
|
|
$param_types = array( |
222
|
|
|
'action_attribution_windows' => 'list<action_attribution_windows_enum>', |
223
|
|
|
'action_breakdowns' => 'list<action_breakdowns_enum>', |
224
|
|
|
'action_report_time' => 'action_report_time_enum', |
225
|
|
|
'breakdowns' => 'list<breakdowns_enum>', |
226
|
|
|
'date_preset' => 'date_preset_enum', |
227
|
|
|
'default_summary' => 'bool', |
228
|
|
|
'export_columns' => 'list<string>', |
229
|
|
|
'export_format' => 'string', |
230
|
|
|
'export_name' => 'string', |
231
|
|
|
'fields' => 'list<fields_enum>', |
232
|
|
|
'filtering' => 'list<Object>', |
233
|
|
|
'level' => 'level_enum', |
234
|
|
|
'product_id_limit' => 'int', |
235
|
|
|
'sort' => 'list<string>', |
236
|
|
|
'summary' => 'list<summary_enum>', |
237
|
|
|
'summary_action_breakdowns' => 'list<summary_action_breakdowns_enum>', |
238
|
|
|
'time_increment' => 'string', |
239
|
|
|
'time_range' => 'Object', |
240
|
|
|
'time_ranges' => 'list<Object>', |
241
|
|
|
'use_account_attribution_setting' => 'bool', |
242
|
|
|
); |
243
|
|
|
$enums = array( |
244
|
|
|
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(), |
245
|
|
|
'action_breakdowns_enum' => AdsInsightsActionBreakdownsValues::getInstance()->getValues(), |
246
|
|
|
'action_report_time_enum' => AdsInsightsActionReportTimeValues::getInstance()->getValues(), |
247
|
|
|
'breakdowns_enum' => AdsInsightsBreakdownsValues::getInstance()->getValues(), |
248
|
|
|
'date_preset_enum' => AdsInsightsDatePresetValues::getInstance()->getValues(), |
249
|
|
|
'summary_enum' => AdsInsightsSummaryValues::getInstance()->getValues(), |
250
|
|
|
'level_enum' => AdsInsightsLevelValues::getInstance()->getValues(), |
251
|
|
|
'summary_action_breakdowns_enum' => AdsInsightsSummaryActionBreakdownsValues::getInstance()->getValues(), |
252
|
|
|
); |
253
|
|
|
|
254
|
|
|
$request = new ApiRequest( |
255
|
|
|
$this->api, |
256
|
|
|
$this->data['id'], |
257
|
|
|
RequestInterface::METHOD_POST, |
258
|
|
|
'/insights', |
259
|
|
|
new AdReportRun(), |
260
|
|
|
'EDGE', |
261
|
|
|
AdReportRun::getFieldsEnum()->getValues(), |
262
|
|
|
new TypeChecker($param_types, $enums) |
263
|
|
|
); |
264
|
|
|
$request->addParams($params); |
265
|
|
|
$request->addFields($fields); |
266
|
|
|
return $pending ? $request : $request->execute(); |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
public function getKeywordStats(array $fields = array(), array $params = array(), $pending = false) { |
270
|
|
|
$this->assureId(); |
271
|
|
|
|
272
|
|
|
$param_types = array( |
273
|
|
|
'date' => 'datetime', |
274
|
|
|
); |
275
|
|
|
$enums = array( |
276
|
|
|
); |
277
|
|
|
|
278
|
|
|
$request = new ApiRequest( |
279
|
|
|
$this->api, |
280
|
|
|
$this->data['id'], |
281
|
|
|
RequestInterface::METHOD_GET, |
282
|
|
|
'/keywordstats', |
283
|
|
|
new AdKeywordStats(), |
284
|
|
|
'EDGE', |
285
|
|
|
AdKeywordStats::getFieldsEnum()->getValues(), |
286
|
|
|
new TypeChecker($param_types, $enums) |
287
|
|
|
); |
288
|
|
|
$request->addParams($params); |
289
|
|
|
$request->addFields($fields); |
290
|
|
|
return $pending ? $request : $request->execute(); |
291
|
|
|
} |
292
|
|
|
|
293
|
|
|
public function getLeads(array $fields = array(), array $params = array(), $pending = false) { |
294
|
|
|
$this->assureId(); |
295
|
|
|
|
296
|
|
|
$param_types = array( |
297
|
|
|
); |
298
|
|
|
$enums = array( |
299
|
|
|
); |
300
|
|
|
|
301
|
|
|
$request = new ApiRequest( |
302
|
|
|
$this->api, |
303
|
|
|
$this->data['id'], |
304
|
|
|
RequestInterface::METHOD_GET, |
305
|
|
|
'/leads', |
306
|
|
|
new Lead(), |
307
|
|
|
'EDGE', |
308
|
|
|
Lead::getFieldsEnum()->getValues(), |
309
|
|
|
new TypeChecker($param_types, $enums) |
310
|
|
|
); |
311
|
|
|
$request->addParams($params); |
312
|
|
|
$request->addFields($fields); |
313
|
|
|
return $pending ? $request : $request->execute(); |
314
|
|
|
} |
315
|
|
|
|
316
|
|
|
public function getPreviews(array $fields = array(), array $params = array(), $pending = false) { |
317
|
|
|
$this->assureId(); |
318
|
|
|
|
319
|
|
|
$param_types = array( |
320
|
|
|
'ad_format' => 'ad_format_enum', |
321
|
|
|
'dynamic_creative_spec' => 'Object', |
322
|
|
|
'end_date' => 'datetime', |
323
|
|
|
'height' => 'unsigned int', |
324
|
|
|
'locale' => 'string', |
325
|
|
|
'place_page_id' => 'int', |
326
|
|
|
'post' => 'Object', |
327
|
|
|
'product_item_ids' => 'list<string>', |
328
|
|
|
'start_date' => 'datetime', |
329
|
|
|
'width' => 'unsigned int', |
330
|
|
|
); |
331
|
|
|
$enums = array( |
332
|
|
|
'ad_format_enum' => AdPreviewAdFormatValues::getInstance()->getValues(), |
333
|
|
|
); |
334
|
|
|
|
335
|
|
|
$request = new ApiRequest( |
336
|
|
|
$this->api, |
337
|
|
|
$this->data['id'], |
338
|
|
|
RequestInterface::METHOD_GET, |
339
|
|
|
'/previews', |
340
|
|
|
new AdPreview(), |
341
|
|
|
'EDGE', |
342
|
|
|
AdPreview::getFieldsEnum()->getValues(), |
343
|
|
|
new TypeChecker($param_types, $enums) |
344
|
|
|
); |
345
|
|
|
$request->addParams($params); |
346
|
|
|
$request->addFields($fields); |
347
|
|
|
return $pending ? $request : $request->execute(); |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
public function getTargetingSentenceLines(array $fields = array(), array $params = array(), $pending = false) { |
351
|
|
|
$this->assureId(); |
352
|
|
|
|
353
|
|
|
$param_types = array( |
354
|
|
|
); |
355
|
|
|
$enums = array( |
356
|
|
|
); |
357
|
|
|
|
358
|
|
|
$request = new ApiRequest( |
359
|
|
|
$this->api, |
360
|
|
|
$this->data['id'], |
361
|
|
|
RequestInterface::METHOD_GET, |
362
|
|
|
'/targetingsentencelines', |
363
|
|
|
new TargetingSentenceLine(), |
364
|
|
|
'EDGE', |
365
|
|
|
TargetingSentenceLine::getFieldsEnum()->getValues(), |
366
|
|
|
new TypeChecker($param_types, $enums) |
367
|
|
|
); |
368
|
|
|
$request->addParams($params); |
369
|
|
|
$request->addFields($fields); |
370
|
|
|
return $pending ? $request : $request->execute(); |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
public function deleteSelf(array $fields = array(), array $params = array(), $pending = false) { |
374
|
|
|
$this->assureId(); |
375
|
|
|
|
376
|
|
|
$param_types = array( |
377
|
|
|
); |
378
|
|
|
$enums = array( |
379
|
|
|
); |
380
|
|
|
|
381
|
|
|
$request = new ApiRequest( |
382
|
|
|
$this->api, |
383
|
|
|
$this->data['id'], |
384
|
|
|
RequestInterface::METHOD_DELETE, |
385
|
|
|
'/', |
386
|
|
|
new AbstractCrudObject(), |
387
|
|
|
'NODE', |
388
|
|
|
array(), |
389
|
|
|
new TypeChecker($param_types, $enums) |
390
|
|
|
); |
391
|
|
|
$request->addParams($params); |
392
|
|
|
$request->addFields($fields); |
393
|
|
|
return $pending ? $request : $request->execute(); |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
public function getSelf(array $fields = array(), array $params = array(), $pending = false) { |
397
|
|
|
$this->assureId(); |
398
|
|
|
|
399
|
|
|
$param_types = array( |
400
|
|
|
); |
401
|
|
|
$enums = array( |
402
|
|
|
); |
403
|
|
|
|
404
|
|
|
$request = new ApiRequest( |
405
|
|
|
$this->api, |
406
|
|
|
$this->data['id'], |
407
|
|
|
RequestInterface::METHOD_GET, |
408
|
|
|
'/', |
409
|
|
|
new Ad(), |
410
|
|
|
'NODE', |
411
|
|
|
Ad::getFieldsEnum()->getValues(), |
412
|
|
|
new TypeChecker($param_types, $enums) |
413
|
|
|
); |
414
|
|
|
$request->addParams($params); |
415
|
|
|
$request->addFields($fields); |
416
|
|
|
return $pending ? $request : $request->execute(); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
public function updateSelf(array $fields = array(), array $params = array(), $pending = false) { |
420
|
|
|
$this->assureId(); |
421
|
|
|
|
422
|
|
|
$param_types = array( |
423
|
|
|
'adlabels' => 'list<Object>', |
424
|
|
|
'adset_id' => 'unsigned int', |
425
|
|
|
'bid_amount' => 'int', |
426
|
|
|
'creative' => 'AdCreative', |
427
|
|
|
'display_sequence' => 'unsigned int', |
428
|
|
|
'execution_options' => 'list<execution_options_enum>', |
429
|
|
|
'name' => 'string', |
430
|
|
|
'redownload' => 'bool', |
431
|
|
|
'status' => 'status_enum', |
432
|
|
|
'tracking_specs' => 'Object', |
433
|
|
|
); |
434
|
|
|
$enums = array( |
435
|
|
|
'execution_options_enum' => AdExecutionOptionsValues::getInstance()->getValues(), |
436
|
|
|
'status_enum' => AdStatusValues::getInstance()->getValues(), |
437
|
|
|
); |
438
|
|
|
|
439
|
|
|
$request = new ApiRequest( |
440
|
|
|
$this->api, |
441
|
|
|
$this->data['id'], |
442
|
|
|
RequestInterface::METHOD_POST, |
443
|
|
|
'/', |
444
|
|
|
new Ad(), |
445
|
|
|
'NODE', |
446
|
|
|
Ad::getFieldsEnum()->getValues(), |
447
|
|
|
new TypeChecker($param_types, $enums) |
448
|
|
|
); |
449
|
|
|
$request->addParams($params); |
450
|
|
|
$request->addFields($fields); |
451
|
|
|
return $pending ? $request : $request->execute(); |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
} |
455
|
|
|
|