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 ( d9a634...e591c7 )
by Juan Jose
07:17 queued 16s
created
src/Route4Me/V5/Addresses/GeoPoint.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,13 +10,13 @@
 block discarded – undo
10 10
  */
11 11
 class GeoPoint extends \Route4Me\Common
12 12
 {
13
-    /** Latitude
14
-     * @var double $lat
15
-     */
16
-    public $lat;
13
+	/** Latitude
14
+	 * @var double $lat
15
+	 */
16
+	public $lat;
17 17
 
18
-    /** Longitude
19
-     * @var double $lng
20
-     */
21
-    public $lng;
18
+	/** Longitude
19
+	 * @var double $lng
20
+	 */
21
+	public $lng;
22 22
 }
23 23
\ No newline at end of file
Please login to merge, or discard this patch.
src/Route4Me/V5/Addresses/OverrideAddresses.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,21 +11,21 @@
 block discarded – undo
11 11
  */
12 12
 class OverrideAddresses
13 13
 {
14
-    /**
15
-     * The service time specified or all the addresses in the route.
16
-     * @var long
17
-     */
18
-    public $time;
14
+	/**
15
+	 * The service time specified or all the addresses in the route.
16
+	 * @var long
17
+	 */
18
+	public $time;
19 19
 
20
-    /**
21
-     * Route address stop type
22
-     * @var string
23
-     */
24
-    public $address_stop_type;
20
+	/**
21
+	 * Route address stop type
22
+	 * @var string
23
+	 */
24
+	public $address_stop_type;
25 25
 
26
-    /**
27
-     * The address group
28
-     * @var string
29
-     */
30
-    public $group;
26
+	/**
27
+	 * The address group
28
+	 * @var string
29
+	 */
30
+	public $group;
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
src/Route4Me/V5/Vehicles/DataTypes/VehicleProfile.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
         //$vehicleProfileID = isset($params['vehicle_profile_id']) ? $params['vehicle_profile_id'] : null;
194 194
 
195 195
         $response = Route4Me::makeRequst([
196
-            'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId,
196
+            'url' => Endpoint::VehicleProfiles.'/'.$vehicleProfileId,
197 197
             'method' => 'DELETE',
198 198
             'HTTPHEADER' => 'Content-Type: application/json; Accept: application/json',
199 199
         ]);
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
     public function getVehicleProfileById($vehicleProfileId)
243 243
     {
244 244
         $response = Route4Me::makeRequst([
245
-            'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId,
245
+            'url' => Endpoint::VehicleProfiles.'/'.$vehicleProfileId,
246 246
             'method' => 'GET',
247 247
         ]);
248 248
 
Please login to merge, or discard this patch.
Indentation   +254 added lines, -254 removed lines patch added patch discarded remove patch
@@ -15,258 +15,258 @@
 block discarded – undo
15 15
  */
16 16
 class VehicleProfile extends Common
17 17
 {
18
-    /** Vehicle profile ID
19
-     * @var integer $vehicle_profile_id
20
-     */
21
-    public $vehicle_profile_id;
22
-
23
-    /** Root member ID
24
-     * @var integer $root_member_id
25
-     */
26
-    public $root_member_id;
27
-
28
-    /** Vehicle profile name
29
-     * @var string $name
30
-     */
31
-    public $name;
32
-
33
-    /** Vehicle height
34
-     * @var float $height
35
-     */
36
-    public $height;
37
-
38
-    /** Vehicle width
39
-     * @var float $width
40
-     */
41
-    public $width;
42
-
43
-    /** Vehicle length
44
-     * @var float $length
45
-     */
46
-    public $length;
47
-
48
-    /** Vehicle weight
49
-     * @var float $weight
50
-     */
51
-    public $weight;
52
-
53
-    /** Maximum weight per axle.
54
-     * @var float $max_weight_per_axle
55
-     */
56
-    public $max_weight_per_axle;
57
-
58
-    /** When the profile deleted
59
-     * @var string $deleted_at
60
-     */
61
-    public $deleted_at;
62
-
63
-    /** When the profile created
64
-     * @var string $created_at
65
-     */
66
-    public $created_at;
67
-
68
-    /** When the profile updated
69
-     * @var string $updated_at
70
-     */
71
-    public $updated_at;
72
-
73
-    /** A type of the fuel
74
-     * enum: ['unleaded 87','unleaded 89','unleaded 91',
75
-     * 'unleaded 93','diesel','electric','hybrid']
76
-     * @var string $fuel_type
77
-     */
78
-    public $fuel_type;
79
-
80
-    /** Fuel consumption city
81
-     * @var float $fuel_consumption_city
82
-     */
83
-    public $fuel_consumption_city;
84
-
85
-    /** Fuel consumption in the highway area
86
-     * @var float $fuel_consumption_highway
87
-     */
88
-    public $fuel_consumption_highway;
89
-
90
-    /** Type of a hazardous material.
91
-     * enum: ['general', 'explosives', 'flammable', 'inhalants', 'caustic', 'radioactive']
92
-     * @var string $hazmat_type
93
-     */
94
-    public $hazmat_type;
95
-
96
-    /** If true, the profile is predefined.
97
-     * @var boolean $is_predefined
98
-     */
99
-    public $is_predefined;
100
-
101
-    /** If true, the profile is default.
102
-     * @var boolean $is_default
103
-     */
104
-    public $is_default;
105
-
106
-    /** Height units (e.g. 'ft', 'm')
107
-     * @var string $height_units
108
-     */
109
-    public $height_units;
110
-
111
-    /** Width units (e.g. 'ft', 'm')
112
-     * @var string $width_units
113
-     */
114
-    public $width_units;
115
-
116
-    /** Length units (e.g. 'ft', 'm')
117
-     * @var string $length_units
118
-     */
119
-    public $length_units;
120
-
121
-    /** Weight units (e.g. 'lb', 'kg')
122
-     * @var string $weight_units
123
-     */
124
-    public $weight_units;
125
-
126
-    /** Maximum weight per axle units (e.g. 'lb', 'kg')
127
-     * @var string $max_weight_per_axle_units
128
-     */
129
-    public $max_weight_per_axle_units;
130
-
131
-    /** Fuel consumption units in the city area (e.g. mpg)
132
-     * @var string $fuel_consumption_city_unit
133
-     */
134
-    public $fuel_consumption_city_unit;
135
-
136
-    /** Fuel consumption units in the highway area (e.g. mpg)
137
-     * @var string $fuel_consumption_highway_unit
138
-     */
139
-    public $fuel_consumption_highway_unit;
140
-
141
-    /** Height UF value (e.g. "7'")
142
-     * @var string $height_uf_value
143
-     */
144
-    public $height_uf_value;
145
-
146
-    /** Width UF value (e.g. "8'")
147
-     * @var string $width_uf_value
148
-     */
149
-    public $width_uf_value;
150
-
151
-    /** Length UF value (e.g. "20'")
152
-     * @var string $length_uf_value
153
-     */
154
-    public $length_uf_value;
155
-
156
-    /** Weight UF value (e.g. "8,500lb")
157
-     * @var string $weight_uf_value
158
-     */
159
-    public $weight_uf_value;
160
-
161
-    /** Maximum weight per axle (UF value, e.g. "8,500lb")
162
-     * @var string $max_weight_per_axle_uf_value
163
-     */
164
-    public $max_weight_per_axle_uf_value;
165
-
166
-    /** Fuel consumption city (UF value, e.g. "20.01 mi/l")
167
-     * @var string $fuel_consumption_city_uf_value
168
-     */
169
-    public $fuel_consumption_city_uf_value;
170
-
171
-    /** Fuel consumption highway (UF value, e.g. "2,000.01 mpg")
172
-     * @var string $fuel_consumption_highway_uf_value
173
-     */
174
-    public $fuel_consumption_highway_uf_value;
175
-
176
-    public static function fromArray(array $params)
177
-    {
178
-        $vehicleProfile = new self();
179
-
180
-        foreach ($params as $key => $value) {
181
-            if (is_null(Common::getValue($params, $key))) {
182
-                continue;
183
-            }
184
-            if (property_exists($vehicleProfile, $key)) {
185
-                $vehicleProfile->$key = $value;
186
-            }
187
-        }
188
-
189
-        return $vehicleProfile;
190
-    }
191
-
192
-    public function __construct()
193
-    {
194
-        Route4Me::setBaseUrl("");
195
-    }
196
-
197
-    public function removeVehicleProfile($vehicleProfileId)
198
-    {
199
-        //$vehicleProfileID = isset($params['vehicle_profile_id']) ? $params['vehicle_profile_id'] : null;
200
-
201
-        $response = Route4Me::makeRequst([
202
-            'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId,
203
-            'method' => 'DELETE',
204
-            'HTTPHEADER' => 'Content-Type: application/json; Accept: application/json',
205
-        ]);
206
-
207
-        return $response;
208
-    }
209
-
210
-    /**
211
-     * @param  $profileParams - an array from the VehicleParameters object.
212
-     * @return array          - an array of parameters of the vehicle profiles.
213
-     * @throws \Route4Me\Exception\ApiError
214
-     */
215
-    public function getVehicleProfiles($profileParams)
216
-    {
217
-        $allQueryFields = ['with_pagination', 'page', 'perPage'];
218
-
219
-        $response = Route4Me::makeRequst([
220
-            'url' => Endpoint::VehicleProfiles,
221
-            'method' => 'GET',
222
-            'query' => Route4Me::generateRequestParameters($allQueryFields, $profileParams),
223
-        ]);
224
-
225
-        return $response;
226
-    }
227
-
228
-    /**
229
-     * @param $profileParams - Vehicle profile body parameters
230
-     * @return array         - Created vehicle profile
231
-     * @throws \Route4Me\Exception\ApiError
232
-     */
233
-    public function createVehicleProfile($profileParams)
234
-    {
235
-        $excludeFields = [];
236
-        $allBodyFields = Route4Me::getObjectProperties(new VehicleProfile(), $excludeFields);
237
-
238
-        $response = Route4Me::makeRequst([
239
-            'url' => Endpoint::VehicleProfiles,
240
-            'method' => 'POST',
241
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $profileParams),
242
-            'HTTPHEADERS' => ['Content-Type: application/json', 'Accept: application/json']
243
-        ]);
244
-
245
-        return $response;
246
-    }
247
-
248
-    public function getVehicleProfileById($vehicleProfileId)
249
-    {
250
-        $response = Route4Me::makeRequst([
251
-            'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId,
252
-            'method' => 'GET',
253
-        ]);
254
-
255
-        return $response;
256
-    }
257
-
258
-    public function updateVehicleProfile($vehicleProfile)
259
-    {
260
-        $excludeFields = ['vehicle_profile_id', 'deleted_at', 'created_at', 'updated_at'];
261
-        $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields);
262
-
263
-        $response = Route4Me::makeRequst([
264
-            'url' => Endpoint::VehicleProfiles.'/'.$vehicleProfile['vehicle_profile_id'],
265
-            'method' => 'PATCH',
266
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleProfile),
267
-            'HTTPHEADER' => 'Content-Type: application/json'
268
-        ]);
269
-
270
-        return $response;
271
-    }
18
+	/** Vehicle profile ID
19
+	 * @var integer $vehicle_profile_id
20
+	 */
21
+	public $vehicle_profile_id;
22
+
23
+	/** Root member ID
24
+	 * @var integer $root_member_id
25
+	 */
26
+	public $root_member_id;
27
+
28
+	/** Vehicle profile name
29
+	 * @var string $name
30
+	 */
31
+	public $name;
32
+
33
+	/** Vehicle height
34
+	 * @var float $height
35
+	 */
36
+	public $height;
37
+
38
+	/** Vehicle width
39
+	 * @var float $width
40
+	 */
41
+	public $width;
42
+
43
+	/** Vehicle length
44
+	 * @var float $length
45
+	 */
46
+	public $length;
47
+
48
+	/** Vehicle weight
49
+	 * @var float $weight
50
+	 */
51
+	public $weight;
52
+
53
+	/** Maximum weight per axle.
54
+	 * @var float $max_weight_per_axle
55
+	 */
56
+	public $max_weight_per_axle;
57
+
58
+	/** When the profile deleted
59
+	 * @var string $deleted_at
60
+	 */
61
+	public $deleted_at;
62
+
63
+	/** When the profile created
64
+	 * @var string $created_at
65
+	 */
66
+	public $created_at;
67
+
68
+	/** When the profile updated
69
+	 * @var string $updated_at
70
+	 */
71
+	public $updated_at;
72
+
73
+	/** A type of the fuel
74
+	 * enum: ['unleaded 87','unleaded 89','unleaded 91',
75
+	 * 'unleaded 93','diesel','electric','hybrid']
76
+	 * @var string $fuel_type
77
+	 */
78
+	public $fuel_type;
79
+
80
+	/** Fuel consumption city
81
+	 * @var float $fuel_consumption_city
82
+	 */
83
+	public $fuel_consumption_city;
84
+
85
+	/** Fuel consumption in the highway area
86
+	 * @var float $fuel_consumption_highway
87
+	 */
88
+	public $fuel_consumption_highway;
89
+
90
+	/** Type of a hazardous material.
91
+	 * enum: ['general', 'explosives', 'flammable', 'inhalants', 'caustic', 'radioactive']
92
+	 * @var string $hazmat_type
93
+	 */
94
+	public $hazmat_type;
95
+
96
+	/** If true, the profile is predefined.
97
+	 * @var boolean $is_predefined
98
+	 */
99
+	public $is_predefined;
100
+
101
+	/** If true, the profile is default.
102
+	 * @var boolean $is_default
103
+	 */
104
+	public $is_default;
105
+
106
+	/** Height units (e.g. 'ft', 'm')
107
+	 * @var string $height_units
108
+	 */
109
+	public $height_units;
110
+
111
+	/** Width units (e.g. 'ft', 'm')
112
+	 * @var string $width_units
113
+	 */
114
+	public $width_units;
115
+
116
+	/** Length units (e.g. 'ft', 'm')
117
+	 * @var string $length_units
118
+	 */
119
+	public $length_units;
120
+
121
+	/** Weight units (e.g. 'lb', 'kg')
122
+	 * @var string $weight_units
123
+	 */
124
+	public $weight_units;
125
+
126
+	/** Maximum weight per axle units (e.g. 'lb', 'kg')
127
+	 * @var string $max_weight_per_axle_units
128
+	 */
129
+	public $max_weight_per_axle_units;
130
+
131
+	/** Fuel consumption units in the city area (e.g. mpg)
132
+	 * @var string $fuel_consumption_city_unit
133
+	 */
134
+	public $fuel_consumption_city_unit;
135
+
136
+	/** Fuel consumption units in the highway area (e.g. mpg)
137
+	 * @var string $fuel_consumption_highway_unit
138
+	 */
139
+	public $fuel_consumption_highway_unit;
140
+
141
+	/** Height UF value (e.g. "7'")
142
+	 * @var string $height_uf_value
143
+	 */
144
+	public $height_uf_value;
145
+
146
+	/** Width UF value (e.g. "8'")
147
+	 * @var string $width_uf_value
148
+	 */
149
+	public $width_uf_value;
150
+
151
+	/** Length UF value (e.g. "20'")
152
+	 * @var string $length_uf_value
153
+	 */
154
+	public $length_uf_value;
155
+
156
+	/** Weight UF value (e.g. "8,500lb")
157
+	 * @var string $weight_uf_value
158
+	 */
159
+	public $weight_uf_value;
160
+
161
+	/** Maximum weight per axle (UF value, e.g. "8,500lb")
162
+	 * @var string $max_weight_per_axle_uf_value
163
+	 */
164
+	public $max_weight_per_axle_uf_value;
165
+
166
+	/** Fuel consumption city (UF value, e.g. "20.01 mi/l")
167
+	 * @var string $fuel_consumption_city_uf_value
168
+	 */
169
+	public $fuel_consumption_city_uf_value;
170
+
171
+	/** Fuel consumption highway (UF value, e.g. "2,000.01 mpg")
172
+	 * @var string $fuel_consumption_highway_uf_value
173
+	 */
174
+	public $fuel_consumption_highway_uf_value;
175
+
176
+	public static function fromArray(array $params)
177
+	{
178
+		$vehicleProfile = new self();
179
+
180
+		foreach ($params as $key => $value) {
181
+			if (is_null(Common::getValue($params, $key))) {
182
+				continue;
183
+			}
184
+			if (property_exists($vehicleProfile, $key)) {
185
+				$vehicleProfile->$key = $value;
186
+			}
187
+		}
188
+
189
+		return $vehicleProfile;
190
+	}
191
+
192
+	public function __construct()
193
+	{
194
+		Route4Me::setBaseUrl("");
195
+	}
196
+
197
+	public function removeVehicleProfile($vehicleProfileId)
198
+	{
199
+		//$vehicleProfileID = isset($params['vehicle_profile_id']) ? $params['vehicle_profile_id'] : null;
200
+
201
+		$response = Route4Me::makeRequst([
202
+			'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId,
203
+			'method' => 'DELETE',
204
+			'HTTPHEADER' => 'Content-Type: application/json; Accept: application/json',
205
+		]);
206
+
207
+		return $response;
208
+	}
209
+
210
+	/**
211
+	 * @param  $profileParams - an array from the VehicleParameters object.
212
+	 * @return array          - an array of parameters of the vehicle profiles.
213
+	 * @throws \Route4Me\Exception\ApiError
214
+	 */
215
+	public function getVehicleProfiles($profileParams)
216
+	{
217
+		$allQueryFields = ['with_pagination', 'page', 'perPage'];
218
+
219
+		$response = Route4Me::makeRequst([
220
+			'url' => Endpoint::VehicleProfiles,
221
+			'method' => 'GET',
222
+			'query' => Route4Me::generateRequestParameters($allQueryFields, $profileParams),
223
+		]);
224
+
225
+		return $response;
226
+	}
227
+
228
+	/**
229
+	 * @param $profileParams - Vehicle profile body parameters
230
+	 * @return array         - Created vehicle profile
231
+	 * @throws \Route4Me\Exception\ApiError
232
+	 */
233
+	public function createVehicleProfile($profileParams)
234
+	{
235
+		$excludeFields = [];
236
+		$allBodyFields = Route4Me::getObjectProperties(new VehicleProfile(), $excludeFields);
237
+
238
+		$response = Route4Me::makeRequst([
239
+			'url' => Endpoint::VehicleProfiles,
240
+			'method' => 'POST',
241
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $profileParams),
242
+			'HTTPHEADERS' => ['Content-Type: application/json', 'Accept: application/json']
243
+		]);
244
+
245
+		return $response;
246
+	}
247
+
248
+	public function getVehicleProfileById($vehicleProfileId)
249
+	{
250
+		$response = Route4Me::makeRequst([
251
+			'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId,
252
+			'method' => 'GET',
253
+		]);
254
+
255
+		return $response;
256
+	}
257
+
258
+	public function updateVehicleProfile($vehicleProfile)
259
+	{
260
+		$excludeFields = ['vehicle_profile_id', 'deleted_at', 'created_at', 'updated_at'];
261
+		$allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields);
262
+
263
+		$response = Route4Me::makeRequst([
264
+			'url' => Endpoint::VehicleProfiles.'/'.$vehicleProfile['vehicle_profile_id'],
265
+			'method' => 'PATCH',
266
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleProfile),
267
+			'HTTPHEADER' => 'Content-Type: application/json'
268
+		]);
269
+
270
+		return $response;
271
+	}
272 272
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/DataObjectBase.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,33 +6,33 @@
 block discarded – undo
