Failed Conditions
Push — master ( 81ead6...837ea5 )
by
unknown
13:08
created

AdAccountGroup::getSelf()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
rs 9.2
cc 2
eloc 16
nc 2
nop 3
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\AdAccountGroupFields;
32
use FacebookAds\Api;
33
34
/**
35
 * This class is auto-genereated.
36
 *
37
 * For any issues or feature requests related to this class, please let us know
38
 * on github and we'll fix in our codegen framework. We'll not be able to accept
39
 * pull request for this class.
40
 *
41
 */
42
43
class AdAccountGroup extends AbstractCrudObject {
44
45
  public function __construct($id = null, $parent_id = 'me', Api $api = null) {
46
    parent::__construct($id, $parent_id, $api);
47
  }
48
49
  protected function getEndpoint() {
50
    return 'adaccountgroups';
51
  }
52
53
  /**
54
   * @return AdAccountGroupFields
55
   */
56
  public static function getFieldsEnum() {
57
    return AdAccountGroupFields::getInstance();
58
  }
59
60
  protected static function getReferencedEnums() {
61
    $ref_enums = array();
62
    return $ref_enums;
63
  }
64
65
66
  public function deleteAdAccounts(array $fields = array(), array $params = array(), $pending = false) {
67
    $this->assureId();
68
69
    $param_types = array(
70
      'account_id' => 'string',
71
      'id' => 'string',
72
    );
73
    $enums = array(
74
    );
75
76
    $request = new ApiRequest(
77
      $this->api,
78
      $this->data['id'],
79
      RequestInterface::METHOD_DELETE,
80
      '/adaccounts',
81
      new AbstractCrudObject(),
82
      'EDGE',
83
      array(),
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 getAdAccounts(array $fields = array(), array $params = array(), $pending = false) {
92
    $this->assureId();
93
94
    $param_types = array(
95
    );
96
    $enums = array(
97
    );
98
99
    $request = new ApiRequest(
100
      $this->api,
101
      $this->data['id'],
102
      RequestInterface::METHOD_GET,
103
      '/adaccounts',
104
      new AbstractCrudObject(),
105
      'EDGE',
106
      array(),
107
      new TypeChecker($param_types, $enums)
108
    );
109
    $request->addParams($params);
110
    $request->addFields($fields);
111
    return $pending ? $request : $request->execute();
112
  }
113
114
  public function createAdAccount(array $fields = array(), array $params = array(), $pending = false) {
115
    $this->assureId();
116
117
    $param_types = array(
118
      'account_ids' => 'list<string>',
119
      'id' => 'string',
120
      'redownload' => 'bool',
121
    );
122
    $enums = array(
123
    );
124
125
    $request = new ApiRequest(
126
      $this->api,
127
      $this->data['id'],
128
      RequestInterface::METHOD_POST,
129
      '/adaccounts',
130
      new AbstractCrudObject(),
131
      'EDGE',
132
      array(),
133
      new TypeChecker($param_types, $enums)
134
    );
135
    $request->addParams($params);
136
    $request->addFields($fields);
137
    return $pending ? $request : $request->execute();
138
  }
139
140
  public function deleteUsers(array $fields = array(), array $params = array(), $pending = false) {
141
    $this->assureId();
142
143
    $param_types = array(
144
      'id' => 'string',
145
      'redownload' => 'bool',
146
      'uid' => 'int',
147
    );
148
    $enums = array(
149
    );
150
151
    $request = new ApiRequest(
152
      $this->api,
153
      $this->data['id'],
154
      RequestInterface::METHOD_DELETE,
155
      '/users',
156
      new AbstractCrudObject(),
157
      'EDGE',
158
      array(),
159
      new TypeChecker($param_types, $enums)
160
    );
161
    $request->addParams($params);
162
    $request->addFields($fields);
163
    return $pending ? $request : $request->execute();
164
  }
165
166
  public function createUser(array $fields = array(), array $params = array(), $pending = false) {
167
    $this->assureId();
168
169
    $param_types = array(
170
      'account_group_roles' => 'list<map>',
171
      'id' => 'string',
172
      'redownload' => 'bool',
173
    );
174
    $enums = array(
175
    );
176
177
    $request = new ApiRequest(
178
      $this->api,
179
      $this->data['id'],
180
      RequestInterface::METHOD_POST,
181
      '/users',
182
      new AbstractCrudObject(),
183
      'EDGE',
184
      array(),
185
      new TypeChecker($param_types, $enums)
186
    );
187
    $request->addParams($params);
188
    $request->addFields($fields);
189
    return $pending ? $request : $request->execute();
190
  }
191
192
  public function deleteSelf(array $fields = array(), array $params = array(), $pending = false) {
193
    $this->assureId();
194
195
    $param_types = array(
196
      'id' => 'string',
197
    );
198
    $enums = array(
199
    );
200
201
    $request = new ApiRequest(
202
      $this->api,
203
      $this->data['id'],
204
      RequestInterface::METHOD_DELETE,
205
      '/',
206
      new AbstractCrudObject(),
207
      'NODE',
208
      array(),
209
      new TypeChecker($param_types, $enums)
210
    );
211
    $request->addParams($params);
212
    $request->addFields($fields);
213
    return $pending ? $request : $request->execute();
214
  }
215
216
  public function getSelf(array $fields = array(), array $params = array(), $pending = false) {
217
    $this->assureId();
218
219
    $param_types = array(
220
    );
221
    $enums = array(
222
    );
223
224
    $request = new ApiRequest(
225
      $this->api,
226
      $this->data['id'],
227
      RequestInterface::METHOD_GET,
228
      '/',
229
      new AdAccountGroup(),
230
      'NODE',
231
      AdAccountGroup::getFieldsEnum()->getValues(),
232
      new TypeChecker($param_types, $enums)
233
    );
234
    $request->addParams($params);
235
    $request->addFields($fields);
236
    return $pending ? $request : $request->execute();
237
  }
238
239
  public function updateSelf(array $fields = array(), array $params = array(), $pending = false) {
240
    $this->assureId();
241
242
    $param_types = array(
243
      'accounts' => 'map',
244
      'id' => 'string',
245
      'name' => 'string',
246
      'redownload' => 'bool',
247
      'status' => 'unsigned int',
248
      'users' => 'map',
249
    );
250
    $enums = array(
251
    );
252
253
    $request = new ApiRequest(
254
      $this->api,
255
      $this->data['id'],
256
      RequestInterface::METHOD_POST,
257
      '/',
258
      new AbstractCrudObject(),
259
      'NODE',
260
      array(),
261
      new TypeChecker($param_types, $enums)
262
    );
263
    $request->addParams($params);
264
    $request->addFields($fields);
265
    return $pending ? $request : $request->execute();
266
  }
267
268
  public function getUsers(array $fields = array(), array $params = array(), $pending = false) {
269
    $this->assureId();
270
271
    $param_types = array(
272
    );
273
    $enums = array(
274
    );
275
276
    $request = new ApiRequest(
277
      $this->api,
278
      $this->data['id'],
279
      RequestInterface::METHOD_GET,
280
      '/users',
281
      new AbstractCrudObject(),
282
      'EDGE',
283
      array(),
284
      new TypeChecker($param_types, $enums)
285
    );
286
    $request->addParams($params);
287
    $request->addFields($fields);
288
    return $pending ? $request : $request->execute();
289
  }
290
291
  /**
292
   * @deprecated use createUser instead
293
   */
294
  public function addUsers(array $roles, $pending = false) {
295
    $params = array();
296
    foreach ($roles as $uid => $role) {
297
      $params[] = array(
298
        'uid' => $uid,
299
        'role' => $role
300
      );
301
    }
302
303
    return $this->createUser(array(), array('account_group_roles' => $params), $pending);
304
  }
305
306
  /**
307
   * @deprecated use createUser instead
308
   */
309
  public function updateUsers(array $roles, $pending = false) {
310
    $params = array();
311
    foreach ($roles as $uid => $role) {
312
      $params[] = array(
313
        'uid' => $uid,
314
        'role' => $role
315
      );
316
    }
317
318
    return $this->createUser(array(), array('account_group_roles' => $params), $pending);
319
  }
320
321
  /**
322
   * @deprecated use deleteUsers instead
323
   */
324
  public function removeUser($user_id, $pending = false) {
325
    return $this->deleteUsers(array(), array('uid' => $user_id), $pending);
326
  }
327
328
  /**
329
   * @deprecated use createAdAccount instead
330
   */
331
  public function addAdAccounts(array $account_ids, $pending = false) {
332
    return $this->createAdAccount(array(), array('account_ids' => $account_ids), $pending);
333
  }
334
335
  /**
336
   * @deprecated use deleteAdAccounts instead
337
   */
338
  public function removeAdAccount($account_id, $pending = false) {
339
    return $this->deleteAdAccounts(array(), array('account_id' => $account_id), $pending);
340
  }
341
}
342