Completed
Push — master ( 86d4f9...53bee2 )
by
unknown
04:49
created

CustomConversion   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 152
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 8

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 13
c 4
b 0
f 1
lcom 1
cbo 8
dl 0
loc 152
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getEndpoint() 0 3 1
A getFieldsEnum() 0 3 1
A getReferencedEnums() 0 5 1
B getActivities() 0 31 2
B getStats() 0 26 2
A deleteSelf() 0 22 2
A getSelf() 0 22 2
B updateSelf() 0 25 2
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\CustomConversionFields;
32
use FacebookAds\Object\Values\AdsPixelStatsResultAggregationValues;
33
use FacebookAds\Object\Values\CustomConversionActivitiesEventTypeValues;
34
use FacebookAds\Object\Values\CustomConversionCustomEventTypeValues;
35
36
/**
37
 * This class is auto-genereated.
38
 *
39
 * For any issues or feature requests related to this class, please let us know
40
 * on github and we'll fix in our codegen framework. We'll not be able to accept
41
 * pull request for this class.
42
 *
43
 */
44
45
class CustomConversion extends AbstractCrudObject {
46
47
  protected function getEndpoint() {
48
    return 'customconversions';
49
  }
50
51
  /**
52
   * @return CustomConversionFields
53
   */
54
  public static function getFieldsEnum() {
55
    return CustomConversionFields::getInstance();
56
  }
57
58
  protected static function getReferencedEnums() {
59
    $ref_enums = array();
60
    $ref_enums['CustomEventType'] = CustomConversionCustomEventTypeValues::getInstance()->getValues();
61
    return $ref_enums;
62
  }
63
64
65
  public function getActivities(array $fields = array(), array $params = array(), $pending = false) {
66
    $this->assureId();
67
68
    $param_types = array(
69
      'end_time' => 'datetime',
70
      'event_type' => 'event_type_enum',
71
      'start_time' => 'datetime',
72
    );
73
    $enums = array(
74
      'event_type_enum' => array(
75
        'conversion_archive',
76
        'conversion_create',
77
        'conversion_delete',
78
        'conversion_update',
79
      ),
80
    );
81
82
    $request = new ApiRequest(
83
      $this->api,
84
      $this->data['id'],
85
      RequestInterface::METHOD_GET,
86
      '/activities',
87
      new AbstractCrudObject(),
88
      'EDGE',
89
      array(),
90
      new TypeChecker($param_types, $enums)
91
    );
92
    $request->addParams($params);
93
    $request->addFields($fields);
94
    return $pending ? $request : $request->execute();
95
  }
96
97
  public function getStats(array $fields = array(), array $params = array(), $pending = false) {
98
    $this->assureId();
99
100
    $param_types = array(
101
      'aggregation' => 'aggregation_enum',
102
      'end_time' => 'datetime',
103
      'start_time' => 'datetime',
104
    );
105
    $enums = array(
106
      'aggregation_enum' => AdsPixelStatsResultAggregationValues::getInstance()->getValues(),
107
    );
108
109
    $request = new ApiRequest(
110
      $this->api,
111
      $this->data['id'],
112
      RequestInterface::METHOD_GET,
113
      '/stats',
114
      new AdsPixelStatsResult(),
115
      'EDGE',
116
      AdsPixelStatsResult::getFieldsEnum()->getValues(),
117
      new TypeChecker($param_types, $enums)
118
    );
119
    $request->addParams($params);
120
    $request->addFields($fields);
121
    return $pending ? $request : $request->execute();
122
  }
123
124
  public function deleteSelf(array $fields = array(), array $params = array(), $pending = false) {
125
    $this->assureId();
126
127
    $param_types = array(
128
    );
129
    $enums = array(
130
    );
131
132
    $request = new ApiRequest(
133
      $this->api,
134
      $this->data['id'],
135
      RequestInterface::METHOD_DELETE,
136
      '/',
137
      new AbstractCrudObject(),
138
      'NODE',
139
      array(),
140
      new TypeChecker($param_types, $enums)
141
    );
142
    $request->addParams($params);
143
    $request->addFields($fields);
144
    return $pending ? $request : $request->execute();
145
  }
146
147
  public function getSelf(array $fields = array(), array $params = array(), $pending = false) {
148
    $this->assureId();
149
150
    $param_types = array(
151
    );
152
    $enums = array(
153
    );
154
155
    $request = new ApiRequest(
156
      $this->api,
157
      $this->data['id'],
158
      RequestInterface::METHOD_GET,
159
      '/',
160
      new CustomConversion(),
161
      'NODE',
162
      CustomConversion::getFieldsEnum()->getValues(),
163
      new TypeChecker($param_types, $enums)
164
    );
165
    $request->addParams($params);
166
    $request->addFields($fields);
167
    return $pending ? $request : $request->execute();
168
  }
169
170
  public function updateSelf(array $fields = array(), array $params = array(), $pending = false) {
171
    $this->assureId();
172
173
    $param_types = array(
174
      'default_conversion_value' => 'float',
175
      'description' => 'string',
176
      'name' => 'string',
177
    );
178
    $enums = array(
179
    );
180
181
    $request = new ApiRequest(
182
      $this->api,
183
      $this->data['id'],
184
      RequestInterface::METHOD_POST,
185
      '/',
186
      new CustomConversion(),
187
      'NODE',
188
      CustomConversion::getFieldsEnum()->getValues(),
189
      new TypeChecker($param_types, $enums)
190
    );
191
    $request->addParams($params);
192
    $request->addFields($fields);
193
    return $pending ? $request : $request->execute();
194
  }
195
196
}
197