6 6
 
7 7
 class DataObjectBase extends \Route4Me\Common
8 8
 {
9
-    /** @var string $optimization_problem_id
10
-     * Optimization problem ID
11
-     */
12
-    public $optimization_problem_id;
13
-
14
-    /** @var string $smart_optimization_id
15
-     * Smart Optimization Problem ID
16
-     */
17
-    public $smart_optimization_id;
18
-
19
-    /** @var long $created_timestamp
20
-     * When the optimization problem was created.
21
-     */
22
-    public $created_timestamp;
23
-
24
-    /** @var RouteParameters $parameters
25
-     * Route Parameters.
26
-     */
27
-    public $parameters = [];
28
-
29
-    /** @var Address[] $addresses
30
-     * An array ot the Address type objects.
31
-     */
32
-    public $addresses = [];
33
-
34
-    /** @var string[] $links
35
-     * The links to the GET operations for the optimization problem.
36
-     */
37
-    public $links = [];
9
+	/** @var string $optimization_problem_id
10
+	 * Optimization problem ID
11
+	 */
12
+	public $optimization_problem_id;
13
+
14
+	/** @var string $smart_optimization_id
15
+	 * Smart Optimization Problem ID
16
+	 */
17
+	public $smart_optimization_id;
18
+
19
+	/** @var long $created_timestamp
20
+	 * When the optimization problem was created.
21
+	 */
22
+	public $created_timestamp;
23
+
24
+	/** @var RouteParameters $parameters
25
+	 * Route Parameters.
26
+	 */
27
+	public $parameters = [];
28
+
29
+	/** @var Address[] $addresses
30
+	 * An array ot the Address type objects.
31
+	 */
32
+	public $addresses = [];
33
+
34
+	/** @var string[] $links
35
+	 * The links to the GET operations for the optimization problem.
36
+	 */
37
+	public $links = [];
38 38
 }
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
src/Route4Me/OptimizationProblemParams.php 2 patches
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -6,131 +6,131 @@
 block discarded – undo
