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.
Completed
Branch Editing-Fixing (c4d168)
by Igor
03:30
created

AddressBookLocation::addAdressBookLocation()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 22

Duplication

Lines 22
Ratio 100 %

Importance

Changes 0
Metric Value
cc 5
nc 5
nop 1
dl 22
loc 22
rs 9.2568
c 0
b 0
f 0
1
<?php
2
namespace Route4Me;
3
4
use Route4Me\Common;
5
use Route4Me\Enum\Endpoint;
6
7
class AddressBookLocation extends Common
8
{
9
    public $address_id;
10
    public $address_group;
11
    public $address_alias;
12
    public $address_1;
13
    public $address_2;
14
    public $first_name;
15
    public $last_name;
16
    public $address_email;
17
    public $address_phone_number;
18
    public $address_city;
19
    public $address_state_id;
20
    public $address_country_id;
21
    public $address_zip;
22
    public $cached_lat;
23
    public $cached_lng;
24
    public $curbside_lat;
25
    public $curbside_lng;
26
    public $color;
27
    public $address_custom_data;
28
    public $schedule;
29
    
30
    public $created_timestamp;
31
    public $member_id;
32
    public $schedule_blacklist;
33
    public $in_route_count;
34
    public $last_visited_timestamp;
35
    public $last_routed_timestamp;
36
    public $local_time_window_start;
37
    public $local_time_window_end;
38
    public $local_time_window_start_2;
39
    public $local_time_window_end_2;
40
    public $service_time;
41
    public $local_timezone_string;
42
    public $address_icon;
43
    public $address_stop_type;
44
    public $address_cube;
45
    public $address_pieces;
46
    public $address_reference_no;
47
    public $address_revenue;
48
    public $address_weight;
49
    public $address_priority;
50
    public $address_customer_po;
51
    
52
    public static function fromArray(array $params)
53
    {
54
        $addressbooklocation = new AddressBookLocation();
55
        
56
        foreach($params as $key => $value) {
57
            if (property_exists($addressbooklocation, $key)) {
58
                $addressbooklocation->{$key} = $value;
59
            }
60
        }
61
        
62
        return $addressbooklocation;
63
    }
64
    
65 View Code Duplication
    public static function getAddressBookLocation($addressId)
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...
66
    {
67
        $ablocations = Route4Me::makeRequst(array(
68
            'url'    => Endpoint::ADDRESS_BOOK_V4,
69
            'method' => 'GET',
70
            'query'  => array(
71
                'query' => $addressId,
72
                'limit' => 30
73
            )
74
        ));
75
76
        return $ablocations;
77
    }
78
    
79 View Code Duplication
    public static function searchRoutedLocation($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...
80
    {
81
        $result= Route4Me::makeRequst(array(
82
            'url'    => Endpoint::ADDRESS_BOOK_V4,
83
            'method' => 'GET',
84
            'query'  => array(
85
                'display' => isset($params['display']) ? $params['display'] : null,
86
                'query'   => isset($params['query']) ? $params['query'] : null,
87
                'fields'  => isset($params['fields']) ? $params['fields'] : null,
88
                'limit'   => isset($params['limit']) ? $params['limit'] : null,
89
                'offset'  => isset($params['offset']) ? $params['offset'] : null,
90
            )
91
        ));
92
93
        return $result;
94
    }
95
    
96 View Code Duplication
    public static function getAddressBookLocations($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...
97
    {
98
        $ablocations = Route4Me::makeRequst(array(
99
            'url'    => Endpoint::ADDRESS_BOOK_V4,
100
            'method' => 'GET',
101
            'query'  => array(
102
                'limit'  => isset($params['limit']) ? $params['limit'] : null,
103
                'offset' => isset($params['offset']) ? $params['offset'] : null,
104
            )
105
        ));
106
107
        return $ablocations;
108
    }
109
    
110
    public static function getAddressBookLocationsByIDs($ids)
111
    {
112
        $ablocations = Route4Me::makeRequst(array(
113
            'url'    => Endpoint::ADDRESS_BOOK_V4,
114
            'method' => 'GET',
115
            'query'  => array(
116
                'address_id' => $ids
117
            )
118
        ));
119
120
        return $ablocations;
121
    }
122
    
123
    public static function getRandomAddressBookLocation($params)
124
    {
125
        $ablocations = Route4Me::makeRequst(array(
126
            'url'    => Endpoint::ADDRESS_BOOK_V4,
127
            'method' => 'GET',
128
            'query'  => array(
129
                'limit'  => isset($params['limit']) ? $params['limit'] : 0,
130
                'offset' => isset($params['offset']) ? $params['offset'] : 10,
131
            )
132
        ));
133
        
134
        if (isset($ablocations["results"])) {
135
            $locationsSize = sizeof($ablocations["results"]);
136
            
137
            if ($locationsSize > 0) {
138
                $randomLocationIndex = rand(0, $locationsSize - 1);
139
                return $ablocations["results"][$randomLocationIndex];
140
            } 
141
        } 
142
143
        return null;
144
    }
145
    
146 View Code Duplication
    public static function addAdressBookLocation($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...
147
    {
148
        $body = array();
149
        $abLocations = new AddressBookLocation();
150
        
151
        foreach($params as $key => $value) {
152
            if ($key == "address_id") continue; 
153
            if (property_exists($abLocations, $key)) {
154
                if (isset($params->{$key})) {
155
                    $body[$key] = $params->{$key};
156
                } 
157
            }
158
        }
159
        
160
        $response = Route4Me::makeRequst(array(
161
            'url'    => Endpoint::ADDRESS_BOOK_V4,
162
            'method' => 'POST',
163
            'body'   => $body
164
        ));
165
166
        return $response;
167
    }
168
    
169 View Code Duplication
    public function deleteAdressBookLocation($address_ids)
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
        $result = Route4Me::makeRequst(array(
172
            'url'    => Endpoint::ADDRESS_BOOK_V4,
173
            'method' => 'DELETEARRAY',
174
            'query'  => array(
175
                'address_ids' => $address_ids
176
            )
177
        ));
178
179
        return $result;
180
    }
181
    
182 View Code Duplication
    public function updateAdressBookLocation($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...
183
    {
184
        $body = array();
185
        $abLocations = new AddressBookLocation();
186
        
187
        foreach($params as $key => $value) {
188
            if (property_exists($abLocations, $key)) {
189
                if (isset($params->{$key})) {
190
                    $body[$key] = $params->{$key};
191
                } 
192
            }
193
        }
194
195
        $response = Route4Me::makeRequst(array(
196
            'url'    => Endpoint::ADDRESS_BOOK_V4,
197
            'method' => 'PUT',
198
            'body'   => $body,
199
        ));
200
201
        return $response;
202
    }
203
        
204 View Code Duplication
    public static function get($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...
205
    {
206
        $ablocations = Route4Me::makeRequst(array(
207
            'url'    => Endpoint::ADDRESS_BOOK_V4,
208
            'method' => 'ADD',
209
            'query'  => array(
210
                'first_name' => isset($params->first_name) ? $params->first_name : null,
211
                'address_1'  => isset($params->address_1) ? $params->address_1 : null,
212
                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
213
                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
214
            )
215
        ));
216
217
        return $ablocations;
218
    }
219
    
220
    public static function validateScheduleMode($scheduleMode)
221
    {
222
        $schedMmodes = array("daily","weekly","monthly","annually");
223
        
224
        if (in_array($scheduleMode, $schedMmodes)) 
225
            return TRUE; 
226
        else 
227
            return FALSE;
228
    }
229
    
230
    public static function validateScheduleEnable($scheduleEnabled)
231
    {
232
        $schedEnambles = array(TRUE,FALSE);
233
        
234
        if (in_array($scheduleEnabled, $schedEnambles))
235
            return TRUE;
236
        else
237
            return FALSE;
238
    }
239
    
240
    public static function validateScheduleEvery($scheduleEvery)
241
    {
242
        if (is_numeric($scheduleEvery))
243
            return TRUE;
244
        else
245
            return FALSE;
246
    }
247
    
248 View Code Duplication
    public static function validateScheduleWeekDays($scheduleWeekDays)
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...
249
    {
250
        $weekdays = explode(',', $scheduleWeekDays);
251
        
252
        if (sizeof($weekdays) < 1) return FALSE;
253
        
254
        $isValid = TRUE;
255
        
256
        for ($i=0; $i < sizeof($weekdays); $i++) { 
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function sizeof() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
257
            if (is_numeric($weekdays[$i])) {
258
                $wday = intval($weekdays[$i]);
259
                if ($wday < 1 || $wday > 7) $isValid = FALSE;
260
            }
261
            else $isValid = FALSE;
262
        }
263
        
264
        return $isValid;
265
    }
266
    
267
    public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
268
    {
269
        $schedMonthlyMmodes = array("dates","nth");
270
        
271
        if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes))
272
            return TRUE;
273
        else
274
            return FALSE;
275
    }
276
    
277 View Code Duplication
    public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
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...
278
    {
279
        $monthlyDates = explode(',', $scheduleMonthlyDates);
280
        
281
        if (sizeof($monthlyDates) <1) return FALSE;
282
        
283
        $isValid = TRUE;
284
        
285
        for ($i=0; $i < sizeof($monthlyDates); $i++) { 
0 ignored issues
show
Performance Best Practice introduced by
It seems like you are calling the size function sizeof() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.

If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration:

for ($i=0; $i<count($array); $i++) { // calls count() on each iteration
}

// Better
for ($i=0, $c=count($array); $i<$c; $i++) { // calls count() just once
}
Loading history...
286
            if (is_numeric($monthlyDates[$i])) {
287
                $mday = intval($monthlyDates[$i]);
288
                if ($mday <1 || $mday > 31) $isValid = FALSE;
289
            }
290
            else $isValid = FALSE;
291
        }
292
293
        return $isValid;
294
    }
295
    
296
    public static function validateScheduleNthN($scheduleNthN)
297
    {
298
        if (!is_numeric($scheduleNthN)) return FALSE;
299
        
300
        $schedNthNs = array(1,2,3,4,5,-1);
301
        
302
        if (in_array($scheduleNthN, $schedNthNs))
303
            return TRUE;
304
        else
305
            return FALSE;
306
    }
307
    
308
    public static function validateScheduleNthWhat($scheduleNthWhat)
309
    {
310
        if (!is_numeric($scheduleNthWhat)) return FALSE;
311
        
312
        $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
313
        
314
        if (in_array($scheduleNthWhat, $schedNthWhats))
315
            return TRUE;
316
        else
317
            return FALSE;
318
    }
319
    
320
    /* Function adds the locations (with/without schedule) from the CSV file. 
321
     * $csvFileHandle - a file handler.
322
     * Returns array $results which contains two arrays: fail and succes.
323
     */
324
    public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
325
    {
326
        $max_line_length = 512;
327
        $delemietr = ',';
328
        
329
        $results = array();
330
        $results['fail'] = array();
331
        $results['success'] = array();
332
        
333
        $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
334
335
        if (empty($columns)) {
336
            array_push($results['fail'],'Empty CSV table');
337
            return ($results);
338
        }
339
340
        $iRow = 1;
341
        
342
        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
343
            if ($rows[$locationsFieldsMapping['cached_lat']] 
344
                  && $rows[$locationsFieldsMapping['cached_lng']] 
345
                  && $rows[$locationsFieldsMapping['address_1']] 
346
                  && array(null) !== $rows) {
347
                $curSchedule = "";
0 ignored issues
show
Unused Code introduced by
$curSchedule is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
348
                $mode = "";
349
                
350 View Code Duplication
                if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
351
                    if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
352
                        $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
353
                        $mode = $rows[$locationsFieldsMapping['schedule_mode']];
354
                    } else {
355
                        array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); 
356
                        $curSchedule = "";
357
                    }
358
                } else {
359
                    array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); 
360
                    $curSchedule = "";
361
                }
362
                
363
                if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
364
                    if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
365
                        $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
366
                    } else {
367
                        array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set ");  
368
                        $curSchedule = "";
369
                    }
