Completed
Push — master ( 212bcc...86d4f9 )
by
unknown
15:01
created

ProductItem::updateSelf()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 75
Code Lines 69

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 75
rs 9
cc 2
eloc 69
nc 2
nop 3

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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\ProductItemFields;
32
use FacebookAds\Object\Values\ProductItemAgeGroupValues;
33
use FacebookAds\Object\Values\ProductItemAvailabilityValues;
34
use FacebookAds\Object\Values\ProductItemConditionValues;
35
use FacebookAds\Object\Values\ProductItemGenderValues;
36
use FacebookAds\Object\Values\ProductItemReviewStatusValues;
37
use FacebookAds\Object\Values\ProductItemShippingWeightUnitValues;
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 ProductItem extends AbstractCrudObject {
50
51
  protected function getEndpoint() {
52
    return 'products';
53
  }
54
55
  /**
56
   * @return ProductItemFields
57
   */
58
  public static function getFieldsEnum() {
59
    return ProductItemFields::getInstance();
60
  }
61
62
  protected static function getReferencedEnums() {
63
    $ref_enums = array();
64
    $ref_enums['AgeGroup'] = ProductItemAgeGroupValues::getInstance()->getValues();
65
    $ref_enums['Availability'] = ProductItemAvailabilityValues::getInstance()->getValues();
66
    $ref_enums['Condition'] = ProductItemConditionValues::getInstance()->getValues();
67
    $ref_enums['Gender'] = ProductItemGenderValues::getInstance()->getValues();
68
    $ref_enums['ReviewStatus'] = ProductItemReviewStatusValues::getInstance()->getValues();
69
    $ref_enums['ShippingWeightUnit'] = ProductItemShippingWeightUnitValues::getInstance()->getValues();
70
    $ref_enums['Visibility'] = ProductItemVisibilityValues::getInstance()->getValues();
71
    return $ref_enums;
72
  }
73
74
75
  public function getProductSets(array $fields = array(), array $params = array(), $pending = false) {
76
    $this->assureId();
77
78
    $param_types = array(
79
    );
80
    $enums = array(
81
    );
82
83
    $request = new ApiRequest(
84
      $this->api,
85
      $this->data['id'],
86
      RequestInterface::METHOD_GET,
87
      '/product_sets',
88
      new ProductSet(),
89
      'EDGE',
90
      ProductSet::getFieldsEnum()->getValues(),
91
      new TypeChecker($param_types, $enums)
92
    );
93
    $request->addParams($params);
94
    $request->addFields($fields);
95
    return $pending ? $request : $request->execute();
96
  }
97
98
  public function deleteSelf(array $fields = array(), array $params = array(), $pending = false) {
99
    $this->assureId();
100
101
    $param_types = array(
102
    );
103
    $enums = array(
104
    );
105
106
    $request = new ApiRequest(
107
      $this->api,
108
      $this->data['id'],
109
      RequestInterface::METHOD_DELETE,
110
      '/',
111
      new AbstractCrudObject(),
112
      'NODE',
113
      array(),
114
      new TypeChecker($param_types, $enums)
115
    );
116
    $request->addParams($params);
117
    $request->addFields($fields);
118
    return $pending ? $request : $request->execute();
119
  }
120
121
  public function getSelf(array $fields = array(), array $params = array(), $pending = false) {
122
    $this->assureId();
123
124
    $param_types = array(
125
      'image_height' => 'unsigned int',
126
      'image_width' => 'unsigned int',
127
    );
128
    $enums = array(
129
    );
130
131
    $request = new ApiRequest(
132
      $this->api,
133
      $this->data['id'],
134
      RequestInterface::METHOD_GET,
135
      '/',
136
      new ProductItem(),
137
      'NODE',
138
      ProductItem::getFieldsEnum()->getValues(),
139
      new TypeChecker($param_types, $enums)
140
    );
141
    $request->addParams($params);
142
    $request->addFields($fields);
143
    return $pending ? $request : $request->execute();
144
  }
145
146
  public function updateSelf(array $fields = array(), array $params = array(), $pending = false) {
147
    $this->assureId();
148
149
    $param_types = array(
150
      'additional_image_urls' => 'list<string>',
151
      'android_app_name' => 'string',
152
      'android_class' => 'string',
153
      'android_package' => 'string',
154
      'android_url' => 'string',
155
      'availability' => 'availability_enum',
156
      'brand' => 'string',
157
      'category' => 'string',
158
      'checkout_url' => 'string',
159
      'color' => 'string',
160
      'condition' => 'condition_enum',
161
      'currency' => 'string',
162
      'custom_data' => 'map',
163
      'custom_label_0' => 'string',
164
      'custom_label_1' => 'string',
165
      'custom_label_2' => 'string',
166
      'custom_label_3' => 'string',
167
      'custom_label_4' => 'string',
168
      'description' => 'string',
169
      'expiration_date' => 'string',
170
      'gender' => 'gender_enum',
171
      'gtin' => 'string',
172
      'image_url' => 'string',
173
      'inventory' => 'unsigned int',
174
      'ios_app_name' => 'string',
175
      'ios_app_store_id' => 'unsigned int',
176
      'ios_url' => 'string',
177
      'ipad_app_name' => 'string',
178
      'ipad_app_store_id' => 'unsigned int',
179
      'ipad_url' => 'string',
180
      'iphone_app_name' => 'string',
181
      'iphone_app_store_id' => 'unsigned int',
182
      'iphone_url' => 'string',
183
      'manufacturer_part_number' => 'string',
184
      'name' => 'string',
185
      'ordering_index' => 'unsigned int',
186
      'pattern' => 'string',
187
      'price' => 'unsigned int',
188
      'product_type' => 'string',
189
      'sale_price' => 'unsigned int',
190
      'sale_price_end_date' => 'datetime',
191
      'sale_price_start_date' => 'datetime',
192
      'size' => 'string',
193
      'start_date' => 'string',
194
      'url' => 'string',
195
      'visibility' => 'visibility_enum',
196
      'windows_phone_app_id' => 'unsigned int',
197
      'windows_phone_app_name' => 'string',
198
      'windows_phone_url' => 'string',
199
    );
200
    $enums = array(
201
      'availability_enum' => ProductItemAvailabilityValues::getInstance()->getValues(),
202
      'condition_enum' => ProductItemConditionValues::getInstance()->getValues(),
203
      'gender_enum' => ProductItemGenderValues::getInstance()->getValues(),
204
      'visibility_enum' => ProductItemVisibilityValues::getInstance()->getValues(),
205
    );
206
207
    $request = new ApiRequest(
208
      $this->api,
209
      $this->data['id'],
210
      RequestInterface::METHOD_POST,
211
      '/',
212
      new ProductItem(),
213
      'NODE',
214
      ProductItem::getFieldsEnum()->getValues(),
215
      new TypeChecker($param_types, $enums)
216
    );
217
    $request->addParams($params);
218
    $request->addFields($fields);
219
    return $pending ? $request : $request->execute();
220
  }
221
222
}
223