6 6
 
7 7
 class OptimizationProblemParams extends Common
8 8
 {
9
-    public $optimization_problem_id;
10
-    public $reoptimize;
11
-    public $addresses = [];
12
-    public $depots = [];
13
-    public $parameters;
14
-    public $directions;
15
-    public $format;
16
-    public $route_path_output;
17
-    public $optimized_callback_url;
18
-    public $redirect = true;
19
-
20
-    public static function fromArray($params)
21
-    {
22
-        $param = new self();
23
-        if (!isset($params['addresses'])) {
24
-            throw new BadParam('addresses must be provided.');
25
-        }
26
-
27
-        if (!isset($params['parameters'])) {
28
-            throw new BadParam('parameters must be provided.');
29
-        }
30
-
31
-        if ($params['parameters'] instanceof RouteParameters) {
32
-            $param->setParameters($params['parameters']);
33
-        } else {
34
-            $param->setParameters(RouteParameters::fromArray($params['parameters']));
35
-        }
36
-
37
-        foreach ($params['addresses'] as $address) {
38
-            if (!($address instanceof Address)) {
39
-                $address = Address::fromArray($address);
40
-            }
41
-
42
-            $param->addAddress($address);
43
-        }
44
-
45
-        if (isset($params['depots'] )) {
46
-            foreach ($params['depots'] as $depot) {
47
-                if (!($depot instanceof Address)) {
48
-                    $depot = Address::fromArray($depot);
49
-                }
50
-
51
-                $param->addAddress($address);
52
-            }
53
-        }
54
-
55
-        $param->directions = self::getValue($params, 'directions');
56
-        $param->format = self::getValue($params, 'format');
57
-        $param->route_path_output = self::getValue($params, 'route_path_output');
58
-        $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url');
59
-        $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id');
60
-        $param->reoptimize = self::getValue($params, 'reoptimize');
61
-        $param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN);
62
-
63
-        return $param;
64
-    }
65
-
66
-    public function __construct()
67
-    {
68
-        $this->parameters = new RouteParameters();
69
-    }
70
-
71
-    public function setParameters(RouteParameters $params)
72
-    {
73
-        $this->parameters = $params;
74
-
75
-        return $this;
76
-    }
77
-
78
-    public function addAddress(Address $address)
79
-    {
80
-        $this->addresses[] = $address;
81
-
82
-        return $this;
83
-    }
84
-
85
-    public function addDepot(Address $depot)
86
-    {
87
-        $this->depots[] = $depot;
88
-
89
-        return $this;
90
-    }
91
-
92
-    public function getAddressesArray()
93
-    {
94
-        $addresses = [];
95
-
96
-        foreach ($this->addresses as $address) {
97
-            $addresses[] = $address->toArray();
98
-        }
99
-
100
-        return $addresses;
101
-    }
102
-
103
-    public function getDepotsArray()
104
-    {
105
-        $depots = [];
106
-
107
-        foreach ($this->depots as $depot) {
108
-            $depots[] = $depot->toArray();
109
-        }
110
-
111
-        return $depots;
112
-    }
113
-
114
-    public function getParametersArray()
115
-    {
116
-        return $this->parameters->toArray();
117
-    }
118
-
119
-    public function setAddresses(array $addresses)
120
-    {
121
-        foreach ($addresses as $address) {
122
-            $this->addAddress($address);
123
-        }
124
-
125
-        return $this;
126
-    }
127
-
128
-    public function setDepots(array $depots)
129
-    {
130
-        foreach ($depots as $depot) {
131
-            $this->addDepot($depot);
132
-        }
133
-
134
-        return $this;
135
-    }
9
+	public $optimization_problem_id;
10
+	public $reoptimize;
11
+	public $addresses = [];
12
+	public $depots = [];
13
+	public $parameters;
14
+	public $directions;
15
+	public $format;
16
+	public $route_path_output;
17
+	public $optimized_callback_url;
18
+	public $redirect = true;
19
+
20
+	public static function fromArray($params)
21
+	{
22
+		$param = new self();
23
+		if (!isset($params['addresses'])) {
24
+			throw new BadParam('addresses must be provided.');
25
+		}
26
+
27
+		if (!isset($params['parameters'])) {
28
+			throw new BadParam('parameters must be provided.');
29
+		}
30
+
31
+		if ($params['parameters'] instanceof RouteParameters) {
32
+			$param->setParameters($params['parameters']);
33
+		} else {
34
+			$param->setParameters(RouteParameters::fromArray($params['parameters']));
35
+		}
36
+
37
+		foreach ($params['addresses'] as $address) {
38
+			if (!($address instanceof Address)) {
39
+				$address = Address::fromArray($address);
40
+			}
41
+
42
+			$param->addAddress($address);
43
+		}
44
+
45
+		if (isset($params['depots'] )) {
46
+			foreach ($params['depots'] as $depot) {
47
+				if (!($depot instanceof Address)) {
48
+					$depot = Address::fromArray($depot);
49
+				}
50
+
51
+				$param->addAddress($address);
52
+			}
53
+		}
54
+
55
+		$param->directions = self::getValue($params, 'directions');
56
+		$param->format = self::getValue($params, 'format');
57
+		$param->route_path_output = self::getValue($params, 'route_path_output');
58
+		$param->optimized_callback_url = self::getValue($params, 'optimized_callback_url');
59
+		$param->optimization_problem_id = self::getValue($params, 'optimization_problem_id');
60
+		$param->reoptimize = self::getValue($params, 'reoptimize');
61
+		$param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN);
62
+
63
+		return $param;
64
+	}
65
+
66
+	public function __construct()
67
+	{
68
+		$this->parameters = new RouteParameters();
69
+	}
70
+
71
+	public function setParameters(RouteParameters $params)
72
+	{
73
+		$this->parameters = $params;
74
+
75
+		return $this;
76
+	}
77
+
78
+	public function addAddress(Address $address)
79
+	{
80
+		$this->addresses[] = $address;
81
+
82
+		return $this;
83
+	}
84
+
85
+	public function addDepot(Address $depot)
86
+	{
87
+		$this->depots[] = $depot;
88
+
89
+		return $this;
90
+	}
91
+
92
+	public function getAddressesArray()
93
+	{
94
+		$addresses = [];
95
+
96
+		foreach ($this->addresses as $address) {
97
+			$addresses[] = $address->toArray();
98
+		}
99
+
100
+		return $addresses;
101
+	}
102
+
103
+	public function getDepotsArray()
104
+	{
105
+		$depots = [];
106
+
107
+		foreach ($this->depots as $depot) {
108
+			$depots[] = $depot->toArray();
109
+		}
110
+
111
+		return $depots;
112
+	}
113
+
114
+	public function getParametersArray()
115
+	{
116
+		return $this->parameters->toArray();
117
+	}
118
+
119
+	public function setAddresses(array $addresses)
120
+	{
121
+		foreach ($addresses as $address) {
122
+			$this->addAddress($address);
123
+		}
124
+
125
+		return $this;
126
+	}
127
+
128
+	public function setDepots(array $depots)
129
+	{
130
+		foreach ($depots as $depot) {
131
+			$this->addDepot($depot);
132
+		}
133
+
134
+		return $this;
135
+	}
136 136
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
             $param->addAddress($address);