370
                }
371
                
372
                if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
373
                    if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
374
                        $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
375
                        if ($mode == 'daily') {
376
                            $curSchedule = trim($curSchedule,',');
377
                            $curSchedule.='}';
378
                        }
379
                    } else {
380
                        array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); 
381
                        $curSchedule = ""; 
382
                    }
383
                }
384
                
385
                if ($mode!='daily') {
386
                    switch ($mode) {
387
                        case 'weekly':
388 View Code Duplication
                            if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
389
                                if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
390
                                     $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
391
                                } else {
392
                                    array_push($results['fail'],"$iRow --> Wrong weekdays"); 
393
                                    $curSchedule = "";
394
                                }
395
                            } else {
396
                                array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); 
397
                                $curSchedule = "";
398
                            }
399
                            break;
400
                        case 'monthly':
401
                            $monthlyMode = "";
402 View Code Duplication
                            if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
403
                                if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
404
                                     $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
405
                                     $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
406
                                } else {
407
                                    array_push($results['fail'],"$iRow --> Wrong monthly mode"); 
408
                                    $curSchedule = "";
409
                                }
410
                            } else {
411
                                array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); 
412
                                $curSchedule = "";
413
                            }
414
                            
415
                            if ($monthlyMode != "") {
416
                                switch ($monthlyMode) {
417
                                    case 'dates':
418
                                        if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
419
                                            if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
420
                                                 $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
421
                                            } else {
422
                                                array_push($results['fail'],"$iRow --> Wrong monthly dates"); 
423
                                                $curSchedule = "";
424
                                            }
425
                                        }
