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