43 43
         }
44 44
 
45
-        if (isset($params['depots'] )) {
45
+        if (isset($params['depots'])) {
46 46
             foreach ($params['depots'] as $depot) {
47 47
                 if (!($depot instanceof Address)) {
48 48
                     $depot = Address::fromArray($depot);
Please login to merge, or discard this patch.
src/Route4Me/Common.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@
 block discarded – undo
11 11
 
12 12
     public function toArray()
13 13
     {
14
-        $params = array_filter(get_object_vars($this), function ($item) {
15
-            return (null !== $item) && !(is_array($item) && !count($item));
14
+        $params = array_filter(get_object_vars($this), function($item) {
15
+            return (null!==$item) && !(is_array($item) && !count($item));
16 16
         });
17 17
 
18 18
         return $params;
Please login to merge, or discard this patch.
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -4,37 +4,37 @@
 block discarded – undo
4 4
 
5 5
 class Common
6 6
 {
7
-    public static function getValue($array, $item, $default = null)
8
-    {
9
-        return (isset($array[$item])) ? $array[$item] : $default;
10
-    }
7
+	public static function getValue($array, $item, $default = null)
8
+	{
9
+		return (isset($array[$item])) ? $array[$item] : $default;
10
+	}
11 11
 
12
-    public function toArray()
13
-    {
14
-        $params = array_filter(get_object_vars($this), function ($item) {
15
-            return (null !== $item) && !(is_array($item) && !count($item));
16
-        });
12
+	public function toArray()
13
+	{
14
+		$params = array_filter(get_object_vars($this), function ($item) {
15
+			return (null !== $item) && !(is_array($item) && !count($item));
16
+		});
17 17
 
18
-        return $params;
19
-    }
18
+		return $params;
19
+	}
20 20
 
21
-    protected function fillFromArray(array $params)
22
-    {
23
-        foreach ($this as $key => $value) {
24
-            if (isset($params[$key])) {
25
-                $this->{$key} = $params[$key];
26
-            }
27
-        }
28
-    }
21
+	protected function fillFromArray(array $params)
22
+	{
23
+		foreach ($this as $key => $value) {
24
+			if (isset($params[$key])) {
25
+				$this->{$key} = $params[$key];
26
+			}
27
+		}
28
+	}
29 29
 
30
-    public static function fromArray(array $params)
31
-    {
32
-        $_this = new static;
33
-        foreach ($params as $key => $value) {
34
-            if (property_exists($_this, $key)) {
35
-                $_this->{$key} = $value;
36
-            }
37
-        }
38
-        return $_this;
39
-    }
30
+	public static function fromArray(array $params)
31
+	{
32
+		$_this = new static;
33
+		foreach ($params as $key => $value) {
34
+			if (property_exists($_this, $key)) {
35
+				$_this->{$key} = $value;
36
+			}
37
+		}
38
+		return $_this;
39
+	}
40 40
 }
Please login to merge, or discard this patch.
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/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/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.