426
                                        break;
427
                                    case 'nth':
428 View Code Duplication
                                        if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
429
                                            if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
430
                                                 $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
431
                                            } else {
432
                                                array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); 
433
                                                $curSchedule = "";
434
                                            }
435
                                        } else {
436
                                            array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); 
437
                                            $curSchedule = "";
438
                                        }
439
                                        
440 View Code Duplication
                                        if ($curSchedule != "") {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
441
                                            if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
442
                                                if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
443
                                                     $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
444
                                                } else {
445
                                                    array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); 
446
                                                    $curSchedule = "";
447
                                                }
448
                                            } else {
449
                                                array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); 
450
                                                $curSchedule = "";
451
                                            }
452
                                        }
453
                                        break;
454
                                }
455
                            }
456
                            break;
457
                        default:
458
                            $curSchedule = "";
459
                            break;
460
                    }
461
                }
462
463
                if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") {
464
                    $iRow++; 
465
                    continue;
466
                }
467
                
468
                $curSchedule =strtolower($curSchedule);
469
                
470
                $curSchedule = '[{'.$curSchedule.'}]';
471
472
                $oSchedule = json_decode($curSchedule,TRUE);
473
                
474
                $AdressBookLocationParameters = AddressBookLocation::fromArray(array(
475
                    "cached_lat"                 => $rows[$locationsFieldsMapping['cached_lat']],
476
                    "cached_lng"                 => $rows[$locationsFieldsMapping['cached_lng']],
477
                    "curbside_lat"               => isset($locationsFieldsMapping['curbside_lat'])
478
                                                     ? $rows[$locationsFieldsMapping['curbside_lat']] : null,
479
                    "curbside_lng"               => isset($locationsFieldsMapping['curbside_lng'])
480
                                                     ? $rows[$locationsFieldsMapping['curbside_lng']] : null,
481
                    "address_alias"              => isset($locationsFieldsMapping['address_alias'])
482
                                                     ? $rows[$locationsFieldsMapping['address_alias']] : null,
483
                    "address_1"                  => $rows[$locationsFieldsMapping['address_1']],
484
                    "address_2"                  => isset($locationsFieldsMapping['address_2'])
485
                                                     ? $rows[$locationsFieldsMapping['address_2']] : null,
486
                    "address_city"               => isset($locationsFieldsMapping['address_city'])
487
                                                      ? $rows[$locationsFieldsMapping['address_city']] : null,
488
                    "address_state_id"           => isset($locationsFieldsMapping['address_state_id'])
489
                                                      ? $rows[$locationsFieldsMapping['address_state_id']] : null,
490
                    "address_zip"                => isset($locationsFieldsMapping['address_zip'])
491
                                                      ? $rows[$locationsFieldsMapping['address_zip']] : null,
492
                    "address_phone_number"       => isset($locationsFieldsMapping['address_phone_number'])
493
                                                      ? $rows[$locationsFieldsMapping['address_phone_number']] : null,
494
                    "schedule"                   => isset($oSchedule) ? $oSchedule : null,
495
                    "address_group"              => isset($locationsFieldsMapping['address_group']) 
496
                                                      ? $rows[$locationsFieldsMapping['address_group']] : null,
497
                    "first_name"                 => isset($locationsFieldsMapping['first_name']) 
498
                                                      ? $rows[$locationsFieldsMapping['first_name']] : null,
499
                    "last_name"                  => isset($locationsFieldsMapping['last_name']) 
500
                                                      ? $rows[$locationsFieldsMapping['last_name']] : null,
501
                    "local_time_window_start"    => isset($locationsFieldsMapping['local_time_window_start'])
502
                                                      ? $rows[$locationsFieldsMapping['local_time_window_start']] : null,
503
                    "local_time_window_end"      => isset($locationsFieldsMapping['local_time_window_end'])
504
                                                      ? $rows[$locationsFieldsMapping['local_time_window_end']] : null,
505
                    "local_time_window_start_2"  => isset($locationsFieldsMapping['local_time_window_start_2'])
506
                                                      ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null,
507
                    "local_time_window_end_2"    => isset($locationsFieldsMapping['local_time_window_end_2'])
508
                                                      ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null,
509
                    "address_email"              => isset($locationsFieldsMapping['address_email'])
510
                                                      ? $rows[$locationsFieldsMapping['address_email']] : null,
511
                    "address_country_id"         => isset($locationsFieldsMapping['address_country_id'])
512
                                                      ? $rows[$locationsFieldsMapping['address_country_id']] : null,
513
                    "address_custom_data"        => isset($locationsFieldsMapping['address_custom_data'])
514
                                                      ? $rows[$locationsFieldsMapping['address_custom_data']] : null,
515
                    "schedule_blacklist"         => isset($locationsFieldsMapping['schedule_blacklist'])
516
                                                      ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null,
517
                    "service_time"               => isset($locationsFieldsMapping['service_time'])
518
                                                      ? $rows[$locationsFieldsMapping['service_time']] : null,
519
                    "local_timezone_string"      => isset($locationsFieldsMapping['local_timezone_string'])
520
                                                      ? $rows[$locationsFieldsMapping['local_timezone_string']] : null,
521
                    "color"                      => isset($locationsFieldsMapping['color'])
522
                                                      ? $rows[$locationsFieldsMapping['color']] : null,
523
                    "address_icon"               => isset($locationsFieldsMapping['address_icon'])
524
                                                      ? $rows[$locationsFieldsMapping['address_icon']] : null,
525
                    "address_stop_type"          => isset($locationsFieldsMapping['address_stop_type'])
526
                                                      ? $rows[$locationsFieldsMapping['address_stop_type']] : null,
527
                    "address_cube"               => isset($locationsFieldsMapping['address_cube'])
528
                                                      ? $rows[$locationsFieldsMapping['address_cube']] : null,
529
                    "address_pieces"             => isset($locationsFieldsMapping['address_pieces'])
530
                                                      ? $rows[$locationsFieldsMapping['address_pieces']] : null,
531
                    "address_reference_no"       => isset($locationsFieldsMapping['address_reference_no'])
532
                                                      ? $rows[$locationsFieldsMapping['address_reference_no']] : null,
533
                    "address_revenue"            => isset($locationsFieldsMapping['address_revenue'])
534
                                                      ? $rows[$locationsFieldsMapping['address_revenue']] : null,
535
                    "address_weight"             => isset($locationsFieldsMapping['address_weight'])
536
                                                      ? $rows[$locationsFieldsMapping['address_weight']] : null,
537
                    "address_priority"           => isset($locationsFieldsMapping['address_priority'])
538
                                                      ? $rows[$locationsFieldsMapping['address_priority']] : null,
539
                    "address_customer_po"        => isset($locationsFieldsMapping['address_customer_po'])
540
                                                      ? $rows[$locationsFieldsMapping['address_customer_po']] : null,
541
                ));
542
                
543
                $abContacts = new AddressBookLocation();
544
545
                $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
546
                
547
                array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
548
            }
549
        }
550
551
        return $results;
552
    }
553
 }
554