@@ -7,8 +7,8 @@ |
||
7 | 7 | |
8 | 8 | class DataVehicle extends Common |
9 | 9 | { |
10 | - /** Reduced vehicle object |
|
11 | - * @var VehicleReduced $vehicle |
|
12 | - */ |
|
13 | - public $vehicle = []; |
|
10 | + /** Reduced vehicle object |
|
11 | + * @var VehicleReduced $vehicle |
|
12 | + */ |
|
13 | + public $vehicle = []; |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -12,27 +12,27 @@ |
||
12 | 12 | */ |
13 | 13 | class VehicleOrderResponse extends Common |
14 | 14 | { |
15 | - /** Vehicle ID |
|
16 | - * @var string $vehicle_id |
|
17 | - */ |
|
18 | - public $vehicle_id; |
|
19 | - |
|
20 | - /** Order ID |
|
21 | - * @var integer $order_id |
|
22 | - */ |
|
23 | - public $order_id; |
|
24 | - |
|
25 | - public static function fromArray(array $params) |
|
26 | - { |
|
27 | - $ordParams = new self(); |
|
28 | - |
|
29 | - foreach ($params as $key => $value) { |
|
30 | - if (is_null(Common::getValue($params, $key))) continue; |
|
31 | - if (property_exists($ordParams, $key)) { |
|
32 | - $ordParams->$key = $value; |
|
33 | - } |
|
34 | - } |
|
35 | - |
|
36 | - return $ordParams; |
|
37 | - } |
|
15 | + /** Vehicle ID |
|
16 | + * @var string $vehicle_id |
|
17 | + */ |
|
18 | + public $vehicle_id; |
|
19 | + |
|
20 | + /** Order ID |
|
21 | + * @var integer $order_id |
|
22 | + */ |
|
23 | + public $order_id; |
|
24 | + |
|
25 | + public static function fromArray(array $params) |
|
26 | + { |
|
27 | + $ordParams = new self(); |
|
28 | + |
|
29 | + foreach ($params as $key => $value) { |
|
30 | + if (is_null(Common::getValue($params, $key))) continue; |
|
31 | + if (property_exists($ordParams, $key)) { |
|
32 | + $ordParams->$key = $value; |
|
33 | + } |
|
34 | + } |
|
35 | + |
|
36 | + return $ordParams; |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -27,7 +27,9 @@ |
||
27 | 27 | $ordParams = new self(); |
28 | 28 | |
29 | 29 | foreach ($params as $key => $value) { |
30 | - if (is_null(Common::getValue($params, $key))) continue; |
|
30 | + if (is_null(Common::getValue($params, $key))) { |
|
31 | + continue; |
|
32 | + } |
|
31 | 33 | if (property_exists($ordParams, $key)) { |
32 | 34 | $ordParams->$key = $value; |
33 | 35 | } |
@@ -12,42 +12,42 @@ |
||
12 | 12 | */ |
13 | 13 | class VehicleTemporary extends Common |
14 | 14 | { |
15 | - /** The vehicle ID |
|
16 | - * @var integer $vehicle_id |
|
17 | - */ |
|
18 | - public $vehicle_id; |
|
19 | - |
|
20 | - /** A license plate of the vehicle. |
|
21 | - * @var string $vehicle_license_plate |
|
22 | - */ |
|
23 | - public $vehicle_license_plate; |
|
24 | - |
|
25 | - /** Member ID assigned to the temporary vehicle. |
|
26 | - * @var string $assigned_member_id |
|
27 | - */ |
|
28 | - public $assigned_member_id; |
|
29 | - |
|
30 | - /** An expiration date of the temporary vehicle. |
|
31 | - * @var string $expires_at |
|
32 | - */ |
|
33 | - public $expires_at; |
|
34 | - |
|
35 | - /** If true, an assignment forced. |
|
36 | - * @var boolean $force_assignment |
|
37 | - */ |
|
38 | - public $force_assignment; |
|
39 | - |
|
40 | - public static function fromArray(array $params) |
|
41 | - { |
|
42 | - $vehicleTemp = new self(); |
|
43 | - |
|
44 | - foreach ($params as $key => $value) { |
|
45 | - if (is_null(Common::getValue($params, $key))) continue; |
|
46 | - if (property_exists($vehicleTemp, $key)) { |
|
47 | - $vehicleTemp->$key = $value; |
|
48 | - } |
|
49 | - } |
|
50 | - |
|
51 | - return $vehicleTemp; |
|
52 | - } |
|
15 | + /** The vehicle ID |
|
16 | + * @var integer $vehicle_id |
|
17 | + */ |
|
18 | + public $vehicle_id; |
|
19 | + |
|
20 | + /** A license plate of the vehicle. |
|
21 | + * @var string $vehicle_license_plate |
|
22 | + */ |
|
23 | + public $vehicle_license_plate; |
|
24 | + |
|
25 | + /** Member ID assigned to the temporary vehicle. |
|
26 | + * @var string $assigned_member_id |
|
27 | + */ |
|
28 | + public $assigned_member_id; |
|
29 | + |
|
30 | + /** An expiration date of the temporary vehicle. |
|
31 | + * @var string $expires_at |
|
32 | + */ |
|
33 | + public $expires_at; |
|
34 | + |
|
35 | + /** If true, an assignment forced. |
|
36 | + * @var boolean $force_assignment |
|
37 | + */ |
|
38 | + public $force_assignment; |
|
39 | + |
|
40 | + public static function fromArray(array $params) |
|
41 | + { |
|
42 | + $vehicleTemp = new self(); |
|
43 | + |
|
44 | + foreach ($params as $key => $value) { |
|
45 | + if (is_null(Common::getValue($params, $key))) continue; |
|
46 | + if (property_exists($vehicleTemp, $key)) { |
|
47 | + $vehicleTemp->$key = $value; |
|
48 | + } |
|
49 | + } |
|
50 | + |
|
51 | + return $vehicleTemp; |
|
52 | + } |
|
53 | 53 | } |
54 | 54 | \ No newline at end of file |
@@ -42,7 +42,9 @@ |
||
42 | 42 | $vehicleTemp = new self(); |
43 | 43 | |
44 | 44 | foreach ($params as $key => $value) { |
45 | - if (is_null(Common::getValue($params, $key))) continue; |
|
45 | + if (is_null(Common::getValue($params, $key))) { |
|
46 | + continue; |
|
47 | + } |
|
46 | 48 | if (property_exists($vehicleTemp, $key)) { |
47 | 49 | $vehicleTemp->$key = $value; |
48 | 50 | } |
@@ -18,378 +18,378 @@ |
||
18 | 18 | */ |
19 | 19 | class Vehicle extends Common |
20 | 20 | { |
21 | - /** The vehicle ID |
|
22 | - * @var string $vehicle_id |
|
23 | - */ |
|
24 | - public $vehicle_id; |
|
25 | - |
|
26 | - /** Member ID assigned to the vehicle. |
|
27 | - * @var integer $member_id |
|
28 | - */ |
|
29 | - public $member_id; |
|
30 | - |
|
31 | - /** If true, the vehicle is marked as deleted. |
|
32 | - * @var boolean $is_deleted |
|
33 | - */ |
|
34 | - public $is_deleted; |
|
35 | - |
|
36 | - /** Vehicle alias |
|
37 | - * @var string $vehicle_alias |
|
38 | - */ |
|
39 | - public $vehicle_alias; |
|
40 | - |
|
41 | - /** Vehicle VIN |
|
42 | - * @var string $vehicle_vin |
|
43 | - */ |
|
44 | - public $vehicle_vin; |
|
45 | - |
|
46 | - /** Vehicle registration state ID. |
|
47 | - * @var integer $vehicle_reg_state_id |
|
48 | - */ |
|
49 | - public $vehicle_reg_state_id; |
|
50 | - |
|
51 | - /** Vehicle registration country ID. |
|
52 | - * @var integer $vehicle_reg_country_id |
|
53 | - */ |
|
54 | - public $vehicle_reg_country_id; |
|
55 | - |
|
56 | - /** A license plate of the vehicle. |
|
57 | - * @var string $vehicle_license_plate |
|
58 | - */ |
|
59 | - public $vehicle_license_plate; |
|
60 | - |
|
61 | - /** Vehicle type. |
|
62 | - * <para>Availbale values:</para> |
|
63 | - * sedan', 'suv', 'pickup_truck', 'van', '18wheeler', 'cabin', 'hatchback', |
|
64 | - * '<para>motorcyle', 'waste_disposal', 'tree_cutting', 'bigrig', 'cement_mixer', </para> |
|
65 | - * 'livestock_carrier', 'dairy','tractor_trailer'. |
|
66 | - * @var string $vehicle_type_id |
|
67 | - */ |
|
68 | - public $vehicle_type_id; |
|
69 | - |
|
70 | - /** When the vehicle was added. |
|
71 | - * @var string $timestamp_added |
|
72 | - */ |
|
73 | - public $timestamp_added; |
|
74 | - |
|
75 | - /** Vehicle maker brend. |
|
76 | - * <para>Available values:</para> |
|
77 | - * "american coleman", "bmw", "chevrolet", "ford", "freightliner", "gmc", |
|
78 | - * <para>"hino", "honda", "isuzu", "kenworth", "mack", "mercedes-benz", "mitsubishi", </para> |
|
79 | - * "navistar", "nissan", "peterbilt", "renault", "scania", "sterling", "toyota", |
|
80 | - * <para>"volvo", "western star" </para> |
|
81 | - * </value>" |
|
82 | - * @var string $vehicle_make |
|
83 | - */ |
|
84 | - public $vehicle_make; |
|
85 | - |
|
86 | - /** Vehicle model year |
|
87 | - * @var integer $vehicle_model_year |
|
88 | - */ |
|
89 | - public $vehicle_model_year; |
|
90 | - |
|
91 | - /** Vehicle model |
|
92 | - * @var string $vehicle_model |
|
93 | - */ |
|
94 | - public $vehicle_model; |
|
95 | - |
|
96 | - /** The year, vehicle was acquired |
|
97 | - * @var integer $vehicle_year_acquired |
|
98 | - */ |
|
99 | - public $vehicle_year_acquired; |
|
100 | - |
|
101 | - /** A cost of the new vehicle |
|
102 | - * @var float $vehicle_cost_new |
|
103 | - */ |
|
104 | - public $vehicle_cost_new; |
|
105 | - |
|
106 | - /** If true, the vehicle was purchased new. |
|
107 | - * @var boolean $purchased_new |
|
108 | - */ |
|
109 | - public $purchased_new; |
|
110 | - |
|
111 | - /** Start date of the license |
|
112 | - * @var string $license_start_date |
|
113 | - */ |
|
114 | - public $license_start_date; |
|
115 | - |
|
116 | - /** End date of the license |
|
117 | - * @var string $license_end_date |
|
118 | - */ |
|
119 | - public $license_end_date; |
|
120 | - |
|
121 | - /** If equal to '1', the vehicle is operational. |
|
122 | - * @var boolean $is_operational |
|
123 | - */ |
|
124 | - public $is_operational; |
|
125 | - |
|
126 | - /** A type of the fuel |
|
127 | - * @var string $fuel_type |
|
128 | - * enum: ['unleaded 87','unleaded 89','unleaded 91','unleaded 93','diesel','electric','hybrid'] |
|
129 | - */ |
|
130 | - public $fuel_type; |
|
131 | - |
|
132 | - /** External telematics vehicle IDs |
|
133 | - * @var integer $external_telematics_vehicle_ids |
|
134 | - */ |
|
135 | - public $external_telematics_vehicle_id; |
|
136 | - |
|
137 | - /** When the vehcile was marked as deleted. |
|
138 | - * @var integer $timestamp_removed |
|
139 | - */ |
|
140 | - public $timestamp_removed; |
|
141 | - |
|
142 | - /** Vehicle profile ID |
|
143 | - * @var integer $vehicle_profile_id |
|
144 | - */ |
|
145 | - public $vehicle_profile_id; |
|
146 | - |
|
147 | - /** Fuel consumption city |
|
148 | - * @var float $fuel_consumption_city |
|
149 | - */ |
|
150 | - public $fuel_consumption_city; |
|
151 | - |
|
152 | - /** Fuel consumption in the highway area |
|
153 | - * @var float $fuel_consumption_highway |
|
154 | - */ |
|
155 | - public $fuel_consumption_highway; |
|
156 | - |
|
157 | - /** Fuel consumption units in the city area (e.g. mi/l) |
|
158 | - * @var string $fuel_consumption_city_unit |
|
159 | - */ |
|
160 | - public $fuel_consumption_city_unit; |
|
161 | - |
|
162 | - /** Fuel consumption units in the highway area (e.g. mi/l) |
|
163 | - * @var string $fuel_consumption_highway_unit |
|
164 | - */ |
|
165 | - public $fuel_consumption_highway_unit; |
|
166 | - |
|
167 | - /** Miles per gallon in the city area |
|
168 | - * @var float $mpg_city |
|
169 | - */ |
|
170 | - public $mpg_city; |
|
171 | - |
|
172 | - /** Miles per gallon in the highway area |
|
173 | - * @var float $mpg_highway |
|
174 | - */ |
|
175 | - public $mpg_highway; |
|
176 | - |
|
177 | - /** Fuel consumption UF value in the city area (e.g. '20.01 mi/l') |
|
178 | - * @var string $fuel_consumption_city_uf_value |
|
179 | - */ |
|
180 | - public $fuel_consumption_city_uf_value; |
|
181 | - |
|
182 | - /** Fuel consumption UF value in the highway area (e.g. '2,000.01 mpg') |
|
183 | - * @var string $fuel_consumption_highway_uf_value |
|
184 | - */ |
|
185 | - public $fuel_consumption_highway_uf_value; |
|
186 | - |
|
187 | - public static function fromArray(array $params) |
|
188 | - { |
|
189 | - $vehicle = new self(); |
|
190 | - |
|
191 | - foreach ($params as $key => $value) { |
|
192 | - if (is_null(Common::getValue($params, $key))) continue; |
|
193 | - if (property_exists($vehicle, $key)) { |
|
194 | - $vehicle->$key = $value; |
|
195 | - } |
|
196 | - } |
|
197 | - |
|
198 | - return $vehicle; |
|
199 | - } |
|
200 | - |
|
201 | - public function __construct() |
|
202 | - { |
|
203 | - Route4Me::setBaseUrl(""); |
|
204 | - } |
|
205 | - |
|
206 | - /** Creates a vehicle |
|
207 | - * @param $vehicleParams |
|
208 | - * Returns a vehicle object or failure info. |
|
209 | - */ |
|
210 | - public function createVehicle($vehicleParams) |
|
211 | - { |
|
212 | - $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
213 | - $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
214 | - |
|
215 | - $response = Route4Me::makeRequst([ |
|
216 | - 'url' => Endpoint::Vehicles, |
|
217 | - 'method' => 'POST', |
|
218 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
219 | - 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
220 | - ]); |
|
221 | - |
|
222 | - return $response; |
|
223 | - } |
|
224 | - |
|
225 | - /** Removes a vehicle by specified vehicle ID. |
|
226 | - * @param string $vehicleID - Vehicle ID |
|
227 | - * @return Vehicle object - removed vehicle object. |
|
228 | - * @throws \Route4Me\Exception\ApiError |
|
229 | - */ |
|
230 | - public function removeVehicle($vehicleParams) |
|
231 | - { |
|
232 | - $vehicleId = $vehicleParams['vehicle_id']; |
|
233 | - |
|
234 | - $response = Route4Me::makeRequst([ |
|
235 | - 'url' => Endpoint::Vehicles . '/' . $vehicleId, |
|
236 | - 'method' => 'DELETE', |
|
237 | - 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
238 | - ]); |
|
239 | - |
|
240 | - return $response; |
|
241 | - } |
|
242 | - |
|
243 | - /** Returns the VehiclesPaginated type object containing an array of the vehicles. |
|
244 | - * @param array $params - an array from the VehicleParameters object. |
|
245 | - * @return an array of the Vehicle objects. |
|
246 | - * @throws \Route4Me\Exception\ApiError |
|
247 | - */ |
|
248 | - public function getVehiclesPaginatedList($params) |
|
249 | - { |
|
250 | - $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
251 | - |
|
252 | - $response = Route4Me::makeRequst([ |
|
253 | - 'url' => Endpoint::Vehicles, |
|
254 | - 'method' => 'GET', |
|
255 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
256 | - ]); |
|
257 | - |
|
258 | - return $response; |
|
259 | - } |
|
260 | - |
|
261 | - /** Creates temporary vehicle in the database. |
|
262 | - * @param $vehicleParams - an array from the VehicleTemporary object. |
|
263 | - * @return an object of the type VehicleTemporary. |
|
264 | - * @throws \Route4Me\Exception\ApiError |
|
265 | - */ |
|
266 | - public function createTemporaryVehicle($vehicleParams) |
|
267 | - { |
|
268 | - $excludeFields = []; |
|
269 | - $allBodyFields = Route4Me::getObjectProperties(new VehicleTemporary(), $excludeFields); |
|
270 | - |
|
271 | - $response = Route4Me::makeRequst([ |
|
272 | - 'url' => Endpoint::VehicleTemporary, |
|
273 | - 'method' => 'POST', |
|
274 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
275 | - 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
276 | - ]); |
|
277 | - |
|
278 | - return $response; |
|
279 | - } |
|
280 | - |
|
281 | - /** Execute a vehicle order. |
|
282 | - * @param $vehicleParams - Vehicle order parameters. |
|
283 | - * @return an object of the type VehicleOrderResponse |
|
284 | - * @throws \Route4Me\Exception\ApiError |
|
285 | - */ |
|
286 | - public function executeVehicleOrder($vehicleParams) |
|
287 | - { |
|
288 | - $excludeFields = []; |
|
289 | - $allBodyFields = Route4Me::getObjectProperties(new VehicleOrderParameters(), $excludeFields); |
|
290 | - |
|
291 | - $response = Route4Me::makeRequst([ |
|
292 | - 'url' => Endpoint::VehicleExecuteOrder, |
|
293 | - 'method' => 'POST', |
|
294 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
295 | - 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
296 | - ]); |
|
297 | - |
|
298 | - return $response; |
|
299 | - } |
|
300 | - |
|
301 | - /** Get latest vehicle locations by specified vehicle IDs. |
|
302 | - * @param $vehicleParams - Vehicle query parameters containing vehicle IDs |
|
303 | - * @return Data with vehicles |
|
304 | - * @throws \Route4Me\Exception\ApiError |
|
305 | - */ |
|
306 | - public function getVehicleLocations($vehicleParams) |
|
307 | - { |
|
308 | - $allQueryFields = ['ids']; |
|
309 | - |
|
310 | - $response = Route4Me::makeRequst([ |
|
311 | - 'url' => Endpoint::VehicleLocation, |
|
312 | - 'method' => 'GET', |
|
313 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $vehicleParams), |
|
314 | - ]); |
|
315 | - |
|
316 | - return $response; |
|
317 | - } |
|
318 | - |
|
319 | - /** Get the Vehicle by specifying vehicle ID. |
|
320 | - * @param $vehicleParams - Vehicle query parameters containing vehicle ID. |
|
321 | - * @return an object of the type Vehicle |
|
322 | - * @throws \Route4Me\Exception\ApiError |
|
323 | - */ |
|
324 | - public function getVehicleById($vehicleParams) |
|
325 | - { |
|
326 | - $allQueryFields = ['vehicle_id']; |
|
327 | - |
|
328 | - $response = Route4Me::makeRequst([ |
|
329 | - 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'], |
|
330 | - 'method' => 'GET', |
|
331 | - 'query' => null, |
|
332 | - ]); |
|
333 | - |
|
334 | - return $response; |
|
335 | - } |
|
336 | - |
|
337 | - /** Get the Vehicle track by specifying vehicle ID. |
|
338 | - * @param $vehicleParams - Vehicle query parameters containing vehicle ID. |
|
339 | - * @return Vehicle track object |
|
340 | - * @throws \Route4Me\Exception\ApiError |
|
341 | - */ |
|
342 | - public function getVehicleTrack($vehicleParams) |
|
343 | - { |
|
344 | - $response = Route4Me::makeRequst([ |
|
345 | - 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'].'/track', |
|
346 | - 'method' => 'GET', |
|
347 | - 'query' => null, |
|
348 | - ]); |
|
349 | - |
|
350 | - return $response; |
|
351 | - } |
|
352 | - |
|
353 | - public function getVehicleByLicensePlate($vehicleParams) |
|
354 | - { |
|
355 | - $allQueryFields = ['vehicle_license_plate']; |
|
356 | - |
|
357 | - $response = Route4Me::makeRequst([ |
|
358 | - 'url' => Endpoint::VehicleLicense, |
|
359 | - 'method' => 'GET', |
|
360 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $vehicleParams), |
|
361 | - ]); |
|
362 | - |
|
363 | - return $response; |
|
364 | - } |
|
365 | - |
|
366 | - public function searchVehicles($searchParams) |
|
367 | - { |
|
368 | - $excludeFields = []; |
|
369 | - $allBodyFields = Route4Me::getObjectProperties(new VehicleSearchParameters(), $excludeFields); |
|
370 | - |
|
371 | - $response = Route4Me::makeRequst([ |
|
372 | - 'url' => Endpoint::VehicleSearch, |
|
373 | - 'method' => 'POST', |
|
374 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $searchParams), |
|
375 | - 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
376 | - ]); |
|
377 | - |
|
378 | - return $response; |
|
379 | - } |
|
380 | - |
|
381 | - public function updateVehicle($vehicleParams) |
|
382 | - { |
|
383 | - $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
384 | - $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
385 | - |
|
386 | - $response = Route4Me::makeRequst([ |
|
387 | - 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'], |
|
388 | - 'method' => 'PATCH', |
|
389 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
390 | - 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
391 | - ]); |
|
392 | - |
|
393 | - return $response; |
|
394 | - } |
|
21 | + /** The vehicle ID |
|
22 | + * @var string $vehicle_id |
|
23 | + */ |
|
24 | + public $vehicle_id; |
|
25 | + |
|
26 | + /** Member ID assigned to the vehicle. |
|
27 | + * @var integer $member_id |
|
28 | + */ |
|
29 | + public $member_id; |
|
30 | + |
|
31 | + /** If true, the vehicle is marked as deleted. |
|
32 | + * @var boolean $is_deleted |
|
33 | + */ |
|
34 | + public $is_deleted; |
|
35 | + |
|
36 | + /** Vehicle alias |
|
37 | + * @var string $vehicle_alias |
|
38 | + */ |
|
39 | + public $vehicle_alias; |
|
40 | + |
|
41 | + /** Vehicle VIN |
|
42 | + * @var string $vehicle_vin |
|
43 | + */ |
|
44 | + public $vehicle_vin; |
|
45 | + |
|
46 | + /** Vehicle registration state ID. |
|
47 | + * @var integer $vehicle_reg_state_id |
|
48 | + */ |
|
49 | + public $vehicle_reg_state_id; |
|
50 | + |
|
51 | + /** Vehicle registration country ID. |
|
52 | + * @var integer $vehicle_reg_country_id |
|
53 | + */ |
|
54 | + public $vehicle_reg_country_id; |
|
55 | + |
|
56 | + /** A license plate of the vehicle. |
|
57 | + * @var string $vehicle_license_plate |
|
58 | + */ |
|
59 | + public $vehicle_license_plate; |
|
60 | + |
|
61 | + /** Vehicle type. |
|
62 | + * <para>Availbale values:</para> |
|
63 | + * sedan', 'suv', 'pickup_truck', 'van', '18wheeler', 'cabin', 'hatchback', |
|
64 | + * '<para>motorcyle', 'waste_disposal', 'tree_cutting', 'bigrig', 'cement_mixer', </para> |
|
65 | + * 'livestock_carrier', 'dairy','tractor_trailer'. |
|
66 | + * @var string $vehicle_type_id |
|
67 | + */ |
|
68 | + public $vehicle_type_id; |
|
69 | + |
|
70 | + /** When the vehicle was added. |
|
71 | + * @var string $timestamp_added |
|
72 | + */ |
|
73 | + public $timestamp_added; |
|
74 | + |
|
75 | + /** Vehicle maker brend. |
|
76 | + * <para>Available values:</para> |
|
77 | + * "american coleman", "bmw", "chevrolet", "ford", "freightliner", "gmc", |
|
78 | + * <para>"hino", "honda", "isuzu", "kenworth", "mack", "mercedes-benz", "mitsubishi", </para> |
|
79 | + * "navistar", "nissan", "peterbilt", "renault", "scania", "sterling", "toyota", |
|
80 | + * <para>"volvo", "western star" </para> |
|
81 | + * </value>" |
|
82 | + * @var string $vehicle_make |
|
83 | + */ |
|
84 | + public $vehicle_make; |
|
85 | + |
|
86 | + /** Vehicle model year |
|
87 | + * @var integer $vehicle_model_year |
|
88 | + */ |
|
89 | + public $vehicle_model_year; |
|
90 | + |
|
91 | + /** Vehicle model |
|
92 | + * @var string $vehicle_model |
|
93 | + */ |
|
94 | + public $vehicle_model; |
|
95 | + |
|
96 | + /** The year, vehicle was acquired |
|
97 | + * @var integer $vehicle_year_acquired |
|
98 | + */ |
|
99 | + public $vehicle_year_acquired; |
|
100 | + |
|
101 | + /** A cost of the new vehicle |
|
102 | + * @var float $vehicle_cost_new |
|
103 | + */ |
|
104 | + public $vehicle_cost_new; |
|
105 | + |
|
106 | + /** If true, the vehicle was purchased new. |
|
107 | + * @var boolean $purchased_new |
|
108 | + */ |
|
109 | + public $purchased_new; |
|
110 | + |
|
111 | + /** Start date of the license |
|
112 | + * @var string $license_start_date |
|
113 | + */ |
|
114 | + public $license_start_date; |
|
115 | + |
|
116 | + /** End date of the license |
|
117 | + * @var string $license_end_date |
|
118 | + */ |
|
119 | + public $license_end_date; |
|
120 | + |
|
121 | + /** If equal to '1', the vehicle is operational. |
|
122 | + * @var boolean $is_operational |
|
123 | + */ |
|
124 | + public $is_operational; |
|
125 | + |
|
126 | + /** A type of the fuel |
|
127 | + * @var string $fuel_type |
|
128 | + * enum: ['unleaded 87','unleaded 89','unleaded 91','unleaded 93','diesel','electric','hybrid'] |
|
129 | + */ |
|
130 | + public $fuel_type; |
|
131 | + |
|
132 | + /** External telematics vehicle IDs |
|
133 | + * @var integer $external_telematics_vehicle_ids |
|
134 | + */ |
|
135 | + public $external_telematics_vehicle_id; |
|
136 | + |
|
137 | + /** When the vehcile was marked as deleted. |
|
138 | + * @var integer $timestamp_removed |
|
139 | + */ |
|
140 | + public $timestamp_removed; |
|
141 | + |
|
142 | + /** Vehicle profile ID |
|
143 | + * @var integer $vehicle_profile_id |
|
144 | + */ |
|
145 | + public $vehicle_profile_id; |
|
146 | + |
|
147 | + /** Fuel consumption city |
|
148 | + * @var float $fuel_consumption_city |
|
149 | + */ |
|
150 | + public $fuel_consumption_city; |
|
151 | + |
|
152 | + /** Fuel consumption in the highway area |
|
153 | + * @var float $fuel_consumption_highway |
|
154 | + */ |
|
155 | + public $fuel_consumption_highway; |
|
156 | + |
|
157 | + /** Fuel consumption units in the city area (e.g. mi/l) |
|
158 | + * @var string $fuel_consumption_city_unit |
|
159 | + */ |
|
160 | + public $fuel_consumption_city_unit; |
|
161 | + |
|
162 | + /** Fuel consumption units in the highway area (e.g. mi/l) |
|
163 | + * @var string $fuel_consumption_highway_unit |
|
164 | + */ |
|
165 | + public $fuel_consumption_highway_unit; |
|
166 | + |
|
167 | + /** Miles per gallon in the city area |
|
168 | + * @var float $mpg_city |
|
169 | + */ |
|
170 | + public $mpg_city; |
|
171 | + |
|
172 | + /** Miles per gallon in the highway area |
|
173 | + * @var float $mpg_highway |
|
174 | + */ |
|
175 | + public $mpg_highway; |
|
176 | + |
|
177 | + /** Fuel consumption UF value in the city area (e.g. '20.01 mi/l') |
|
178 | + * @var string $fuel_consumption_city_uf_value |
|
179 | + */ |
|
180 | + public $fuel_consumption_city_uf_value; |
|
181 | + |
|
182 | + /** Fuel consumption UF value in the highway area (e.g. '2,000.01 mpg') |
|
183 | + * @var string $fuel_consumption_highway_uf_value |
|
184 | + */ |
|
185 | + public $fuel_consumption_highway_uf_value; |
|
186 | + |
|
187 | + public static function fromArray(array $params) |
|
188 | + { |
|
189 | + $vehicle = new self(); |
|
190 | + |
|
191 | + foreach ($params as $key => $value) { |
|
192 | + if (is_null(Common::getValue($params, $key))) continue; |
|
193 | + if (property_exists($vehicle, $key)) { |
|
194 | + $vehicle->$key = $value; |
|
195 | + } |
|
196 | + } |
|
197 | + |
|
198 | + return $vehicle; |
|
199 | + } |
|
200 | + |
|
201 | + public function __construct() |
|
202 | + { |
|
203 | + Route4Me::setBaseUrl(""); |
|
204 | + } |
|
205 | + |
|
206 | + /** Creates a vehicle |
|
207 | + * @param $vehicleParams |
|
208 | + * Returns a vehicle object or failure info. |
|
209 | + */ |
|
210 | + public function createVehicle($vehicleParams) |
|
211 | + { |
|
212 | + $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
213 | + $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
214 | + |
|
215 | + $response = Route4Me::makeRequst([ |
|
216 | + 'url' => Endpoint::Vehicles, |
|
217 | + 'method' => 'POST', |
|
218 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
219 | + 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
220 | + ]); |
|
221 | + |
|
222 | + return $response; |
|
223 | + } |
|
224 | + |
|
225 | + /** Removes a vehicle by specified vehicle ID. |
|
226 | + * @param string $vehicleID - Vehicle ID |
|
227 | + * @return Vehicle object - removed vehicle object. |
|
228 | + * @throws \Route4Me\Exception\ApiError |
|
229 | + */ |
|
230 | + public function removeVehicle($vehicleParams) |
|
231 | + { |
|
232 | + $vehicleId = $vehicleParams['vehicle_id']; |
|
233 | + |
|
234 | + $response = Route4Me::makeRequst([ |
|
235 | + 'url' => Endpoint::Vehicles . '/' . $vehicleId, |
|
236 | + 'method' => 'DELETE', |
|
237 | + 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
238 | + ]); |
|
239 | + |
|
240 | + return $response; |
|
241 | + } |
|
242 | + |
|
243 | + /** Returns the VehiclesPaginated type object containing an array of the vehicles. |
|
244 | + * @param array $params - an array from the VehicleParameters object. |
|
245 | + * @return an array of the Vehicle objects. |
|
246 | + * @throws \Route4Me\Exception\ApiError |
|
247 | + */ |
|
248 | + public function getVehiclesPaginatedList($params) |
|
249 | + { |
|
250 | + $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
251 | + |
|
252 | + $response = Route4Me::makeRequst([ |
|
253 | + 'url' => Endpoint::Vehicles, |
|
254 | + 'method' => 'GET', |
|
255 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
256 | + ]); |
|
257 | + |
|
258 | + return $response; |
|
259 | + } |
|
260 | + |
|
261 | + /** Creates temporary vehicle in the database. |
|
262 | + * @param $vehicleParams - an array from the VehicleTemporary object. |
|
263 | + * @return an object of the type VehicleTemporary. |
|
264 | + * @throws \Route4Me\Exception\ApiError |
|
265 | + */ |
|
266 | + public function createTemporaryVehicle($vehicleParams) |
|
267 | + { |
|
268 | + $excludeFields = []; |
|
269 | + $allBodyFields = Route4Me::getObjectProperties(new VehicleTemporary(), $excludeFields); |
|
270 | + |
|
271 | + $response = Route4Me::makeRequst([ |
|
272 | + 'url' => Endpoint::VehicleTemporary, |
|
273 | + 'method' => 'POST', |
|
274 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
275 | + 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
276 | + ]); |
|
277 | + |
|
278 | + return $response; |
|
279 | + } |
|
280 | + |
|
281 | + /** Execute a vehicle order. |
|
282 | + * @param $vehicleParams - Vehicle order parameters. |
|
283 | + * @return an object of the type VehicleOrderResponse |
|
284 | + * @throws \Route4Me\Exception\ApiError |
|
285 | + */ |
|
286 | + public function executeVehicleOrder($vehicleParams) |
|
287 | + { |
|
288 | + $excludeFields = []; |
|
289 | + $allBodyFields = Route4Me::getObjectProperties(new VehicleOrderParameters(), $excludeFields); |
|
290 | + |
|
291 | + $response = Route4Me::makeRequst([ |
|
292 | + 'url' => Endpoint::VehicleExecuteOrder, |
|
293 | + 'method' => 'POST', |
|
294 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
295 | + 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
296 | + ]); |
|
297 | + |
|
298 | + return $response; |
|
299 | + } |
|
300 | + |
|
301 | + /** Get latest vehicle locations by specified vehicle IDs. |
|
302 | + * @param $vehicleParams - Vehicle query parameters containing vehicle IDs |
|
303 | + * @return Data with vehicles |
|
304 | + * @throws \Route4Me\Exception\ApiError |
|
305 | + */ |
|
306 | + public function getVehicleLocations($vehicleParams) |
|
307 | + { |
|
308 | + $allQueryFields = ['ids']; |
|
309 | + |
|
310 | + $response = Route4Me::makeRequst([ |
|
311 | + 'url' => Endpoint::VehicleLocation, |
|
312 | + 'method' => 'GET', |
|
313 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $vehicleParams), |
|
314 | + ]); |
|
315 | + |
|
316 | + return $response; |
|
317 | + } |
|
318 | + |
|
319 | + /** Get the Vehicle by specifying vehicle ID. |
|
320 | + * @param $vehicleParams - Vehicle query parameters containing vehicle ID. |
|
321 | + * @return an object of the type Vehicle |
|
322 | + * @throws \Route4Me\Exception\ApiError |
|
323 | + */ |
|
324 | + public function getVehicleById($vehicleParams) |
|
325 | + { |
|
326 | + $allQueryFields = ['vehicle_id']; |
|
327 | + |
|
328 | + $response = Route4Me::makeRequst([ |
|
329 | + 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'], |
|
330 | + 'method' => 'GET', |
|
331 | + 'query' => null, |
|
332 | + ]); |
|
333 | + |
|
334 | + return $response; |
|
335 | + } |
|
336 | + |
|
337 | + /** Get the Vehicle track by specifying vehicle ID. |
|
338 | + * @param $vehicleParams - Vehicle query parameters containing vehicle ID. |
|
339 | + * @return Vehicle track object |
|
340 | + * @throws \Route4Me\Exception\ApiError |
|
341 | + */ |
|
342 | + public function getVehicleTrack($vehicleParams) |
|
343 | + { |
|
344 | + $response = Route4Me::makeRequst([ |
|
345 | + 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'].'/track', |
|
346 | + 'method' => 'GET', |
|
347 | + 'query' => null, |
|
348 | + ]); |
|
349 | + |
|
350 | + return $response; |
|
351 | + } |
|
352 | + |
|
353 | + public function getVehicleByLicensePlate($vehicleParams) |
|
354 | + { |
|
355 | + $allQueryFields = ['vehicle_license_plate']; |
|
356 | + |
|
357 | + $response = Route4Me::makeRequst([ |
|
358 | + 'url' => Endpoint::VehicleLicense, |
|
359 | + 'method' => 'GET', |
|
360 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $vehicleParams), |
|
361 | + ]); |
|
362 | + |
|
363 | + return $response; |
|
364 | + } |
|
365 | + |
|
366 | + public function searchVehicles($searchParams) |
|
367 | + { |
|
368 | + $excludeFields = []; |
|
369 | + $allBodyFields = Route4Me::getObjectProperties(new VehicleSearchParameters(), $excludeFields); |
|
370 | + |
|
371 | + $response = Route4Me::makeRequst([ |
|
372 | + 'url' => Endpoint::VehicleSearch, |
|
373 | + 'method' => 'POST', |
|
374 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $searchParams), |
|
375 | + 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
376 | + ]); |
|
377 | + |
|
378 | + return $response; |
|
379 | + } |
|
380 | + |
|
381 | + public function updateVehicle($vehicleParams) |
|
382 | + { |
|
383 | + $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
384 | + $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
385 | + |
|
386 | + $response = Route4Me::makeRequst([ |
|
387 | + 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'], |
|
388 | + 'method' => 'PATCH', |
|
389 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
390 | + 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
|
391 | + ]); |
|
392 | + |
|
393 | + return $response; |
|
394 | + } |
|
395 | 395 | } |
396 | 396 | \ No newline at end of file |
@@ -232,7 +232,7 @@ |
||
232 | 232 | $vehicleId = $vehicleParams['vehicle_id']; |
233 | 233 | |
234 | 234 | $response = Route4Me::makeRequst([ |
235 | - 'url' => Endpoint::Vehicles . '/' . $vehicleId, |
|
235 | + 'url' => Endpoint::Vehicles.'/'.$vehicleId, |
|
236 | 236 | 'method' => 'DELETE', |
237 | 237 | 'HTTPHEADER' => Constants::DEFAULT_HTTP_HEADER, |
238 | 238 | ]); |
@@ -189,7 +189,9 @@ |
||
189 | 189 | $vehicle = new self(); |
190 | 190 | |
191 | 191 | foreach ($params as $key => $value) { |
192 | - if (is_null(Common::getValue($params, $key))) continue; |
|
192 | + if (is_null(Common::getValue($params, $key))) { |
|
193 | + continue; |
|
194 | + } |
|
193 | 195 | if (property_exists($vehicle, $key)) { |
194 | 196 | $vehicle->$key = $value; |
195 | 197 | } |
@@ -9,46 +9,46 @@ |
||
9 | 9 | */ |
10 | 10 | class AccountProfile extends Common |
11 | 11 | { |
12 | - /** |
|
13 | - * Account profile email |
|
14 | - * @var type string |
|
15 | - */ |
|
16 | - public $email; |
|
12 | + /** |
|
13 | + * Account profile email |
|
14 | + * @var type string |
|
15 | + */ |
|
16 | + public $email; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Account member ID |
|
20 | - * @var type integer |
|
21 | - */ |
|
22 | - public $member_id; |
|
18 | + /** |
|
19 | + * Account member ID |
|
20 | + * @var type integer |
|
21 | + */ |
|
22 | + public $member_id; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Account API key |
|
26 | - * @var type string |
|
27 | - */ |
|
28 | - public $api_key; |
|
24 | + /** |
|
25 | + * Account API key |
|
26 | + * @var type string |
|
27 | + */ |
|
28 | + public $api_key; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Account root member ID |
|
32 | - * @var type integer |
|
33 | - */ |
|
34 | - public $root_member_id; |
|
30 | + /** |
|
31 | + * Account root member ID |
|
32 | + * @var type integer |
|
33 | + */ |
|
34 | + public $root_member_id; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Preferred units of the account. |
|
38 | - * @var type string |
|
39 | - */ |
|
40 | - public $preferred_units; |
|
36 | + /** |
|
37 | + * Preferred units of the account. |
|
38 | + * @var type string |
|
39 | + */ |
|
40 | + public $preferred_units; |
|
41 | 41 | |
42 | - public static function fromArray(array $params) |
|
43 | - { |
|
44 | - $thisParams = new self(); |
|
42 | + public static function fromArray(array $params) |
|
43 | + { |
|
44 | + $thisParams = new self(); |
|
45 | 45 | |
46 | - foreach ($params as $key => $value) { |
|
47 | - if (property_exists($thisParams, $key)) { |
|
48 | - $thisParams->{$key} = $value; |
|
49 | - } |
|
50 | - } |
|
46 | + foreach ($params as $key => $value) { |
|
47 | + if (property_exists($thisParams, $key)) { |
|
48 | + $thisParams->{$key} = $value; |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - return $thisParams; |
|
53 | - } |
|
52 | + return $thisParams; |
|
53 | + } |
|
54 | 54 | } |
@@ -9,10 +9,10 @@ discard block |
||
9 | 9 | */ |
10 | 10 | class TelematicsVendorFeature extends Common |
11 | 11 | { |
12 | - /** |
|
13 | - * Feature ID |
|
14 | - * @var type string |
|
15 | - */ |
|
12 | + /** |
|
13 | + * Feature ID |
|
14 | + * @var type string |
|
15 | + */ |
|
16 | 16 | public $id; |
17 | 17 | |
18 | 18 | /** |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | */ |
34 | 34 | public $feature_group; |
35 | 35 | |
36 | - public static function fromArray(array $params) |
|
37 | - { |
|
38 | - $thisParams = new self(); |
|
36 | + public static function fromArray(array $params) |
|
37 | + { |
|
38 | + $thisParams = new self(); |
|
39 | 39 | |
40 | - foreach ($params as $key => $value) { |
|
41 | - if (property_exists($thisParams, $key)) { |
|
42 | - $thisParams->{$key} = $value; |
|
43 | - } |
|
44 | - } |
|
40 | + foreach ($params as $key => $value) { |
|
41 | + if (property_exists($thisParams, $key)) { |
|
42 | + $thisParams->{$key} = $value; |
|
43 | + } |
|
44 | + } |
|
45 | 45 | |
46 | - return $thisParams; |
|
47 | - } |
|
46 | + return $thisParams; |
|
47 | + } |
|
48 | 48 | } |
@@ -6,33 +6,33 @@ |
||
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 |
@@ -9,101 +9,101 @@ |
||
9 | 9 | */ |
10 | 10 | class ScheduleCalendarParameters extends Common |
11 | 11 | { |
12 | - /** |
|
13 | - * Start date to filter the schedules in the string format<br> |
|
14 | - * (e.g. 2020-10-27). |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - public $date_from_string; |
|
18 | - |
|
19 | - /** |
|
20 | - * End date to filter the schedules in the string format<br> |
|
21 | - * (e.g. 2020-10-30). |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - public $date_to_string; |
|
25 | - |
|
26 | - /** |
|
27 | - * Member ID |
|
28 | - * @var integer |
|
29 | - */ |
|
30 | - public $member_id; |
|
31 | - |
|
32 | - /** |
|
33 | - * Timezone offset (in minutes)<br> |
|
34 | - * (e.g. NYT: -4*60 = -480, Kiev: 3*60 = 180). |
|
35 | - * @var integer |
|
36 | - */ |
|
37 | - public $timezone_offset_minutes; |
|
38 | - |
|
39 | - /** |
|
40 | - * If true, the scheduled orders are included in the calendar. |
|
41 | - * @var Boolean |
|
42 | - */ |
|
43 | - public $orders; |
|
44 | - |
|
45 | - /** |
|
46 | - * If true, the scheduled address book contacts |
|
47 | - * are included in the calendar. |
|
48 | - * @var Boolean |
|
49 | - */ |
|
50 | - public $ab; |
|
51 | - |
|
52 | - /** |
|
53 | - * If true, the scheduled routes are included in the calendar. |
|
54 | - * @var Boolean |
|
55 | - */ |
|
56 | - public $routes_count; |
|
57 | - |
|
58 | - /** |
|
59 | - * Class constructor. |
|
60 | - * @var |
|
61 | - */ |
|
62 | - public function __construct() |
|
63 | - { |
|
64 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Convert an array to this object |
|
69 | - */ |
|
70 | - public static function fromArray(array $params) |
|
71 | - { |
|
72 | - $scheduleCalendarParameters = new self(); |
|
73 | - |
|
74 | - foreach ($params as $key => $value) { |
|
75 | - if (property_exists($scheduleCalendarParameters, $key)) { |
|
76 | - $scheduleCalendarParameters->{$key} = $value; |
|
77 | - } |
|
78 | - } |
|
79 | - |
|
80 | - return $scheduleCalendarParameters; |
|
81 | - } |
|
82 | - |
|
83 | - public function setTimezoneOffsetMinutes($tz) |
|
84 | - { |
|
85 | - $this->timezone_offset_minutes = -$tz; |
|
86 | - } |
|
87 | - |
|
88 | - public function getTimezoneOffsetMinutes() |
|
89 | - { |
|
90 | - if (is_numeric($this->timezone_offset_minutes)) { |
|
91 | - return -$this->timezone_offset_minutes; |
|
92 | - } else { |
|
93 | - return 0; |
|
94 | - } |
|
95 | - } |
|
96 | - |
|
97 | - public function getScheduleCalendar($params) |
|
98 | - { |
|
99 | - $allQueryFields = ['date_from_string', 'date_to_string', 'member_id', 'timezone_offset_minutes', 'orders', 'ab', 'routes_count']; |
|
100 | - |
|
101 | - $schedCalendar = Route4Me::makeRequst([ |
|
102 | - 'url' => Endpoint::SCHEDULE_CALENDAR, |
|
103 | - 'method' => 'GET', |
|
104 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
105 | - ]); |
|
106 | - |
|
107 | - return $schedCalendar; |
|
108 | - } |
|
12 | + /** |
|
13 | + * Start date to filter the schedules in the string format<br> |
|
14 | + * (e.g. 2020-10-27). |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + public $date_from_string; |
|
18 | + |
|
19 | + /** |
|
20 | + * End date to filter the schedules in the string format<br> |
|
21 | + * (e.g. 2020-10-30). |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + public $date_to_string; |
|
25 | + |
|
26 | + /** |
|
27 | + * Member ID |
|
28 | + * @var integer |
|
29 | + */ |
|
30 | + public $member_id; |
|
31 | + |
|
32 | + /** |
|
33 | + * Timezone offset (in minutes)<br> |
|
34 | + * (e.g. NYT: -4*60 = -480, Kiev: 3*60 = 180). |
|
35 | + * @var integer |
|
36 | + */ |
|
37 | + public $timezone_offset_minutes; |
|
38 | + |
|
39 | + /** |
|
40 | + * If true, the scheduled orders are included in the calendar. |
|
41 | + * @var Boolean |
|
42 | + */ |
|
43 | + public $orders; |
|
44 | + |
|
45 | + /** |
|
46 | + * If true, the scheduled address book contacts |
|
47 | + * are included in the calendar. |
|
48 | + * @var Boolean |
|
49 | + */ |
|
50 | + public $ab; |
|
51 | + |
|
52 | + /** |
|
53 | + * If true, the scheduled routes are included in the calendar. |
|
54 | + * @var Boolean |
|
55 | + */ |
|
56 | + public $routes_count; |
|
57 | + |
|
58 | + /** |
|
59 | + * Class constructor. |
|
60 | + * @var |
|
61 | + */ |
|
62 | + public function __construct() |
|
63 | + { |
|
64 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Convert an array to this object |
|
69 | + */ |
|
70 | + public static function fromArray(array $params) |
|
71 | + { |
|
72 | + $scheduleCalendarParameters = new self(); |
|
73 | + |
|
74 | + foreach ($params as $key => $value) { |
|
75 | + if (property_exists($scheduleCalendarParameters, $key)) { |
|
76 | + $scheduleCalendarParameters->{$key} = $value; |
|
77 | + } |
|
78 | + } |
|
79 | + |
|
80 | + return $scheduleCalendarParameters; |
|
81 | + } |
|
82 | + |
|
83 | + public function setTimezoneOffsetMinutes($tz) |
|
84 | + { |
|
85 | + $this->timezone_offset_minutes = -$tz; |
|
86 | + } |
|
87 | + |
|
88 | + public function getTimezoneOffsetMinutes() |
|
89 | + { |
|
90 | + if (is_numeric($this->timezone_offset_minutes)) { |
|
91 | + return -$this->timezone_offset_minutes; |
|
92 | + } else { |
|
93 | + return 0; |
|
94 | + } |
|
95 | + } |
|
96 | + |
|
97 | + public function getScheduleCalendar($params) |
|
98 | + { |
|
99 | + $allQueryFields = ['date_from_string', 'date_to_string', 'member_id', 'timezone_offset_minutes', 'orders', 'ab', 'routes_count']; |
|
100 | + |
|
101 | + $schedCalendar = Route4Me::makeRequst([ |
|
102 | + 'url' => Endpoint::SCHEDULE_CALENDAR, |
|
103 | + 'method' => 'GET', |
|
104 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
105 | + ]); |
|
106 | + |
|
107 | + return $schedCalendar; |
|
108 | + } |
|
109 | 109 | } |
110 | 110 | \ No newline at end of file |
@@ -6,131 +6,131 @@ |
||
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 | } |
@@ -42,7 +42,7 @@ |
||
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); |