GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 7f01d7...1527b5 )
by Oleg
02:36
created

Member::deleteMember()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.8333
c 0
b 0
f 0
cc 2
nc 1
nop 1
1
<?php
2
namespace Route4Me;
3
4
use Route4Me\Common;
5
use Route4Me\Enum\Endpoint;
6
7
class Member extends Common
8
{
9
    public $device_id;
10
    public $device_type;
11
    public $format;
12
    
13
    public $strEmail;
14
    public $strPassword;
15
    public $strPassword_1;
16
    public $strPassword_2;
17
    public $strFirstName;
18
    public $strLastName;
19
    public $strIndustry;
20
    public $chkTerms;
21
    public $plan;
22
    
23
    public $session_guid;
24
    public $member_id;
25
    
26
    public $email_address;
27
    public $first_name;
28
    public $last_name;
29
    public $phone_number;
30
    public $company_name;
31
    public $webiinar_date;
32
    
33
    public $subscription_name;
34
    public $token;
35
    public $payload;
36
    
37
    public $HIDE_ROUTED_ADDRESSES;
38
    public $member_phone;
39
    public $member_zipcode;
40
    public $route_count;
41
    public $member_email;
42
    public $HIDE_VISITED_ADDRESSES;
43
    public $READONLY_USER;
44
    public $member_type;
45
    public $date_of_birth;
46
    public $member_first_name;
47
    public $member_password;
48
    public $HIDE_NONFUTURE_ROUTES;
49
    public $member_last_name;
50
    public $SHOW_ALL_VEHICLES;
51
    public $SHOW_ALL_DRIVERS;
52
    
53
    public $config_key;
54
    public $config_value;
55
    
56
    public $preferred_units;
57
    public $preferred_language;
58
    public $timezone;
59
    public $OWNER_MEMBER_ID;
60
    public $user_reg_state_id;
61
    public $user_reg_country_id;
62
    public $member_picture;
63
    public $api_key;
64
    public $custom_data;
65
    
66
    public static function fromArray(array $params) 
67
    {
68
        $member= new Member();
69
        
70
        foreach($params as $key => $value) {
71
            if (property_exists($member, $key)) {
72
                $member->{$key} = $value;
73
            }
74
        }
75
        
76
        return $member;
77
    }
78
    
79
    public static function getUsers()
80
    {
81
        $response = Route4Me::makeRequst(array(
82
            'url'    => Endpoint::USER_V4,
83
            'method' => 'GET'
84
        ));
85
86
        return $response;
87
    }
88
    
89 View Code Duplication
    public static function getUser($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
    {
91
        $response = Route4Me::makeRequst(array(
92
            'url'    => Endpoint::USER_V4,
93
            'method' => 'GET',
94
            'query'  => array(
95
                'member_id' => isset($params['member_id']) ? $params['member_id'] : null
96
            )
97
        ));
98
99
        return $response;
100
    }
101
    
102
    public static function getUserLocations($param)
103
    {
104
        $response = Route4Me::makeRequst(array(
105
            'url'    => Endpoint::VIEW_USER_LOCATIONS,
106
            'method' => 'GET',
107
            'query'  => array(
108
                'query' => $param
109
            )
110
        ));
111
112
        return $response;
113
    }
114
    
115 View Code Duplication
    public static function addDeviceRecord($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
116
    {
117
        $allQueryFields = array('device_id', 'device_type');
118
        $allBodyFields = array('device_id', 'device_type', 'format');
119
        
120
        $response = Route4Me::makeRequst(array(
121
            'url'    => Endpoint::VERIFY_DEVICE_LICENSE,
122
            'method' => 'POST',
123
            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
124
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
125
        ));
126
        
127
        return $response;
128
    }
129
    
130 View Code Duplication
    public static function createMember($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
131
    {
132
        $excludeFields = array('session_guid', 'member_id', 'token', 'payload', 'webiinar_date', 
133
        'company_name', 'config_key', 'config_value', 'api_key');
134
        
135
        $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields);
136
137
        $response = Route4Me::makeRequst(array(
138
            'url'    => Endpoint::USER_V4,
139
            'method' => 'POST',
140
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
141
        ));
142
        
143
        return $response;
144
    }
145
146
    public static function getRandomMemberByType($memberType)
147
    {
148
        $members = self::getUsers();
149
        
150
        if (is_null($members)) return null;
151
        if (!isset($members['results'])) return null;
152
        
153
        $memberIDs = array();
154
        
155
        foreach ($members['results'] as $memb) {
156
            if (isset($memb['member_id']) && isset($memb['member_type'])) {
157
                if ($memberType==$memb['member_type']) $memberIDs[]=$memb['member_id'];
158
            }
159
        }
160
        
161
        if (sizeof($memberIDs)<1) return null;
162
        
163
        $randomIndex = rand(0, sizeof($memberIDs)-1);
164
        
165
        return $memberIDs[$randomIndex];
166
    }
167
168
169 View Code Duplication
    public static function updateMember($body)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
170
    {
171
        $excludeFields = array('session_guid', 'token', 'payload', 'webiinar_date', 
172
        'company_name', 'config_key', 'config_value', 'api_key');
173
        
174
        $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields);
175
        
176
        $response = Route4Me::makeRequst(array(
177
            'url'    => Endpoint::USER_V4,
178
            'method' => 'PUT',
179
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $body)
180
        ));
181
        
182
        return $response;
183
    }
184
185
    public static function deleteMember($body)
186
    {
187
        $response = Route4Me::makeRequst(array(
188
            'url'    => Endpoint::USER_V4,
189
            'method' => 'DELETE',
190
            'body'   => array(
191
                'member_id' =>  isset($body->member_id) ? $body->member_id : null
192
            )
193
194
        ));
195
        
196
        return $response;
197
    }
198
    
199
    public static function newAccountRegistration($params)
200
    {
201
        $allQueryFields = array('plan');
202
        $allBodyFields = array('strEmail', 'strPassword_1', 'strPassword_2', 'strFirstName', 
203
        'strLastName', 'format', 'strIndustry', 'chkTerms', 
204
        'device_type', 'strSubAccountType', 'blDisableMarketing', 'blDisableAccountActivationEmail');
205
        
206
        $response = Route4Me::makeRequst(array(
207
            'url'    => Endpoint::REGISTER_ACTION,
208
            'method' => 'POST',
209
            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
210
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
211
            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
212
        ));
213
        
214
        return $response;
215
    }
216
    
217
    public static function validateSession($params)
218
    {
219
        $allQueryFields = array('session_guid', 'member_id', 'format');
220
        
221
        $response = Route4Me::makeRequst(array(
222
            'url'    => Endpoint::VALIDATE_SESSION,
223
            'method' => 'GET',
224
            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
225
        ));
226
        
227
        return $response;
228
    }
229
    
230 View Code Duplication
    public static function memberAuthentication($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
231
    {
232
        $allBodyFields = array('strEmail', 'strPassword', 'format');
233
        
234
        $response = Route4Me::makeRequst(array(
235
            'url'    => Endpoint::AUTHENTICATE,
236
            'method' => 'POST',
237
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
238
            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
239
        ));
240
        
241
        return $response;
242
    }
243
    
244 View Code Duplication
    public static function webinarRegistration($params)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
245
    {
246
        $allBodyFields = array('email_address', 'first_name', 'last_name', 'phone_number', 
247
        'company_name', 'member_id', 'webiinar_date');
248
        
249
        $response = Route4Me::makeRequst(array(
250
            'url'    => Endpoint::WEBINAR_REGISTER,
251
            'method' => 'POST',
252
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
253
        ));
254
        
255
        return $response;
256
    }
257
    
258
    public static function purchaseUserLicense($params)
259
    {
260
        $allQueryFields = array('device_id');
261
        $allBodyFields = array('member_id', 'session_guid', 'device_id', 'device_type', 
262
        'subscription_name', 'token', 'payload', 'format');
263
        
264
        $response = Route4Me::makeRequst(array(
265
            'url'    => Endpoint::USER_LICENSE,
266
            'method' => 'POST',
267
            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
268
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
269
        ));
270
        
271
        return $response;
272
    }
273
    
274
    public static function newMemberConfigKey($params)
275
    {
276
        $allBodyFields = array('config_key', 'config_value');
277
        
278
        $response = Route4Me::makeRequst(array(
279
            'url'    => Endpoint::CONFIGURATION_SETTINGS,
280
            'method' => 'POST',
281
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
282
        ));
283
        
284
        return $response;
285
    }
286
    
287
    public static function removeMemberConfigKey($params)
288
    {
289
        $allBodyFields = array('config_key');
290
        
291
        $response = Route4Me::makeRequst(array(
292
            'url'    => Endpoint::CONFIGURATION_SETTINGS,
293
            'method' => 'DELETE',
294
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
295
        ));
296
        
297
        return $response;
298
    }
299
    
300
    public static function getMemberConfigData($params)
301
    {
302
        $allQueryFields = array('config_key');
303
        
304
        $response = Route4Me::makeRequst(array(
305
            'url'    => Endpoint::CONFIGURATION_SETTINGS,
306
            'method' => 'GET',
307
            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params)
308
        ));
309
        
310
        return $response;
311
    }
312
313
    public static function updateMemberConfigKey($params)
314
    {
315
        $allBodyFields = array('config_key', 'config_value');
316
        
317
        $response = Route4Me::makeRequst(array(
318
            'url'    => Endpoint::CONFIGURATION_SETTINGS,
319
            'method' => 'PUT',
320
            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params)
321
        ));
322
        
323
        return $response;
324
    }
325
}
326