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\AdCreativeFields; |
32
|
|
|
use FacebookAds\Object\Values\AdCreativeApplinkTreatmentValues; |
33
|
|
|
use FacebookAds\Object\Values\AdCreativeCallToActionTypeValues; |
34
|
|
|
use FacebookAds\Object\Values\AdCreativeDynamicAdVoiceValues; |
35
|
|
|
use FacebookAds\Object\Values\AdCreativeObjectTypeValues; |
36
|
|
|
use FacebookAds\Object\Values\AdCreativeOperatorValues; |
37
|
|
|
use FacebookAds\Object\Values\AdCreativeStatusValues; |
38
|
|
|
use FacebookAds\Object\Values\AdPreviewAdFormatValues; |
39
|
|
|
use FacebookAds\Object\Traits\AdLabelAwareCrudObjectTrait; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* This class is auto-generated. |
43
|
|
|
* |
44
|
|
|
* For any issues or feature requests related to this class, please let us know |
45
|
|
|
* on github and we'll fix in our codegen framework. We'll not be able to accept |
46
|
|
|
* pull request for this class. |
47
|
|
|
* |
48
|
|
|
*/ |
49
|
|
|
|
50
|
|
|
class AdCreative extends AbstractCrudObject { |
51
|
|
|
|
52
|
|
|
use AdLabelAwareCrudObjectTrait; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @deprecated getEndpoint function is deprecated |
56
|
|
|
*/ |
57
|
|
|
protected function getEndpoint() { |
58
|
|
|
return 'adcreatives'; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return AdCreativeFields |
63
|
|
|
*/ |
64
|
|
|
public static function getFieldsEnum() { |
65
|
|
|
return AdCreativeFields::getInstance(); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
protected static function getReferencedEnums() { |
69
|
|
|
$ref_enums = array(); |
70
|
|
|
$ref_enums['ApplinkTreatment'] = AdCreativeApplinkTreatmentValues::getInstance()->getValues(); |
71
|
|
|
$ref_enums['CallToActionType'] = AdCreativeCallToActionTypeValues::getInstance()->getValues(); |
72
|
|
|
$ref_enums['ObjectType'] = AdCreativeObjectTypeValues::getInstance()->getValues(); |
73
|
|
|
$ref_enums['Status'] = AdCreativeStatusValues::getInstance()->getValues(); |
74
|
|
|
$ref_enums['DynamicAdVoice'] = AdCreativeDynamicAdVoiceValues::getInstance()->getValues(); |
75
|
|
|
$ref_enums['Operator'] = AdCreativeOperatorValues::getInstance()->getValues(); |
76
|
|
|
return $ref_enums; |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
protected function setDataTrigger($data) { |
80
|
|
|
if (array_key_exists('id', $data)) { |
81
|
|
|
$this->data['creative_id'] = $data['id']; |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function deleteAdLabels(array $fields = array(), array $params = array(), $pending = false) { |
86
|
|
|
$this->assureId(); |
87
|
|
|
|
88
|
|
|
$param_types = array( |
89
|
|
|
'adlabels' => 'list<Object>', |
90
|
|
|
); |
91
|
|
|
$enums = array( |
92
|
|
|
); |
93
|
|
|
|
94
|
|
|
$request = new ApiRequest( |
95
|
|
|
$this->api, |
96
|
|
|
$this->data['id'], |
97
|
|
|
RequestInterface::METHOD_DELETE, |
98
|
|
|
'/adlabels', |
99
|
|
|
new AbstractCrudObject(), |
100
|
|
|
'EDGE', |
101
|
|
|
array(), |
102
|
|
|
new TypeChecker($param_types, $enums) |
103
|
|
|
); |
104
|
|
|
$request->addParams($params); |
105
|
|
|
$request->addFields($fields); |
106
|
|
|
return $pending ? $request : $request->execute(); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
public function createAdLabel(array $fields = array(), array $params = array(), $pending = false) { |
110
|
|
|
$this->assureId(); |
111
|
|
|
|
112
|
|
|
$param_types = array( |
113
|
|
|
'adlabels' => 'list<Object>', |
114
|
|
|
); |
115
|
|
|
$enums = array( |
116
|
|
|
); |
117
|
|
|
|
118
|
|
|
$request = new ApiRequest( |
119
|
|
|
$this->api, |
120
|
|
|
$this->data['id'], |
121
|
|
|
RequestInterface::METHOD_POST, |
122
|
|
|
'/adlabels', |
123
|
|
|
new AdLabel(), |
124
|
|
|
'EDGE', |
125
|
|
|
AdLabel::getFieldsEnum()->getValues(), |
126
|
|
|
new TypeChecker($param_types, $enums) |
127
|
|
|
); |
128
|
|
|
$request->addParams($params); |
129
|
|
|
$request->addFields($fields); |
130
|
|
|
return $pending ? $request : $request->execute(); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
public function getPreviews(array $fields = array(), array $params = array(), $pending = false) { |
134
|
|
|
$this->assureId(); |
135
|
|
|
|
136
|
|
|
$param_types = array( |
137
|
|
|
'ad_format' => 'ad_format_enum', |
138
|
|
|
'dynamic_creative_spec' => 'Object', |
139
|
|
|
'end_date' => 'datetime', |
140
|
|
|
'height' => 'unsigned int', |
141
|
|
|
'locale' => 'string', |
142
|
|
|
'place_page_id' => 'int', |
143
|
|
|
'post' => 'Object', |
144
|
|
|
'product_item_ids' => 'list<string>', |
145
|
|
|
'start_date' => 'datetime', |
146
|
|
|
'width' => 'unsigned int', |
147
|
|
|
); |
148
|
|
|
$enums = array( |
149
|
|
|
'ad_format_enum' => AdPreviewAdFormatValues::getInstance()->getValues(), |
150
|
|
|
); |
151
|
|
|
|
152
|
|
|
$request = new ApiRequest( |
153
|
|
|
$this->api, |
154
|
|
|
$this->data['id'], |
155
|
|
|
RequestInterface::METHOD_GET, |
156
|
|
|
'/previews', |
157
|
|
|
new AdPreview(), |
158
|
|
|
'EDGE', |
159
|
|
|
AdPreview::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 deleteSelf(array $fields = array(), array $params = array(), $pending = false) { |
168
|
|
|
$this->assureId(); |
169
|
|
|
|
170
|
|
|
$param_types = array( |
171
|
|
|
'account_id' => 'string', |
172
|
|
|
'adlabels' => 'list<Object>', |
173
|
|
|
'name' => 'string', |
174
|
|
|
'status' => 'status_enum', |
175
|
|
|
); |
176
|
|
|
$enums = array( |
177
|
|
|
'status_enum' => AdCreativeStatusValues::getInstance()->getValues(), |
178
|
|
|
); |
179
|
|
|
|
180
|
|
|
$request = new ApiRequest( |
181
|
|
|
$this->api, |
182
|
|
|
$this->data['id'], |
183
|
|
|
RequestInterface::METHOD_DELETE, |
184
|
|
|
'/', |
185
|
|
|
new AbstractCrudObject(), |
186
|
|
|
'NODE', |
187
|
|
|
array(), |
188
|
|
|
new TypeChecker($param_types, $enums) |
189
|
|
|
); |
190
|
|
|
$request->addParams($params); |
191
|
|
|
$request->addFields($fields); |
192
|
|
|
return $pending ? $request : $request->execute(); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
public function getSelf(array $fields = array(), array $params = array(), $pending = false) { |
196
|
|
|
$this->assureId(); |
197
|
|
|
|
198
|
|
|
$param_types = array( |
199
|
|
|
'thumbnail_height' => 'unsigned int', |
200
|
|
|
'thumbnail_width' => 'unsigned int', |
201
|
|
|
); |
202
|
|
|
$enums = array( |
203
|
|
|
); |
204
|
|
|
|
205
|
|
|
$request = new ApiRequest( |
206
|
|
|
$this->api, |
207
|
|
|
$this->data['id'], |
208
|
|
|
RequestInterface::METHOD_GET, |
209
|
|
|
'/', |
210
|
|
|
new AdCreative(), |
211
|
|
|
'NODE', |
212
|
|
|
AdCreative::getFieldsEnum()->getValues(), |
213
|
|
|
new TypeChecker($param_types, $enums) |
214
|
|
|
); |
215
|
|
|
$request->addParams($params); |
216
|
|
|
$request->addFields($fields); |
217
|
|
|
return $pending ? $request : $request->execute(); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
public function updateSelf(array $fields = array(), array $params = array(), $pending = false) { |
221
|
|
|
$this->assureId(); |
222
|
|
|
|
223
|
|
|
$param_types = array( |
224
|
|
|
'account_id' => 'string', |
225
|
|
|
'adlabels' => 'list<Object>', |
226
|
|
|
'name' => 'string', |
227
|
|
|
'status' => 'status_enum', |
228
|
|
|
); |
229
|
|
|
$enums = array( |
230
|
|
|
'status_enum' => AdCreativeStatusValues::getInstance()->getValues(), |
231
|
|
|
); |
232
|
|
|
|
233
|
|
|
$request = new ApiRequest( |
234
|
|
|
$this->api, |
235
|
|
|
$this->data['id'], |
236
|
|
|
RequestInterface::METHOD_POST, |
237
|
|
|
'/', |
238
|
|
|
new AdCreative(), |
239
|
|
|
'NODE', |
240
|
|
|
AdCreative::getFieldsEnum()->getValues(), |
241
|
|
|
new TypeChecker($param_types, $enums) |
242
|
|
|
); |
243
|
|
|
$request->addParams($params); |
244
|
|
|
$request->addFields($fields); |
245
|
|
|
return $pending ? $request : $request->execute(); |
246
|
|
|
} |
247
|
|
|
|
248
|
|
|
} |
249
|
|
|
|