Completed
Push — master ( 470970...a080c6 )
by
unknown
05:31
created

ProductCatalog::deleteUserPermission()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 1
eloc 7
nc 1
nop 1
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\ProductCatalogFields;
32
use FacebookAds\Object\Values\ProductFeedDelimiterValues;
33
use FacebookAds\Object\Values\ProductFeedEncodingValues;
34
use FacebookAds\Object\Values\ProductFeedQuotedFieldsModeValues;
35
use FacebookAds\Object\Values\ProductItemAvailabilityValues;
36
use FacebookAds\Object\Values\ProductItemConditionValues;
37
use FacebookAds\Object\Values\ProductItemGenderValues;
38
use FacebookAds\Object\Values\ProductItemVisibilityValues;
39
40
/**
41
 * This class is auto-genereated.
42
 *
43
 * For any issues or feature requests related to this class, please let us know
44
 * on github and we'll fix in our codegen framework. We'll not be able to accept
45
 * pull request for this class.
46
 *
47
 */
48
49
class ProductCatalog extends AbstractCrudObject {
50
51
  protected function getEndpoint() {
52
    return 'product_catalogs';
53
  }
54
55
  /**
56
   * @return ProductCatalogFields
57
   */
58
  public static function getFieldsEnum() {
59
    return ProductCatalogFields::getInstance();
60
  }
61
62
  protected static function getReferencedEnums() {
63
    $ref_enums = array();
64
    return $ref_enums;
65
  }
66
67
68
  public function getAgencies(array $fields = array(), array $params = array(), $pending = false) {
69
    $this->assureId();
70
71
    $param_types = array(
72
    );
73
    $enums = array(
74
    );
75
76
    $request = new ApiRequest(
77
      $this->api,
78
      $this->data['id'],
79
      RequestInterface::METHOD_GET,
80
      '/agencies',
81
      new Business(),
82
      'EDGE',
83
      Business::getFieldsEnum()->getValues(),
84
      new TypeChecker($param_types, $enums)
85
    );
86
    $request->addParams($params);
87
    $request->addFields($fields);
88
    return $pending ? $request : $request->execute();
89
  }
90
91
  public function deleteExternalEventSources(array $fields = array(), array $params = array(), $pending = false) {
92
    $this->assureId();
93
94
    $param_types = array(
95
      'external_event_sources' => 'list<string>',
96
      'id' => 'string',
97
    );
98
    $enums = array(
99
    );
100
101
    $request = new ApiRequest(
102
      $this->api,
103
      $this->data['id'],
104
      RequestInterface::METHOD_DELETE,
105
      '/external_event_sources',
106
      new ExternalEventSource(),
107
      'EDGE',
108
      ExternalEventSource::getFieldsEnum()->getValues(),
109
      new TypeChecker($param_types, $enums)
110
    );
111
    $request->addParams($params);
112
    $request->addFields($fields);
113
    return $pending ? $request : $request->execute();
114
  }
115
116
  public function getExternalEventSources(array $fields = array(), array $params = array(), $pending = false) {
117
    $this->assureId();
118
119
    $param_types = array(
120
    );
121
    $enums = array(
122
    );
123
124
    $request = new ApiRequest(
125
      $this->api,
126
      $this->data['id'],
127
      RequestInterface::METHOD_GET,
128
      '/external_event_sources',
129
      new ExternalEventSource(),
130
      'EDGE',
131
      ExternalEventSource::getFieldsEnum()->getValues(),
132
      new TypeChecker($param_types, $enums)
133
    );
134
    $request->addParams($params);
135
    $request->addFields($fields);
136
    return $pending ? $request : $request->execute();
137
  }
138
139
  public function createExternalEventSource(array $fields = array(), array $params = array(), $pending = false) {
140
    $this->assureId();
141
142
    $param_types = array(
143
      'external_event_sources' => 'list<string>',
144
      'id' => 'string',
145
    );
146
    $enums = array(
147
    );
148
149
    $request = new ApiRequest(
150
      $this->api,
151
      $this->data['id'],
152
      RequestInterface::METHOD_POST,
153
      '/external_event_sources',
154
      new ExternalEventSource(),
155
      'EDGE',
156
      ExternalEventSource::getFieldsEnum()->getValues(),
157
      new TypeChecker($param_types, $enums)
158
    );
159
    $request->addParams($params);
160
    $request->addFields($fields);
161
    return $pending ? $request : $request->execute();
162
  }
163
164
  public function getProductFeeds(array $fields = array(), array $params = array(), $pending = false) {
165
    $this->assureId();
166
167
    $param_types = array(
168
    );
169
    $enums = array(
170
    );
171
172
    $request = new ApiRequest(
173
      $this->api,
174
      $this->data['id'],
175
      RequestInterface::METHOD_GET,
176
      '/product_feeds',
177
      new ProductFeed(),
178
      'EDGE',
179
      ProductFeed::getFieldsEnum()->getValues(),
180
      new TypeChecker($param_types, $enums)
181
    );
182
    $request->addParams($params);
183
    $request->addFields($fields);
184
    return $pending ? $request : $request->execute();
185
  }
186
187
  public function createProductFeed(array $fields = array(), array $params = array(), $pending = false) {
188
    $this->assureId();
189
190
    $param_types = array(
191
      'country' => 'string',
192
      'default_currency' => 'string',
193
      'deletion_enabled' => 'bool',
194
      'delimiter' => 'delimiter_enum',
195
      'encoding' => 'encoding_enum',
196
      'file_name' => 'string',
197
      'id' => 'string',
198
      'name' => 'string',
199
      'quoted_fields_mode' => 'quoted_fields_mode_enum',
200
      'schedule' => 'string',
201
    );
202
    $enums = array(
203
      'delimiter_enum' => ProductFeedDelimiterValues::getInstance()->getValues(),
204
      'encoding_enum' => ProductFeedEncodingValues::getInstance()->getValues(),
205
      'quoted_fields_mode_enum' => ProductFeedQuotedFieldsModeValues::getInstance()->getValues(),
206
    );
207
208
    $request = new ApiRequest(
209
      $this->api,
210
      $this->data['id'],
211
      RequestInterface::METHOD_POST,
212
      '/product_feeds',
213
      new ProductFeed(),
214
      'EDGE',
215
      ProductFeed::getFieldsEnum()->getValues(),
216
      new TypeChecker($param_types, $enums)
217
    );
218
    $request->addParams($params);
219
    $request->addFields($fields);
220
    return $pending ? $request : $request->execute();
221
  }
222
223
  public function getProductGroups(array $fields = array(), array $params = array(), $pending = false) {
224
    $this->assureId();
225
226
    $param_types = array(
227
    );
228
    $enums = array(
229
    );
230
231
    $request = new ApiRequest(
232
      $this->api,
233
      $this->data['id'],
234
      RequestInterface::METHOD_GET,
235
      '/product_groups',
236
      new ProductGroup(),
237
      'EDGE',
238
      ProductGroup::getFieldsEnum()->getValues(),
239
      new TypeChecker($param_types, $enums)
240
    );
241
    $request->addParams($params);
242
    $request->addFields($fields);
243
    return $pending ? $request : $request->execute();
244
  }
245
246
  public function createProductGroup(array $fields = array(), array $params = array(), $pending = false) {
247
    $this->assureId();
248
249
    $param_types = array(
250
      'id' => 'string',
251
      'retailer_id' => 'string',
252
      'variants' => 'list<Object>',
253
    );
254
    $enums = array(
255
    );
256
257
    $request = new ApiRequest(
258
      $this->api,
259
      $this->data['id'],
260
      RequestInterface::METHOD_POST,
261
      '/product_groups',
262
      new ProductGroup(),
263
      'EDGE',
264
      ProductGroup::getFieldsEnum()->getValues(),
265
      new TypeChecker($param_types, $enums)
266
    );
267
    $request->addParams($params);
268
    $request->addFields($fields);
269
    return $pending ? $request : $request->execute();
270
  }
271
272
  public function getProductSets(array $fields = array(), array $params = array(), $pending = false) {
273
    $this->assureId();
274
275
    $param_types = array(
276
      'ancestor_id' => 'string',
277
      'has_children' => 'bool',
278
      'parent_id' => 'string',
279
    );
280
    $enums = array(
281
    );
282
283
    $request = new ApiRequest(
284
      $this->api,
285
      $this->data['id'],
286
      RequestInterface::METHOD_GET,
287
      '/product_sets',
288
      new ProductSet(),
289
      'EDGE',
290
      ProductSet::getFieldsEnum()->getValues(),
291
      new TypeChecker($param_types, $enums)
292
    );
293
    $request->addParams($params);
294
    $request->addFields($fields);
295
    return $pending ? $request : $request->execute();
296
  }
297
298
  public function createProductSet(array $fields = array(), array $params = array(), $pending = false) {
299
    $this->assureId();
300
301
    $param_types = array(
302
      'filter' => 'Object',
303
      'id' => 'string',
304
      'name' => 'string',
305
    );
306
    $enums = array(
307
    );
308
309
    $request = new ApiRequest(
310
      $this->api,
311
      $this->data['id'],
312
      RequestInterface::METHOD_POST,
313
      '/product_sets',
314
      new ProductSet(),
315
      'EDGE',
316
      ProductSet::getFieldsEnum()->getValues(),
317
      new TypeChecker($param_types, $enums)
318
    );
319
    $request->addParams($params);
320
    $request->addFields($fields);
321
    return $pending ? $request : $request->execute();
322
  }
323
324
  public function getProducts(array $fields = array(), array $params = array(), $pending = false) {
325
    $this->assureId();
326
327
    $param_types = array(
328
      'filter' => 'Object',
329
    );
330
    $enums = array(
331
    );
332
333
    $request = new ApiRequest(
334
      $this->api,
335
      $this->data['id'],
336
      RequestInterface::METHOD_GET,
337
      '/products',
338
      new ProductItem(),
339
      'EDGE',
340
      ProductItem::getFieldsEnum()->getValues(),
341
      new TypeChecker($param_types, $enums)
342
    );
343
    $request->addParams($params);
344
    $request->addFields($fields);
345
    return $pending ? $request : $request->execute();
346
  }
347
348
  public function createProduct(array $fields = array(), array $params = array(), $pending = false) {
349
    $this->assureId();
350
351
    $param_types = array(
352
      'additional_image_urls' => 'list<string>',
353
      'android_app_name' => 'string',
354
      'android_class' => 'string',
355
      'android_package' => 'string',
356
      'android_url' => 'string',
357
      'availability' => 'availability_enum',
358
      'brand' => 'string',
359
      'category' => 'string',
360
      'checkout_url' => 'string',
361
      'color' => 'string',
362
      'condition' => 'condition_enum',
363
      'currency' => 'string',
364
      'custom_data' => 'map',
365
      'custom_label_0' => 'string',
366
      'custom_label_1' => 'string',
367
      'custom_label_2' => 'string',
368
      'custom_label_3' => 'string',
369
      'custom_label_4' => 'string',
370
      'description' => 'string',
371
      'expiration_date' => 'string',
372
      'gender' => 'gender_enum',
373
      'gtin' => 'string',
374
      'id' => 'string',
375
      'image_url' => 'string',
376
      'inventory' => 'unsigned int',
377
      'ios_app_name' => 'string',
378
      'ios_app_store_id' => 'unsigned int',
379
      'ios_url' => 'string',
380
      'ipad_app_name' => 'string',
381
      'ipad_app_store_id' => 'unsigned int',
382
      'ipad_url' => 'string',
383
      'iphone_app_name' => 'string',
384
      'iphone_app_store_id' => 'unsigned int',
385
      'iphone_url' => 'string',
386
      'manufacturer_part_number' => 'string',
387
      'name' => 'string',
388
      'ordering_index' => 'unsigned int',
389
      'pattern' => 'string',
390
      'price' => 'unsigned int',
391
      'product_type' => 'string',
392
      'retailer_id' => 'string',
393
      'retailer_product_group_id' => 'string',
394
      'sale_price' => 'unsigned int',
395
      'sale_price_end_date' => 'datetime',
396
      'sale_price_start_date' => 'datetime',
397
      'size' => 'string',
398
      'start_date' => 'string',
399
      'url' => 'string',
400
      'visibility' => 'visibility_enum',
401
      'windows_phone_app_id' => 'unsigned int',
402
      'windows_phone_app_name' => 'string',
403
      'windows_phone_url' => 'string',
404
    );
405
    $enums = array(
406
      'availability_enum' => ProductItemAvailabilityValues::getInstance()->getValues(),
407
      'condition_enum' => ProductItemConditionValues::getInstance()->getValues(),
408
      'gender_enum' => ProductItemGenderValues::getInstance()->getValues(),
409
      'visibility_enum' => ProductItemVisibilityValues::getInstance()->getValues(),
410
    );
411
412
    $request = new ApiRequest(
413
      $this->api,
414
      $this->data['id'],
415
      RequestInterface::METHOD_POST,
416
      '/products',
417
      new ProductItem(),
418
      'EDGE',
419
      ProductItem::getFieldsEnum()->getValues(),
420
      new TypeChecker($param_types, $enums)
421
    );
422
    $request->addParams($params);
423
    $request->addFields($fields);
424
    return $pending ? $request : $request->execute();
425
  }
426
427
  public function deleteSelf(array $fields = array(), array $params = array(), $pending = false) {
428
    $this->assureId();
429
430
    $param_types = array(
431
      'id' => 'string',
432
    );
433
    $enums = array(
434
    );
435
436
    $request = new ApiRequest(
437
      $this->api,
438
      $this->data['id'],
439
      RequestInterface::METHOD_DELETE,
440
      '/',
441
      new AbstractCrudObject(),
442
      'NODE',
443
      array(),
444
      new TypeChecker($param_types, $enums)
445
    );
446
    $request->addParams($params);
447
    $request->addFields($fields);
448
    return $pending ? $request : $request->execute();
449
  }
450
451
  public function getSelf(array $fields = array(), array $params = array(), $pending = false) {
452
    $this->assureId();
453
454
    $param_types = array(
455
    );
456
    $enums = array(
457
    );
458
459
    $request = new ApiRequest(
460
      $this->api,
461
      $this->data['id'],
462
      RequestInterface::METHOD_GET,
463
      '/',
464
      new ProductCatalog(),
465
      'NODE',
466
      ProductCatalog::getFieldsEnum()->getValues(),
467
      new TypeChecker($param_types, $enums)
468
    );
469
    $request->addParams($params);
470
    $request->addFields($fields);
471
    return $pending ? $request : $request->execute();
472
  }
473
474
  public function updateSelf(array $fields = array(), array $params = array(), $pending = false) {
475
    $this->assureId();
476
477
    $param_types = array(
478
      'id' => 'string',
479
      'name' => 'string',
480
    );
481
    $enums = array(
482
    );
483
484
    $request = new ApiRequest(
485
      $this->api,
486
      $this->data['id'],
487
      RequestInterface::METHOD_POST,
488
      '/',
489
      new AbstractCrudObject(),
490
      'NODE',
491
      array(),
492
      new TypeChecker($param_types, $enums)
493
    );
494
    $request->addParams($params);
495
    $request->addFields($fields);
496
    return $pending ? $request : $request->execute();
497
  }
498
499
  /**
500
   * @deprecated use createExternalEventSource instead
501
   */
502
  public function setExternalEventSources(array $pixel_ids, $pending = false) {
503
    $params = array(
504
      'external_event_sources' => $pixel_ids,
505
    );
506
    return $this->createExternalEventSource(array(), $params, $pending);
507
  }
508
509
  /**
510
   * @deprecated use deleteExternalEventSources instead
511
   */
512
  public function removeExternalEventSources(array $pixel_ids, $pending = false) {
513
    $params = array(
514
      'external_event_sources' => $pixel_ids,
515
    );
516
    return $this->deleteExternalEventSources(array(), $params, $pending);
517
  }
518
519
  /**
520
   * @param int $user_id
521
   * @param string $role
522
   */
523
  public function addUserPermission($user_id, $role) {
524
    $params = array(
525
      'user' => $user_id,
526
      'role' => $role,
527
    );
528
    $this->getApi()->call(
529
      '/'.$this->assureId().'/userpermissions',
530
      RequestInterface::METHOD_POST,
531
      $params);
532
  }
533
534
  /**
535
   * @param int $user_id
536
   */
537
  public function deleteUserPermission($user_id) {
538
    $params = array(
539
      'user' => $user_id,
540
    );
541
    $this->getApi()->call(
542
      '/'.$this->assureId().'/userpermissions',
543
      RequestInterface::METHOD_DELETE,
544
      $params);
545
  }
546
}
547