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.
Test Failed
Push — master ( fd5711...77a95b )
by Igor
09:00 queued 13s
created
src/Route4Me/Route.php 2 patches
Indentation   +805 added lines, -805 removed lines patch added patch discarded remove patch
@@ -12,809 +12,809 @@
 block discarded – undo
12 12
  */
13 13
 class Route extends Common
14 14
 {
15
-    /**
16
-     * The route ID
17
-     * @var string
18
-     */
19
-    public $route_id;
20
-
21
-    /**
22
-     * Member ID of a route owner
23
-     * @var integer
24
-     */
25
-    public $member_id;
26
-
27
-    /**
28
-     * Optimization problem ID
29
-     * @var string
30
-     */
31
-    public $optimization_problem_id;
32
-
33
-    /**
34
-     * Vehicle alias
35
-     * @var string
36
-     */
37
-    public $vehicle_alias;
38
-
39
-    /**
40
-     * Driver alias
41
-     * @var string
42
-     */
43
-    public $driver_alias;
44
-
45
-    /**
46
-     * Total route's trip distance
47
-     * @var double
48
-     */
49
-    public $trip_distance;
50
-
51
-    /**
52
-     * The UDU distance measurement unit for the route.<br>
53
-     * @note km or mi, the route4me api will convert all distance measurements into these units.
54
-     * @var string
55
-     */
56
-    public $udu_distance_unit;
57
-
58
-    /**
59
-     * Total route's UDU trip distance
60
-     * @var double
61
-     */
62
-    public $udu_trip_distance;
63
-
64
-    /** Miles per gallon
65
-     * @var double
66
-     */
67
-    public $mpg;
68
-
69
-    /**
70
-     * Gas price
71
-     * @var double
72
-     */
73
-    public $gas_price;
74
-
75
-    /**
76
-     * Total route duration (seconds)
77
-     * @var integer
78
-     */
79
-    public $route_duration_sec;
80
-
81
-    /**
82
-     * Number of the destinations in the route.
83
-     * @var integer
84
-     */
85
-    public $destination_count;
86
-
87
-    /**
88
-     * Notes count in the route.
89
-     * @var integer
90
-     */
91
-    public $notes_count;
92
-
93
-    /**
94
-     * Route parameters
95
-     * @var RouteParameters
96
-     */
97
-    public $parameters;
98
-
99
-    /**
100
-     * An array of the route addresses
101
-     * @var Address[]
102
-     */
103
-    public $addresses = [];
104
-
105
-    /**
106
-     * An array of the links
107
-     * @var string[]
108
-     */
109
-    public $links = [];
110
-
111
-    /**
112
-     * Edge by edge turn-by-turn directions.
113
-     * @var Direction[]
114
-     */
115
-    public $directions = [];
116
-
117
-    /**
118
-     * Edge-wise path to be drawn on the map.
119
-     * @var GeoPoint[]
120
-     */
121
-    public $path = [];
122
-
123
-    /**
124
-     * A collection of device tracking data with coordinates, speed, and timestamps.
125
-     * @var Tracking\TrackingHistory[]
126
-     */
127
-    public $tracking_history = [];
128
-
129
-    /**
130
-     * HTTP headers
131
-     * @var string
132
-     */
133
-    public $httpheaders;
134
-
135
-    /**
136
-     * If true, the route is unrouted.
137
-     * @var Boolean
138
-     */
139
-    public $is_unrouted;
140
-
141
-    /**
142
-     * User route rating [0, 5]. A null value means no rating was given.<br>
143
-     * Users can rate routes so that future optimizations take these ratings into account.
144
-     * @var integer
145
-     */
146
-    public $user_route_rating;
147
-
148
-    /**
149
-     * The member's email
150
-     * @var string
151
-     */
152
-    public $member_email;
153
-
154
-    /**
155
-     * URL to a member picture
156
-     * @var string
157
-     */
158
-    public $member_picture;
159
-
160
-    /**
161
-     * Member tracking subheadline.
162
-     * @var string
163
-     */
164
-    public $member_tracking_subheadline;
165
-
166
-    /**
167
-     * If true, the order is approved for execution.
168
-     * @var Boolean
169
-     */
170
-    public $approved_for_execution;
171
-
172
-    /**
173
-     * Counter of the approved revisions.
174
-     * @var integer
175
-     */
176
-    public $approved_revisions_counter;
177
-
178
-    /**
179
-     * The member's first name.
180
-     * @var string
181
-     */
182
-    public $member_first_name;
183
-
184
-    /**
185
-     * The member's last name.
186
-     * @var string
187
-     */
188
-    public $member_last_name;
189
-
190
-    /**
191
-     * Channel name
192
-     * @var string
193
-     */
194
-    public $channel_name;
195
-
196
-    /**
197
-     * Total cost of the route.
198
-     * @var double
199
-     */
200
-    public $route_cost;
201
-
202
-    /**
203
-     * Total route revenue
204
-     * @var double
205
-     */
206
-    public $route_revenue;
207
-
208
-    /**
209
-     * Net revenue per distance unit.
210
-     * @var double
211
-     */
212
-    public $net_revenue_per_distance_unit;
213
-
214
-    /**
215
-     * When route created (UNIX format timestamp).
216
-     * @var integer
217
-     */
218
-    public $created_timestamp;
219
-
220
-    /**
221
-     * Planned total route duration (seconds).
222
-     * @var integer
223
-     */
224
-    public $planned_total_route_duration;
225
-
226
-    /**
227
-     * Total wait time (seconds).
228
-     * @var integer
229
-     */
230
-    public $total_wait_time;
231
-
232
-    /**
233
-     * UDU Actual travel distance.
234
-     * @var double
235
-     */
236
-    public $udu_actual_travel_distance;
237
-
238
-    /**
239
-     * Actual travel distance.
240
-     * @var double
241
-     */
242
-    public $actual_travel_distance;
243
-
244
-    /**
245
-     * Actual travel time (seconds).
246
-     * @var integer
247
-     */
248
-    public $actual_travel_time;
249
-
250
-    /**
251
-     * Actual footsteps.
252
-     * @var integer
253
-     */
254
-    public $actual_footsteps;
255
-
256
-    /**
257
-     * Working time.
258
-     * @var integer
259
-     */
260
-    public $working_time;
261
-
262
-    /**
263
-     * Driving time.
264
-     * @var integer
265
-     */
266
-    public $driving_time;
267
-
268
-    /**
269
-     * Idling time.
270
-     * @var integer
271
-     */
272
-    public $idling_time;
273
-
274
-    /**
275
-     * Paying miles
276
-     * @var double
277
-     */
278
-    public $paying_miles;
279
-
280
-    /**
281
-     * Geofence polygon type.<br>
282
-     * enum: ["circle", "poly", "rect"]
283
-     * @var string
284
-     */
285
-    public $geofence_polygon_type;
286
-
287
-    /**
288
-     * Geofence polygon size.
289
-     * @var integer
290
-     */
291
-    public $geofence_polygon_size;
292
-
293
-    /**
294
-     * Route notes
295
-     * @var AddressNote[]
296
-     */
297
-    public $notes=[];
298
-
299
-    /**
300
-     * A vehicle assigned to the route.
301
-     * @var Vehicles\VehicleResponseV4
302
-     */
303
-    public $vehicle=[];
304
-
305
-    /**
306
-     * Member config key-value pairs.
307
-     * @var array
308
-     */
309
-    public $member_config_storage;
310
-
311
-    /**
312
-     * Original route
313
-     * @var Route
314
-     */
315
-    public $original_route;
316
-
317
-    /**
318
-     * If true, the route will be unlinked from the master optimization.
319
-     * @var Boolean
320
-     */
321
-    public $unlink_from_master_optimization;
322
-
323
-    public function __construct()
324
-    {
325
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
326
-    }
327
-
328
-    public static function fromArray(array $params)
329
-    {
330
-        $route = new self();
331
-        $route->route_id = Common::getValue($params, 'route_id');
332
-        $route->member_id = Common::getValue($params, 'member_id');
333
-        $route->member_email = Common::getValue($params, 'member_email');
334
-        $route->member_picture = Common::getValue($params, 'member_picture');
335
-        $route->member_tracking_subheadline = Common::getValue($params, 'member_tracking_subheadline');
336
-        $route->approved_for_execution = Common::getValue($params, 'approved_for_execution');
337
-        $route->approved_revisions_counter = Common::getValue($params, 'approved_revisions_counter');
338
-        $route->member_first_name = Common::getValue($params, 'member_first_name');
339
-        $route->member_last_name = Common::getValue($params, 'member_last_name');
340
-        $route->channel_name = Common::getValue($params, 'channel_name');
341
-        $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
342
-        $route->user_route_rating = Common::getValue($params, 'user_route_rating');
343
-        $route->vehicle_alias = Common::getValue($params, 'vehicle_alias');
344
-        $route->driver_alias = Common::getValue($params, 'driver_alias');
345
-        $route->trip_distance = Common::getValue($params, 'trip_distance');
346
-        $route->udu_distance_unit = Common::getValue($params, 'udu_distance_unit');
347
-        $route->udu_trip_distance = Common::getValue($params, 'udu_trip_distance');
348
-        $route->mpg = Common::getValue($params, 'mpg');
349
-        $route->gas_price = Common::getValue($params, 'gas_price');
350
-        $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec');
351
-        $route->planned_total_route_duration = Common::getvalue($params, 'planned_total_route_duration');
352
-        $route->total_wait_time = Common::getvalue($params, 'total_wait_time');
353
-        $route->udu_actual_travel_distance = Common::getvalue($params, 'udu_actual_travel_distance');
354
-        $route->actual_travel_distance = Common::getvalue($params, 'actual_travel_distance');
355
-        $route->actual_travel_time = Common::getvalue($params, 'actual_travel_time');
356
-        $route->actual_footsteps = Common::getvalue($params, 'actual_footsteps');
357
-        $route->working_time = Common::getvalue($params, 'working_time');
358
-        $route->driving_time = Common::getvalue($params, 'driving_time');
359
-        $route->idling_time = Common::getvalue($params, 'idling_time');
360
-        $route->paying_miles = Common::getvalue($params, 'paying_miles');
361
-        $route->geofence_polygon_type = Common::getvalue($params, 'geofence_polygon_type');
362
-        $route->geofence_polygon_size = Common::getvalue($params, 'geofence_polygon_size');
363
-        $route->destination_count = Common::getvalue($params, 'destination_count');
364
-        $route->notes_count = Common::getvalue($params, 'notes_count');
365
-        $route->is_unrouted = Common::getvalue($params, 'is_unrouted');
366
-        $route->route_cost = Common::getvalue($params, 'route_cost');
367
-        $route->route_revenue = Common::getvalue($params, 'route_revenue');
368
-        $route->net_revenue_per_distance_unit = Common::getvalue($params, 'net_revenue_per_distance_unit');
369
-        $route->created_timestamp = Common::getvalue($params, 'created_timestamp');
370
-
371
-        if (isset($params['vehicle'])) {
372
-            $route->vehicle = new Vehicle();
373
-            $route->vehicle = Vehicle::fromArray($params['vehicle']);
374
-            Route4Me::setBaseUrl(Endpoint::BASE_URL);
375
-        };
376
-
377
-        $route->member_config_storage = Common::getvalue($params, 'member_config_storage');
378
-
379
-        // Make RouteParameters
380
-        if (isset($params['parameters'])) {
381
-            $route->parameters = new RouteParameters();
382
-            $route->parameters = RouteParameters::fromArray($params['parameters']);
383
-            Route4Me::setBaseUrl(Endpoint::BASE_URL);
384
-        }
385
-
386
-        if (isset($params['addresses'])) {
387
-            $addresses = [];
388
-
389
-            foreach ($params['addresses'] as $address) {
390
-                $addresses[] = Address::fromArray($address);
391
-            }
392
-
393
-            $route->addresses = $addresses;
394
-        }
395
-
396
-        $route->links = Common::getValue($params, 'links', []);
397
-        $route->notes = Common::getValue($params, 'notes', []);
398
-        $route->directions = Common::getValue($params, 'directions', []);
399
-        $route->path = Common::getValue($params, 'path', []);
400
-        $route->tracking_history = Common::getValue($params, 'tracking_history', []);
401
-
402
-        if (isset($params['original_route'])) {
403
-            $route->original_route = Route::fromArray($params['original_route']);
404
-        };
405
-
406
-        return $route;
407
-    }
408
-
409
-    /**
410
-     * @param RouteParametersQuery $params
411
-     * @return An array of the routes
412
-     * @throws Exception\ApiError
413
-     */
414
-    public static function getRoutes($params = null)
415
-    {
416
-        $allQueryFields = ['route_id', 'original', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset','start_date','end_date'];
417
-
418
-        $result = Route4Me::makeRequst([
419
-            'url'       => Endpoint::ROUTE_V4,
420
-            'method'    => 'GET',
421
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
422
-        ]);
423
-
424
-        if (isset($params['route_id'])) {
425
-            if (strlen($params['route_id'])==32) {
426
-                return self::fromArray($result);
427
-            } else {
428
-                return $result;
429
-            }
430
-        } else {
431
-            $routes = [];
432
-            foreach ($result as $route) {
433
-                $routes[] = self::fromArray($route);
434
-            }
435
-
436
-            return $routes;
437
-        }
438
-    }
439
-
440
-    public function getRoutePoints($params)
441
-    {
442
-        $allQueryFields = ['route_id', 'route_path_output', 'compress_path_points', 'directions'];
443
-
444
-        $result = Route4Me::makeRequst([
445
-            'url'    => Endpoint::ROUTE_V4,
446
-            'method' => 'GET',
447
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
448
-        ]);
449
-
450
-        return $result;
451
-    }
452
-
453
-    public function duplicateRoute($routeIDs)
454
-    {
455
-        $result = Route4Me::makeRequst([
456
-            'url'    => Endpoint::ROUTE_V4,
457
-            'method' => 'POST',
458
-            'body'   => [
459
-                'duplicate_routes_id' => $routeIDs
460
-            ],
461
-        ]);
462
-
463
-        return $result;
464
-    }
465
-
466
-    public function resequenceRoute($params)
467
-    {
468
-        $allQueryFields = ['route_id', 'route_destination_id'];
469
-        $allBodyFields = ['addresses'];
470
-
471
-        $result = Route4Me::makeRequst([
472
-            'url'       => Endpoint::ROUTE_V4,
473
-            'method'    => 'PUT',
474
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
475
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
476
-        ]);
477
-
478
-        return $result;
479
-    }
480
-
481
-    /**
482
-     * @deprecated 'The method is obsolete, use the method ReoptimizeRoute instead.'
483
-     * @param $params
484
-     * @return mixed|string
485
-     */
486
-    public function resequenceAllAddresses($params)
487
-    {
488
-        $allQueryFields = ['route_id', 'disable_optimization', 'optimize'];
489
-
490
-        $result = Route4Me::makeRequst([
491
-            'url'       => Endpoint::REOPTIMIZE_V3_2,
492
-            'method'    => 'GET',
493
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
494
-        ]);
495
-
496
-        return $result;
497
-    }
498
-
499
-    /**
500
-     * Reoptimize a route
501
-     * @param $params type Route
502
-     * @return mixed|string
503
-     * @throws Exception\ApiError
504
-     */
505
-    public function reoptimizeRoute($params)
506
-    {
507
-        $allQueryFields = ['route_id', 'reoptimize', 'remaining', 'device_type'];
508
-
509
-        $result = Route4Me::makeRequst([
510
-            'url'       => Endpoint::ROUTE_V4,
511
-            'method'    => 'PUT',
512
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
513
-        ]);
514
-
515
-        return $result;
516
-    }
517
-
518
-    /**
519
-     * Merges the routes
520
-     * @param $params array contains:
521
-     * @param route_ids IDs of the routes to be merged.
522
-     * @param depot_address a depot address of the merged route.
523
-     * @param remove_origin if true, the origin routes will be removed.
524
-     * @param depot_lat the depot's latitude
525
-     * @param depot_lng the depot's longitude
526
-     * @return Status response
527
-     * @throws Exception\ApiError
528
-     */
529
-    public function mergeRoutes($params)
530
-    {
531
-        $allBodyFields = ['route_ids', 'depot_address', 'remove_origin', 'depot_lat',  'depot_lng'];
532
-
533
-        $result = Route4Me::makeRequst([
534
-            'url'           => Endpoint::ROUTES_MERGE,
535
-            'method'        => 'POST',
536
-            'body'          => Route4Me::generateRequestParameters($allBodyFields, $params),
537
-            'HTTPHEADER'    => 'Content-Type: multipart/form-data',
538
-        ]);
539
-
540
-        return $result;
541
-    }
542
-
543
-    /**
544
-     * Share a route by an email
545
-     * @param $params RouteParametersQuery contains:
546
-     * @param route_id a route ID to be shared.
547
-     * @param response_format the response format.
548
-     * @param recipient_email Recipient email.
549
-     * @return Status response
550
-     * @throws Exception\ApiError
551
-     */
552
-    public function shareRoute($params)
553
-    {
554
-        $allQueryFields = ['route_id', 'response_format'];
555
-        $allBodyFields = ['recipient_email'];
556
-
557
-        $result = Route4Me::makeRequst([
558
-            'url'           => Endpoint::ROUTE_SHARE,
559
-            'method'        => 'POST',
560
-            'query'         => Route4Me::generateRequestParameters($allQueryFields, $params),
561
-            'body'          => Route4Me::generateRequestParameters($allBodyFields, $params),
562
-            'HTTPHEADER'    => 'Content-Type: multipart/form-data',
563
-        ]);
564
-
565
-        return $result;
566
-    }
567
-
568
-    /**
569
-     * Returns random route_id from existing routes between $offset and $offset+$limit
570
-     * @param $offset integer The page number for route listing pagination.
571
-     * @param $limit integer The maximum number of the returned routes.
572
-     * @return string random route ID
573
-     * @throws Exception\ApiError
574
-     */
575
-    public function getRandomRouteId($offset, $limit)
576
-    {
577
-        $params = [
578
-            'offset'    => !is_null($offset) ? $offset : 0,
579
-            'limit'     => !is_null($limit) ? $limit : 30,
580
-        ];
581
-
582
-        $route = new self();
583
-        $routes = $route->getRoutes($params);
584
-
585
-        if (is_null($routes) || sizeof($routes) < 1) {
586
-            echo '<br> There are no routes in the account. Please, create the routes first. <br>';
587
-
588
-            return null;
589
-        }
590
-
591
-        $randomIndex = rand(0, sizeof($routes) - 1);
592
-
593
-        return $routes[$randomIndex]->route_id;
594
-    }
595
-
596
-    /**
597
-     * Update a route
598
-     * @param $params array contains:
599
-     * @param route_id string : route ID
600
-     * @param reoptimize int : if equal to 1 the route re-optimized.
601
-     * @param route_destination_id int : route destination ID
602
-     * @param addresses Address[] : an array of a route addresses.
603
-     * @param parameters RouteParameters : route parameters.
604
-     * @param unlink_from_master_optimization  Boolean : if true, the route will be unlinked from optimization.
605
-     * @return Route updated route
606
-     * @throws Exception\ApiError
607
-     */
608
-    public function updateRoute($params)
609
-    {
610
-        $allQueryFields = ['route_id', 'reoptimize','route_destination_id'];
611
-        $allBodyFields = ['addresses', 'parameters', 'unlink_from_master_optimization'];
612
-
613
-        $result = Route4Me::makeRequst([
614
-            'url'       => Endpoint::ROUTE_V4,
615
-            'method'    => 'PUT',
616
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
617
-            'body'      => (isset($params['addresses']) || isset($params['parameters']) || isset($params['unlink_from_master_optimization']))
618
-                            ? Route4Me::generateRequestParameters($allBodyFields, $params)
619
-                            : null,
620
-        ]);
621
-
622
-        return $result;
623
-    }
624
-
625
-    public function update()
626
-    {
627
-        $route = Route4Me::makeRequst([
628
-            'url'    => Endpoint::ROUTE_V4,
629
-            'method' => 'PUT',
630
-            'query'  => [
631
-                'route_id' => isset($this->route_id) ? $this->route_id : null,
632
-            ],
633
-            'body'   => [
634
-                'parameters' => $this->parameters,
635
-                ],
636
-            'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null,
637
-        ]);
638
-
639
-        return self::fromArray($route);
640
-    }
641
-
642
-    public function updateAddress($address = null)
643
-    {
644
-        $body = sizeof($this->addresses) < 1 ? get_object_vars($this->parameters)
645
-            : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters));
646
-
647
-        $result = Route4Me::makeRequst([
648
-            'url'    => Endpoint::ADDRESS_V4,
649
-            'method' => 'PUT',
650
-            'query'  => [
651
-                'route_id' => isset($this->route_id) ? $this->route_id : null,
652
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
653
-            ],
654
-            'body'   => $body,
655
-            'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null,
656
-        ]);
657
-
658
-        return $result;
659
-    }
660
-
661
-    public function updateRouteAddress()
662
-    {
663
-        $result = Route4Me::makeRequst([
664
-            'url'    => Endpoint::ADDRESS_V4,
665
-            'method' => 'PUT',
666
-            'query'  => [
667
-                'route_id' => isset($this->route_id) ? $this->route_id : null,
668
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
669
-            ],
670
-            'body'   => [
671
-                'parameters' => isset($this->parameters) ? get_object_vars($this->parameters) : null,
672
-                'addresses' => isset($this->addresses) ? $this->addresses : null,
673
-            ],
674
-            'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null,
675
-        ]);
676
-
677
-        return $result;
678
-    }
679
-
680
-    public function addAddresses($params)
681
-    {
682
-        $allQueryFields = ['route_id'];
683
-        $allBodyFields = ['addresses'];
684
-
685
-        $route = Route4Me::makeRequst([
686
-            'url'           => Endpoint::ROUTE_V4,
687
-            'method'        => 'PUT',
688
-            'query'         => Route4Me::generateRequestParameters($allQueryFields, $params),
689
-            'body'          => Route4Me::generateRequestParameters($allBodyFields, $params),
690
-            'HTTPHEADER'    => isset($this->httpheaders) ? $this->httpheaders : null,
691
-        ]);
692
-
693
-        return self::fromArray($route);
694
-    }
695
-
696
-    public function insertAddressOptimalPosition(array $params)
697
-    {
698
-        $allQueryFields = ['route_id'];
699
-        $allBodyFields = ['addresses', 'optimal_position'];
700
-
701
-        $route = Route4Me::makeRequst([
702
-            'url'    => Endpoint::ROUTE_V4,
703
-            'method' => 'PUT',
704
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
705
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
706
-        ]);
707
-
708
-        return self::fromArray($route);
709
-    }
710
-
711
-    public function addNoteFile($params)
712
-    {
713
-        $fname = isset($params['strFilename']) ? $params['strFilename'] : null;
714
-        $rpath = realpath($fname);
715
-
716
-        $allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'];
717
-        $allBodyFields = ['strUpdateType', 'strFilename', 'strNoteContents'];
718
-
719
-        $result = Route4Me::makeRequst([
720
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
721
-            'method' => 'POST',
722
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
723
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
724
-            'FILE'   => $rpath,
725
-            'HTTPHEADER' => [
726
-                'Content-Type: application/x-www-form-urlencoded',
727
-            ],
728
-        ]);
729
-
730
-        return $result;
731
-    }
732
-
733
-    public function deleteRoutes($route_id)
734
-    {
735
-        $result = Route4Me::makeRequst([
736
-            'url'    => Endpoint::ROUTE_V4,
737
-            'method' => 'DELETE',
738
-            'query'  => [
739
-                'route_id' => $route_id,
740
-            ],
741
-        ]);
742
-
743
-        return $result;
744
-    }
745
-
746
-    public function GetAddressesFromRoute($route_id)
747
-    {
748
-        $route1 = self::getRoutes(['route_id' => $route_id]);
749
-
750
-        if (isset($route1)) {
751
-            return $route1->addresses;
752
-        } else {
753
-            return null;
754
-        }
755
-    }
756
-
757
-    public function GetRandomAddressFromRoute($route_id)
758
-    {
759
-        $route1 = self::getRoutes(['route_id' => $route_id]);
760
-
761
-        if (isset($route1)) {
762
-            $addresses = $route1->addresses;
763
-
764
-            $rnd = rand(0, sizeof($addresses) - 1);
765
-
766
-            return $addresses[$rnd];
767
-        } else {
768
-            return null;
769
-        }
770
-    }
771
-
772
-    public function getRouteId()
773
-    {
774
-        return $this->route_id;
775
-    }
776
-
777
-    public function getOptimizationId()
778
-    {
779
-        return $this->optimization_problem_id;
780
-    }
781
-
782
-    public function GetLastLocation(array $params)
783
-    {
784
-        $allQueryFields = ['route_id', 'device_tracking_history'];
785
-
786
-        $route = Route4Me::makeRequst([
787
-            'url'    => Endpoint::ROUTE_V4,
788
-            'method' => 'GET',
789
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
790
-        ]);
791
-
792
-        return self::fromArray($route);
793
-    }
794
-
795
-    public function GetTrackingHistoryFromTimeRange(array $params)
796
-    {
797
-        $allQueryFields = ['route_id', 'format', 'time_period', 'start_date', 'end_date'];
798
-
799
-        $route = Route4Me::makeRequst([
800
-            'url'    => Endpoint::GET_DEVICE_LOCATION,
801
-            'method' => 'GET',
802
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
803
-        ]);
804
-
805
-        return $route;
806
-    }
807
-
808
-    public function GetAssetTracking(array $params)
809
-    {
810
-        $allQueryFields = ['tracking'];
811
-
812
-        $assetResponse = Route4Me::makeRequst([
813
-            'url'    => Endpoint::STATUS_V4,
814
-            'method' => 'GET',
815
-            'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
816
-        ]);
817
-
818
-        return $assetResponse;
819
-    }
15
+	/**
16
+	 * The route ID
17
+	 * @var string
18
+	 */
19
+	public $route_id;
20
+
21
+	/**
22
+	 * Member ID of a route owner
23
+	 * @var integer
24
+	 */
25
+	public $member_id;
26
+
27
+	/**
28
+	 * Optimization problem ID
29
+	 * @var string
30
+	 */
31
+	public $optimization_problem_id;
32
+
33
+	/**
34
+	 * Vehicle alias
35
+	 * @var string
36
+	 */
37
+	public $vehicle_alias;
38
+
39
+	/**
40
+	 * Driver alias
41
+	 * @var string
42
+	 */
43
+	public $driver_alias;
44
+
45
+	/**
46
+	 * Total route's trip distance
47
+	 * @var double
48
+	 */
49
+	public $trip_distance;
50
+
51
+	/**
52
+	 * The UDU distance measurement unit for the route.<br>
53
+	 * @note km or mi, the route4me api will convert all distance measurements into these units.
54
+	 * @var string
55
+	 */
56
+	public $udu_distance_unit;
57
+
58
+	/**
59
+	 * Total route's UDU trip distance
60
+	 * @var double
61
+	 */
62
+	public $udu_trip_distance;
63
+
64
+	/** Miles per gallon
65
+	 * @var double
66
+	 */
67
+	public $mpg;
68
+
69
+	/**
70
+	 * Gas price
71
+	 * @var double
72
+	 */
73
+	public $gas_price;
74
+
75
+	/**
76
+	 * Total route duration (seconds)
77
+	 * @var integer
78
+	 */
79
+	public $route_duration_sec;
80
+
81
+	/**
82
+	 * Number of the destinations in the route.
83
+	 * @var integer
84
+	 */
85
+	public $destination_count;
86
+
87
+	/**
88
+	 * Notes count in the route.
89
+	 * @var integer
90
+	 */
91
+	public $notes_count;
92
+
93
+	/**
94
+	 * Route parameters
95
+	 * @var RouteParameters
96
+	 */
97
+	public $parameters;
98
+
99
+	/**
100
+	 * An array of the route addresses
101
+	 * @var Address[]
102
+	 */
103
+	public $addresses = [];
104
+
105
+	/**
106
+	 * An array of the links
107
+	 * @var string[]
108
+	 */
109
+	public $links = [];
110
+
111
+	/**
112
+	 * Edge by edge turn-by-turn directions.
113
+	 * @var Direction[]
114
+	 */
115
+	public $directions = [];
116
+
117
+	/**
118
+	 * Edge-wise path to be drawn on the map.
119
+	 * @var GeoPoint[]
120
+	 */
121
+	public $path = [];
122
+
123
+	/**
124
+	 * A collection of device tracking data with coordinates, speed, and timestamps.
125
+	 * @var Tracking\TrackingHistory[]
126
+	 */
127
+	public $tracking_history = [];
128
+
129
+	/**
130
+	 * HTTP headers
131
+	 * @var string
132
+	 */
133
+	public $httpheaders;
134
+
135
+	/**
136
+	 * If true, the route is unrouted.
137
+	 * @var Boolean
138
+	 */
139
+	public $is_unrouted;
140
+
141
+	/**
142
+	 * User route rating [0, 5]. A null value means no rating was given.<br>
143
+	 * Users can rate routes so that future optimizations take these ratings into account.
144
+	 * @var integer
145
+	 */
146
+	public $user_route_rating;
147
+
148
+	/**
149
+	 * The member's email
150
+	 * @var string
151
+	 */
152
+	public $member_email;
153
+
154
+	/**
155
+	 * URL to a member picture
156
+	 * @var string
157
+	 */
158
+	public $member_picture;
159
+
160
+	/**
161
+	 * Member tracking subheadline.
162
+	 * @var string
163
+	 */
164
+	public $member_tracking_subheadline;
165
+
166
+	/**
167
+	 * If true, the order is approved for execution.
168
+	 * @var Boolean
169
+	 */
170
+	public $approved_for_execution;
171
+
172
+	/**
173
+	 * Counter of the approved revisions.
174
+	 * @var integer
175
+	 */
176
+	public $approved_revisions_counter;
177
+
178
+	/**
179
+	 * The member's first name.
180
+	 * @var string
181
+	 */
182
+	public $member_first_name;
183
+
184
+	/**
185
+	 * The member's last name.
186
+	 * @var string
187
+	 */
188
+	public $member_last_name;
189
+
190
+	/**
191
+	 * Channel name
192
+	 * @var string
193
+	 */
194
+	public $channel_name;
195
+
196
+	/**
197
+	 * Total cost of the route.
198
+	 * @var double
199
+	 */
200
+	public $route_cost;
201
+
202
+	/**
203
+	 * Total route revenue
204
+	 * @var double
205
+	 */
206
+	public $route_revenue;
207
+
208
+	/**
209
+	 * Net revenue per distance unit.
210
+	 * @var double
211
+	 */
212
+	public $net_revenue_per_distance_unit;
213
+
214
+	/**
215
+	 * When route created (UNIX format timestamp).
216
+	 * @var integer
217
+	 */
218
+	public $created_timestamp;
219
+
220
+	/**
221
+	 * Planned total route duration (seconds).
222
+	 * @var integer
223
+	 */
224
+	public $planned_total_route_duration;
225
+
226
+	/**
227
+	 * Total wait time (seconds).
228
+	 * @var integer
229
+	 */
230
+	public $total_wait_time;
231
+
232
+	/**
233
+	 * UDU Actual travel distance.
234
+	 * @var double
235
+	 */
236
+	public $udu_actual_travel_distance;
237
+
238
+	/**
239
+	 * Actual travel distance.
240
+	 * @var double
241
+	 */
242
+	public $actual_travel_distance;
243
+
244
+	/**
245
+	 * Actual travel time (seconds).
246
+	 * @var integer
247
+	 */
248
+	public $actual_travel_time;
249
+
250
+	/**
251
+	 * Actual footsteps.
252
+	 * @var integer
253
+	 */
254
+	public $actual_footsteps;
255
+
256
+	/**
257
+	 * Working time.
258
+	 * @var integer
259
+	 */
260
+	public $working_time;
261
+
262
+	/**
263
+	 * Driving time.
264
+	 * @var integer
265
+	 */
266
+	public $driving_time;
267
+
268
+	/**
269
+	 * Idling time.
270
+	 * @var integer
271
+	 */
272
+	public $idling_time;
273
+
274
+	/**
275
+	 * Paying miles
276
+	 * @var double
277
+	 */
278
+	public $paying_miles;
279
+
280
+	/**
281
+	 * Geofence polygon type.<br>
282
+	 * enum: ["circle", "poly", "rect"]
283
+	 * @var string
284
+	 */
285
+	public $geofence_polygon_type;
286
+
287
+	/**
288
+	 * Geofence polygon size.
289
+	 * @var integer
290
+	 */
291
+	public $geofence_polygon_size;
292
+
293
+	/**
294
+	 * Route notes
295
+	 * @var AddressNote[]
296
+	 */
297
+	public $notes=[];
298
+
299
+	/**
300
+	 * A vehicle assigned to the route.
301
+	 * @var Vehicles\VehicleResponseV4
302
+	 */
303
+	public $vehicle=[];
304
+
305
+	/**
306
+	 * Member config key-value pairs.
307
+	 * @var array
308
+	 */
309
+	public $member_config_storage;
310
+
311
+	/**
312
+	 * Original route
313
+	 * @var Route
314
+	 */
315
+	public $original_route;
316
+
317
+	/**
318
+	 * If true, the route will be unlinked from the master optimization.
319
+	 * @var Boolean
320
+	 */
321
+	public $unlink_from_master_optimization;
322
+
323
+	public function __construct()
324
+	{
325
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
326
+	}
327
+
328
+	public static function fromArray(array $params)
329
+	{
330
+		$route = new self();
331
+		$route->route_id = Common::getValue($params, 'route_id');
332
+		$route->member_id = Common::getValue($params, 'member_id');
333
+		$route->member_email = Common::getValue($params, 'member_email');
334
+		$route->member_picture = Common::getValue($params, 'member_picture');
335
+		$route->member_tracking_subheadline = Common::getValue($params, 'member_tracking_subheadline');
336
+		$route->approved_for_execution = Common::getValue($params, 'approved_for_execution');
337
+		$route->approved_revisions_counter = Common::getValue($params, 'approved_revisions_counter');
338
+		$route->member_first_name = Common::getValue($params, 'member_first_name');
339
+		$route->member_last_name = Common::getValue($params, 'member_last_name');
340
+		$route->channel_name = Common::getValue($params, 'channel_name');
341
+		$route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
342
+		$route->user_route_rating = Common::getValue($params, 'user_route_rating');
343
+		$route->vehicle_alias = Common::getValue($params, 'vehicle_alias');
344
+		$route->driver_alias = Common::getValue($params, 'driver_alias');
345
+		$route->trip_distance = Common::getValue($params, 'trip_distance');
346
+		$route->udu_distance_unit = Common::getValue($params, 'udu_distance_unit');
347
+		$route->udu_trip_distance = Common::getValue($params, 'udu_trip_distance');
348
+		$route->mpg = Common::getValue($params, 'mpg');
349
+		$route->gas_price = Common::getValue($params, 'gas_price');
350
+		$route->route_duration_sec = Common::getvalue($params, 'route_duration_sec');
351
+		$route->planned_total_route_duration = Common::getvalue($params, 'planned_total_route_duration');
352
+		$route->total_wait_time = Common::getvalue($params, 'total_wait_time');
353
+		$route->udu_actual_travel_distance = Common::getvalue($params, 'udu_actual_travel_distance');
354
+		$route->actual_travel_distance = Common::getvalue($params, 'actual_travel_distance');
355
+		$route->actual_travel_time = Common::getvalue($params, 'actual_travel_time');
356
+		$route->actual_footsteps = Common::getvalue($params, 'actual_footsteps');
357
+		$route->working_time = Common::getvalue($params, 'working_time');
358
+		$route->driving_time = Common::getvalue($params, 'driving_time');
359
+		$route->idling_time = Common::getvalue($params, 'idling_time');
360
+		$route->paying_miles = Common::getvalue($params, 'paying_miles');
361
+		$route->geofence_polygon_type = Common::getvalue($params, 'geofence_polygon_type');
362
+		$route->geofence_polygon_size = Common::getvalue($params, 'geofence_polygon_size');
363
+		$route->destination_count = Common::getvalue($params, 'destination_count');
364
+		$route->notes_count = Common::getvalue($params, 'notes_count');
365
+		$route->is_unrouted = Common::getvalue($params, 'is_unrouted');
366
+		$route->route_cost = Common::getvalue($params, 'route_cost');
367
+		$route->route_revenue = Common::getvalue($params, 'route_revenue');
368
+		$route->net_revenue_per_distance_unit = Common::getvalue($params, 'net_revenue_per_distance_unit');
369
+		$route->created_timestamp = Common::getvalue($params, 'created_timestamp');
370
+
371
+		if (isset($params['vehicle'])) {
372
+			$route->vehicle = new Vehicle();
373
+			$route->vehicle = Vehicle::fromArray($params['vehicle']);
374
+			Route4Me::setBaseUrl(Endpoint::BASE_URL);
375
+		};
376
+
377
+		$route->member_config_storage = Common::getvalue($params, 'member_config_storage');
378
+
379
+		// Make RouteParameters
380
+		if (isset($params['parameters'])) {
381
+			$route->parameters = new RouteParameters();
382
+			$route->parameters = RouteParameters::fromArray($params['parameters']);
383
+			Route4Me::setBaseUrl(Endpoint::BASE_URL);
384
+		}
385
+
386
+		if (isset($params['addresses'])) {
387
+			$addresses = [];
388
+
389
+			foreach ($params['addresses'] as $address) {
390
+				$addresses[] = Address::fromArray($address);
391
+			}
392
+
393
+			$route->addresses = $addresses;
394
+		}
395
+
396
+		$route->links = Common::getValue($params, 'links', []);
397
+		$route->notes = Common::getValue($params, 'notes', []);
398
+		$route->directions = Common::getValue($params, 'directions', []);
399
+		$route->path = Common::getValue($params, 'path', []);
400
+		$route->tracking_history = Common::getValue($params, 'tracking_history', []);
401
+
402
+		if (isset($params['original_route'])) {
403
+			$route->original_route = Route::fromArray($params['original_route']);
404
+		};
405
+
406
+		return $route;
407
+	}
408
+
409
+	/**
410
+	 * @param RouteParametersQuery $params
411
+	 * @return An array of the routes
412
+	 * @throws Exception\ApiError
413
+	 */
414
+	public static function getRoutes($params = null)
415
+	{
416
+		$allQueryFields = ['route_id', 'original', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset','start_date','end_date'];
417
+
418
+		$result = Route4Me::makeRequst([
419
+			'url'       => Endpoint::ROUTE_V4,
420
+			'method'    => 'GET',
421
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
422
+		]);
423
+
424
+		if (isset($params['route_id'])) {
425
+			if (strlen($params['route_id'])==32) {
426
+				return self::fromArray($result);
427
+			} else {
428
+				return $result;
429
+			}
430
+		} else {
431
+			$routes = [];
432
+			foreach ($result as $route) {
433
+				$routes[] = self::fromArray($route);
434
+			}
435
+
436
+			return $routes;
437
+		}
438
+	}
439
+
440
+	public function getRoutePoints($params)
441
+	{
442
+		$allQueryFields = ['route_id', 'route_path_output', 'compress_path_points', 'directions'];
443
+
444
+		$result = Route4Me::makeRequst([
445
+			'url'    => Endpoint::ROUTE_V4,
446
+			'method' => 'GET',
447
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
448
+		]);
449
+
450
+		return $result;
451
+	}
452
+
453
+	public function duplicateRoute($routeIDs)
454
+	{
455
+		$result = Route4Me::makeRequst([
456
+			'url'    => Endpoint::ROUTE_V4,
457
+			'method' => 'POST',
458
+			'body'   => [
459
+				'duplicate_routes_id' => $routeIDs
460
+			],
461
+		]);
462
+
463
+		return $result;
464
+	}
465
+
466
+	public function resequenceRoute($params)
467
+	{
468
+		$allQueryFields = ['route_id', 'route_destination_id'];
469
+		$allBodyFields = ['addresses'];
470
+
471
+		$result = Route4Me::makeRequst([
472
+			'url'       => Endpoint::ROUTE_V4,
473
+			'method'    => 'PUT',
474
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
475
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
476
+		]);
477
+
478
+		return $result;
479
+	}
480
+
481
+	/**
482
+	 * @deprecated 'The method is obsolete, use the method ReoptimizeRoute instead.'
483
+	 * @param $params
484
+	 * @return mixed|string
485
+	 */
486
+	public function resequenceAllAddresses($params)
487
+	{
488
+		$allQueryFields = ['route_id', 'disable_optimization', 'optimize'];
489
+
490
+		$result = Route4Me::makeRequst([
491
+			'url'       => Endpoint::REOPTIMIZE_V3_2,
492
+			'method'    => 'GET',
493
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
494
+		]);
495
+
496
+		return $result;
497
+	}
498
+
499
+	/**
500
+	 * Reoptimize a route
501
+	 * @param $params type Route
502
+	 * @return mixed|string
503
+	 * @throws Exception\ApiError
504
+	 */
505
+	public function reoptimizeRoute($params)
506
+	{
507
+		$allQueryFields = ['route_id', 'reoptimize', 'remaining', 'device_type'];
508
+
509
+		$result = Route4Me::makeRequst([
510
+			'url'       => Endpoint::ROUTE_V4,
511
+			'method'    => 'PUT',
512
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
513
+		]);
514
+
515
+		return $result;
516
+	}
517
+
518
+	/**
519
+	 * Merges the routes
520
+	 * @param $params array contains:
521
+	 * @param route_ids IDs of the routes to be merged.
522
+	 * @param depot_address a depot address of the merged route.
523
+	 * @param remove_origin if true, the origin routes will be removed.
524
+	 * @param depot_lat the depot's latitude
525
+	 * @param depot_lng the depot's longitude
526
+	 * @return Status response
527
+	 * @throws Exception\ApiError
528
+	 */
529
+	public function mergeRoutes($params)
530
+	{
531
+		$allBodyFields = ['route_ids', 'depot_address', 'remove_origin', 'depot_lat',  'depot_lng'];
532
+
533
+		$result = Route4Me::makeRequst([
534
+			'url'           => Endpoint::ROUTES_MERGE,
535
+			'method'        => 'POST',
536
+			'body'          => Route4Me::generateRequestParameters($allBodyFields, $params),
537
+			'HTTPHEADER'    => 'Content-Type: multipart/form-data',
538
+		]);
539
+
540
+		return $result;
541
+	}
542
+
543
+	/**
544
+	 * Share a route by an email
545
+	 * @param $params RouteParametersQuery contains:
546
+	 * @param route_id a route ID to be shared.
547
+	 * @param response_format the response format.
548
+	 * @param recipient_email Recipient email.
549
+	 * @return Status response
550
+	 * @throws Exception\ApiError
551
+	 */
552
+	public function shareRoute($params)
553
+	{
554
+		$allQueryFields = ['route_id', 'response_format'];
555
+		$allBodyFields = ['recipient_email'];
556
+
557
+		$result = Route4Me::makeRequst([
558
+			'url'           => Endpoint::ROUTE_SHARE,
559
+			'method'        => 'POST',
560
+			'query'         => Route4Me::generateRequestParameters($allQueryFields, $params),
561
+			'body'          => Route4Me::generateRequestParameters($allBodyFields, $params),
562
+			'HTTPHEADER'    => 'Content-Type: multipart/form-data',
563
+		]);
564
+
565
+		return $result;
566
+	}
567
+
568
+	/**
569
+	 * Returns random route_id from existing routes between $offset and $offset+$limit
570
+	 * @param $offset integer The page number for route listing pagination.
571
+	 * @param $limit integer The maximum number of the returned routes.
572
+	 * @return string random route ID
573
+	 * @throws Exception\ApiError
574
+	 */
575
+	public function getRandomRouteId($offset, $limit)
576
+	{
577
+		$params = [
578
+			'offset'    => !is_null($offset) ? $offset : 0,
579
+			'limit'     => !is_null($limit) ? $limit : 30,
580
+		];
581
+
582
+		$route = new self();
583
+		$routes = $route->getRoutes($params);
584
+
585
+		if (is_null($routes) || sizeof($routes) < 1) {
586
+			echo '<br> There are no routes in the account. Please, create the routes first. <br>';
587
+
588
+			return null;
589
+		}
590
+
591
+		$randomIndex = rand(0, sizeof($routes) - 1);
592
+
593
+		return $routes[$randomIndex]->route_id;
594
+	}
595
+
596
+	/**
597
+	 * Update a route
598
+	 * @param $params array contains:
599
+	 * @param route_id string : route ID
600
+	 * @param reoptimize int : if equal to 1 the route re-optimized.
601
+	 * @param route_destination_id int : route destination ID
602
+	 * @param addresses Address[] : an array of a route addresses.
603
+	 * @param parameters RouteParameters : route parameters.
604
+	 * @param unlink_from_master_optimization  Boolean : if true, the route will be unlinked from optimization.
605
+	 * @return Route updated route
606
+	 * @throws Exception\ApiError
607
+	 */
608
+	public function updateRoute($params)
609
+	{
610
+		$allQueryFields = ['route_id', 'reoptimize','route_destination_id'];
611
+		$allBodyFields = ['addresses', 'parameters', 'unlink_from_master_optimization'];
612
+
613
+		$result = Route4Me::makeRequst([
614
+			'url'       => Endpoint::ROUTE_V4,
615
+			'method'    => 'PUT',
616
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
617
+			'body'      => (isset($params['addresses']) || isset($params['parameters']) || isset($params['unlink_from_master_optimization']))
618
+							? Route4Me::generateRequestParameters($allBodyFields, $params)
619
+							: null,
620
+		]);
621
+
622
+		return $result;
623
+	}
624
+
625
+	public function update()
626
+	{
627
+		$route = Route4Me::makeRequst([
628
+			'url'    => Endpoint::ROUTE_V4,
629
+			'method' => 'PUT',
630
+			'query'  => [
631
+				'route_id' => isset($this->route_id) ? $this->route_id : null,
632
+			],
633
+			'body'   => [
634
+				'parameters' => $this->parameters,
635
+				],
636
+			'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null,
637
+		]);
638
+
639
+		return self::fromArray($route);
640
+	}
641
+
642
+	public function updateAddress($address = null)
643
+	{
644
+		$body = sizeof($this->addresses) < 1 ? get_object_vars($this->parameters)
645
+			: (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters));
646
+
647
+		$result = Route4Me::makeRequst([
648
+			'url'    => Endpoint::ADDRESS_V4,
649
+			'method' => 'PUT',
650
+			'query'  => [
651
+				'route_id' => isset($this->route_id) ? $this->route_id : null,
652
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
653
+			],
654
+			'body'   => $body,
655
+			'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null,
656
+		]);
657
+
658
+		return $result;
659
+	}
660
+
661
+	public function updateRouteAddress()
662
+	{
663
+		$result = Route4Me::makeRequst([
664
+			'url'    => Endpoint::ADDRESS_V4,
665
+			'method' => 'PUT',
666
+			'query'  => [
667
+				'route_id' => isset($this->route_id) ? $this->route_id : null,
668
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
669
+			],
670
+			'body'   => [
671
+				'parameters' => isset($this->parameters) ? get_object_vars($this->parameters) : null,
672
+				'addresses' => isset($this->addresses) ? $this->addresses : null,
673
+			],
674
+			'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null,
675
+		]);
676
+
677
+		return $result;
678
+	}
679
+
680
+	public function addAddresses($params)
681
+	{
682
+		$allQueryFields = ['route_id'];
683
+		$allBodyFields = ['addresses'];
684
+
685
+		$route = Route4Me::makeRequst([
686
+			'url'           => Endpoint::ROUTE_V4,
687
+			'method'        => 'PUT',
688
+			'query'         => Route4Me::generateRequestParameters($allQueryFields, $params),
689
+			'body'          => Route4Me::generateRequestParameters($allBodyFields, $params),
690
+			'HTTPHEADER'    => isset($this->httpheaders) ? $this->httpheaders : null,
691
+		]);
692
+
693
+		return self::fromArray($route);
694
+	}
695
+
696
+	public function insertAddressOptimalPosition(array $params)
697
+	{
698
+		$allQueryFields = ['route_id'];
699
+		$allBodyFields = ['addresses', 'optimal_position'];
700
+
701
+		$route = Route4Me::makeRequst([
702
+			'url'    => Endpoint::ROUTE_V4,
703
+			'method' => 'PUT',
704
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
705
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
706
+		]);
707
+
708
+		return self::fromArray($route);
709
+	}
710
+
711
+	public function addNoteFile($params)
712
+	{
713
+		$fname = isset($params['strFilename']) ? $params['strFilename'] : null;
714
+		$rpath = realpath($fname);
715
+
716
+		$allQueryFields = ['route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'];
717
+		$allBodyFields = ['strUpdateType', 'strFilename', 'strNoteContents'];
718
+
719
+		$result = Route4Me::makeRequst([
720
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
721
+			'method' => 'POST',
722
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
723
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
724
+			'FILE'   => $rpath,
725
+			'HTTPHEADER' => [
726
+				'Content-Type: application/x-www-form-urlencoded',
727
+			],
728
+		]);
729
+
730
+		return $result;
731
+	}
732
+
733
+	public function deleteRoutes($route_id)
734
+	{
735
+		$result = Route4Me::makeRequst([
736
+			'url'    => Endpoint::ROUTE_V4,
737
+			'method' => 'DELETE',
738
+			'query'  => [
739
+				'route_id' => $route_id,
740
+			],
741
+		]);
742
+
743
+		return $result;
744
+	}
745
+
746
+	public function GetAddressesFromRoute($route_id)
747
+	{
748
+		$route1 = self::getRoutes(['route_id' => $route_id]);
749
+
750
+		if (isset($route1)) {
751
+			return $route1->addresses;
752
+		} else {
753
+			return null;
754
+		}
755
+	}
756
+
757
+	public function GetRandomAddressFromRoute($route_id)
758
+	{
759
+		$route1 = self::getRoutes(['route_id' => $route_id]);
760
+
761
+		if (isset($route1)) {
762
+			$addresses = $route1->addresses;
763
+
764
+			$rnd = rand(0, sizeof($addresses) - 1);
765
+
766
+			return $addresses[$rnd];
767
+		} else {
768
+			return null;
769
+		}
770
+	}
771
+
772
+	public function getRouteId()
773
+	{
774
+		return $this->route_id;
775
+	}
776
+
777
+	public function getOptimizationId()
778
+	{
779
+		return $this->optimization_problem_id;
780
+	}
781
+
782
+	public function GetLastLocation(array $params)
783
+	{
784
+		$allQueryFields = ['route_id', 'device_tracking_history'];
785
+
786
+		$route = Route4Me::makeRequst([
787
+			'url'    => Endpoint::ROUTE_V4,
788
+			'method' => 'GET',
789
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
790
+		]);
791
+
792
+		return self::fromArray($route);
793
+	}
794
+
795
+	public function GetTrackingHistoryFromTimeRange(array $params)
796
+	{
797
+		$allQueryFields = ['route_id', 'format', 'time_period', 'start_date', 'end_date'];
798
+
799
+		$route = Route4Me::makeRequst([
800
+			'url'    => Endpoint::GET_DEVICE_LOCATION,
801
+			'method' => 'GET',
802
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
803
+		]);
804
+
805
+		return $route;
806
+	}
807
+
808
+	public function GetAssetTracking(array $params)
809
+	{
810
+		$allQueryFields = ['tracking'];
811
+
812
+		$assetResponse = Route4Me::makeRequst([
813
+			'url'    => Endpoint::STATUS_V4,
814
+			'method' => 'GET',
815
+			'query'  => Route4Me::generateRequestParameters($allQueryFields, $params),
816
+		]);
817
+
818
+		return $assetResponse;
819
+	}
820 820
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -294,13 +294,13 @@  discard block
 block discarded – undo
