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-genereated. |
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
|
|
|
); |
191
|
|
|
$enums = array( |
192
|
|
|
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(), |
193
|
|
|
'action_breakdowns_enum' => AdsInsightsActionBreakdownsValues::getInstance()->getValues(), |
194
|
|
|
'action_report_time_enum' => AdsInsightsActionReportTimeValues::getInstance()->getValues(), |
195
|
|
|
'breakdowns_enum' => AdsInsightsBreakdownsValues::getInstance()->getValues(), |
196
|
|
|
'date_preset_enum' => AdsInsightsDatePresetValues::getInstance()->getValues(), |
197
|
|
|
'summary_enum' => AdsInsightsSummaryValues::getInstance()->getValues(), |
198
|
|
|
'level_enum' => AdsInsightsLevelValues::getInstance()->getValues(), |
199
|
|
|
'summary_action_breakdowns_enum' => AdsInsightsSummaryActionBreakdownsValues::getInstance()->getValues(), |
200
|
|
|
); |
201
|
|
|
|
202
|
|
|
$request = new ApiRequest( |
203
|
|
|
$this->api, |
204
|
|
|
$this->data['id'], |
205
|
|
|
RequestInterface::METHOD_GET, |
206
|
|
|
'/insights', |
207
|
|
|
new AdsInsights(), |
208
|
|
|
'EDGE', |
209
|
|
|
AdsInsights::getFieldsEnum()->getValues(), |
210
|
|
|
new TypeChecker($param_types, $enums) |
211
|
|
|
); |
212
|
|
|
$request->addParams($params); |
213
|
|
|
$request->addFields($fields); |
214
|
|
|
return $pending ? $request : $request->execute(); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function getInsightsAsync(array $fields = array(), array $params = array(), $pending = false) { |
218
|
|
|
$this->assureId(); |
219
|
|
|
|
220
|
|
|
$param_types = array( |
221
|
|
|
'action_attribution_windows' => 'list<action_attribution_windows_enum>', |
222
|
|
|
'action_breakdowns' => 'list<action_breakdowns_enum>', |
223
|
|
|
'action_report_time' => 'action_report_time_enum', |
224
|
|
|
'breakdowns' => 'list<breakdowns_enum>', |
225
|
|
|
'date_preset' => 'date_preset_enum', |
226
|
|
|
'default_summary' => 'bool', |
227
|
|
|
'export_columns' => 'list<string>', |
228
|
|
|
'export_format' => 'string', |
229
|
|
|
'export_name' => 'string', |
230
|
|
|
'fields' => 'list<fields_enum>', |
231
|
|
|
'filtering' => 'list<Object>', |
232
|
|
|
'level' => 'level_enum', |
233
|
|
|
'product_id_limit' => 'int', |
234
|
|
|
'sort' => 'list<string>', |
235
|
|
|
'summary' => 'list<summary_enum>', |
236
|
|
|
'summary_action_breakdowns' => 'list<summary_action_breakdowns_enum>', |
237
|
|
|
'time_increment' => 'string', |
238
|
|
|
'time_range' => 'Object', |
239
|
|
|
'time_ranges' => 'list<Object>', |
240
|
|
|
); |
241
|
|
|
$enums = array( |
242
|
|
|
'action_attribution_windows_enum' => AdsInsightsActionAttributionWindowsValues::getInstance()->getValues(), |
243
|
|
|
'action_breakdowns_enum' => AdsInsightsActionBreakdownsValues::getInstance()->getValues(), |
244
|
|
|
'action_report_time_enum' => AdsInsightsActionReportTimeValues::getInstance()->getValues(), |
245
|
|
|
'breakdowns_enum' => AdsInsightsBreakdownsValues::getInstance()->getValues(), |
246
|
|
|
'date_preset_enum' => AdsInsightsDatePresetValues::getInstance()->getValues(), |
247
|
|
|
'summary_enum' => AdsInsightsSummaryValues::getInstance()->getValues(), |
248
|
|
|
'level_enum' => AdsInsightsLevelValues::getInstance()->getValues(), |
249
|
|
|
'summary_action_breakdowns_enum' => AdsInsightsSummaryActionBreakdownsValues::getInstance()->getValues(), |
250
|
|
|
); |
251
|
|
|
|
252
|
|
|
$request = new ApiRequest( |
253
|
|
|
$this->api, |
254
|
|
|
$this->data['id'], |
255
|
|
|
RequestInterface::METHOD_POST, |
256
|
|
|
'/insights', |
257
|
|
|
new AdReportRun(), |
258
|
|
|
'EDGE', |
259
|
|
|
AdReportRun::getFieldsEnum()->getValues(), |
260
|
|
|
new TypeChecker($param_types, $enums) |
261
|
|
|
); |
262
|
|
|
$request->addParams($params); |
263
|
|
|
$request->addFields($fields); |
264
|
|
|
return $pending ? $request : $request->execute(); |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
public function getKeywordStats(array $fields = array(), array $params = array(), $pending = false) { |
268
|
|
|
$this->assureId(); |
269
|
|
|
|
270
|
|
|
$param_types = array( |
271
|
|
|
'date' => 'datetime', |
272
|
|
|
); |
273
|
|
|
$enums = array( |
274
|
|
|
); |
275
|
|
|
|
276
|
|
|
$request = new ApiRequest( |
277
|
|
|
$this->api, |
278
|
|
|
$this->data['id'], |
279
|
|
|
RequestInterface::METHOD_GET, |
280
|
|
|
'/keywordstats', |
281
|
|
|
new AdKeywordStats(), |
282
|
|
|
'EDGE', |
283
|
|
|
AdKeywordStats::getFieldsEnum()->getValues(), |
284
|
|
|
new TypeChecker($param_types, $enums) |
285
|
|
|
); |
286
|
|
|
$request->addParams($params); |
287
|
|
|
$request->addFields($fields); |
288
|
|
|
return $pending ? $request : $request->execute(); |
289
|
|
|
} |
290
|
|
|
|
291
|
|
|
public function getLeads(array $fields = array(), array $params = array(), $pending = false) { |
292
|
|
|
$this->assureId(); |
293
|
|
|
|
294
|
|
|
$param_types = array( |
295
|
|
|
); |
296
|
|
|
$enums = array( |
297
|
|
|
); |
298
|
|
|
|
299
|
|
|
$request = new ApiRequest( |
300
|
|
|
$this->api, |
301
|
|
|
$this->data['id'], |
302
|
|
|
RequestInterface::METHOD_GET, |
303
|
|
|
'/leads', |
304
|
|
|
new Lead(), |
305
|
|
|
'EDGE', |
306
|
|
|
Lead::getFieldsEnum()->getValues(), |
307
|
|
|
new TypeChecker($param_types, $enums) |
308
|
|
|
); |
309
|
|
|
$request->addParams($params); |
310
|
|
|
$request->addFields($fields); |
311
|
|
|
return $pending ? $request : $request->execute(); |
312
|
|
|
} |
313
|
|
|
|
314
|
|
|
public function getPreviews(array $fields = array(), array $params = array(), $pending = false) { |
315
|
|
|
$this->assureId(); |
316
|
|
|
|
317
|
|
|
$param_types = array( |
318
|
|
|
'ad_format' => 'ad_format_enum', |
319
|
|
|
'end_date' => 'datetime', |
320
|
|
|
'height' => 'unsigned int', |
321
|
|
|
'locale' => 'string', |
322
|
|
|
'place_page_id' => 'int', |
323
|
|
|
'post' => 'Object', |
324
|
|
|
'product_item_ids' => 'list<string>', |
325
|
|
|
'start_date' => 'datetime', |
326
|
|
|
'width' => 'unsigned int', |
327
|
|
|
); |
328
|
|
|
$enums = array( |
329
|
|
|
'ad_format_enum' => AdPreviewAdFormatValues::getInstance()->getValues(), |
330
|
|
|
); |
331
|
|
|
|
332
|
|
|
$request = new ApiRequest( |
333
|
|
|
$this->api, |
334
|
|
|
$this->data['id'], |
335
|
|
|
RequestInterface::METHOD_GET, |
336
|
|
|
'/previews', |
337
|
|
|
new AdPreview(), |
338
|
|
|
'EDGE', |
339
|
|
|
AdPreview::getFieldsEnum()->getValues(), |
340
|
|
|
new TypeChecker($param_types, $enums) |
341
|
|
|
); |
342
|
|
|
$request->addParams($params); |
343
|
|
|
$request->addFields($fields); |
344
|
|
|
return $pending ? $request : $request->execute(); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
public function getTargetingSentenceLines(array $fields = array(), array $params = array(), $pending = false) { |
348
|
|
|
$this->assureId(); |
349
|
|
|
|
350
|
|
|
$param_types = array( |
351
|
|
|
); |
352
|
|
|
$enums = array( |
353
|
|
|
); |
354
|
|
|
|
355
|
|
|
$request = new ApiRequest( |
356
|
|
|
$this->api, |
357
|
|
|
$this->data['id'], |
358
|
|
|
RequestInterface::METHOD_GET, |
359
|
|
|
'/targetingsentencelines', |
360
|
|
|
new TargetingSentenceLine(), |
361
|
|
|
'EDGE', |
362
|
|
|
TargetingSentenceLine::getFieldsEnum()->getValues(), |
363
|
|
|
new TypeChecker($param_types, $enums) |
364
|
|
|
); |
365
|
|
|
$request->addParams($params); |
366
|
|
|
$request->addFields($fields); |
367
|
|
|
return $pending ? $request : $request->execute(); |
368
|
|
|
} |
369
|
|
|
|
370
|
|
|
public function deleteSelf(array $fields = array(), array $params = array(), $pending = false) { |
371
|
|
|
$this->assureId(); |
372
|
|
|
|
373
|
|
|
$param_types = array( |
374
|
|
|
); |
375
|
|
|
$enums = array( |
376
|
|
|
); |
377
|
|
|
|
378
|
|
|
$request = new ApiRequest( |
379
|
|
|
$this->api, |
380
|
|
|
$this->data['id'], |
381
|
|
|
RequestInterface::METHOD_DELETE, |
382
|
|
|
'/', |
383
|
|
|
new AbstractCrudObject(), |
384
|
|
|
'NODE', |
385
|
|
|
array(), |
386
|
|
|
new TypeChecker($param_types, $enums) |
387
|
|
|
); |
388
|
|
|
$request->addParams($params); |
389
|
|
|
$request->addFields($fields); |
390
|
|
|
return $pending ? $request : $request->execute(); |
391
|
|
|
} |
392
|
|
|
|
393
|
|
|
public function getSelf(array $fields = array(), array $params = array(), $pending = false) { |
394
|
|
|
$this->assureId(); |
395
|
|
|
|
396
|
|
|
$param_types = array( |
397
|
|
|
); |
398
|
|
|
$enums = array( |
399
|
|
|
); |
400
|
|
|
|
401
|
|
|
$request = new ApiRequest( |
402
|
|
|
$this->api, |
403
|
|
|
$this->data['id'], |
404
|
|
|
RequestInterface::METHOD_GET, |
405
|
|
|
'/', |
406
|
|
|
new Ad(), |
407
|
|
|
'NODE', |
408
|
|
|
Ad::getFieldsEnum()->getValues(), |
409
|
|
|
new TypeChecker($param_types, $enums) |
410
|
|
|
); |
411
|
|
|
$request->addParams($params); |
412
|
|
|
$request->addFields($fields); |
413
|
|
|
return $pending ? $request : $request->execute(); |
414
|
|
|
} |
415
|
|
|
|
416
|
|
|
public function updateSelf(array $fields = array(), array $params = array(), $pending = false) { |
417
|
|
|
$this->assureId(); |
418
|
|
|
|
419
|
|
|
$param_types = array( |
420
|
|
|
'adlabels' => 'list<Object>', |
421
|
|
|
'adset_id' => 'unsigned int', |
422
|
|
|
'bid_amount' => 'int', |
423
|
|
|
'creative' => 'AdCreative', |
424
|
|
|
'display_sequence' => 'unsigned int', |
425
|
|
|
'execution_options' => 'list<execution_options_enum>', |
426
|
|
|
'name' => 'string', |
427
|
|
|
'redownload' => 'bool', |
428
|
|
|
'status' => 'status_enum', |
429
|
|
|
'tracking_specs' => 'Object', |
430
|
|
|
); |
431
|
|
|
$enums = array( |
432
|
|
|
'execution_options_enum' => AdExecutionOptionsValues::getInstance()->getValues(), |
433
|
|
|
'status_enum' => AdStatusValues::getInstance()->getValues(), |
434
|
|
|
); |
435
|
|
|
|
436
|
|
|
$request = new ApiRequest( |
437
|
|
|
$this->api, |
438
|
|
|
$this->data['id'], |
439
|
|
|
RequestInterface::METHOD_POST, |
440
|
|
|
'/', |
441
|
|
|
new Ad(), |
442
|
|
|
'NODE', |
443
|
|
|
Ad::getFieldsEnum()->getValues(), |
444
|
|
|
new TypeChecker($param_types, $enums) |
445
|
|
|
); |
446
|
|
|
$request->addParams($params); |
447
|
|
|
$request->addFields($fields); |
448
|
|
|
return $pending ? $request : $request->execute(); |
449
|
|
|
} |
450
|
|
|
|
451
|
|
|
} |
452
|
|
|
|