294 294
      * Route notes
295 295
      * @var AddressNote[]
296 296
      */
297
-    public $notes=[];
297
+    public $notes = [];
298 298
 
299 299
     /**
300 300
      * A vehicle assigned to the route.
301 301
      * @var Vehicles\VehicleResponseV4
302 302
      */
303
-    public $vehicle=[];
303
+    public $vehicle = [];
304 304
 
305 305
     /**
306 306
      * Member config key-value pairs.
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
      */
414 414
     public static function getRoutes($params = null)
415 415
     {
416
-        $allQueryFields = ['route_id', 'original', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset','start_date','end_date'];
416
+        $allQueryFields = ['route_id', 'original', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset', 'start_date', 'end_date'];
417 417
 
418 418
         $result = Route4Me::makeRequst([
419 419
             'url'       => Endpoint::ROUTE_V4,
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
      */
529 529
     public function mergeRoutes($params)
530 530
     {
531
-        $allBodyFields = ['route_ids', 'depot_address', 'remove_origin', 'depot_lat',  'depot_lng'];
531
+        $allBodyFields = ['route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'];
532 532
 
533 533
         $result = Route4Me::makeRequst([
534 534
             'url'           => Endpoint::ROUTES_MERGE,
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
         $route = new self();
583 583
         $routes = $route->getRoutes($params);
584 584
 
585
-        if (is_null($routes) || sizeof($routes) < 1) {
585
+        if (is_null($routes) || sizeof($routes)<1) {
586 586
             echo '<br> There are no routes in the account. Please, create the routes first. <br>';
587 587
 
588 588
             return null;
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
      */
608 608
     public function updateRoute($params)
609 609
     {
610
-        $allQueryFields = ['route_id', 'reoptimize','route_destination_id'];
610
+        $allQueryFields = ['route_id', 'reoptimize', 'route_destination_id'];
611 611
         $allBodyFields = ['addresses', 'parameters', 'unlink_from_master_optimization'];
612 612
 
613 613
         $result = Route4Me::makeRequst([
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 
642 642
     public function updateAddress($address = null)
643 643
     {
644
-        $body = sizeof($this->addresses) < 1 ? get_object_vars($this->parameters)
644
+        $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters)
645 645
             : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters));
646 646
 
647 647
         $result = Route4Me::makeRequst([
Please login to merge, or discard this patch.
src/Route4Me/Order.php 2 patches
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -6,329 +6,329 @@
 block discarded – undo
6 6
 
7 7
 class Order extends Common
8 8
 {
9
-    public $address_1;
10
-    public $address_2;
11
-    public $cached_lat;
12
-    public $cached_lng;
13
-    public $curbside_lat;
14
-    public $curbside_lng;
15
-    public $address_alias;
16
-    public $address_city;
17
-    public $EXT_FIELD_first_name;
18
-    public $EXT_FIELD_last_name;
19
-    public $EXT_FIELD_email;
20
-    public $EXT_FIELD_phone;
21
-    public $EXT_FIELD_custom_data;
22
-
23
-    public $color;
24
-    public $order_icon;
25
-    public $local_time_window_start;
26
-    public $local_time_window_end;
27
-    public $local_time_window_start_2;
28
-    public $local_time_window_end_2;
29
-    public $service_time;
30
-
31
-    public $day_scheduled_for_YYMMDD;
32
-
33
-    public $route_id;
34
-    public $redirect;
35
-    public $optimization_problem_id;
36
-    public $order_id;
37
-    public $order_ids;
38
-
39
-    public $day_added_YYMMDD;
40
-    public $scheduled_for_YYMMDD;
41
-    public $fields;
42
-    public $offset;
43
-    public $limit;
44
-    public $query;
45
-
46
-    public $created_timestamp;
47
-    public $order_status_id;
48
-    public $member_id;
49
-    public $address_state_id;
50
-    public $address_country_id;
51
-    public $address_zip;
52
-    public $in_route_count;
53
-    public $last_visited_timestamp;
54
-    public $last_routed_timestamp;
55
-    public $local_timezone_string;
56
-    public $is_validated;
57
-    public $is_pending;
58
-    public $is_accepted;
59
-    public $is_started;
60
-    public $is_completed;
61
-    public $custom_user_fields;
62
-
63
-    public $addresses = [];
64
-
65
-    public function __construct()
66
-    {
67
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
68
-    }
69
-
70
-    public static function fromArray(array $params)
71
-    {
72
-        $order = new self();
73
-        foreach ($params as $key => $value) {
74
-            if (property_exists($order, $key)) {
75
-                $order->{$key} = $value;
76
-            }
77
-        }
78
-
79
-        return $order;
80
-    }
81
-
82
-    /**
83
-     * @param Order $params
84
-     */
85
-    public static function addOrder($params)
86
-    {
87
-        $excludeFields = ['route_id', 'redirect', 'optimization_problem_id', 'order_id',
88
-        'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp', ];
89
-
90
-        $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields);
91
-
92
-        $response = Route4Me::makeRequst([
93
-            'url'       => Endpoint::ORDER_V4,
94
-            'method'    => 'POST',
95
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
96
-        ]);
97
-
98
-        return $response;
99
-    }
100
-
101
-    public static function addOrder2Route($params)
102
-    {
103
-        $allQueryFields = ['route_id', 'redirect'];
104
-        $allBodyFields = ['addresses'];
105
-
106
-        $response = Route4Me::makeRequst([
107
-            'url'       => Endpoint::ROUTE_V4,
108
-            'method'    => 'PUT',
109
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
110
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
111
-        ]);
112
-
113
-        return $response;
114
-    }
115
-
116
-    public static function addOrder2Optimization($params)
117
-    {
118
-        $allQueryFields = ['optimization_problem_id', 'redirect', 'device_type'];
119
-        $allBodyFields  = ['addresses'];
120
-
121
-        $response = Route4Me::makeRequst([
122
-            'url'       => Endpoint::OPTIMIZATION_PROBLEM,
123
-            'method'    => 'PUT',
124
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
125
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
126
-        ]);
127
-
128
-        return $response;
129
-    }
130
-
131
-    public static function getOrder($params)
132
-    {
133
-        $allQueryFields = ['order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'];
134
-
135
-        $response = Route4Me::makeRequst([
136
-            'url'       => Endpoint::ORDER_V4,
137
-            'method'    => 'GET',
138
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
139
-        ]);
140
-
141
-        return $response;
142
-    }
143
-
144
-    public static function getOrders($params)
145
-    {
146
-        $allQueryFields = ['offset', 'limit'];
147
-
148
-        $response = Route4Me::makeRequst([
149
-            'url'       => Endpoint::ORDER_V4,
150
-            'method'    => 'GET',
151
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
152
-        ]);
153
-
154
-        return $response;
155
-    }
156
-
157
-    public function getRandomOrderId($offset, $limit)
158
-    {
159
-        $randomOrder = $this->getRandomOrder($offset, $limit);
160
-
161
-        if (is_null($randomOrder) || !isset($randomOrder)) {
162
-            return null;
163
-        }
164
-
165
-        return $randomOrder['order_id'];
166
-    }
167
-
168
-    public function getRandomOrder($offset, $limit)
169
-    {
170
-        $params = ['offset' => $offset, 'limit' => $limit];
171
-
172
-        $orders = self::getOrders($params);
173
-
174
-        if (is_null($orders) || !isset($orders['results'])) {
175
-            return null;
176
-        }
177
-
178
-        $randomIndex = rand(0, sizeof($orders['results']) - 1);
179
-
180
-        $order = $orders['results'][$randomIndex];
181
-
182
-        return $order;
183
-    }
184
-
185
-    public static function removeOrder($params)
186
-    {
187
-        $allBodyFields = ['order_ids'];
188
-
189
-        $response = Route4Me::makeRequst([
190
-            'url'       => Endpoint::ORDER_V4,
191
-            'method'    => 'DELETE',
192
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
193
-        ]);
194
-
195
-        return $response;
196
-    }
197
-
198
-    public static function updateOrder($params)
199
-    {
200
-        $excludeFields = ['route_id', 'redirect', 'optimization_problem_id',
201
-        'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp', ];
202
-
203
-        $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields);
204
-
205
-        $response = Route4Me::makeRequst([
206
-            'url'       => Endpoint::ORDER_V4,
207
-            'method'    => 'PUT',
208
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
209
-        ]);
210
-
211
-        return $response;
212
-    }
213
-
214
-    public static function searchOrder($params)
215
-    {
216
-        $allQueryFields = ['fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'];
217
-
218
-        $response = Route4Me::makeRequst([
219
-            'url'       => Endpoint::ORDER_V4,
220
-            'method'    => 'GET',
221
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
222
-        ]);
223
-
224
-        return $response;
225
-    }
9
+	public $address_1;
10
+	public $address_2;
11
+	public $cached_lat;
12
+	public $cached_lng;
13
+	public $curbside_lat;
14
+	public $curbside_lng;
15
+	public $address_alias;
16
+	public $address_city;
17
+	public $EXT_FIELD_first_name;
18
+	public $EXT_FIELD_last_name;
19
+	public $EXT_FIELD_email;
20
+	public $EXT_FIELD_phone;
21
+	public $EXT_FIELD_custom_data;
22
+
23
+	public $color;
24
+	public $order_icon;
25
+	public $local_time_window_start;
26
+	public $local_time_window_end;
27
+	public $local_time_window_start_2;
28
+	public $local_time_window_end_2;
29
+	public $service_time;
30
+
31
+	public $day_scheduled_for_YYMMDD;
32
+
33
+	public $route_id;
34
+	public $redirect;
35
+	public $optimization_problem_id;
36
+	public $order_id;
37
+	public $order_ids;
38
+
39
+	public $day_added_YYMMDD;
40
+	public $scheduled_for_YYMMDD;
41
+	public $fields;
42
+	public $offset;
43
+	public $limit;
44
+	public $query;
45
+
46
+	public $created_timestamp;
47
+	public $order_status_id;
48
+	public $member_id;
49
+	public $address_state_id;
50
+	public $address_country_id;
51
+	public $address_zip;
52
+	public $in_route_count;
53
+	public $last_visited_timestamp;
54
+	public $last_routed_timestamp;
55
+	public $local_timezone_string;
56
+	public $is_validated;
57
+	public $is_pending;
58
+	public $is_accepted;
59
+	public $is_started;
60
+	public $is_completed;
61
+	public $custom_user_fields;
62
+
63
+	public $addresses = [];
64
+
65
+	public function __construct()
66
+	{
67
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
68
+	}
69
+
70
+	public static function fromArray(array $params)
71
+	{
72
+		$order = new self();
73
+		foreach ($params as $key => $value) {
74
+			if (property_exists($order, $key)) {
75
+				$order->{$key} = $value;
76
+			}
77
+		}
78
+
79
+		return $order;
80
+	}
81
+
82
+	/**
83
+	 * @param Order $params
84
+	 */
85
+	public static function addOrder($params)
86
+	{
87
+		$excludeFields = ['route_id', 'redirect', 'optimization_problem_id', 'order_id',
88
+		'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp', ];
89
+
90
+		$allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields);
91
+
92
+		$response = Route4Me::makeRequst([
93
+			'url'       => Endpoint::ORDER_V4,
94
+			'method'    => 'POST',
95
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
96
+		]);
97
+
98
+		return $response;
99
+	}
100
+
101
+	public static function addOrder2Route($params)
102
+	{
103
+		$allQueryFields = ['route_id', 'redirect'];
104
+		$allBodyFields = ['addresses'];
105
+
106
+		$response = Route4Me::makeRequst([
107
+			'url'       => Endpoint::ROUTE_V4,
108
+			'method'    => 'PUT',
109
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
110
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
111
+		]);
112
+
113
+		return $response;
114
+	}
115
+
116
+	public static function addOrder2Optimization($params)
117
+	{
118
+		$allQueryFields = ['optimization_problem_id', 'redirect', 'device_type'];
119
+		$allBodyFields  = ['addresses'];
120
+
121
+		$response = Route4Me::makeRequst([
122
+			'url'       => Endpoint::OPTIMIZATION_PROBLEM,
123
+			'method'    => 'PUT',
124
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
125
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
126
+		]);
127
+
128
+		return $response;
129
+	}
130
+
131
+	public static function getOrder($params)
132
+	{
133
+		$allQueryFields = ['order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'];
134
+
135
+		$response = Route4Me::makeRequst([
136
+			'url'       => Endpoint::ORDER_V4,
137
+			'method'    => 'GET',
138
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
139
+		]);
140
+
141
+		return $response;
142
+	}
143
+
144
+	public static function getOrders($params)
145
+	{
146
+		$allQueryFields = ['offset', 'limit'];
147
+
148
+		$response = Route4Me::makeRequst([
149
+			'url'       => Endpoint::ORDER_V4,
150
+			'method'    => 'GET',
151
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
152
+		]);
153
+
154
+		return $response;
155
+	}
156
+
157
+	public function getRandomOrderId($offset, $limit)
158
+	{
159
+		$randomOrder = $this->getRandomOrder($offset, $limit);
160
+
161
+		if (is_null($randomOrder) || !isset($randomOrder)) {
162
+			return null;
163
+		}
164
+
165
+		return $randomOrder['order_id'];
166
+	}
167
+
168
+	public function getRandomOrder($offset, $limit)
169
+	{
170
+		$params = ['offset' => $offset, 'limit' => $limit];
171
+
172
+		$orders = self::getOrders($params);
173
+
174
+		if (is_null($orders) || !isset($orders['results'])) {
175
+			return null;
176
+		}
177
+
178
+		$randomIndex = rand(0, sizeof($orders['results']) - 1);
179
+
180
+		$order = $orders['results'][$randomIndex];
181
+
182
+		return $order;
183
+	}
184
+
185
+	public static function removeOrder($params)
186
+	{
187
+		$allBodyFields = ['order_ids'];
188
+
189
+		$response = Route4Me::makeRequst([
190
+			'url'       => Endpoint::ORDER_V4,
191
+			'method'    => 'DELETE',
192
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
193
+		]);
194
+
195
+		return $response;
196
+	}
197
+
198
+	public static function updateOrder($params)
199
+	{
200
+		$excludeFields = ['route_id', 'redirect', 'optimization_problem_id',
201
+		'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp', ];
202
+
203
+		$allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields);
204
+
205
+		$response = Route4Me::makeRequst([
206
+			'url'       => Endpoint::ORDER_V4,
207
+			'method'    => 'PUT',
208
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
209
+		]);
210
+
211
+		return $response;
212
+	}
213
+
214
+	public static function searchOrder($params)
215
+	{
216
+		$allQueryFields = ['fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'];
217
+
218
+		$response = Route4Me::makeRequst([
219
+			'url'       => Endpoint::ORDER_V4,
220
+			'method'    => 'GET',
221
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
222
+		]);
223
+
224
+		return $response;
225
+	}
226 226
 
227
-    public static function validateCoordinate($coord)
228
-    {
229
-        $key = key($coord);
227
+	public static function validateCoordinate($coord)
228
+	{
229
+		$key = key($coord);
230 230
 
231
-        if (!is_numeric($coord[$key])) {
232
-            return false;
233
-        }
234
-
235
-        switch ($key) {
236
-        case 'cached_lat':
237
-        case 'curbside_lat':
238
-            if ($coord[$key] > 90 || $coord[$key] < -90) {
239
-                return false;
240
-            }
241
-            break;
242
-        case 'cached_lng':
243
-        case 'curbside_lng':
244
-            if ($coord[$key] > 180 || $coord[$key] < -180) {
245
-                return false;
246
-            }
247
-            break;
248
-        }
249
-
250
-        return true;
251
-    }
231
+		if (!is_numeric($coord[$key])) {
232
+			return false;
233
+		}
234
+
235
+		switch ($key) {
236
+		case 'cached_lat':
237
+		case 'curbside_lat':
238
+			if ($coord[$key] > 90 || $coord[$key] < -90) {
239
+				return false;
240
+			}
241
+			break;
242
+		case 'cached_lng':
243
+		case 'curbside_lng':
244
+			if ($coord[$key] > 180 || $coord[$key] < -180) {
245
+				return false;
246
+			}
247
+			break;
248
+		}
249
+
250
+		return true;
251
+	}
252 252
 
253
-    public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping)
254
-    {
255
-        $max_line_length = 512;
256
-        $delemietr = ',';
257
-
258
-        $results = [];
259
-        $results['fail'] = [];
260
-        $results['success'] = [];
261
-
262
-        $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
253
+	public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping)
254
+	{
255
+		$max_line_length = 512;
256
+		$delemietr = ',';
257
+
258
+		$results = [];
259
+		$results['fail'] = [];
260
+		$results['success'] = [];
261
+
262
+		$columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
263 263
 
264
-        $excludeFields = ['route_id', 'redirect', 'optimization_problem_id', 'order_id',
265
-        'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp', ];
266
-
267
-        $allOrderFields = Route4Me::getObjectProperties(new self(), $excludeFields);
268
-
269
-        if (!empty($columns)) {
270
-            array_push($results['fail'], 'Empty CSV table');
264
+		$excludeFields = ['route_id', 'redirect', 'optimization_problem_id', 'order_id',
265
+		'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp', ];
266
+
267
+		$allOrderFields = Route4Me::getObjectProperties(new self(), $excludeFields);
268
+
269
+		if (!empty($columns)) {
270
+			array_push($results['fail'], 'Empty CSV table');
271 271
 
272
-            return $results;
273
-        }
274
-
275
-        $iRow = 1;
276
-
277
-        while (false !== ($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))) {
278
-            if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && [null] !== $rows) {
279
-                $cached_lat = 0.000;
280
-                $cached_lng = 0.000;
281
-
282
-                foreach (['cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng'] as $coord) {
283
-                    if (!$this->validateCoordinate([$coord => $rows[$ordersFieldsMapping[$coord]]])) {
284
-                        array_push($results['fail'], "$iRow --> Wrong " + $coord);
285
-                        ++$iRow;
286
-                        continue;
287
-                    } else {
288
-                        switch ($coord) {
289
-                        case 'cached_lat':
290
-                            $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]);
291
-                            break;
292
-                        case 'cached_lng':
293
-                            $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]);
294
-                            break;
295
-                        }
296
-                    }
297
-                }
298
-
299
-                $address = $rows[$ordersFieldsMapping['address_1']];
300
-
301
-                foreach (['order_city', 'order_state_id', 'order_zip_code', 'order_country_id'] as $addressPart) {
302
-                    if (isset($ordersFieldsMapping[$addressPart])) {
303
-                        $address .= ', '.$rows[$ordersFieldsMapping[$addressPart]];
304
-                    }
305
-                }
306
-
307
-                echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].', '.$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']].'<br>';
308
-
309
-                $parametersArray = [];
310
-
311
-                $parametersArray['cached_lat'] = $cached_lat;
312
-                $parametersArray['cached_lng'] = $cached_lng;
313
-
314
-                foreach ($allOrderFields as $orderField) {
315
-                    if (isset($ordersFieldsMapping[$orderField])) {
316
-                        $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]];
317
-                    }
318
-                }
319
-
320
-                $orderParameters = self::fromArray($parametersArray);
321
-
322
-                $order = new self();
323
-
324
-                $orderResults = $order->addOrder($orderParameters);
325
-
326
-                array_push($results['success'], 'The order with order_id = '.strval($orderResults['order_id']).' added successfuly.');
327
-            } else {
328
-                array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set");
329
-            }
330
-
331
-            ++$iRow;
332
-        }
333
-    }
272
+			return $results;
273
+		}
274
+
275
+		$iRow = 1;
276
+
277
+		while (false !== ($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))) {
278
+			if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && [null] !== $rows) {
279
+				$cached_lat = 0.000;
280
+				$cached_lng = 0.000;
281
+
282
+				foreach (['cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng'] as $coord) {
283
+					if (!$this->validateCoordinate([$coord => $rows[$ordersFieldsMapping[$coord]]])) {
284
+						array_push($results['fail'], "$iRow --> Wrong " + $coord);
285
+						++$iRow;
286
+						continue;
287
+					} else {
288
+						switch ($coord) {
289
+						case 'cached_lat':
290
+							$cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]);
291
+							break;
292
+						case 'cached_lng':
293
+							$cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]);
294
+							break;
295
+						}
296
+					}
297
+				}
298
+
299
+				$address = $rows[$ordersFieldsMapping['address_1']];
300
+
301
+				foreach (['order_city', 'order_state_id', 'order_zip_code', 'order_country_id'] as $addressPart) {
302
+					if (isset($ordersFieldsMapping[$addressPart])) {
303
+						$address .= ', '.$rows[$ordersFieldsMapping[$addressPart]];
304
+					}
305
+				}
306
+
307
+				echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].', '.$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']].'<br>';
308
+
309
+				$parametersArray = [];
310
+
311
+				$parametersArray['cached_lat'] = $cached_lat;
312
+				$parametersArray['cached_lng'] = $cached_lng;
313
+
314
+				foreach ($allOrderFields as $orderField) {
315
+					if (isset($ordersFieldsMapping[$orderField])) {
316
+						$parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]];
317
+					}
318
+				}
319
+
320
+				$orderParameters = self::fromArray($parametersArray);
321
+
322
+				$order = new self();
323
+
324
+				$orderResults = $order->addOrder($orderParameters);
325
+
326
+				array_push($results['success'], 'The order with order_id = '.strval($orderResults['order_id']).' added successfuly.');
327
+			} else {
328
+				array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set");
329
+			}
330
+
331
+			++$iRow;
332
+		}
333
+	}
334 334
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
         switch ($key) {
236 236
         case 'cached_lat':
237 237
         case 'curbside_lat':
238
-            if ($coord[$key] > 90 || $coord[$key] < -90) {
238
+            if ($coord[$key]>90 || $coord[$key]<-90) {
239 239
                 return false;
240 240
             }
241 241
             break;
242 242
         case 'cached_lng':
243 243
         case 'curbside_lng':
244
-            if ($coord[$key] > 180 || $coord[$key] < -180) {
244
+            if ($coord[$key]>180 || $coord[$key]<-180) {
245 245
                 return false;
246 246
             }
247 247
             break;
@@ -274,14 +274,14 @@  discard block
 block discarded – undo
274 274
 
275 275
         $iRow = 1;
276 276
 
277
-        while (false !== ($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))) {
278
-            if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && [null] !== $rows) {
277
+        while (false!==($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))) {
278
+            if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && [null]!==$rows) {
279 279
                 $cached_lat = 0.000;
280 280
                 $cached_lng = 0.000;
281 281
 
282 282
                 foreach (['cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng'] as $coord) {
283 283
                     if (!$this->validateCoordinate([$coord => $rows[$ordersFieldsMapping[$coord]]])) {
284
-                        array_push($results['fail'], "$iRow --> Wrong " + $coord);
284
+                        array_push($results['fail'], "$iRow --> Wrong " +$coord);
285 285
                         ++$iRow;
286 286
                         continue;
287 287
                     } else {
Please login to merge, or discard this patch.
src/Route4Me/AvoidanceZone.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -7,116 +7,116 @@
 block discarded – undo
7 7
 
8 8
 class AvoidanceZone extends Common
9 9
 {
10
-    public $territory_id; // Avoidance zone id
11
-    public $territory_name;
12
-    public $territory_color;
13
-    public $orders;
14
-    public $member_id;
15
-    public $territory; // Territory parameters
16
-
17
-    public function __construct()
18
-    {
19
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
20
-    }
21
-
22
-    public static function fromArray(array $params)
23
-    {
24
-        if (!isset($params['territory_name'])) {
25
-            throw new BadParam('Territory name must be provided');
26
-        }
27
-
28
-        if (!isset($params['territory_color'])) {
29
-            throw new BadParam('Territory color must be provided');
30
-        }
31
-
32
-        if (!isset($params['territory'])) {
33
-            throw new BadParam('Territory must be provided');
34
-        }
35
-
36
-        $avoidanceZoneParameters = new self();
37
-
38
-        foreach ($params as $key => $value) {
39
-            if (property_exists($avoidanceZoneParameters, $key)) {
40
-                $avoidanceZoneParameters->{$key} = $value;
41
-            }
42
-        }
43
-
44
-        return $avoidanceZoneParameters;
45
-    }
46
-
47
-    public static function getAvoidanceZone($territory_id)
48
-    {
49
-        $avoidanceZone = Route4Me::makeRequst([
50
-            'url'       => Endpoint::AVOIDANCE_ZONE,
51
-            'method'    => 'GET',
52
-            'query'     => [
53
-                'territory_id' => $territory_id,
54
-            ],
55
-        ]);
56
-
57
-        return $avoidanceZone;
58
-    }
59
-
60
-    public static function getAvoidanceZones($params)
61
-    {
62
-        $avoidanceZones = Route4Me::makeRequst([
63
-            'url'       => Endpoint::AVOIDANCE_ZONE,
64
-            'method'    => 'GET',
65
-            'query'     => [
66
-                'offset' => isset($params->offset) ? $params->offset : null,
67
-                'limit'  => isset($params->limit) ? $params->limit : null,
68
-            ],
69
-        ]);
70
-
71
-        return $avoidanceZones;
72
-    }
73
-
74
-    public static function addAvoidanceZone($params)
75
-    {
76
-        $terParams = [];
77
-
78
-        if (isset($params->territory['type'])) {
79
-            $terParams['type'] = $params->territory['type'];
80
-        }
81
-
82
-        if (isset($params->territory['data'])) {
83
-            $terParams['data'] = $params->territory['data'];
84
-        }
85
-
86
-        $abContacts = Route4Me::makeRequst([
87
-            'url'       => Endpoint::AVOIDANCE_ZONE,
88
-            'method'    => 'POST',
89
-            'body'      => [
90
-                'territory_name'    => isset($params->territory_name) ? $params->territory_name : null,
91
-                'territory_color'   => isset($params->territory_color) ? $params->territory_color : null,
92
-                'territory'         => $terParams,
93
-            ],
94
-        ]);
95
-
96
-        return $abContacts;
97
-    }
98
-
99
-    public function deleteAvoidanceZone($territory_id)
100
-    {
101
-        $result = Route4Me::makeRequst([
102
-            'url'       => Endpoint::AVOIDANCE_ZONE,
103
-            'method'    => 'DELETEARRAY',
104
-            'query'     => [
105
-                'territory_id' => $territory_id,
106
-            ],
107
-        ]);
108
-
109
-        return $result;
110
-    }
111
-
112
-    public function updateAvoidanceZone($params)
113
-    {
114
-        $avoidanceZone = Route4Me::makeRequst([
115
-            'url'       => Endpoint::AVOIDANCE_ZONE,
116
-            'method'    => 'PUT',
117
-            'body'      => $params,
118
-        ]);
119
-
120
-        return $avoidanceZone;
121
-    }
10
+	public $territory_id; // Avoidance zone id
11
+	public $territory_name;
12
+	public $territory_color;
13
+	public $orders;
14
+	public $member_id;
15
+	public $territory; // Territory parameters
16
+
17
+	public function __construct()
18
+	{
19
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
20
+	}
21
+
22
+	public static function fromArray(array $params)
23
+	{
24
+		if (!isset($params['territory_name'])) {
25
+			throw new BadParam('Territory name must be provided');
26
+		}
27
+
28
+		if (!isset($params['territory_color'])) {
29
+			throw new BadParam('Territory color must be provided');
30
+		}
31
+
32
+		if (!isset($params['territory'])) {
33
+			throw new BadParam('Territory must be provided');
34
+		}
35
+
36
+		$avoidanceZoneParameters = new self();
37
+
38
+		foreach ($params as $key => $value) {
39
+			if (property_exists($avoidanceZoneParameters, $key)) {
40
+				$avoidanceZoneParameters->{$key} = $value;
41
+			}
42
+		}
43
+
44
+		return $avoidanceZoneParameters;
45
+	}
46
+
47
+	public static function getAvoidanceZone($territory_id)
48
+	{
49
+		$avoidanceZone = Route4Me::makeRequst([
50
+			'url'       => Endpoint::AVOIDANCE_ZONE,
51
+			'method'    => 'GET',
52
+			'query'     => [
53
+				'territory_id' => $territory_id,
54
+			],
55
+		]);
56
+
57
+		return $avoidanceZone;
58
+	}
59
+
60
+	public static function getAvoidanceZones($params)
61
+	{
62
+		$avoidanceZones = Route4Me::makeRequst([
63
+			'url'       => Endpoint::AVOIDANCE_ZONE,
64
+			'method'    => 'GET',
65
+			'query'     => [
66
+				'offset' => isset($params->offset) ? $params->offset : null,
67
+				'limit'  => isset($params->limit) ? $params->limit : null,
68
+			],
69
+		]);
70
+
71
+		return $avoidanceZones;
72
+	}
73
+
74
+	public static function addAvoidanceZone($params)
75
+	{
76
+		$terParams = [];
77
+
78
+		if (isset($params->territory['type'])) {
79
+			$terParams['type'] = $params->territory['type'];
80
+		}
81
+
82
+		if (isset($params->territory['data'])) {
83
+			$terParams['data'] = $params->territory['data'];
84
+		}
85
+
86
+		$abContacts = Route4Me::makeRequst([
87
+			'url'       => Endpoint::AVOIDANCE_ZONE,
88
+			'method'    => 'POST',
89
+			'body'      => [
90
+				'territory_name'    => isset($params->territory_name) ? $params->territory_name : null,
91
+				'territory_color'   => isset($params->territory_color) ? $params->territory_color : null,
92
+				'territory'         => $terParams,
93
+			],
94
+		]);
95
+
96
+		return $abContacts;
97
+	}
98
+
99
+	public function deleteAvoidanceZone($territory_id)
100
+	{
101
+		$result = Route4Me::makeRequst([
102
+			'url'       => Endpoint::AVOIDANCE_ZONE,
103
+			'method'    => 'DELETEARRAY',
104
+			'query'     => [
105
+				'territory_id' => $territory_id,
106
+			],
107
+		]);
108
+
109
+		return $result;
110
+	}
111
+
112
+	public function updateAvoidanceZone($params)
113
+	{
114
+		$avoidanceZone = Route4Me::makeRequst([
115
+			'url'       => Endpoint::AVOIDANCE_ZONE,
116
+			'method'    => 'PUT',
117
+			'body'      => $params,
118
+		]);
119
+
120
+		return $avoidanceZone;
121
+	}
122 122
 }
Please login to merge, or discard this patch.
src/Route4Me/ActivityParameters.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -6,92 +6,92 @@
 block discarded – undo
6 6
 
7 7
 class ActivityParameters extends Common
8 8
 {
9
-    public $route_id;
10
-    public $device_id;
11
-    public $member_id;
12
-    public $team;
13
-    public $limit;
14
-    public $offset;
15
-    public $start;
16
-    public $end;
17
-    public $activity_type;
18
-    public $activity_message;
19
-
20
-    public $activity_id;
21
-    public $activity_timestamp;
22
-    public $route_destination_id;
23
-    public $note_id;
24
-    public $member;
25
-    public $note_type;
26
-    public $note_contents;
27
-    public $route_name;
28
-    public $note_file;
29
-    public $destination_name;
30
-    public $destination_alias;
31
-
32
-    public function __construct()
33
-    {
34
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
35
-    }
36
-
37
-    public static function fromArray(array $params)
38
-    {
39
-        $activityparameters = new self();
40
-
41
-        foreach ($params as $key => $value) {
42
-            if (property_exists($activityparameters, $key)) {
43
-                $activityparameters->{$key} = $value;
44
-            }
45
-        }
46
-
47
-        return $activityparameters;
48
-    }
49
-
50
-    /*
9
+	public $route_id;
10
+	public $device_id;
11
+	public $member_id;
12
+	public $team;
13
+	public $limit;
14
+	public $offset;
15
+	public $start;
16
+	public $end;
17
+	public $activity_type;
18
+	public $activity_message;
19
+
20
+	public $activity_id;
21
+	public $activity_timestamp;
22
+	public $route_destination_id;
23
+	public $note_id;
24
+	public $member;
25
+	public $note_type;
26
+	public $note_contents;
27
+	public $route_name;
28
+	public $note_file;
29
+	public $destination_name;
30
+	public $destination_alias;
31
+
32
+	public function __construct()
33
+	{
34
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
35
+	}
36
+
37
+	public static function fromArray(array $params)
38
+	{
39
+		$activityparameters = new self();
40
+
41
+		foreach ($params as $key => $value) {
42
+			if (property_exists($activityparameters, $key)) {
43
+				$activityparameters->{$key} = $value;
44
+			}
45
+		}
46
+
47
+		return $activityparameters;
48
+	}
49
+
50
+	/*
51 51
      * Get all the activities limited by query parameters.
52 52
      */
53
-    public static function getActivities($params)
54
-    {
55
-        $allQueryFields = ['route_id', 'team', 'limit', 'offset', 'start', 'member_id'];
53
+	public static function getActivities($params)
54
+	{
55
+		$allQueryFields = ['route_id', 'team', 'limit', 'offset', 'start', 'member_id'];
56 56
 
57
-        $activity = Route4Me::makeRequst([
58
-            'url'       => Endpoint::GET_ACTIVITIES,
59
-            'method'    => 'GET',
60
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
61
-        ]);
57
+		$activity = Route4Me::makeRequst([
58
+			'url'       => Endpoint::GET_ACTIVITIES,
59
+			'method'    => 'GET',
60
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
61
+		]);
62 62
 
63
-        return $activity;
64
-    }
63
+		return $activity;
64
+	}
65 65
 
66
-    /*
66
+	/*
67 67
      * Returns the activity feed.
68 68
      */
69
-    public static function searchActivities($params)
70
-    {
71
-        $allQueryFields = ['route_id', 'limit', 'offset', 'activity_type'];
69
+	public static function searchActivities($params)
70
+	{
71
+		$allQueryFields = ['route_id', 'limit', 'offset', 'activity_type'];
72 72
 
73
-        $activity = Route4Me::makeRequst([
74
-            'url'       => Endpoint::GET_ACTIVITIES,
75
-            'method'    => 'GET',
76
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
77
-        ]);
73
+		$activity = Route4Me::makeRequst([
74
+			'url'       => Endpoint::GET_ACTIVITIES,
75
+			'method'    => 'GET',
76
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
77
+		]);
78 78
 
79
-        return $activity;
80
-    }
79
+		return $activity;
80
+	}
81 81
 
82
-    /*
82
+	/*
83 83
      * Creates a user's activity by sending a custom message to the activity stream.
84 84
      */
85
-    public static function sendUserMessage($params)
86
-    {
87
-        $allBodyFields = ['activity_type', 'activity_message', 'route_id'];
88
-
89
-        $result = Route4Me::makeRequst([
90
-            'url'       => Endpoint::ACTIVITY_FEED,
91
-            'method'    => 'POST',
92
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
93
-        ]);
94
-
95
-        return $result;
96
-    }
85
+	public static function sendUserMessage($params)
86
+	{
87
+		$allBodyFields = ['activity_type', 'activity_message', 'route_id'];
88
+
89
+		$result = Route4Me::makeRequst([
90
+			'url'       => Endpoint::ACTIVITY_FEED,
91
+			'method'    => 'POST',
92
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
93
+		]);
94
+
95
+		return $result;
96
+	}
97 97
 }
Please login to merge, or discard this patch.
src/Route4Me/OptimizationProblem.php 2 patches
Indentation   +322 added lines, -322 removed lines patch added patch discarded remove patch
@@ -6,185 +6,185 @@  discard block
 block discarded – undo
6 6
 
7 7
 class OptimizationProblem extends Common
8 8
 {
9
-    /**
10
-     * Optimization problem ID
11
-     * @var string
12
-     */
13
-    public $optimization_problem_id;
14
-
15
-    /**
16
-     * Smart Optimization Problem ID
17
-     * @var string
18
-     */
19
-    public $smart_optimization_id;
20
-
21
-    /**
22
-     * An array of the user errors.
23
-     * @var string[]
24
-     */
25
-    public $user_errors = [];
26
-
27
-    /**
28
-     * An optimization problem state.<br>
29
-     * Available values:
30
-     * - OptimizationStateNew = 0,
31
-     * - Initial = 1,
32
-     * - MatrixProcessing = 2,
33
-     * - Optimizing = 3,
34
-     * - Optimized = 4,
35
-     * - Error = 5,
36
-     * - ComputingDirections = 6,
37
-     * - OptimizationStateInQueue = 7
38
-     * @var int
39
-     */
40
-    public $state;
41
-
42
-    /**
43
-     * An array of the optimization errors.
44
-     * @var string[]
45
-     */
46
-    public $optimization_errors = [];
47
-
48
-    /**
49
-     * Route Parameters.
50
-     * @var RouteParameters
51
-     */
52
-    public $parameters;
53
-
54
-    /**
55
-     * If true it means the solution was not returned (it is being computed in the background).
56
-     * @var boolean
57
-     */
58
-    public $sent_to_background;
59
-
60
-    /**
61
-     * When the optimization problem was created.
62
-     * @var long
63
-     */
64
-    public $created_timestamp;
65
-
66
-    /**
67
-     * An Unix Timestamp the Optimization Problem was scheduled for.
68
-     * @var long
69
-     */
70
-    public $scheduled_for;
71
-
72
-    /**
73
-     * When the optimization completed.
74
-     * @var long
75
-     */
76
-    public $optimization_completed_timestamp;
77
-
78
-    /**
79
-     * An array ot the Address type objects.
80
-     * @var Address[]
81
-     */
82
-    public $addresses = [];
83
-
84
-    /**
85
-     * An array ot the DataObjectRoute type objects.<br>
86
-     * The routes included in the optimization problem.
87
-     * @var Route[]
88
-     */
89
-    public $routes = [];
90
-
91
-    /** @var string[] $links
92
-     * The links to the GET operations for the optimization problem.
93
-     */
94
-    public $links = [];
95
-
96
-    public function __construct()
97
-    {
98
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
99
-        $this->parameters = new RouteParameters();
100
-    }
101
-
102
-    public static function fromArray(array $params)
103
-    {
104
-        $problem = new self();
105
-        $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
106
-        $problem->user_errors = Common::getValue($params, 'user_errors', []);
107
-        $problem->state = Common::getValue($params, 'state', []);
108
-        $problem->sent_to_background = Common::getValue($params, 'sent_to_background', []);
109
-        $problem->links = Common::getValue($params, 'links', []);
110
-
111
-        if (isset($params['parameters'])) {
112
-            $problem->parameters = RouteParameters::fromArray($params['parameters']);
113
-        }
114
-
115
-        if (isset($params['addresses'])) {
116
-            $addresses = [];
117
-
118
-            foreach ($params['addresses'] as $address) {
119
-                $addresses[] = Address::fromArray($address);
120
-            }
121
-
122
-            $problem->addresses = $addresses;
123
-        }
124
-
125
-        if (isset($params['routes'])) {
126
-            $routes = [];
127
-
128
-            foreach ($params['routes'] as $route) {
129
-                $routes[] = Route::fromArray($route);
130
-            }
131
-
132
-            $problem->routes = $routes;
133
-        }
134
-
135
-        return $problem;
136
-    }
137
-
138
-    public static function optimize(OptimizationProblemParams $params)
139
-    {
140
-        $allQueryFields = ['redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url'];
141
-
142
-        $optimize = Route4Me::makeRequst([
143
-            'url'       => Endpoint::OPTIMIZATION_PROBLEM,
144
-            'method'    => 'POST',
145
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
146
-            'body'      => [
147
-                'addresses'     => $params->getAddressesArray(),
148
-                'depots'        => $params->getDepotsArray(),
149
-                'parameters'    => $params->getParametersArray(),
150
-            ],
151
-        ]);
152
-
153
-        return self::fromArray($optimize);
154
-    }
155
-
156
-    public static function get($params)
157
-    {
158
-        $allQueryFields = ['state', 'limit', 'format', 'offset',
159
-        'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ];
160
-
161
-        $result = Route4Me::makeRequst([
162
-            'url'       => Endpoint::OPTIMIZATION_PROBLEM,
163
-            'method'    => 'GET',
164
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
165
-        ]);
166
-
167
-        if (isset($result['optimizations'])) {
168
-            $problems = [];
169
-
170
-            foreach ($result['optimizations'] as $problem) {
171
-                $problems[] = self::fromArray($problem);
172
-            }
173
-
174
-            return $problems;
175
-        } else {
176
-            return self::fromArray($result);
177
-        }
178
-    }
179
-
180
-    public function reoptimize($params)
181
-    {
182
-        $param['reoptimize'] = 1;
183
-
184
-        return self::update($params);
185
-    }
186
-
187
-    /*
9
+	/**
10
+	 * Optimization problem ID
11
+	 * @var string
12
+	 */
13
+	public $optimization_problem_id;
14
+
15
+	/**
16
+	 * Smart Optimization Problem ID
17
+	 * @var string
18
+	 */
19
+	public $smart_optimization_id;
20
+
21
+	/**
22
+	 * An array of the user errors.
23
+	 * @var string[]
24
+	 */
25
+	public $user_errors = [];
26
+
27
+	/**
28
+	 * An optimization problem state.<br>
29
+	 * Available values:
30
+	 * - OptimizationStateNew = 0,
31
+	 * - Initial = 1,
32
+	 * - MatrixProcessing = 2,
33
+	 * - Optimizing = 3,
34
+	 * - Optimized = 4,
35
+	 * - Error = 5,
36
+	 * - ComputingDirections = 6,
37
+	 * - OptimizationStateInQueue = 7
38
+	 * @var int
39
+	 */
40
+	public $state;
41
+
42
+	/**
43
+	 * An array of the optimization errors.
44
+	 * @var string[]
45
+	 */
46
+	public $optimization_errors = [];
47
+
48
+	/**
49
+	 * Route Parameters.
50
+	 * @var RouteParameters
51
+	 */
52
+	public $parameters;
53
+
54
+	/**
55
+	 * If true it means the solution was not returned (it is being computed in the background).
56
+	 * @var boolean
57
+	 */
58
+	public $sent_to_background;
59
+
60
+	/**
61
+	 * When the optimization problem was created.
62
+	 * @var long
63
+	 */
64
+	public $created_timestamp;
65
+
66
+	/**
67
+	 * An Unix Timestamp the Optimization Problem was scheduled for.
68
+	 * @var long
69
+	 */
70
+	public $scheduled_for;
71
+
72
+	/**
73
+	 * When the optimization completed.
74
+	 * @var long
75
+	 */
76
+	public $optimization_completed_timestamp;
77
+
78
+	/**
79
+	 * An array ot the Address type objects.
80
+	 * @var Address[]
81
+	 */
82
+	public $addresses = [];
83
+
84
+	/**
85
+	 * An array ot the DataObjectRoute type objects.<br>
86
+	 * The routes included in the optimization problem.
87
+	 * @var Route[]
88
+	 */
89
+	public $routes = [];
90
+
91
+	/** @var string[] $links
92
+	 * The links to the GET operations for the optimization problem.
93
+	 */
94
+	public $links = [];
95
+
96
+	public function __construct()
97
+	{
98
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
99
+		$this->parameters = new RouteParameters();
100
+	}
101
+
102
+	public static function fromArray(array $params)
103
+	{
104
+		$problem = new self();
105
+		$problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
106
+		$problem->user_errors = Common::getValue($params, 'user_errors', []);
107
+		$problem->state = Common::getValue($params, 'state', []);
108
+		$problem->sent_to_background = Common::getValue($params, 'sent_to_background', []);
109
+		$problem->links = Common::getValue($params, 'links', []);
110
+
111
+		if (isset($params['parameters'])) {
112
+			$problem->parameters = RouteParameters::fromArray($params['parameters']);
113
+		}
114
+
115
+		if (isset($params['addresses'])) {
116
+			$addresses = [];
117
+
118
+			foreach ($params['addresses'] as $address) {
119
+				$addresses[] = Address::fromArray($address);
120
+			}
121
+
122
+			$problem->addresses = $addresses;
123
+		}
124
+
125
+		if (isset($params['routes'])) {
126
+			$routes = [];
127
+
128
+			foreach ($params['routes'] as $route) {
129
+				$routes[] = Route::fromArray($route);
130
+			}
131
+
132
+			$problem->routes = $routes;
133
+		}
134
+
135
+		return $problem;
136
+	}
137
+
138
+	public static function optimize(OptimizationProblemParams $params)
139
+	{
140
+		$allQueryFields = ['redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url'];
141
+
142
+		$optimize = Route4Me::makeRequst([
143
+			'url'       => Endpoint::OPTIMIZATION_PROBLEM,
144
+			'method'    => 'POST',
145
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
146
+			'body'      => [
147
+				'addresses'     => $params->getAddressesArray(),
148
+				'depots'        => $params->getDepotsArray(),
149
+				'parameters'    => $params->getParametersArray(),
150
+			],
151
+		]);
152
+
153
+		return self::fromArray($optimize);
154
+	}
155
+
156
+	public static function get($params)
157
+	{
158
+		$allQueryFields = ['state', 'limit', 'format', 'offset',
159
+		'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ];
160
+
161
+		$result = Route4Me::makeRequst([
162
+			'url'       => Endpoint::OPTIMIZATION_PROBLEM,
163
+			'method'    => 'GET',
164
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
165
+		]);
166
+
167
+		if (isset($result['optimizations'])) {
168
+			$problems = [];
169
+
170
+			foreach ($result['optimizations'] as $problem) {
171
+				$problems[] = self::fromArray($problem);
172
+			}
173
+
174
+			return $problems;
175
+		} else {
176
+			return self::fromArray($result);
177
+		}
178
+	}
179
+
180
+	public function reoptimize($params)
181
+	{
182
+		$param['reoptimize'] = 1;
183
+
184
+		return self::update($params);
185
+	}
186
+
187
+	/*
188 188
      * Updates an existing optimization problem.<br>
189 189
      * @param array $params with items:
190 190
      * - optimization_problem_id   : query parameter. ID of an updated optimization;
@@ -193,151 +193,151 @@  discard block
 block discarded – undo
193 193
      * - parameters                : body parameter. Modified route parameters;
194 194
      * @return Optimization problem
195 195
      */
196
-    public static function update($params)
197
-    {
198
-        $allQueryFields = ['optimization_problem_id', 'reoptimize'];
199
-        $allBodyFields = ['addresses', 'parameters'];
200
-
201
-        $query = is_array($params)
202
-                    ? (isset($params['optimization_problem_id']) || isset($params['parameters']))
203
-                        ? Route4Me::generateRequestParameters($allQueryFields, $params)
204
-                        : null
205
-                    : (isset($params->optimization_problem_id) || isset($params->parameters))
206
-                        ? Route4Me::generateRequestParameters($allQueryFields, $params)
207
-                        : null;
208
-
209
-        $body = is_array($params)
210
-            ? (isset($params['addresses']) && sizeof($params['addresses'])>0) ||
211
-            (isset($params['parameters']) && sizeof($params['parameters'])>0)
212
-                ? Route4Me::generateRequestParameters($allBodyFields, $params)
213
-                : null
214
-            : (isset($params->addresses) && sizeof($params->addresses)>0) ||
215
-                (isset($params->parameters) && sizeof($params->parameters)>0)
216
-                    ? Route4Me::generateRequestParameters($allBodyFields, $params)
217
-                    : null;
218
-
219
-        $optimize = Route4Me::makeRequst([
220
-            'url'       => Endpoint::OPTIMIZATION_PROBLEM,
221
-            'method'    => 'PUT',
222
-            'query'     => $query,
223
-            'body'      => $body,
224
-        ]);
225
-
226
-        return $optimize;
227
-    }
228
-
229
-    public function getOptimizationId()
230
-    {
231
-        return $this->optimization_problem_id;
232
-    }
233
-
234
-    public function getRoutes()
235
-    {
236
-        return $this->routes;
237
-    }
238
-
239
-    public function getRandomOptimizationId($offset, $limit)
240
-    {
241
-        $optimizations = self::get(['offset' => $offset, 'limit' => $limit]);
242
-
243
-        $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)];
244
-
245
-        if (!isset($rOptimization->optimization_problem_id)) {
246
-            if (sizeof($optimizations) > 9) {
247
-                $this->getRandomOptimizationId($offset, $limit);
248
-            } else {
249
-                return null;
250
-            }
251
-        }
252
-
253
-        return $rOptimization->optimization_problem_id;
254
-    }
255
-
256
-    public function getAddresses($opt_id)
257
-    {
258
-        if (null == $opt_id) {
259
-            return null;
260
-        }
261
-
262
-        $params = ['optimization_problem_id' => $opt_id];
263
-
264
-        $optimization = (array) $this->get($params);
265
-
266
-        $addresses = $optimization['addresses'];
267
-
268
-        return $addresses;
269
-    }
270
-
271
-    public function getRandomAddressFromOptimization($opt_id)
272
-    {
273
-        $addresses = (array) $this->getAddresses($opt_id);
274
-
275
-        if (null == $addresses) {
276
-            echo 'There are no addresses in this optimization!.. Try again.';
277
-
278
-            return null;
279
-        }
280
-
281
-        $num = rand(0, sizeof($addresses) - 1);
282
-
283
-        $rAddress = $addresses[$num];
284
-
285
-        return $rAddress;
286
-    }
287
-
288
-    public function removeAddress($params)
289
-    {
290
-        $allQueryFields = ['optimization_problem_id', 'route_destination_id'];
291
-
292
-        $response = Route4Me::makeRequst([
293
-            'url'       => Endpoint::ADDRESS_V4,
294
-            'method'    => 'DELETE',
295
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
296
-        ]);
297
-
298
-        return $response;
299
-    }
300
-
301
-    public function removeOptimization($params)
302
-    {
303
-        $allQueryFields = ['redirect'];
304
-        $allBodyFields = ['optimization_problem_ids'];
305
-
306
-        $response = Route4Me::makeRequst([
307
-            'url'       => Endpoint::OPTIMIZATION_PROBLEM,
308
-            'method'    => 'DELETE',
309
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
310
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
311
-        ]);
312
-
313
-        return $response;
314
-    }
315
-
316
-    public function getHybridOptimization($params)
317
-    {
318
-        $allQueryFields = ['target_date_string', 'timezone_offset_minutes'];
319
-
320
-        $optimize = Route4Me::makeRequst([
321
-            'url'       => Endpoint::HYBRID_DATE_OPTIMIZATION,
322
-            'method'    => 'GET',
323
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
324
-        ]);
196
+	public static function update($params)
197
+	{
198
+		$allQueryFields = ['optimization_problem_id', 'reoptimize'];
199
+		$allBodyFields = ['addresses', 'parameters'];
200
+
201
+		$query = is_array($params)
202
+					? (isset($params['optimization_problem_id']) || isset($params['parameters']))
203
+						? Route4Me::generateRequestParameters($allQueryFields, $params)
204
+						: null
205
+					: (isset($params->optimization_problem_id) || isset($params->parameters))
206
+						? Route4Me::generateRequestParameters($allQueryFields, $params)
207
+						: null;
208
+
209
+		$body = is_array($params)
210
+			? (isset($params['addresses']) && sizeof($params['addresses'])>0) ||
211
+			(isset($params['parameters']) && sizeof($params['parameters'])>0)
212
+				? Route4Me::generateRequestParameters($allBodyFields, $params)
213
+				: null
214
+			: (isset($params->addresses) && sizeof($params->addresses)>0) ||
215
+				(isset($params->parameters) && sizeof($params->parameters)>0)
216
+					? Route4Me::generateRequestParameters($allBodyFields, $params)
217
+					: null;
218
+
219
+		$optimize = Route4Me::makeRequst([
220
+			'url'       => Endpoint::OPTIMIZATION_PROBLEM,
221
+			'method'    => 'PUT',
222
+			'query'     => $query,
223
+			'body'      => $body,
224
+		]);
225
+
226
+		return $optimize;
227
+	}
228
+
229
+	public function getOptimizationId()
230
+	{
231
+		return $this->optimization_problem_id;
232
+	}
233
+
234
+	public function getRoutes()
235
+	{
236
+		return $this->routes;
237
+	}
238
+
239
+	public function getRandomOptimizationId($offset, $limit)
240
+	{
241
+		$optimizations = self::get(['offset' => $offset, 'limit' => $limit]);
242
+
243
+		$rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)];
244
+
245
+		if (!isset($rOptimization->optimization_problem_id)) {
246
+			if (sizeof($optimizations) > 9) {
247
+				$this->getRandomOptimizationId($offset, $limit);
248
+			} else {
249
+				return null;
250
+			}
251
+		}
252
+
253
+		return $rOptimization->optimization_problem_id;
254
+	}
255
+
256
+	public function getAddresses($opt_id)
257
+	{
258
+		if (null == $opt_id) {
259
+			return null;
260
+		}
261
+
262
+		$params = ['optimization_problem_id' => $opt_id];
263
+
264
+		$optimization = (array) $this->get($params);
265
+
266
+		$addresses = $optimization['addresses'];
267
+
268
+		return $addresses;
269
+	}
270
+
271
+	public function getRandomAddressFromOptimization($opt_id)
272
+	{
273
+		$addresses = (array) $this->getAddresses($opt_id);
274
+
275
+		if (null == $addresses) {
276
+			echo 'There are no addresses in this optimization!.. Try again.';
277
+
278
+			return null;
279
+		}
280
+
281
+		$num = rand(0, sizeof($addresses) - 1);
282
+
283
+		$rAddress = $addresses[$num];
284
+
285
+		return $rAddress;
286
+	}
287
+
288
+	public function removeAddress($params)
289
+	{
290
+		$allQueryFields = ['optimization_problem_id', 'route_destination_id'];
291
+
292
+		$response = Route4Me::makeRequst([
293
+			'url'       => Endpoint::ADDRESS_V4,
294
+			'method'    => 'DELETE',
295
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
296
+		]);
297
+
298
+		return $response;
299
+	}
300
+
301
+	public function removeOptimization($params)
302
+	{
303
+		$allQueryFields = ['redirect'];
304
+		$allBodyFields = ['optimization_problem_ids'];
305
+
306
+		$response = Route4Me::makeRequst([
307
+			'url'       => Endpoint::OPTIMIZATION_PROBLEM,
308
+			'method'    => 'DELETE',
309
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
310
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
311
+		]);
312
+
313
+		return $response;
314
+	}
315
+
316
+	public function getHybridOptimization($params)
317
+	{
318
+		$allQueryFields = ['target_date_string', 'timezone_offset_minutes'];
319
+
320
+		$optimize = Route4Me::makeRequst([
321
+			'url'       => Endpoint::HYBRID_DATE_OPTIMIZATION,
322
+			'method'    => 'GET',
323
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
324
+		]);
325 325
 
326
-        return $optimize;
327
-    }
326
+		return $optimize;
327
+	}
328 328
 
329
-    public function addDepotsToHybrid($params)
330
-    {
331
-        $allQueryFields = ['optimization_problem_id'];
332
-        $allBodyFields = ['optimization_problem_id', 'delete_old_depots', 'new_depots'];
329
+	public function addDepotsToHybrid($params)
330
+	{
331
+		$allQueryFields = ['optimization_problem_id'];
332
+		$allBodyFields = ['optimization_problem_id', 'delete_old_depots', 'new_depots'];
333 333
 
334
-        $depots = Route4Me::makeRequst([
335
-            'url'       => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT,
336
-            'method'    => 'POST',
337
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
338
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
339
-        ]);
334
+		$depots = Route4Me::makeRequst([
335
+			'url'       => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT,
336
+			'method'    => 'POST',
337
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
338
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
339
+		]);
340 340
 
341
-        return $depots;
342
-    }
341
+		return $depots;
342
+	}
343 343
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
     public static function get($params)
157 157
     {
158 158
         $allQueryFields = ['state', 'limit', 'format', 'offset',
159
-        'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ];
159
+        'optimization_problem_id', 'wait_for_final_state', 'start_date', 'end_date', ];
160 160
 
161 161
         $result = Route4Me::makeRequst([
162 162
             'url'       => Endpoint::OPTIMIZATION_PROBLEM,
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
         $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)];
244 244
 
245 245
         if (!isset($rOptimization->optimization_problem_id)) {
246
-            if (sizeof($optimizations) > 9) {
246
+            if (sizeof($optimizations)>9) {
247 247
                 $this->getRandomOptimizationId($offset, $limit);
248 248
             } else {
249 249
                 return null;
@@ -255,13 +255,13 @@  discard block
 block discarded – undo
255 255
 
256 256
     public function getAddresses($opt_id)
257 257
     {
258
-        if (null == $opt_id) {
258
+        if (null==$opt_id) {
259 259
             return null;
260 260
         }
261 261
 
262 262
         $params = ['optimization_problem_id' => $opt_id];
263 263
 
264
-        $optimization = (array) $this->get($params);
264
+        $optimization = (array)$this->get($params);
265 265
 
266 266
         $addresses = $optimization['addresses'];
267 267
 
@@ -270,9 +270,9 @@  discard block
 block discarded – undo
270 270
 
271 271
     public function getRandomAddressFromOptimization($opt_id)
272 272
     {
273
-        $addresses = (array) $this->getAddresses($opt_id);
273
+        $addresses = (array)$this->getAddresses($opt_id);
274 274
 
275
-        if (null == $addresses) {
275
+        if (null==$addresses) {
276 276
             echo 'There are no addresses in this optimization!.. Try again.';
277 277
 
278 278
             return null;
Please login to merge, or discard this patch.
src/Route4Me/TelematicsGateway/TelematicsVendorsResponse.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@
 block discarded – undo
9 9
  */
10 10
 class TelematicsVendorsResponse 
11 11
 {
12
-    /**
13
-     * An array of the telematics vendors.
14
-     * @var type TelematicsVendors[]
15
-     */
16
-    public $vendors = [];
12
+	/**
13
+	 * An array of the telematics vendors.
14
+	 * @var type TelematicsVendors[]
15
+	 */
16
+	public $vendors = [];
17 17
 }
Please login to merge, or discard this patch.
src/Route4Me/TelematicsGateway/TelematicsConnectionParameters.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -9,88 +9,88 @@
 block discarded – undo
9 9
  */
10 10
 class TelematicsConnectionParameters extends Common
11 11
 {
12
-    /**
13
-     * Account ID
14
-     * @var type string
15
-     */
16
-    public $account_id;
12
+	/**
13
+	 * Account ID
14
+	 * @var type string
15
+	 */
16
+	public $account_id;
17 17
     
18
-    /**
19
-     * User name
20
-     * @var type string
21
-     */
22
-    public $username;
18
+	/**
19
+	 * User name
20
+	 * @var type string
21
+	 */
22
+	public $username;
23 23
     
24
-    /**
25
-     * Password
26
-     * @var type string
27
-     */
28
-    public $password;
24
+	/**
25
+	 * Password
26
+	 * @var type string
27
+	 */
28
+	public $password;
29 29
     
30
-    /**
31
-     * Connection host
32
-     * @var type string
33
-     */
34
-    public $host;
30
+	/**
31
+	 * Connection host
32
+	 * @var type string
33
+	 */
34
+	public $host;
35 35
     
36
-    /**
37
-     * An unique ID of a telematics vendor.
38
-     * @var type integer
39
-     */
40
-    public $vendor_id;
36
+	/**
37
+	 * An unique ID of a telematics vendor.
38
+	 * @var type integer
39
+	 */
40
+	public $vendor_id;
41 41
     
42
-    /**
43
-     * Telematics connection name
44
-     * @var type string
45
-     */
46
-    public $name;
42
+	/**
43
+	 * Telematics connection name
44
+	 * @var type string
45
+	 */
46
+	public $name;
47 47
     
48
-    /**
49
-     * Vehicle tracking interval in seconds
50
-     * @var type integer
51
-     */
52
-    public $vehicle_position_refresh_rate;
48
+	/**
49
+	 * Vehicle tracking interval in seconds
50
+	 * @var type integer
51
+	 */
52
+	public $vehicle_position_refresh_rate;
53 53
     
54
-    /**
55
-     * Connection token
56
-     * @var type string
57
-     */
58
-    public $connection_token;
54
+	/**
55
+	 * Connection token
56
+	 * @var type string
57
+	 */
58
+	public $connection_token;
59 59
     
60
-    /**
61
-     * Connection user ID
62
-     * @var type integer
63
-     */
64
-    public $user_id;
60
+	/**
61
+	 * Connection user ID
62
+	 * @var type integer
63
+	 */
64
+	public $user_id;
65 65
     
66
-    /**
67
-     * Connection ID
68
-     * @var type integer
69
-     */
70
-    public $id;
66
+	/**
67
+	 * Connection ID
68
+	 * @var type integer
69
+	 */
70
+	public $id;
71 71
     
72
-    /**
73
-     * Telemetics connection type
74
-     * @var type string
75
-     */
76
-    public $vendor;
72
+	/**
73
+	 * Telemetics connection type
74
+	 * @var type string
75
+	 */
76
+	public $vendor;
77 77
     
78
-    /**
79
-     * Validate connections credentials.
80
-     * @var type Boolean
81
-     */
82
-    public $validate_remote_credentials;
78
+	/**
79
+	 * Validate connections credentials.
80
+	 * @var type Boolean
81
+	 */
82
+	public $validate_remote_credentials;
83 83
 
84
-    public static function fromArray(array $params)
85
-    {
86
-        $thisParams = new self();
84
+	public static function fromArray(array $params)
85
+	{
86
+		$thisParams = new self();
87 87
 
88
-        foreach ($params as $key => $value) {
89
-            if (property_exists($thisParams, $key)) {
90
-                $thisParams->{$key} = $value;
91
-            }
92
-        }
88
+		foreach ($params as $key => $value) {
89
+			if (property_exists($thisParams, $key)) {
90
+				$thisParams->{$key} = $value;
91
+			}
92
+		}
93 93
 
94
-        return $thisParams;
95
-    }
94
+		return $thisParams;
95
+	}
96 96
 }
Please login to merge, or discard this patch.
src/Route4Me/TelematicsGateway/TelematicsConnection.php 1 patch
Indentation   +231 added lines, -231 removed lines patch added patch discarded remove patch
@@ -11,279 +11,279 @@
 block discarded – undo
11 11
  */
12 12
 class TelematicsConnection extends \Route4Me\Common
13 13
 {
14
-    /**
15
-     * Telematics connection access account_id
16
-     * @var string
17
-     */
18
-    public $account_id;
14
+	/**
15
+	 * Telematics connection access account_id
16
+	 * @var string
17
+	 */
18
+	public $account_id;
19 19
     
20
-    /**
21
-     * Telematics connection access username
22
-     * @var string
23
-     */
24
-    public $username;
20
+	/**
21
+	 * Telematics connection access username
22
+	 * @var string
23
+	 */
24
+	public $username;
25 25
     
26
-    /**
27
-     * Telematics connection access password
28
-     * @var string
29
-     */
30
-    public $password;
26
+	/**
27
+	 * Telematics connection access password
28
+	 * @var string
29
+	 */
30
+	public $password;
31 31
     
32
-    /**
33
-     * Telematics connection access host
34
-     * @var string
35
-     */
36
-    public $host;
32
+	/**
33
+	 * Telematics connection access host
34
+	 * @var string
35
+	 */
36
+	public $host;
37 37
     
38
-    /**
39
-     * Telematics connection access api_key
40
-     * @var string
41
-     */
42
-    public $api_key;
38
+	/**
39
+	 * Telematics connection access api_key
40
+	 * @var string
41
+	 */
42
+	public $api_key;
43 43
     
44
-    /**
45
-     * Telemetics connection type ID
46
-     * @var integer
47
-     */
48
-    public $vendor_id;
44
+	/**
45
+	 * Telemetics connection type ID
46
+	 * @var integer
47
+	 */
48
+	public $vendor_id;
49 49
     
50
-    /**
51
-     * Telemetics connection name
52
-     * @var string
53
-     */
54
-    public $name;
50
+	/**
51
+	 * Telemetics connection name
52
+	 * @var string
53
+	 */
54
+	public $name;
55 55
     
56
-    /**
57
-     * Vehicle tracking interval in seconds.
58
-     * @var integer
59
-     */
60
-    public $vehicle_position_refresh_rate;
56
+	/**
57
+	 * Vehicle tracking interval in seconds.
58
+	 * @var integer
59
+	 */
60
+	public $vehicle_position_refresh_rate;
61 61
     
62
-    /**
63
-     * Maximum idle time
64
-     * @var integer
65
-     */
66
-    public $max_idle_time;
62
+	/**
63
+	 * Maximum idle time
64
+	 * @var integer
65
+	 */
66
+	public $max_idle_time;
67 67
     
68
-    /**
69
-     * Disable/enable vehicle tracking
70
-     * @var integer
71
-     */
72
-    public $is_enabled;
68
+	/**
69
+	 * Disable/enable vehicle tracking
70
+	 * @var integer
71
+	 */
72
+	public $is_enabled;
73 73
     
74
-    /**
75
-     * The last timestamp, when the vehicles reloaded.
76
-     * @var integer
77
-     */
78
-    public $last_vehicles_reload;
74
+	/**
75
+	 * The last timestamp, when the vehicles reloaded.
76
+	 * @var integer
77
+	 */
78
+	public $last_vehicles_reload;
79 79
     
80
-    /**
81
-     * The last timestamp, when the addresses reloaded.
82
-     * @var integer
83
-     */
84
-    public $last_addresses_reload;
80
+	/**
81
+	 * The last timestamp, when the addresses reloaded.
82
+	 * @var integer
83
+	 */
84
+	public $last_addresses_reload;
85 85
     
86
-    /**
87
-     * The last timestamp, when the positions reloaded.
88
-     * @var integer
89
-     */
90
-    public $last_position_reload;
86
+	/**
87
+	 * The last timestamp, when the positions reloaded.
88
+	 * @var integer
89
+	 */
90
+	public $last_position_reload;
91 91
     
92
-    /**
93
-     * Telematics connection access token
94
-     * @var string
95
-     */
96
-    public $connection_token;
92
+	/**
93
+	 * Telematics connection access token
94
+	 * @var string
95
+	 */
96
+	public $connection_token;
97 97
     
98
-    /**
99
-     * Connection user ID
100
-     * @var integer
101
-     */
102
-    public $user_id;
98
+	/**
99
+	 * Connection user ID
100
+	 * @var integer
101
+	 */
102
+	public $user_id;
103 103
     
104
-    /**
105
-     * When the connection updated
106
-     * @var string
107
-     */
108
-    public $updated_at;
104
+	/**
105
+	 * When the connection updated
106
+	 * @var string
107
+	 */
108
+	public $updated_at;
109 109
     
110
-    /**
111
-     * When the connection created
112
-     * @var string
113
-     */
114
-    public $created_at;
110
+	/**
111
+	 * When the connection created
112
+	 * @var string
113
+	 */
114
+	public $created_at;
115 115
     
116
-    /**
117
-     * Telemetics connection ID
118
-     * @var integer
119
-     */
120
-    public $id;
116
+	/**
117
+	 * Telemetics connection ID
118
+	 * @var integer
119
+	 */
120
+	public $id;
121 121
     
122
-    /**
123
-     * Metadata, custom key-value storage.
124
-     * @var array
125
-     */
126
-    public $metadata;
122
+	/**
123
+	 * Metadata, custom key-value storage.
124
+	 * @var array
125
+	 */
126
+	public $metadata;
127 127
     
128
-    /**
129
-     * Total vehicles number
130
-     * @var integer
131
-     */
132
-    public $total_vehicles_count;
128
+	/**
129
+	 * Total vehicles number
130
+	 * @var integer
131
+	 */
132
+	public $total_vehicles_count;
133 133
     
134
-    /**
135
-     * Total addresses number
136
-     * @var integer
137
-     */
138
-    public $total_addresses_count;
134
+	/**
135
+	 * Total addresses number
136
+	 * @var integer
137
+	 */
138
+	public $total_addresses_count;
139 139
     
140
-    /**
141
-     * Synchronized vehicles number
142
-     * @var integer
143
-     */
144
-    public $synced_vehicles_count;
140
+	/**
141
+	 * Synchronized vehicles number
142
+	 * @var integer
143
+	 */
144
+	public $synced_vehicles_count;
145 145
     
146
-    /**
147
-     * Telemetics connection vendor
148
-     * @var string
149
-     */
150
-    public $vendor;
146
+	/**
147
+	 * Telemetics connection vendor
148
+	 * @var string
149
+	 */
150
+	public $vendor;
151 151
 
152
-    /**
153
-     * Validate connections credentials.<br>
154
-     * If true, the connection validated.
155
-     * @var Boolean
156
-     */
157
-    public $validate_remote_credentials;
152
+	/**
153
+	 * Validate connections credentials.<br>
154
+	 * If true, the connection validated.
155
+	 * @var Boolean
156
+	 */
157
+	public $validate_remote_credentials;
158 158
     
159
-    public static function fromArray(array $params)
160
-    {
161
-        $thisParams = new self();
159
+	public static function fromArray(array $params)
160
+	{
161
+		$thisParams = new self();
162 162
 
163
-        foreach ($params as $key => $value) {
164
-            if (property_exists($thisParams, $key)) {
165
-                $thisParams->{$key} = $value;
166
-            }
167
-        }
163
+		foreach ($params as $key => $value) {
164
+			if (property_exists($thisParams, $key)) {
165
+				$thisParams->{$key} = $value;
166
+			}
167
+		}
168 168
 
169
-        return $thisParams;
170
-    }
169
+		return $thisParams;
170
+	}
171 171
 
172
-    /**
173
-     * Create a telematics connection.
174
-     * @param $apiToken string : API token
175
-     * @param $params TelematicsConnectionParameters : Telematics connection parameters
176
-     * @return array Array from a TelematicsConnection type object
177
-     * @throws \Route4Me\Exception\ApiError
178
-     */
179
-    public function createTelematicsConnection($apiToken, $params)
180
-    {
181
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
172
+	/**
173
+	 * Create a telematics connection.
174
+	 * @param $apiToken string : API token
175
+	 * @param $params TelematicsConnectionParameters : Telematics connection parameters
176
+	 * @return array Array from a TelematicsConnection type object
177
+	 * @throws \Route4Me\Exception\ApiError
178
+	 */
179
+	public function createTelematicsConnection($apiToken, $params)
180
+	{
181
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
182 182
 
183
-        $excludeFields = ['id', 'connection_token'];
183
+		$excludeFields = ['id', 'connection_token'];
184 184
 
185
-        $allBodyFields = Route4Me::getObjectProperties(new TelematicsConnectionParameters(), $excludeFields);
185
+		$allBodyFields = Route4Me::getObjectProperties(new TelematicsConnectionParameters(), $excludeFields);
186 186
 
187
-        $result = Route4Me::makeRequst([
188
-            'url'    => Endpoint::TELEMATICS_CONNECTION,
189
-            'method' => 'POST',
190
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
191
-            'query'  => ['api_token' => $apiToken],
192
-            'HTTPHEADER'    => 'Content-Type: multipart/form-data',
193
-        ]);
187
+		$result = Route4Me::makeRequst([
188
+			'url'    => Endpoint::TELEMATICS_CONNECTION,
189
+			'method' => 'POST',
190
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $params),
191
+			'query'  => ['api_token' => $apiToken],
192
+			'HTTPHEADER'    => 'Content-Type: multipart/form-data',
193
+		]);
194 194
 
195
-        return $result;
196
-    }
195
+		return $result;
196
+	}
197 197
 
198
-    /**
199
-     * Delete a telematics connection.
200
-     * @param $apiToken string : API token
201
-     * @param $connectionToken string : connection token
202
-     * @return array Array from a TelematicsConnection type object
203
-     * @throws \Route4Me\Exception\ApiError
204
-     */
205
-    public function deleteTelematicsConnection($apiToken, $connectionToken)
206
-    {
207
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
198
+	/**
199
+	 * Delete a telematics connection.
200
+	 * @param $apiToken string : API token
201
+	 * @param $connectionToken string : connection token
202
+	 * @return array Array from a TelematicsConnection type object
203
+	 * @throws \Route4Me\Exception\ApiError
204
+	 */
205
+	public function deleteTelematicsConnection($apiToken, $connectionToken)
206
+	{
207
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
208 208
 
209
-        $result = Route4Me::makeRequst([
210
-            'url'    => Endpoint::TELEMATICS_CONNECTION,
211
-            'method' => 'DELETE',
212
-            'query'  => [
213
-                    'api_token'         => $apiToken,
214
-                    'connection_token'  => $connectionToken
215
-                ],
216
-        ]);
209
+		$result = Route4Me::makeRequst([
210
+			'url'    => Endpoint::TELEMATICS_CONNECTION,
211
+			'method' => 'DELETE',
212
+			'query'  => [
213
+					'api_token'         => $apiToken,
214
+					'connection_token'  => $connectionToken
215
+				],
216
+		]);
217 217
 
218
-        return $result;
219
-    }
218
+		return $result;
219
+	}
220 220
 
221
-    /**
222
-     * Get all telematics connections.
223
-     * @param $apiToken string : API token
224
-     * @return array Array of the TelematicsConnection type objects
225
-     * @throws \Route4Me\Exception\ApiError
226
-     */
227
-    public function getTelematicsConnections($apiToken)
228
-    {
229
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
221
+	/**
222
+	 * Get all telematics connections.
223
+	 * @param $apiToken string : API token
224
+	 * @return array Array of the TelematicsConnection type objects
225
+	 * @throws \Route4Me\Exception\ApiError
226
+	 */
227
+	public function getTelematicsConnections($apiToken)
228
+	{
229
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
230 230
 
231
-        $result = Route4Me::makeRequst([
232
-            'url'    => Endpoint::TELEMATICS_CONNECTION,
233
-            'method' => 'GET',
234
-            'query'  => [
235
-                'api_token' => $apiToken
236
-            ],
237
-        ]);
231
+		$result = Route4Me::makeRequst([
232
+			'url'    => Endpoint::TELEMATICS_CONNECTION,
233
+			'method' => 'GET',
234
+			'query'  => [
235
+				'api_token' => $apiToken
236
+			],
237
+		]);
238 238
 
239
-        return $result;
240
-    }
239
+		return $result;
240
+	}
241 241
 
242
-    /**
243
-     * Get a telematics connection
244
-     * @param $apiToken string : API token
245
-     * @param $connectionToken string : connection token
246
-     * @return array Array from a TelematicsConnection type object
247
-     * @throws \Route4Me\Exception\ApiError
248
-     */
249
-    public function getTelematicsConnection($apiToken, $connectionToken)
250
-    {
251
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
242
+	/**
243
+	 * Get a telematics connection
244
+	 * @param $apiToken string : API token
245
+	 * @param $connectionToken string : connection token
246
+	 * @return array Array from a TelematicsConnection type object
247
+	 * @throws \Route4Me\Exception\ApiError
248
+	 */
249
+	public function getTelematicsConnection($apiToken, $connectionToken)
250
+	{
251
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
252 252
 
253
-        $result = Route4Me::makeRequst([
254
-            'url'    => Endpoint::TELEMATICS_CONNECTION,
255
-            'method' => 'GE',
256
-            'query'  => [
257
-                'api_token'         => $apiToken,
258
-                'connection_token'  => $connectionToken
259
-            ],
260
-        ]);
253
+		$result = Route4Me::makeRequst([
254
+			'url'    => Endpoint::TELEMATICS_CONNECTION,
255
+			'method' => 'GE',
256
+			'query'  => [
257
+				'api_token'         => $apiToken,
258
+				'connection_token'  => $connectionToken
259
+			],
260
+		]);
261 261
 
262
-        return $result;
263
-    }
262
+		return $result;
263
+	}
264 264
 
265
-    /**
266
-     * Update telematics connection
267
-     * @param $apiToken string : API token
268
-     * @param $connectionToken string : connection token
269
-     * @param $teleConParams TelematicsConnectionParameters : Telematics connection parameters
270
-     * @return array Array from a TelematicsConnection type object
271
-     * @throws \Route4Me\Exception\ApiError
272
-     */
273
-    public function updateTelematicsConnection($apiToken, $connectionToken, $teleConParams)
274
-    {
275
-        $excludeFields = ['id', 'connection_token'];
265
+	/**
266
+	 * Update telematics connection
267
+	 * @param $apiToken string : API token
268
+	 * @param $connectionToken string : connection token
269
+	 * @param $teleConParams TelematicsConnectionParameters : Telematics connection parameters
270
+	 * @return array Array from a TelematicsConnection type object
271
+	 * @throws \Route4Me\Exception\ApiError
272
+	 */
273
+	public function updateTelematicsConnection($apiToken, $connectionToken, $teleConParams)
274
+	{
275
+		$excludeFields = ['id', 'connection_token'];
276 276
 
277
-        $allBodyFields = Route4Me::getObjectProperties(new TelematicsConnectionParameters(), $excludeFields);
277
+		$allBodyFields = Route4Me::getObjectProperties(new TelematicsConnectionParameters(), $excludeFields);
278 278
 
279
-        $result = Route4Me::makeRequst([
280
-            'url'    => Endpoint::TELEMATICS_CONNECTION,
281
-            'method' => 'PUT',
282
-            'body'   => Route4Me::generateRequestParameters($allBodyFields, $teleConParams),
283
-            'query'  => ['api_token' => $apiToken, 'connection_token' => $connectionToken],
284
-            'HTTPHEADER'    => 'Content-Type: multipart/form-data',
285
-        ]);
279
+		$result = Route4Me::makeRequst([
280
+			'url'    => Endpoint::TELEMATICS_CONNECTION,
281
+			'method' => 'PUT',
282
+			'body'   => Route4Me::generateRequestParameters($allBodyFields, $teleConParams),
283
+			'query'  => ['api_token' => $apiToken, 'connection_token' => $connectionToken],
284
+			'HTTPHEADER'    => 'Content-Type: multipart/form-data',
285
+		]);
286 286
 
287
-        return $result;
288
-    }
287
+		return $result;
288
+	}
289 289
 }
Please login to merge, or discard this patch.
src/Route4Me/TelematicsGateway/TelematicsVendorResponse.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
  */
9 9
 class TelematicsVendorResponse extends Common
10 10
 {
11
-    /**
12
-     * Telematics Vendor
13
-     * @var type TelematicsVendor
14
-     */
15
-    public $vendor;
11
+	/**
12
+	 * Telematics Vendor
13
+	 * @var type TelematicsVendor
14
+	 */
15
+	public $vendor;
16 16
 }
Please login to merge, or discard this patch.