@@ -19,499 +19,499 @@ |
||
19 | 19 | */ |
20 | 20 | class Schedules extends Common |
21 | 21 | { |
22 | - public function __construct() |
|
23 | - { |
|
24 | - Route4Me::setBaseUrl(''); |
|
25 | - } |
|
26 | - |
|
27 | - /** |
|
28 | - * Create a new Schedule by sending the corresponding data. |
|
29 | - * |
|
30 | - * @since 1.2.3 |
|
31 | - * |
|
32 | - * @param array $params |
|
33 | - * string schedule_uid - Schedule ID, |
|
34 | - * int root_member_id, |
|
35 | - * string name - Name of Schedule, |
|
36 | - * string[] schedule_blacklist - An array of blacklisted dates as 'YYYY-MM-DD', |
|
37 | - * int advance_interval, |
|
38 | - * int advance_schedule_interval_days, |
|
39 | - * string schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily", |
|
40 | - * "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}', |
|
41 | - * string timezone - Timezone as 'America/New_York' |
|
42 | - * @return Schedule |
|
43 | - * @throws Exception\ApiError |
|
44 | - */ |
|
45 | - public function createSchedule(array $params) : Schedule |
|
46 | - { |
|
47 | - $allBodyFields = ['schedule_uid', 'root_member_id', 'name', 'schedule_blacklist', |
|
48 | - 'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone']; |
|
49 | - |
|
50 | - return $this->toSchedule(Route4Me::makeRequst([ |
|
51 | - 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES, |
|
52 | - 'method' => 'POST', |
|
53 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
54 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
55 | - ])); |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Get the Schedule by specifying the Schedule ID. |
|
60 | - * |
|
61 | - * @since 1.2.3 |
|
62 | - * |
|
63 | - * @param string $scheduleId Schedule ID. |
|
64 | - * @return Schedule |
|
65 | - * @throws Exception\ApiError |
|
66 | - */ |
|
67 | - public function getSchedule(string $scheduleId) : Schedule |
|
68 | - { |
|
69 | - return $this->toSchedule(Route4Me::makeRequst([ |
|
70 | - 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId, |
|
71 | - 'method' => 'GET' |
|
72 | - ])); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Get the list of all Schedules. |
|
77 | - * |
|
78 | - * @since 1.2.3 |
|
79 | - * |
|
80 | - * @return Schedule[] |
|
81 | - * @throws Exception\ApiError |
|
82 | - */ |
|
83 | - public function getAllSchedules() : array |
|
84 | - { |
|
85 | - $result = Route4Me::makeRequst([ |
|
86 | - 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES, |
|
87 | - 'method' => 'GET' |
|
88 | - ]); |
|
89 | - |
|
90 | - if (is_array($result) && isset($result['data'])) { |
|
91 | - $data = $result['data']; |
|
92 | - if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
93 | - $arr = []; |
|
94 | - foreach ($data as $key => $value) { |
|
95 | - array_push($arr, new Schedule($value)); |
|
96 | - } |
|
97 | - return $arr; |
|
98 | - } |
|
99 | - } |
|
100 | - return null; |
|
101 | - } |
|
102 | - |
|
103 | - /** |
|
104 | - * Get paginated list of Schedules. |
|
105 | - * |
|
106 | - * @since 1.2.3 |
|
107 | - * |
|
108 | - * @param int $page Requested page. |
|
109 | - * @param int $per_page Number of Schedules per page. |
|
110 | - * @return array |
|
111 | - * @throws Exception\ApiError |
|
112 | - */ |
|
113 | - public function getSchedules(int $page = 1, int $per_page = 15) : array |
|
114 | - { |
|
115 | - $result = Route4Me::makeRequst([ |
|
116 | - 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES_PAGINATION, |
|
117 | - 'method' => 'GET', |
|
118 | - 'query' => [ |
|
119 | - 'with_pagination' => true, |
|
120 | - 'page' => $page, |
|
121 | - 'per_page' => $per_page |
|
122 | - ] |
|
123 | - ]); |
|
124 | - |
|
125 | - if (is_array($result) && isset($result['data'])) { |
|
126 | - $data = $result['data']; |
|
127 | - $schedules = []; |
|
128 | - if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
129 | - foreach ($data as $key => $value) { |
|
130 | - array_push($schedules, new Schedule($value)); |
|
131 | - } |
|
132 | - } |
|
133 | - return [ |
|
134 | - 'schedules' => $schedules, |
|
135 | - 'page_info' => new PageInfo($result['links'], $result['meta']) |
|
136 | - ]; |
|
137 | - } |
|
138 | - return null; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Update the existing Schedule by sending the corresponding data. |
|
143 | - * |
|
144 | - * @since 1.2.3 |
|
145 | - * |
|
146 | - * @param string $schedule_uid Schedule ID |
|
147 | - * @param array $params |
|
148 | - * string schedule_uid - Schedule ID, |
|
149 | - * int root_member_id, |
|
150 | - * string name - Name of Schedule, |
|
151 | - * string[] schedule_blacklist - An array of blacklisted dates as 'YYYY-MM-DD', |
|
152 | - * int advance_interval, |
|
153 | - * int advance_schedule_interval_days, |
|
154 | - * string schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily", |
|
155 | - * "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}', |
|
156 | - * string timezone - Timezone as 'America/New_York' |
|
157 | - * @return Schedule |
|
158 | - * @throws Exception\ApiError |
|
159 | - */ |
|
160 | - public function updateSchedule(string $scheduleId, array $params) : Schedule |
|
161 | - { |
|
162 | - $allBodyFields = ['root_member_id', 'name', 'schedule_blacklist', |
|
163 | - 'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone']; |
|
164 | - |
|
165 | - return $this->toSchedule(Route4Me::makeRequst([ |
|
166 | - 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId, |
|
167 | - 'method' => 'PUT', |
|
168 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
169 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
170 | - ])); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Delete the specified Schedule with the option to delete the associated route. |
|
175 | - * |
|
176 | - * @since 1.2.3 |
|
177 | - * |
|
178 | - * @param string $schedule_uid Schedule ID |
|
179 | - * @param bool $withRoutes Delete the Schedule that matches the specified Schedule ID. |
|
180 | - * If the deleted Schedule has one or multiple associated Routes, |
|
181 | - * these Routes are also deleted. |
|
182 | - * @return Schedule |
|
183 | - * @throws Exception\ApiError |
|
184 | - */ |
|
185 | - public function deleteSchedule(string $scheduleId, bool $withRoutes = false) : Schedule |
|
186 | - { |
|
187 | - return $this->toSchedule(Route4Me::makeRequst([ |
|
188 | - 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId, |
|
189 | - 'method' => 'DELETE', |
|
190 | - 'query' => ['with_routes' => $withRoutes] |
|
191 | - ])); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Create a new Route Schedule by sending the corresponding data. |
|
196 | - * |
|
197 | - * @since 1.2.3 |
|
198 | - * |
|
199 | - * @param array $params |
|
200 | - * string route_id - Route ID, |
|
201 | - * string schedule_uid - Schedule ID, |
|
202 | - * int member_id - A unique ID of the root member, |
|
203 | - * string vehicle_id - Vehicle ID |
|
204 | - * @return RouteSchedule |
|
205 | - * @throws Exception\ApiError |
|
206 | - */ |
|
207 | - public function createRouteSchedule(array $params) : RouteSchedule |
|
208 | - { |
|
209 | - $allBodyFields = ['route_id', 'schedule_uid', 'member_id', 'vehicle_id']; |
|
210 | - |
|
211 | - return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
212 | - 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES, |
|
213 | - 'method' => 'POST', |
|
214 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
215 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
216 | - ])); |
|
217 | - } |
|
218 | - |
|
219 | - /** |
|
220 | - * Get the Route Schedule by specifying the Route ID. |
|
221 | - * |
|
222 | - * @since 1.2.3 |
|
223 | - * |
|
224 | - * @param string $routeId Route ID. |
|
225 | - * @return RouteSchedule |
|
226 | - * @throws Exception\ApiError |
|
227 | - */ |
|
228 | - public function getRouteSchedule(string $route_id) : RouteSchedule |
|
229 | - { |
|
230 | - return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
231 | - 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id, |
|
232 | - 'method' => 'GET' |
|
233 | - ])); |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Get the list of all Route Schedules. |
|
238 | - * |
|
239 | - * @since 1.2.3 |
|
240 | - * |
|
241 | - * @return RouteSchedule[] |
|
242 | - * @throws Exception\ApiError |
|
243 | - */ |
|
244 | - public function getAllRouteSchedules() : array |
|
245 | - { |
|
246 | - $result = Route4Me::makeRequst([ |
|
247 | - 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES, |
|
248 | - 'method' => 'GET' |
|
249 | - ]); |
|
250 | - |
|
251 | - if (is_array($result) && isset($result['data'])) { |
|
252 | - $data = $result['data']; |
|
253 | - if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
254 | - $arr = []; |
|
255 | - foreach ($data as $key => $value) { |
|
256 | - array_push($arr, new RouteSchedule($value)); |
|
257 | - } |
|
258 | - return $arr; |
|
259 | - } |
|
260 | - } |
|
261 | - return null; |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * Get paginated list of Route Schedules. |
|
266 | - * |
|
267 | - * @since 1.2.3 |
|
268 | - * |
|
269 | - * @param int $page Requested page. |
|
270 | - * @param int $per_page Number of Route Schedules per page. |
|
271 | - * @return array |
|
272 | - * @throws Exception\ApiError |
|
273 | - */ |
|
274 | - public function getRouteSchedules(int $page = 1, int $per_page = 15) : array |
|
275 | - { |
|
276 | - $result = Route4Me::makeRequst([ |
|
277 | - 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_PAGINATION, |
|
278 | - 'method' => 'GET', |
|
279 | - 'query' => [ |
|
280 | - 'with_pagination' => true, |
|
281 | - 'page' => $page, |
|
282 | - 'per_page' => $per_page |
|
283 | - ] |
|
284 | - ]); |
|
285 | - |
|
286 | - if (is_array($result) && isset($result['data'])) { |
|
287 | - $data = $result['data']; |
|
288 | - $route_schedules = []; |
|
289 | - if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
290 | - foreach ($data as $key => $value) { |
|
291 | - array_push($route_schedules, new RouteSchedule($value)); |
|
292 | - } |
|
293 | - } |
|
294 | - return [ |
|
295 | - 'route_schedules' => $route_schedules, |
|
296 | - 'page_info' => new PageInfo($result['links'], $result['meta']) |
|
297 | - ]; |
|
298 | - } |
|
299 | - return null; |
|
300 | - } |
|
301 | - |
|
302 | - /** |
|
303 | - * Update the existing Route Schedule by sending the corresponding data. |
|
304 | - * |
|
305 | - * @since 1.2.3 |
|
306 | - * |
|
307 | - * @param string $route_id Route ID |
|
308 | - * @param array $params |
|
309 | - * string schedule_uid - Schedule ID, |
|
310 | - * int member_id - A unique ID of the root member, |
|
311 | - * string vehicle_id - Vehicle ID |
|
312 | - * @return RouteSchedule |
|
313 | - * @throws Exception\ApiError |
|
314 | - */ |
|
315 | - public function updateRouteSchedule(string $route_id, array $params) : RouteSchedule |
|
316 | - { |
|
317 | - $allBodyFields = ['schedule_uid', 'member_id', 'vehicle_id']; |
|
318 | - |
|
319 | - return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
320 | - 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id, |
|
321 | - 'method' => 'PUT', |
|
322 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
323 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
324 | - ])); |
|
325 | - } |
|
326 | - |
|
327 | - /** |
|
328 | - * Delete the Route Schedules. |
|
329 | - * @todo request return true instead of return json status |
|
330 | - * |
|
331 | - * @since 1.2.3 |
|
332 | - * |
|
333 | - * @param string $route_id Route ID |
|
334 | - * @return bool |
|
335 | - * @throws Exception\ApiError |
|
336 | - */ |
|
337 | - public function deleteRouteSchedules(string $route_id) : bool |
|
338 | - { |
|
339 | - $result = Route4Me::makeRequst([ |
|
340 | - 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id, |
|
341 | - 'method' => 'DELETE' |
|
342 | - ]); |
|
343 | - return ($result == 1 ? true : false); |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Delete the specified Route Schedule. |
|
348 | - * |
|
349 | - * @since 1.2.3 |
|
350 | - * |
|
351 | - * @param string $route_id Route ID |
|
352 | - * @return RouteSchedule |
|
353 | - * @throws Exception\ApiError |
|
354 | - */ |
|
355 | - public function deleteRouteSchedule(string $route_id) : RouteSchedule |
|
356 | - { |
|
357 | - return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
358 | - 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/items', |
|
359 | - 'method' => 'DELETE' |
|
360 | - ])); |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Replace the existing Route Schedule by sending the corresponding data. |
|
365 | - * |
|
366 | - * @since 1.2.3 |
|
367 | - * |
|
368 | - * @param string $route_id Route ID. |
|
369 | - * @param array $params |
|
370 | - * int member_id - A unique ID of the root member, |
|
371 | - * string vehicle_id - Vehicle ID, |
|
372 | - * string schedule_uid - Schedule ID, |
|
373 | - * string name, |
|
374 | - * string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD, |
|
375 | - * int advance_interval, |
|
376 | - * int advance_schedule_interval_days, |
|
377 | - * string schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily", |
|
378 | - * "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}', |
|
379 | - * string timezone - Timezone as 'America/New_York' |
|
380 | - * @return RouteSchedule |
|
381 | - * @throws Exception\ApiError |
|
382 | - */ |
|
383 | - public function replaceRouteSchedule(string $route_id, array $params) |
|
384 | - { |
|
385 | - $allBodyFields = ['member_id', 'vehicle_id', 'schedule_uid', 'name', 'schedule_blacklist', |
|
386 | - 'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone']; |
|
387 | - |
|
388 | - return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
389 | - 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE . '/' . $route_id, |
|
390 | - 'method' => 'PUT', |
|
391 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
392 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
393 | - ])); |
|
394 | - } |
|
395 | - |
|
396 | - /** |
|
397 | - * Get the Route Schedule preview by specifying the 'route_id'. |
|
398 | - * |
|
399 | - * @since 1.2.3 |
|
400 | - * |
|
401 | - * @param string $routeId Route ID. |
|
402 | - * @param string $start Start date as 'YYYY-MM-DD' |
|
403 | - * @param string $end End date as 'YYYY-MM-DD' |
|
404 | - * @return array |
|
405 | - * @throws Exception\ApiError |
|
406 | - */ |
|
407 | - public function getRouteSchedulePreview(string $route_id, string $start, string $end) : array |
|
408 | - { |
|
409 | - return Route4Me::makeRequst([ |
|
410 | - 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/preview', |
|
411 | - 'method' => 'GET', |
|
412 | - 'query' => ['start' => $start, 'end' => $end] |
|
413 | - ]); |
|
414 | - } |
|
415 | - |
|
416 | - /** |
|
417 | - * Check if the Scheduled Route was copied by specifying the 'route_id'. |
|
418 | - * @todo request return true instead of return json status |
|
419 | - * |
|
420 | - * @since 1.2.3 |
|
421 | - * |
|
422 | - * @param string $routeId Route ID. |
|
423 | - * @return bool |
|
424 | - * @throws Exception\ApiError |
|
425 | - */ |
|
426 | - public function isScheduledRouteCopy(string $route_id) : bool |
|
427 | - { |
|
428 | - return Route4Me::makeRequst([ |
|
429 | - 'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY . '/' . $route_id, |
|
430 | - 'method' => 'GET' |
|
431 | - ]); |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Get all routes copied from the specified Scheduled Route by sending |
|
436 | - * the corresponding data. |
|
437 | - * |
|
438 | - * @since 1.2.3 |
|
439 | - * |
|
440 | - * @param string $route_id Route ID. |
|
441 | - * @param string $schedule_uid Schedule ID. |
|
442 | - * @param string $route_date Route date as 'YYYY-MM-DD'. |
|
443 | - * @return array |
|
444 | - * @throws Exception\ApiError |
|
445 | - */ |
|
446 | - public function getScheduledRoutesCopies(string $route_id, string $schedule_uid, string $route_date) : array |
|
447 | - { |
|
448 | - return Route4Me::makeRequst([ |
|
449 | - 'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES, |
|
450 | - 'method' => 'POST', |
|
451 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
452 | - 'body' => [ |
|
453 | - 'route_id' => $route_id, |
|
454 | - 'schedule_uid' => $schedule_uid, |
|
455 | - 'route_date' => $route_date |
|
456 | - ] |
|
457 | - ]); |
|
458 | - } |
|
459 | - |
|
460 | - /** |
|
461 | - * Create a new Master Route by sending the corresponding data. |
|
462 | - * @todo request return true instead of return json status |
|
463 | - * |
|
464 | - * @since 1.2.3 |
|
465 | - * |
|
466 | - * @param array $params |
|
467 | - * string route_id - Route ID, |
|
468 | - * string route_name, |
|
469 | - * int member_id - A unique ID of the root member, |
|
470 | - * string vehicle_id - Vehicle ID, |
|
471 | - * string schedule_uid - Schedule ID, |
|
472 | - * string name, |
|
473 | - * string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD, |
|
474 | - * int advance_interval, |
|
475 | - * int advance_schedule_interval_days, |
|
476 | - * string schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily", |
|
477 | - * "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}', |
|
478 | - * bool sync - Type of result, synchronous or not |
|
479 | - * string timezone - Timezone as 'America/New_York' |
|
480 | - * @return bool |
|
481 | - * @throws Exception\ApiError |
|
482 | - */ |
|
483 | - public function createMasterRoute(array $params) : bool |
|
484 | - { |
|
485 | - $allBodyFields = ['route_id', 'route_name', 'member_id', 'schedule_uid', 'vehicle_id', 'name', |
|
486 | - 'schedule_blacklist', 'advance_schedule_interval_days', 'schedule', 'timezone', 'sync']; |
|
487 | - |
|
488 | - return Route4Me::makeRequst([ |
|
489 | - 'url' => Endpoint::RECURRING_ROUTES_MASTER_ROUTES, |
|
490 | - 'method' => 'POST', |
|
491 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
492 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
493 | - ]); |
|
494 | - } |
|
495 | - |
|
496 | - private function toSchedule($result) : Schedule |
|
497 | - { |
|
498 | - if (is_array($result) && isset($result['data'])) { |
|
499 | - $data = $result['data']; |
|
500 | - if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
501 | - return new Schedule($data[0]); |
|
502 | - } |
|
503 | - } |
|
504 | - throw new ApiError('Can not convert result to Schedule object.'); |
|
505 | - } |
|
506 | - |
|
507 | - private function toRouteSchedule($result) : RouteSchedule |
|
508 | - { |
|
509 | - if (is_array($result) && isset($result['data'])) { |
|
510 | - $data = $result['data']; |
|
511 | - if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
512 | - return new RouteSchedule($data[0]); |
|
513 | - } |
|
514 | - } |
|
515 | - throw new ApiError('Can not convert result to RouteSchedule object.'); |
|
516 | - } |
|
22 | + public function __construct() |
|
23 | + { |
|
24 | + Route4Me::setBaseUrl(''); |
|
25 | + } |
|
26 | + |
|
27 | + /** |
|
28 | + * Create a new Schedule by sending the corresponding data. |
|
29 | + * |
|
30 | + * @since 1.2.3 |
|
31 | + * |
|
32 | + * @param array $params |
|
33 | + * string schedule_uid - Schedule ID, |
|
34 | + * int root_member_id, |
|
35 | + * string name - Name of Schedule, |
|
36 | + * string[] schedule_blacklist - An array of blacklisted dates as 'YYYY-MM-DD', |
|
37 | + * int advance_interval, |
|
38 | + * int advance_schedule_interval_days, |
|
39 | + * string schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily", |
|
40 | + * "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}', |
|
41 | + * string timezone - Timezone as 'America/New_York' |
|
42 | + * @return Schedule |
|
43 | + * @throws Exception\ApiError |
|
44 | + */ |
|
45 | + public function createSchedule(array $params) : Schedule |
|
46 | + { |
|
47 | + $allBodyFields = ['schedule_uid', 'root_member_id', 'name', 'schedule_blacklist', |
|
48 | + 'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone']; |
|
49 | + |
|
50 | + return $this->toSchedule(Route4Me::makeRequst([ |
|
51 | + 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES, |
|
52 | + 'method' => 'POST', |
|
53 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
54 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
55 | + ])); |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Get the Schedule by specifying the Schedule ID. |
|
60 | + * |
|
61 | + * @since 1.2.3 |
|
62 | + * |
|
63 | + * @param string $scheduleId Schedule ID. |
|
64 | + * @return Schedule |
|
65 | + * @throws Exception\ApiError |
|
66 | + */ |
|
67 | + public function getSchedule(string $scheduleId) : Schedule |
|
68 | + { |
|
69 | + return $this->toSchedule(Route4Me::makeRequst([ |
|
70 | + 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId, |
|
71 | + 'method' => 'GET' |
|
72 | + ])); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Get the list of all Schedules. |
|
77 | + * |
|
78 | + * @since 1.2.3 |
|
79 | + * |
|
80 | + * @return Schedule[] |
|
81 | + * @throws Exception\ApiError |
|
82 | + */ |
|
83 | + public function getAllSchedules() : array |
|
84 | + { |
|
85 | + $result = Route4Me::makeRequst([ |
|
86 | + 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES, |
|
87 | + 'method' => 'GET' |
|
88 | + ]); |
|
89 | + |
|
90 | + if (is_array($result) && isset($result['data'])) { |
|
91 | + $data = $result['data']; |
|
92 | + if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
93 | + $arr = []; |
|
94 | + foreach ($data as $key => $value) { |
|
95 | + array_push($arr, new Schedule($value)); |
|
96 | + } |
|
97 | + return $arr; |
|
98 | + } |
|
99 | + } |
|
100 | + return null; |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Get paginated list of Schedules. |
|
105 | + * |
|
106 | + * @since 1.2.3 |
|
107 | + * |
|
108 | + * @param int $page Requested page. |
|
109 | + * @param int $per_page Number of Schedules per page. |
|
110 | + * @return array |
|
111 | + * @throws Exception\ApiError |
|
112 | + */ |
|
113 | + public function getSchedules(int $page = 1, int $per_page = 15) : array |
|
114 | + { |
|
115 | + $result = Route4Me::makeRequst([ |
|
116 | + 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES_PAGINATION, |
|
117 | + 'method' => 'GET', |
|
118 | + 'query' => [ |
|
119 | + 'with_pagination' => true, |
|
120 | + 'page' => $page, |
|
121 | + 'per_page' => $per_page |
|
122 | + ] |
|
123 | + ]); |
|
124 | + |
|
125 | + if (is_array($result) && isset($result['data'])) { |
|
126 | + $data = $result['data']; |
|
127 | + $schedules = []; |
|
128 | + if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
129 | + foreach ($data as $key => $value) { |
|
130 | + array_push($schedules, new Schedule($value)); |
|
131 | + } |
|
132 | + } |
|
133 | + return [ |
|
134 | + 'schedules' => $schedules, |
|
135 | + 'page_info' => new PageInfo($result['links'], $result['meta']) |
|
136 | + ]; |
|
137 | + } |
|
138 | + return null; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Update the existing Schedule by sending the corresponding data. |
|
143 | + * |
|
144 | + * @since 1.2.3 |
|
145 | + * |
|
146 | + * @param string $schedule_uid Schedule ID |
|
147 | + * @param array $params |
|
148 | + * string schedule_uid - Schedule ID, |
|
149 | + * int root_member_id, |
|
150 | + * string name - Name of Schedule, |
|
151 | + * string[] schedule_blacklist - An array of blacklisted dates as 'YYYY-MM-DD', |
|
152 | + * int advance_interval, |
|
153 | + * int advance_schedule_interval_days, |
|
154 | + * string schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily", |
|
155 | + * "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}', |
|
156 | + * string timezone - Timezone as 'America/New_York' |
|
157 | + * @return Schedule |
|
158 | + * @throws Exception\ApiError |
|
159 | + */ |
|
160 | + public function updateSchedule(string $scheduleId, array $params) : Schedule |
|
161 | + { |
|
162 | + $allBodyFields = ['root_member_id', 'name', 'schedule_blacklist', |
|
163 | + 'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone']; |
|
164 | + |
|
165 | + return $this->toSchedule(Route4Me::makeRequst([ |
|
166 | + 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId, |
|
167 | + 'method' => 'PUT', |
|
168 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
169 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
170 | + ])); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Delete the specified Schedule with the option to delete the associated route. |
|
175 | + * |
|
176 | + * @since 1.2.3 |
|
177 | + * |
|
178 | + * @param string $schedule_uid Schedule ID |
|
179 | + * @param bool $withRoutes Delete the Schedule that matches the specified Schedule ID. |
|
180 | + * If the deleted Schedule has one or multiple associated Routes, |
|
181 | + * these Routes are also deleted. |
|
182 | + * @return Schedule |
|
183 | + * @throws Exception\ApiError |
|
184 | + */ |
|
185 | + public function deleteSchedule(string $scheduleId, bool $withRoutes = false) : Schedule |
|
186 | + { |
|
187 | + return $this->toSchedule(Route4Me::makeRequst([ |
|
188 | + 'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId, |
|
189 | + 'method' => 'DELETE', |
|
190 | + 'query' => ['with_routes' => $withRoutes] |
|
191 | + ])); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Create a new Route Schedule by sending the corresponding data. |
|
196 | + * |
|
197 | + * @since 1.2.3 |
|
198 | + * |
|
199 | + * @param array $params |
|
200 | + * string route_id - Route ID, |
|
201 | + * string schedule_uid - Schedule ID, |
|
202 | + * int member_id - A unique ID of the root member, |
|
203 | + * string vehicle_id - Vehicle ID |
|
204 | + * @return RouteSchedule |
|
205 | + * @throws Exception\ApiError |
|
206 | + */ |
|
207 | + public function createRouteSchedule(array $params) : RouteSchedule |
|
208 | + { |
|
209 | + $allBodyFields = ['route_id', 'schedule_uid', 'member_id', 'vehicle_id']; |
|
210 | + |
|
211 | + return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
212 | + 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES, |
|
213 | + 'method' => 'POST', |
|
214 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
215 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
216 | + ])); |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * Get the Route Schedule by specifying the Route ID. |
|
221 | + * |
|
222 | + * @since 1.2.3 |
|
223 | + * |
|
224 | + * @param string $routeId Route ID. |
|
225 | + * @return RouteSchedule |
|
226 | + * @throws Exception\ApiError |
|
227 | + */ |
|
228 | + public function getRouteSchedule(string $route_id) : RouteSchedule |
|
229 | + { |
|
230 | + return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
231 | + 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id, |
|
232 | + 'method' => 'GET' |
|
233 | + ])); |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Get the list of all Route Schedules. |
|
238 | + * |
|
239 | + * @since 1.2.3 |
|
240 | + * |
|
241 | + * @return RouteSchedule[] |
|
242 | + * @throws Exception\ApiError |
|
243 | + */ |
|
244 | + public function getAllRouteSchedules() : array |
|
245 | + { |
|
246 | + $result = Route4Me::makeRequst([ |
|
247 | + 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES, |
|
248 | + 'method' => 'GET' |
|
249 | + ]); |
|
250 | + |
|
251 | + if (is_array($result) && isset($result['data'])) { |
|
252 | + $data = $result['data']; |
|
253 | + if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
254 | + $arr = []; |
|
255 | + foreach ($data as $key => $value) { |
|
256 | + array_push($arr, new RouteSchedule($value)); |
|
257 | + } |
|
258 | + return $arr; |
|
259 | + } |
|
260 | + } |
|
261 | + return null; |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * Get paginated list of Route Schedules. |
|
266 | + * |
|
267 | + * @since 1.2.3 |
|
268 | + * |
|
269 | + * @param int $page Requested page. |
|
270 | + * @param int $per_page Number of Route Schedules per page. |
|
271 | + * @return array |
|
272 | + * @throws Exception\ApiError |
|
273 | + */ |
|
274 | + public function getRouteSchedules(int $page = 1, int $per_page = 15) : array |
|
275 | + { |
|
276 | + $result = Route4Me::makeRequst([ |
|
277 | + 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_PAGINATION, |
|
278 | + 'method' => 'GET', |
|
279 | + 'query' => [ |
|
280 | + 'with_pagination' => true, |
|
281 | + 'page' => $page, |
|
282 | + 'per_page' => $per_page |
|
283 | + ] |
|
284 | + ]); |
|
285 | + |
|
286 | + if (is_array($result) && isset($result['data'])) { |
|
287 | + $data = $result['data']; |
|
288 | + $route_schedules = []; |
|
289 | + if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
290 | + foreach ($data as $key => $value) { |
|
291 | + array_push($route_schedules, new RouteSchedule($value)); |
|
292 | + } |
|
293 | + } |
|
294 | + return [ |
|
295 | + 'route_schedules' => $route_schedules, |
|
296 | + 'page_info' => new PageInfo($result['links'], $result['meta']) |
|
297 | + ]; |
|
298 | + } |
|
299 | + return null; |
|
300 | + } |
|
301 | + |
|
302 | + /** |
|
303 | + * Update the existing Route Schedule by sending the corresponding data. |
|
304 | + * |
|
305 | + * @since 1.2.3 |
|
306 | + * |
|
307 | + * @param string $route_id Route ID |
|
308 | + * @param array $params |
|
309 | + * string schedule_uid - Schedule ID, |
|
310 | + * int member_id - A unique ID of the root member, |
|
311 | + * string vehicle_id - Vehicle ID |
|
312 | + * @return RouteSchedule |
|
313 | + * @throws Exception\ApiError |
|
314 | + */ |
|
315 | + public function updateRouteSchedule(string $route_id, array $params) : RouteSchedule |
|
316 | + { |
|
317 | + $allBodyFields = ['schedule_uid', 'member_id', 'vehicle_id']; |
|
318 | + |
|
319 | + return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
320 | + 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id, |
|
321 | + 'method' => 'PUT', |
|
322 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
323 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
324 | + ])); |
|
325 | + } |
|
326 | + |
|
327 | + /** |
|
328 | + * Delete the Route Schedules. |
|
329 | + * @todo request return true instead of return json status |
|
330 | + * |
|
331 | + * @since 1.2.3 |
|
332 | + * |
|
333 | + * @param string $route_id Route ID |
|
334 | + * @return bool |
|
335 | + * @throws Exception\ApiError |
|
336 | + */ |
|
337 | + public function deleteRouteSchedules(string $route_id) : bool |
|
338 | + { |
|
339 | + $result = Route4Me::makeRequst([ |
|
340 | + 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id, |
|
341 | + 'method' => 'DELETE' |
|
342 | + ]); |
|
343 | + return ($result == 1 ? true : false); |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Delete the specified Route Schedule. |
|
348 | + * |
|
349 | + * @since 1.2.3 |
|
350 | + * |
|
351 | + * @param string $route_id Route ID |
|
352 | + * @return RouteSchedule |
|
353 | + * @throws Exception\ApiError |
|
354 | + */ |
|
355 | + public function deleteRouteSchedule(string $route_id) : RouteSchedule |
|
356 | + { |
|
357 | + return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
358 | + 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/items', |
|
359 | + 'method' => 'DELETE' |
|
360 | + ])); |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Replace the existing Route Schedule by sending the corresponding data. |
|
365 | + * |
|
366 | + * @since 1.2.3 |
|
367 | + * |
|
368 | + * @param string $route_id Route ID. |
|
369 | + * @param array $params |
|
370 | + * int member_id - A unique ID of the root member, |
|
371 | + * string vehicle_id - Vehicle ID, |
|
372 | + * string schedule_uid - Schedule ID, |
|
373 | + * string name, |
|
374 | + * string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD, |
|
375 | + * int advance_interval, |
|
376 | + * int advance_schedule_interval_days, |
|
377 | + * string schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily", |
|
378 | + * "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}', |
|
379 | + * string timezone - Timezone as 'America/New_York' |
|
380 | + * @return RouteSchedule |
|
381 | + * @throws Exception\ApiError |
|
382 | + */ |
|
383 | + public function replaceRouteSchedule(string $route_id, array $params) |
|
384 | + { |
|
385 | + $allBodyFields = ['member_id', 'vehicle_id', 'schedule_uid', 'name', 'schedule_blacklist', |
|
386 | + 'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone']; |
|
387 | + |
|
388 | + return $this->toRouteSchedule(Route4Me::makeRequst([ |
|
389 | + 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE . '/' . $route_id, |
|
390 | + 'method' => 'PUT', |
|
391 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
392 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
393 | + ])); |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * Get the Route Schedule preview by specifying the 'route_id'. |
|
398 | + * |
|
399 | + * @since 1.2.3 |
|
400 | + * |
|
401 | + * @param string $routeId Route ID. |
|
402 | + * @param string $start Start date as 'YYYY-MM-DD' |
|
403 | + * @param string $end End date as 'YYYY-MM-DD' |
|
404 | + * @return array |
|
405 | + * @throws Exception\ApiError |
|
406 | + */ |
|
407 | + public function getRouteSchedulePreview(string $route_id, string $start, string $end) : array |
|
408 | + { |
|
409 | + return Route4Me::makeRequst([ |
|
410 | + 'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/preview', |
|
411 | + 'method' => 'GET', |
|
412 | + 'query' => ['start' => $start, 'end' => $end] |
|
413 | + ]); |
|
414 | + } |
|
415 | + |
|
416 | + /** |
|
417 | + * Check if the Scheduled Route was copied by specifying the 'route_id'. |
|
418 | + * @todo request return true instead of return json status |
|
419 | + * |
|
420 | + * @since 1.2.3 |
|
421 | + * |
|
422 | + * @param string $routeId Route ID. |
|
423 | + * @return bool |
|
424 | + * @throws Exception\ApiError |
|
425 | + */ |
|
426 | + public function isScheduledRouteCopy(string $route_id) : bool |
|
427 | + { |
|
428 | + return Route4Me::makeRequst([ |
|
429 | + 'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY . '/' . $route_id, |
|
430 | + 'method' => 'GET' |
|
431 | + ]); |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Get all routes copied from the specified Scheduled Route by sending |
|
436 | + * the corresponding data. |
|
437 | + * |
|
438 | + * @since 1.2.3 |
|
439 | + * |
|
440 | + * @param string $route_id Route ID. |
|
441 | + * @param string $schedule_uid Schedule ID. |
|
442 | + * @param string $route_date Route date as 'YYYY-MM-DD'. |
|
443 | + * @return array |
|
444 | + * @throws Exception\ApiError |
|
445 | + */ |
|
446 | + public function getScheduledRoutesCopies(string $route_id, string $schedule_uid, string $route_date) : array |
|
447 | + { |
|
448 | + return Route4Me::makeRequst([ |
|
449 | + 'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES, |
|
450 | + 'method' => 'POST', |
|
451 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
452 | + 'body' => [ |
|
453 | + 'route_id' => $route_id, |
|
454 | + 'schedule_uid' => $schedule_uid, |
|
455 | + 'route_date' => $route_date |
|
456 | + ] |
|
457 | + ]); |
|
458 | + } |
|
459 | + |
|
460 | + /** |
|
461 | + * Create a new Master Route by sending the corresponding data. |
|
462 | + * @todo request return true instead of return json status |
|
463 | + * |
|
464 | + * @since 1.2.3 |
|
465 | + * |
|
466 | + * @param array $params |
|
467 | + * string route_id - Route ID, |
|
468 | + * string route_name, |
|
469 | + * int member_id - A unique ID of the root member, |
|
470 | + * string vehicle_id - Vehicle ID, |
|
471 | + * string schedule_uid - Schedule ID, |
|
472 | + * string name, |
|
473 | + * string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD, |
|
474 | + * int advance_interval, |
|
475 | + * int advance_schedule_interval_days, |
|
476 | + * string schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily", |
|
477 | + * "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}', |
|
478 | + * bool sync - Type of result, synchronous or not |
|
479 | + * string timezone - Timezone as 'America/New_York' |
|
480 | + * @return bool |
|
481 | + * @throws Exception\ApiError |
|
482 | + */ |
|
483 | + public function createMasterRoute(array $params) : bool |
|
484 | + { |
|
485 | + $allBodyFields = ['route_id', 'route_name', 'member_id', 'schedule_uid', 'vehicle_id', 'name', |
|
486 | + 'schedule_blacklist', 'advance_schedule_interval_days', 'schedule', 'timezone', 'sync']; |
|
487 | + |
|
488 | + return Route4Me::makeRequst([ |
|
489 | + 'url' => Endpoint::RECURRING_ROUTES_MASTER_ROUTES, |
|
490 | + 'method' => 'POST', |
|
491 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
492 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
493 | + ]); |
|
494 | + } |
|
495 | + |
|
496 | + private function toSchedule($result) : Schedule |
|
497 | + { |
|
498 | + if (is_array($result) && isset($result['data'])) { |
|
499 | + $data = $result['data']; |
|
500 | + if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
501 | + return new Schedule($data[0]); |
|
502 | + } |
|
503 | + } |
|
504 | + throw new ApiError('Can not convert result to Schedule object.'); |
|
505 | + } |
|
506 | + |
|
507 | + private function toRouteSchedule($result) : RouteSchedule |
|
508 | + { |
|
509 | + if (is_array($result) && isset($result['data'])) { |
|
510 | + $data = $result['data']; |
|
511 | + if (is_array($data) && isset($data[0]) && is_array($data[0])) { |
|
512 | + return new RouteSchedule($data[0]); |
|
513 | + } |
|
514 | + } |
|
515 | + throw new ApiError('Can not convert result to RouteSchedule object.'); |
|
516 | + } |
|
517 | 517 | } |
@@ -26,539 +26,539 @@ |
||
26 | 26 | |
27 | 27 | class VehicleTests extends TestCase |
28 | 28 | { |
29 | - public static $createdVehicles = []; |
|
30 | - public static $createdVehicleProfiles = []; |
|
31 | - |
|
32 | - public static function setUpBeforeClass() |
|
33 | - { |
|
34 | - Route4Me::setApiKey(Constants::API_KEY); |
|
35 | - |
|
36 | - $vehicle = new Vehicle(); |
|
37 | - |
|
38 | - //region Create Test Vehicles |
|
39 | - |
|
40 | - $class6TruckParams = Vehicle::fromArray([ |
|
41 | - 'vehicle_alias' => 'GMC TopKick C5500 TST 6', |
|
42 | - 'vehicle_vin' => 'SAJXA01A06FN08012', |
|
43 | - 'vehicle_license_plate' => 'CVH4561', |
|
44 | - 'vehicle_model' => 'TopKick C5500', |
|
45 | - 'vehicle_model_year' => 1995, |
|
46 | - 'vehicle_year_acquired' => 2008, |
|
47 | - 'vehicle_reg_country_id' => 223, |
|
48 | - 'vehicle_reg_state_id' => 12, |
|
49 | - 'vehicle_make' => 'GMC', |
|
50 | - 'vehicle_type_id' => 'pickup_truck', |
|
51 | - 'vehicle_cost_new' => 60000, |
|
52 | - 'purchased_new' => true, |
|
53 | - 'mpg_city' => 8, |
|
54 | - 'mpg_highway' => 14, |
|
55 | - 'fuel_type' => 'diesel', |
|
56 | - 'license_start_date' => '2021-01-01', |
|
57 | - 'license_end_date' => '2031-01-01', |
|
58 | - ]); |
|
59 | - |
|
60 | - $result = $vehicle->createVehicle($class6TruckParams); |
|
61 | - |
|
62 | - self::assertNotNull($result); |
|
63 | - self::assertInstanceOf( |
|
64 | - Vehicle::class, |
|
65 | - Vehicle::fromArray($result) |
|
66 | - ); |
|
67 | - |
|
68 | - self::$createdVehicles[] = $result; |
|
69 | - |
|
70 | - |
|
71 | - $class7TruckParams = Vehicle::fromArray([ |
|
72 | - 'vehicle_alias' => 'FORD F750 TST 7', |
|
73 | - 'vehicle_vin' => '1NPAX6EX2YD550743', |
|
74 | - 'vehicle_license_plate' => 'FFV9547', |
|
75 | - 'vehicle_model' => 'F-750', |
|
76 | - 'vehicle_model_year' => 2010, |
|
77 | - 'vehicle_year_acquired' => 2018, |
|
78 | - 'vehicle_reg_country_id' => 223, |
|
79 | - 'vehicle_make' => 'Ford', |
|
80 | - 'vehicle_type_id' => 'livestock_carrier', |
|
81 | - 'vehicle_cost_new' => 60000, |
|
82 | - 'purchased_new' => true, |
|
83 | - 'mpg_city' => 7, |
|
84 | - 'mpg_highway' => 14, |
|
85 | - 'fuel_consumption_city' => 7, |
|
86 | - 'fuel_consumption_highway' => 14, |
|
87 | - 'fuel_type' => 'diesel', |
|
88 | - 'license_start_date' => '2021-01-01', |
|
89 | - 'license_end_date' => '2031-01-01', |
|
90 | - ]); |
|
91 | - |
|
92 | - $result = $vehicle->createVehicle($class7TruckParams); |
|
93 | - |
|
94 | - self::assertNotNull($result); |
|
95 | - self::assertInstanceOf( |
|
96 | - Vehicle::class, |
|
97 | - Vehicle::fromArray($result) |
|
98 | - ); |
|
99 | - |
|
100 | - self::$createdVehicles[] = $result; |
|
101 | - |
|
102 | - //endregion |
|
103 | - |
|
104 | - #region Create Test Vehicle Profiles |
|
105 | - |
|
106 | - $profile1 = new VehicleProfile(); |
|
107 | - |
|
108 | - $profile1->name = "Heavy Duty - 28 Double Trailer ".date('Y-m-d H:i'); |
|
109 | - $profile1->height_units = VehicleSizeUnits::METER; |
|
110 | - $profile1->width_units = VehicleSizeUnits::METER; |
|
111 | - $profile1->length_units = VehicleSizeUnits::METER; |
|
112 | - $profile1->height = 4; |
|
113 | - $profile1->width = 2.44; |
|
114 | - $profile1->length = 12.2; |
|
115 | - $profile1->is_predefined = false; |
|
116 | - $profile1->is_default = false; |
|
117 | - $profile1->weight_units = VehicleWeightUnits::KILOGRAM; |
|
118 | - $profile1->weight = 20400; |
|
119 | - $profile1->max_weight_per_axle = 15400; |
|
120 | - $profile1->fuel_type = FuelTypes::UNLEADED_91; |
|
121 | - $profile1->fuel_consumption_city = 6; |
|
122 | - $profile1->fuel_consumption_highway = 12; |
|
123 | - $profile1->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
124 | - $profile1->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
125 | - |
|
126 | - $result1 = $profile1->createVehicleProfile($profile1->toArray()); |
|
127 | - |
|
128 | - self::assertNotNull($result1); |
|
129 | - self::assertInstanceOf( |
|
130 | - VehicleProfile::class, |
|
131 | - VehicleProfile::fromArray($result1) |
|
132 | - ); |
|
133 | - |
|
134 | - self::$createdVehicleProfiles[] = $result1; |
|
135 | - |
|
136 | - $profile2 = new VehicleProfile(); |
|
137 | - |
|
138 | - $profile2->name = "Heavy Duty - 40 Straight Truck ".date('Y-m-d H:i'); |
|
139 | - $profile2->height_units = VehicleSizeUnits::METER; |
|
140 | - $profile2->width_units = VehicleSizeUnits::METER; |
|
141 | - $profile2->length_units = VehicleSizeUnits::METER; |
|
142 | - $profile2->height = 4; |
|
143 | - $profile2->width = 2.44; |
|
144 | - $profile2->length = 14.6; |
|
145 | - $profile2->is_predefined = false; |
|
146 | - $profile2->is_default = false; |
|
147 | - $profile2->weight_units = VehicleWeightUnits::KILOGRAM; |
|
148 | - $profile2->weight = 36300; |
|
149 | - $profile2->max_weight_per_axle = 15400; |
|
150 | - $profile2->fuel_type = FuelTypes::UNLEADED_87; |
|
151 | - $profile2->fuel_consumption_city = 5; |
|
152 | - $profile2->fuel_consumption_highway = 10; |
|
153 | - $profile2->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
154 | - $profile2->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
155 | - |
|
156 | - $result2 = $profile2->createVehicleProfile($profile2->toArray()); |
|
157 | - |
|
158 | - self::assertNotNull($result2); |
|
159 | - self::assertInstanceOf( |
|
160 | - VehicleProfile::class, |
|
161 | - VehicleProfile::fromArray($result2) |
|
162 | - ); |
|
163 | - |
|
164 | - self::$createdVehicleProfiles[] = $result2; |
|
165 | - |
|
166 | - #endregion |
|
167 | - } |
|
168 | - |
|
169 | - public function testFromArray() |
|
170 | - { |
|
171 | - $class6TruckParams = Vehicle::fromArray([ |
|
172 | - 'vehicle_alias' => 'GMC TopKick C5500 TST 6', |
|
173 | - 'vehicle_vin' => 'SAJXA01A06FN08012', |
|
174 | - 'vehicle_license_plate' => 'CVH4561', |
|
175 | - 'vehicle_model' => 'TopKick C5500', |
|
176 | - 'vehicle_model_year' => 1995, |
|
177 | - 'vehicle_year_acquired' => 2008, |
|
178 | - 'vehicle_reg_country_id' => 223, |
|
179 | - 'vehicle_reg_state_id' => 12, |
|
180 | - 'vehicle_make' => 'GMC', |
|
181 | - 'vehicle_type_id' => 'pickup_truck', |
|
182 | - 'vehicle_cost_new' => 60000, |
|
183 | - 'purchased_new' => true, |
|
184 | - 'mpg_city' => 8, |
|
185 | - 'mpg_highway' => 14, |
|
186 | - 'fuel_type' => 'diesel', |
|
187 | - 'license_start_date' => '2021-01-01', |
|
188 | - 'license_end_date' => '2031-01-01', |
|
189 | - ]); |
|
190 | - |
|
191 | - $this->assertEquals($class6TruckParams->vehicle_alias, 'GMC TopKick C5500 TST 6'); |
|
192 | - $this->assertEquals($class6TruckParams->vehicle_vin, 'SAJXA01A06FN08012'); |
|
193 | - $this->assertEquals($class6TruckParams->vehicle_license_plate, 'CVH4561'); |
|
194 | - $this->assertEquals($class6TruckParams->vehicle_model, 'TopKick C5500'); |
|
195 | - $this->assertEquals($class6TruckParams->vehicle_model_year, 1995); |
|
196 | - $this->assertEquals($class6TruckParams->vehicle_year_acquired, 2008); |
|
197 | - $this->assertEquals($class6TruckParams->vehicle_reg_country_id, 223); |
|
198 | - $this->assertEquals($class6TruckParams->vehicle_reg_state_id, 12); |
|
199 | - $this->assertEquals($class6TruckParams->vehicle_make, 'GMC'); |
|
200 | - $this->assertEquals($class6TruckParams->vehicle_type_id, 'pickup_truck'); |
|
201 | - $this->assertEquals($class6TruckParams->vehicle_cost_new, 60000); |
|
202 | - $this->assertEquals($class6TruckParams->purchased_new, true); |
|
203 | - $this->assertEquals($class6TruckParams->mpg_city, 8); |
|
204 | - $this->assertEquals($class6TruckParams->mpg_highway, 14); |
|
205 | - $this->assertEquals($class6TruckParams->fuel_type, 'diesel'); |
|
206 | - $this->assertEquals($class6TruckParams->license_start_date, '2021-01-01'); |
|
207 | - $this->assertEquals($class6TruckParams->license_end_date, '2031-01-01'); |
|
208 | - } |
|
209 | - |
|
210 | - public function testGetVehiclesPaginatedList() |
|
211 | - { |
|
212 | - $vehParams = new VehicleParameters(); |
|
213 | - |
|
214 | - $vehParams->with_pagination = true; |
|
215 | - $vehParams->page = 1; |
|
216 | - $vehParams->perPage = 10; |
|
217 | - |
|
218 | - $vehicle = new Vehicle(); |
|
219 | - |
|
220 | - $result = $vehicle->getVehiclesPaginatedList($vehParams->toArray()); |
|
221 | - |
|
222 | - $this->assertNotNull($result); |
|
223 | - $this->assertTrue(is_array($result)); |
|
224 | - $this->assertTrue(sizeof($result)>0); |
|
225 | - $this->assertInstanceOf(Vehicle::class, Vehicle::fromArray($result)); |
|
226 | - } |
|
227 | - |
|
228 | - public function testCreateVehicle() |
|
229 | - { |
|
230 | - $vehicle = new Vehicle(); |
|
231 | - |
|
232 | - $class7TruckParams = Vehicle::fromArray([ |
|
233 | - 'vehicle_alias' => 'FORD F750 TST 7', |
|
234 | - 'vehicle_vin' => '1NPAX6EX2YD550743', |
|
235 | - 'vehicle_license_plate' => 'FFV9547', |
|
236 | - 'vehicle_model' => 'F-750', |
|
237 | - 'vehicle_model_year' => 2010, |
|
238 | - 'vehicle_year_acquired' => 2018, |
|
239 | - 'vehicle_reg_country_id' => 223, |
|
240 | - 'vehicle_reg_state_id' => 12, |
|
241 | - 'vehicle_make' => 'Ford', |
|
242 | - 'vehicle_type_id' => 'livestock_carrier', |
|
243 | - 'vehicle_cost_new' => 70000, |
|
244 | - 'purchased_new' => false, |
|
245 | - 'mpg_city' => 6, |
|
246 | - 'mpg_highway' => 12, |
|
247 | - 'fuel_consumption_city' => 6, |
|
248 | - 'fuel_consumption_highway' => 12, |
|
249 | - 'fuel_type' => 'diesel', |
|
250 | - 'license_start_date' => '2020-03-01', |
|
251 | - 'license_end_date' => '2028-12-01', |
|
252 | - ]); |
|
253 | - |
|
254 | - $result = $vehicle->createVehicle($class7TruckParams); |
|
255 | - |
|
256 | - self::assertNotNull($result); |
|
257 | - self::assertInstanceOf( |
|
258 | - Vehicle::class, |
|
259 | - Vehicle::fromArray($result) |
|
260 | - ); |
|
261 | - |
|
262 | - self::$createdVehicles[] = $result; |
|
263 | - } |
|
264 | - |
|
265 | - public function testCreateTemporaryVehicle() |
|
266 | - { |
|
267 | - $this->markTestSkipped('The endpoint vehicles/assign is enabled for the accounts with the specified features.'); |
|
268 | - |
|
269 | - $vehicle = new Vehicle(); |
|
270 | - |
|
271 | - $tempVehParams = new VehicleTemporary(); |
|
272 | - |
|
273 | - $tempVehParams->assigned_member_id = 1; |
|
274 | - $tempVehParams->expires_at = '2028-12-20'; |
|
275 | - $tempVehParams->force_assignment = true; |
|
276 | - $tempVehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
277 | - $tempVehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate']; |
|
278 | - |
|
279 | - $result = $vehicle->createTemporaryVehicle($tempVehParams->toArray()); |
|
280 | - |
|
281 | - self::assertNotNull($result); |
|
282 | - self::assertInstanceOf( |
|
283 | - VehicleTemporary::class, |
|
284 | - VehicleTemporary::fromArray($result) |
|
285 | - ); |
|
286 | - } |
|
287 | - |
|
288 | - public function testExecuteVehicleOrder() |
|
289 | - { |
|
290 | - $this->markTestSkipped('The endpoint vehicles/execute is enabled for the account with the specified features.'); |
|
291 | - |
|
292 | - $vehicle = new Vehicle(); |
|
293 | - |
|
294 | - $orderParams = new VehicleOrderParameters(); |
|
295 | - $orderParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
296 | - $orderParams->lat = 38.247605; |
|
297 | - $orderParams->lng = -85.746697; |
|
298 | - |
|
299 | - $result = $vehicle->executeVehicleOrder($orderParams->toArray()); |
|
300 | - |
|
301 | - self::assertNotNull($result); |
|
302 | - self::assertInstanceOf( |
|
303 | - VehicleOrderResponse::class, |
|
304 | - VehicleOrderResponse::fromArray($result) |
|
305 | - ); |
|
306 | - } |
|
307 | - |
|
308 | - public function testGetLatestVehicleLocations() |
|
309 | - { |
|
310 | - $vehicle = new Vehicle(); |
|
311 | - |
|
312 | - $vehicleIDs = array_column(self::$createdVehicles, 'vehicle_id'); |
|
313 | - |
|
314 | - $vehParams = new VehicleParameters(); |
|
315 | - $vehParams->ids = $vehicleIDs; |
|
316 | - |
|
317 | - $result = $vehicle->getVehicleLocations($vehParams); |
|
318 | - |
|
319 | - self::assertNotNull($result); |
|
320 | - self::assertInstanceOf( |
|
321 | - VehicleLocationResponse::class, |
|
322 | - VehicleLocationResponse::fromArray($result) |
|
323 | - ); |
|
324 | - self::assertTrue(isset($result['data'])); |
|
325 | - self::assertTrue(is_array($result['data'])); |
|
326 | - } |
|
327 | - |
|
328 | - public function testGetVehicleById() |
|
329 | - { |
|
330 | - $vehicle = new Vehicle(); |
|
331 | - |
|
332 | - $vehParams = new VehicleParameters(); |
|
333 | - $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
334 | - |
|
335 | - $result = $vehicle->getVehicleById($vehParams->toArray()); |
|
336 | - |
|
337 | - self::assertNotNull($result); |
|
338 | - self::assertInstanceOf( |
|
339 | - Vehicle::class, |
|
340 | - Vehicle::fromArray($result) |
|
341 | - ); |
|
342 | - self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - public function testGetVehicleTrack() |
|
347 | - { |
|
348 | - $vehicle = new Vehicle(); |
|
29 | + public static $createdVehicles = []; |
|
30 | + public static $createdVehicleProfiles = []; |
|
31 | + |
|
32 | + public static function setUpBeforeClass() |
|
33 | + { |
|
34 | + Route4Me::setApiKey(Constants::API_KEY); |
|
35 | + |
|
36 | + $vehicle = new Vehicle(); |
|
37 | + |
|
38 | + //region Create Test Vehicles |
|
39 | + |
|
40 | + $class6TruckParams = Vehicle::fromArray([ |
|
41 | + 'vehicle_alias' => 'GMC TopKick C5500 TST 6', |
|
42 | + 'vehicle_vin' => 'SAJXA01A06FN08012', |
|
43 | + 'vehicle_license_plate' => 'CVH4561', |
|
44 | + 'vehicle_model' => 'TopKick C5500', |
|
45 | + 'vehicle_model_year' => 1995, |
|
46 | + 'vehicle_year_acquired' => 2008, |
|
47 | + 'vehicle_reg_country_id' => 223, |
|
48 | + 'vehicle_reg_state_id' => 12, |
|
49 | + 'vehicle_make' => 'GMC', |
|
50 | + 'vehicle_type_id' => 'pickup_truck', |
|
51 | + 'vehicle_cost_new' => 60000, |
|
52 | + 'purchased_new' => true, |
|
53 | + 'mpg_city' => 8, |
|
54 | + 'mpg_highway' => 14, |
|
55 | + 'fuel_type' => 'diesel', |
|
56 | + 'license_start_date' => '2021-01-01', |
|
57 | + 'license_end_date' => '2031-01-01', |
|
58 | + ]); |
|
59 | + |
|
60 | + $result = $vehicle->createVehicle($class6TruckParams); |
|
61 | + |
|
62 | + self::assertNotNull($result); |
|
63 | + self::assertInstanceOf( |
|
64 | + Vehicle::class, |
|
65 | + Vehicle::fromArray($result) |
|
66 | + ); |
|
67 | + |
|
68 | + self::$createdVehicles[] = $result; |
|
69 | + |
|
70 | + |
|
71 | + $class7TruckParams = Vehicle::fromArray([ |
|
72 | + 'vehicle_alias' => 'FORD F750 TST 7', |
|
73 | + 'vehicle_vin' => '1NPAX6EX2YD550743', |
|
74 | + 'vehicle_license_plate' => 'FFV9547', |
|
75 | + 'vehicle_model' => 'F-750', |
|
76 | + 'vehicle_model_year' => 2010, |
|
77 | + 'vehicle_year_acquired' => 2018, |
|
78 | + 'vehicle_reg_country_id' => 223, |
|
79 | + 'vehicle_make' => 'Ford', |
|
80 | + 'vehicle_type_id' => 'livestock_carrier', |
|
81 | + 'vehicle_cost_new' => 60000, |
|
82 | + 'purchased_new' => true, |
|
83 | + 'mpg_city' => 7, |
|
84 | + 'mpg_highway' => 14, |
|
85 | + 'fuel_consumption_city' => 7, |
|
86 | + 'fuel_consumption_highway' => 14, |
|
87 | + 'fuel_type' => 'diesel', |
|
88 | + 'license_start_date' => '2021-01-01', |
|
89 | + 'license_end_date' => '2031-01-01', |
|
90 | + ]); |
|
91 | + |
|
92 | + $result = $vehicle->createVehicle($class7TruckParams); |
|
93 | + |
|
94 | + self::assertNotNull($result); |
|
95 | + self::assertInstanceOf( |
|
96 | + Vehicle::class, |
|
97 | + Vehicle::fromArray($result) |
|
98 | + ); |
|
99 | + |
|
100 | + self::$createdVehicles[] = $result; |
|
101 | + |
|
102 | + //endregion |
|
103 | + |
|
104 | + #region Create Test Vehicle Profiles |
|
105 | + |
|
106 | + $profile1 = new VehicleProfile(); |
|
107 | + |
|
108 | + $profile1->name = "Heavy Duty - 28 Double Trailer ".date('Y-m-d H:i'); |
|
109 | + $profile1->height_units = VehicleSizeUnits::METER; |
|
110 | + $profile1->width_units = VehicleSizeUnits::METER; |
|
111 | + $profile1->length_units = VehicleSizeUnits::METER; |
|
112 | + $profile1->height = 4; |
|
113 | + $profile1->width = 2.44; |
|
114 | + $profile1->length = 12.2; |
|
115 | + $profile1->is_predefined = false; |
|
116 | + $profile1->is_default = false; |
|
117 | + $profile1->weight_units = VehicleWeightUnits::KILOGRAM; |
|
118 | + $profile1->weight = 20400; |
|
119 | + $profile1->max_weight_per_axle = 15400; |
|
120 | + $profile1->fuel_type = FuelTypes::UNLEADED_91; |
|
121 | + $profile1->fuel_consumption_city = 6; |
|
122 | + $profile1->fuel_consumption_highway = 12; |
|
123 | + $profile1->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
124 | + $profile1->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
125 | + |
|
126 | + $result1 = $profile1->createVehicleProfile($profile1->toArray()); |
|
127 | + |
|
128 | + self::assertNotNull($result1); |
|
129 | + self::assertInstanceOf( |
|
130 | + VehicleProfile::class, |
|
131 | + VehicleProfile::fromArray($result1) |
|
132 | + ); |
|
133 | + |
|
134 | + self::$createdVehicleProfiles[] = $result1; |
|
135 | + |
|
136 | + $profile2 = new VehicleProfile(); |
|
137 | + |
|
138 | + $profile2->name = "Heavy Duty - 40 Straight Truck ".date('Y-m-d H:i'); |
|
139 | + $profile2->height_units = VehicleSizeUnits::METER; |
|
140 | + $profile2->width_units = VehicleSizeUnits::METER; |
|
141 | + $profile2->length_units = VehicleSizeUnits::METER; |
|
142 | + $profile2->height = 4; |
|
143 | + $profile2->width = 2.44; |
|
144 | + $profile2->length = 14.6; |
|
145 | + $profile2->is_predefined = false; |
|
146 | + $profile2->is_default = false; |
|
147 | + $profile2->weight_units = VehicleWeightUnits::KILOGRAM; |
|
148 | + $profile2->weight = 36300; |
|
149 | + $profile2->max_weight_per_axle = 15400; |
|
150 | + $profile2->fuel_type = FuelTypes::UNLEADED_87; |
|
151 | + $profile2->fuel_consumption_city = 5; |
|
152 | + $profile2->fuel_consumption_highway = 10; |
|
153 | + $profile2->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
154 | + $profile2->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
155 | + |
|
156 | + $result2 = $profile2->createVehicleProfile($profile2->toArray()); |
|
157 | + |
|
158 | + self::assertNotNull($result2); |
|
159 | + self::assertInstanceOf( |
|
160 | + VehicleProfile::class, |
|
161 | + VehicleProfile::fromArray($result2) |
|
162 | + ); |
|
163 | + |
|
164 | + self::$createdVehicleProfiles[] = $result2; |
|
165 | + |
|
166 | + #endregion |
|
167 | + } |
|
168 | + |
|
169 | + public function testFromArray() |
|
170 | + { |
|
171 | + $class6TruckParams = Vehicle::fromArray([ |
|
172 | + 'vehicle_alias' => 'GMC TopKick C5500 TST 6', |
|
173 | + 'vehicle_vin' => 'SAJXA01A06FN08012', |
|
174 | + 'vehicle_license_plate' => 'CVH4561', |
|
175 | + 'vehicle_model' => 'TopKick C5500', |
|
176 | + 'vehicle_model_year' => 1995, |
|
177 | + 'vehicle_year_acquired' => 2008, |
|
178 | + 'vehicle_reg_country_id' => 223, |
|
179 | + 'vehicle_reg_state_id' => 12, |
|
180 | + 'vehicle_make' => 'GMC', |
|
181 | + 'vehicle_type_id' => 'pickup_truck', |
|
182 | + 'vehicle_cost_new' => 60000, |
|
183 | + 'purchased_new' => true, |
|
184 | + 'mpg_city' => 8, |
|
185 | + 'mpg_highway' => 14, |
|
186 | + 'fuel_type' => 'diesel', |
|
187 | + 'license_start_date' => '2021-01-01', |
|
188 | + 'license_end_date' => '2031-01-01', |
|
189 | + ]); |
|
190 | + |
|
191 | + $this->assertEquals($class6TruckParams->vehicle_alias, 'GMC TopKick C5500 TST 6'); |
|
192 | + $this->assertEquals($class6TruckParams->vehicle_vin, 'SAJXA01A06FN08012'); |
|
193 | + $this->assertEquals($class6TruckParams->vehicle_license_plate, 'CVH4561'); |
|
194 | + $this->assertEquals($class6TruckParams->vehicle_model, 'TopKick C5500'); |
|
195 | + $this->assertEquals($class6TruckParams->vehicle_model_year, 1995); |
|
196 | + $this->assertEquals($class6TruckParams->vehicle_year_acquired, 2008); |
|
197 | + $this->assertEquals($class6TruckParams->vehicle_reg_country_id, 223); |
|
198 | + $this->assertEquals($class6TruckParams->vehicle_reg_state_id, 12); |
|
199 | + $this->assertEquals($class6TruckParams->vehicle_make, 'GMC'); |
|
200 | + $this->assertEquals($class6TruckParams->vehicle_type_id, 'pickup_truck'); |
|
201 | + $this->assertEquals($class6TruckParams->vehicle_cost_new, 60000); |
|
202 | + $this->assertEquals($class6TruckParams->purchased_new, true); |
|
203 | + $this->assertEquals($class6TruckParams->mpg_city, 8); |
|
204 | + $this->assertEquals($class6TruckParams->mpg_highway, 14); |
|
205 | + $this->assertEquals($class6TruckParams->fuel_type, 'diesel'); |
|
206 | + $this->assertEquals($class6TruckParams->license_start_date, '2021-01-01'); |
|
207 | + $this->assertEquals($class6TruckParams->license_end_date, '2031-01-01'); |
|
208 | + } |
|
209 | + |
|
210 | + public function testGetVehiclesPaginatedList() |
|
211 | + { |
|
212 | + $vehParams = new VehicleParameters(); |
|
213 | + |
|
214 | + $vehParams->with_pagination = true; |
|
215 | + $vehParams->page = 1; |
|
216 | + $vehParams->perPage = 10; |
|
217 | + |
|
218 | + $vehicle = new Vehicle(); |
|
219 | + |
|
220 | + $result = $vehicle->getVehiclesPaginatedList($vehParams->toArray()); |
|
221 | + |
|
222 | + $this->assertNotNull($result); |
|
223 | + $this->assertTrue(is_array($result)); |
|
224 | + $this->assertTrue(sizeof($result)>0); |
|
225 | + $this->assertInstanceOf(Vehicle::class, Vehicle::fromArray($result)); |
|
226 | + } |
|
227 | + |
|
228 | + public function testCreateVehicle() |
|
229 | + { |
|
230 | + $vehicle = new Vehicle(); |
|
231 | + |
|
232 | + $class7TruckParams = Vehicle::fromArray([ |
|
233 | + 'vehicle_alias' => 'FORD F750 TST 7', |
|
234 | + 'vehicle_vin' => '1NPAX6EX2YD550743', |
|
235 | + 'vehicle_license_plate' => 'FFV9547', |
|
236 | + 'vehicle_model' => 'F-750', |
|
237 | + 'vehicle_model_year' => 2010, |
|
238 | + 'vehicle_year_acquired' => 2018, |
|
239 | + 'vehicle_reg_country_id' => 223, |
|
240 | + 'vehicle_reg_state_id' => 12, |
|
241 | + 'vehicle_make' => 'Ford', |
|
242 | + 'vehicle_type_id' => 'livestock_carrier', |
|
243 | + 'vehicle_cost_new' => 70000, |
|
244 | + 'purchased_new' => false, |
|
245 | + 'mpg_city' => 6, |
|
246 | + 'mpg_highway' => 12, |
|
247 | + 'fuel_consumption_city' => 6, |
|
248 | + 'fuel_consumption_highway' => 12, |
|
249 | + 'fuel_type' => 'diesel', |
|
250 | + 'license_start_date' => '2020-03-01', |
|
251 | + 'license_end_date' => '2028-12-01', |
|
252 | + ]); |
|
253 | + |
|
254 | + $result = $vehicle->createVehicle($class7TruckParams); |
|
255 | + |
|
256 | + self::assertNotNull($result); |
|
257 | + self::assertInstanceOf( |
|
258 | + Vehicle::class, |
|
259 | + Vehicle::fromArray($result) |
|
260 | + ); |
|
261 | + |
|
262 | + self::$createdVehicles[] = $result; |
|
263 | + } |
|
264 | + |
|
265 | + public function testCreateTemporaryVehicle() |
|
266 | + { |
|
267 | + $this->markTestSkipped('The endpoint vehicles/assign is enabled for the accounts with the specified features.'); |
|
268 | + |
|
269 | + $vehicle = new Vehicle(); |
|
270 | + |
|
271 | + $tempVehParams = new VehicleTemporary(); |
|
272 | + |
|
273 | + $tempVehParams->assigned_member_id = 1; |
|
274 | + $tempVehParams->expires_at = '2028-12-20'; |
|
275 | + $tempVehParams->force_assignment = true; |
|
276 | + $tempVehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
277 | + $tempVehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate']; |
|
278 | + |
|
279 | + $result = $vehicle->createTemporaryVehicle($tempVehParams->toArray()); |
|
280 | + |
|
281 | + self::assertNotNull($result); |
|
282 | + self::assertInstanceOf( |
|
283 | + VehicleTemporary::class, |
|
284 | + VehicleTemporary::fromArray($result) |
|
285 | + ); |
|
286 | + } |
|
287 | + |
|
288 | + public function testExecuteVehicleOrder() |
|
289 | + { |
|
290 | + $this->markTestSkipped('The endpoint vehicles/execute is enabled for the account with the specified features.'); |
|
291 | + |
|
292 | + $vehicle = new Vehicle(); |
|
293 | + |
|
294 | + $orderParams = new VehicleOrderParameters(); |
|
295 | + $orderParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
296 | + $orderParams->lat = 38.247605; |
|
297 | + $orderParams->lng = -85.746697; |
|
298 | + |
|
299 | + $result = $vehicle->executeVehicleOrder($orderParams->toArray()); |
|
300 | + |
|
301 | + self::assertNotNull($result); |
|
302 | + self::assertInstanceOf( |
|
303 | + VehicleOrderResponse::class, |
|
304 | + VehicleOrderResponse::fromArray($result) |
|
305 | + ); |
|
306 | + } |
|
307 | + |
|
308 | + public function testGetLatestVehicleLocations() |
|
309 | + { |
|
310 | + $vehicle = new Vehicle(); |
|
311 | + |
|
312 | + $vehicleIDs = array_column(self::$createdVehicles, 'vehicle_id'); |
|
313 | + |
|
314 | + $vehParams = new VehicleParameters(); |
|
315 | + $vehParams->ids = $vehicleIDs; |
|
316 | + |
|
317 | + $result = $vehicle->getVehicleLocations($vehParams); |
|
318 | + |
|
319 | + self::assertNotNull($result); |
|
320 | + self::assertInstanceOf( |
|
321 | + VehicleLocationResponse::class, |
|
322 | + VehicleLocationResponse::fromArray($result) |
|
323 | + ); |
|
324 | + self::assertTrue(isset($result['data'])); |
|
325 | + self::assertTrue(is_array($result['data'])); |
|
326 | + } |
|
327 | + |
|
328 | + public function testGetVehicleById() |
|
329 | + { |
|
330 | + $vehicle = new Vehicle(); |
|
331 | + |
|
332 | + $vehParams = new VehicleParameters(); |
|
333 | + $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
334 | + |
|
335 | + $result = $vehicle->getVehicleById($vehParams->toArray()); |
|
336 | + |
|
337 | + self::assertNotNull($result); |
|
338 | + self::assertInstanceOf( |
|
339 | + Vehicle::class, |
|
340 | + Vehicle::fromArray($result) |
|
341 | + ); |
|
342 | + self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + public function testGetVehicleTrack() |
|
347 | + { |
|
348 | + $vehicle = new Vehicle(); |
|
349 | 349 | |
350 | - $vehParams = new VehicleParameters(); |
|
351 | - $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
350 | + $vehParams = new VehicleParameters(); |
|
351 | + $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
352 | 352 | |
353 | - $result = $vehicle->getVehicleTrack($vehParams->toArray()); |
|
353 | + $result = $vehicle->getVehicleTrack($vehParams->toArray()); |
|
354 | 354 | |
355 | - self::assertNotNull($result); |
|
356 | - self::assertInstanceOf( |
|
357 | - VehicleTrackResponse::class, |
|
358 | - VehicleTrackResponse::fromArray($result) |
|
359 | - ); |
|
360 | - } |
|
355 | + self::assertNotNull($result); |
|
356 | + self::assertInstanceOf( |
|
357 | + VehicleTrackResponse::class, |
|
358 | + VehicleTrackResponse::fromArray($result) |
|
359 | + ); |
|
360 | + } |
|
361 | 361 | |
362 | - public function testDeleteVehicle() |
|
363 | - { |
|
364 | - $vehicle = new Vehicle(); |
|
362 | + public function testDeleteVehicle() |
|
363 | + { |
|
364 | + $vehicle = new Vehicle(); |
|
365 | 365 | |
366 | - $vehParams = new VehicleParameters(); |
|
367 | - $vehParams->vehicle_id = self::$createdVehicles[sizeof(self::$createdVehicles) - 1]['vehicle_id']; |
|
366 | + $vehParams = new VehicleParameters(); |
|
367 | + $vehParams->vehicle_id = self::$createdVehicles[sizeof(self::$createdVehicles) - 1]['vehicle_id']; |
|
368 | 368 | |
369 | - $result = $vehicle->removeVehicle($vehParams->toArray()); |
|
369 | + $result = $vehicle->removeVehicle($vehParams->toArray()); |
|
370 | 370 | |
371 | - self::assertNotNull($result); |
|
372 | - self::assertInstanceOf( |
|
373 | - Vehicle::class, |
|
374 | - Vehicle::fromArray($result) |
|
375 | - ); |
|
376 | - self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']); |
|
371 | + self::assertNotNull($result); |
|
372 | + self::assertInstanceOf( |
|
373 | + Vehicle::class, |
|
374 | + Vehicle::fromArray($result) |
|
375 | + ); |
|
376 | + self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']); |
|
377 | 377 | |
378 | - array_pop(self::$createdVehicles); |
|
379 | - } |
|
378 | + array_pop(self::$createdVehicles); |
|
379 | + } |
|
380 | 380 | |
381 | - public function testGetVehicleProfiles() |
|
382 | - { |
|
383 | - $vehicleProfile = new VehicleProfile(); |
|
381 | + public function testGetVehicleProfiles() |
|
382 | + { |
|
383 | + $vehicleProfile = new VehicleProfile(); |
|
384 | 384 | |
385 | - $vehProfileParams = new VehicleProfileParameters(); |
|
385 | + $vehProfileParams = new VehicleProfileParameters(); |
|
386 | 386 | |
387 | - $vehProfileParams->with_pagination = true; |
|
388 | - $vehProfileParams->page = 1; |
|
389 | - $vehProfileParams->perPage = 10; |
|
387 | + $vehProfileParams->with_pagination = true; |
|
388 | + $vehProfileParams->page = 1; |
|
389 | + $vehProfileParams->perPage = 10; |
|
390 | 390 | |
391 | - $result = $vehicleProfile->getVehicleProfiles($vehProfileParams->toArray()); |
|
391 | + $result = $vehicleProfile->getVehicleProfiles($vehProfileParams->toArray()); |
|
392 | 392 | |
393 | - self::assertNotNull($result); |
|
394 | - self::assertInstanceOf( |
|
395 | - VehicleProfilesResponse::class, |
|
396 | - VehicleProfilesResponse::fromArray($result) |
|
397 | - ); |
|
398 | - } |
|
393 | + self::assertNotNull($result); |
|
394 | + self::assertInstanceOf( |
|
395 | + VehicleProfilesResponse::class, |
|
396 | + VehicleProfilesResponse::fromArray($result) |
|
397 | + ); |
|
398 | + } |
|
399 | 399 | |
400 | - public function testCreateVehicleProfile() |
|
401 | - { |
|
402 | - $vehicleProfile = new VehicleProfile(); |
|
400 | + public function testCreateVehicleProfile() |
|
401 | + { |
|
402 | + $vehicleProfile = new VehicleProfile(); |
|
403 | 403 | |
404 | - $profile = new VehicleProfile(); |
|
404 | + $profile = new VehicleProfile(); |
|
405 | 405 | |
406 | - $profile->name = "Heavy Duty - 48 Semitrailer ".date('Y-m-d H:i'); |
|
407 | - $profile->height_units = VehicleSizeUnits::METER; |
|
408 | - $profile->width_units = VehicleSizeUnits::METER; |
|
409 | - $profile->length_units = VehicleSizeUnits::METER; |
|
410 | - $profile->height = 3.5; |
|
411 | - $profile->width = 2.5; |
|
412 | - $profile->length = 16; |
|
413 | - $profile->is_predefined = false; |
|
414 | - $profile->is_default = false; |
|
415 | - $profile->weight_units = VehicleWeightUnits::KILOGRAM; |
|
416 | - $profile->weight = 35000; |
|
417 | - $profile->max_weight_per_axle = 17500; |
|
418 | - $profile->fuel_type = FuelTypes::UNLEADED_87; |
|
419 | - $profile->fuel_consumption_city = 6; |
|
420 | - $profile->fuel_consumption_highway = 11; |
|
421 | - $profile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
422 | - $profile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
406 | + $profile->name = "Heavy Duty - 48 Semitrailer ".date('Y-m-d H:i'); |
|
407 | + $profile->height_units = VehicleSizeUnits::METER; |
|
408 | + $profile->width_units = VehicleSizeUnits::METER; |
|
409 | + $profile->length_units = VehicleSizeUnits::METER; |
|
410 | + $profile->height = 3.5; |
|
411 | + $profile->width = 2.5; |
|
412 | + $profile->length = 16; |
|
413 | + $profile->is_predefined = false; |
|
414 | + $profile->is_default = false; |
|
415 | + $profile->weight_units = VehicleWeightUnits::KILOGRAM; |
|
416 | + $profile->weight = 35000; |
|
417 | + $profile->max_weight_per_axle = 17500; |
|
418 | + $profile->fuel_type = FuelTypes::UNLEADED_87; |
|
419 | + $profile->fuel_consumption_city = 6; |
|
420 | + $profile->fuel_consumption_highway = 11; |
|
421 | + $profile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
422 | + $profile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
423 | 423 | |
424 | 424 | |
425 | - $result = $vehicleProfile->createVehicleProfile($profile->toArray()); |
|
425 | + $result = $vehicleProfile->createVehicleProfile($profile->toArray()); |
|
426 | 426 | |
427 | - self::assertNotNull($result); |
|
428 | - self::assertInstanceOf( |
|
429 | - VehicleProfile::class, |
|
430 | - VehicleProfile::fromArray($result) |
|
431 | - ); |
|
427 | + self::assertNotNull($result); |
|
428 | + self::assertInstanceOf( |
|
429 | + VehicleProfile::class, |
|
430 | + VehicleProfile::fromArray($result) |
|
431 | + ); |
|
432 | 432 | |
433 | - self::$createdVehicleProfiles[] = $result; |
|
434 | - } |
|
433 | + self::$createdVehicleProfiles[] = $result; |
|
434 | + } |
|
435 | 435 | |
436 | - public function testDeleteVehicleProfile() |
|
437 | - { |
|
438 | - $vehicleProfile = new VehicleProfile(); |
|
436 | + public function testDeleteVehicleProfile() |
|
437 | + { |
|
438 | + $vehicleProfile = new VehicleProfile(); |
|
439 | 439 | |
440 | - $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
440 | + $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
441 | 441 | |
442 | - $result = $vehicleProfile->removeVehicleProfile($vehProfileId); |
|
442 | + $result = $vehicleProfile->removeVehicleProfile($vehProfileId); |
|
443 | 443 | |
444 | - self::assertNotNull($result); |
|
445 | - self::assertInstanceOf( |
|
446 | - VehicleProfile::class, |
|
447 | - VehicleProfile::fromArray($result) |
|
448 | - ); |
|
444 | + self::assertNotNull($result); |
|
445 | + self::assertInstanceOf( |
|
446 | + VehicleProfile::class, |
|
447 | + VehicleProfile::fromArray($result) |
|
448 | + ); |
|
449 | 449 | |
450 | - array_pop(self::$createdVehicleProfiles); |
|
451 | - } |
|
450 | + array_pop(self::$createdVehicleProfiles); |
|
451 | + } |
|
452 | 452 | |
453 | - public function testGetVehicleProfileById() |
|
454 | - { |
|
455 | - $vehicleProfile = new VehicleProfile(); |
|
456 | - |
|
457 | - $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
453 | + public function testGetVehicleProfileById() |
|
454 | + { |
|
455 | + $vehicleProfile = new VehicleProfile(); |
|
456 | + |
|
457 | + $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
458 | 458 | |
459 | - $result = $vehicleProfile->getVehicleProfileById($vehProfileId); |
|
459 | + $result = $vehicleProfile->getVehicleProfileById($vehProfileId); |
|
460 | 460 | |
461 | - self::assertNotNull($result); |
|
462 | - self::assertInstanceOf( |
|
463 | - VehicleProfile::class, |
|
464 | - VehicleProfile::fromArray($result) |
|
465 | - ); |
|
466 | - self::assertEquals($vehProfileId, $result['vehicle_profile_id']); |
|
467 | - } |
|
468 | - |
|
469 | - public function testGetVehicleByLicensePlate() |
|
470 | - { |
|
471 | - $vehicle = new Vehicle(); |
|
472 | - |
|
473 | - $vehParams = new VehicleParameters(); |
|
474 | - $vehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate']; |
|
475 | - |
|
476 | - $result = $vehicle->getVehicleByLicensePlate($vehParams); |
|
461 | + self::assertNotNull($result); |
|
462 | + self::assertInstanceOf( |
|
463 | + VehicleProfile::class, |
|
464 | + VehicleProfile::fromArray($result) |
|
465 | + ); |
|
466 | + self::assertEquals($vehProfileId, $result['vehicle_profile_id']); |
|
467 | + } |
|
468 | + |
|
469 | + public function testGetVehicleByLicensePlate() |
|
470 | + { |
|
471 | + $vehicle = new Vehicle(); |
|
472 | + |
|
473 | + $vehParams = new VehicleParameters(); |
|
474 | + $vehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate']; |
|
475 | + |
|
476 | + $result = $vehicle->getVehicleByLicensePlate($vehParams); |
|
477 | 477 | |
478 | - self::assertNotNull($result); |
|
479 | - self::assertInstanceOf( |
|
480 | - VehicleResponse::class, |
|
481 | - VehicleResponse::fromArray($result) |
|
482 | - ); |
|
483 | - } |
|
484 | - |
|
485 | - public function testSearchVehicles() |
|
486 | - { |
|
487 | - $this->markTestSkipped('This method is deprecated until resolving the response issue.'); |
|
488 | - |
|
489 | - $vehicle = new Vehicle(); |
|
490 | - |
|
491 | - $searchParams = new VehicleSearchParameters(); |
|
492 | - |
|
493 | - $searchParams->vehicle_ids = array_column(self::$createdVehicles, 'vehicle_id'); |
|
494 | - $searchParams->lat = 29.748868; |
|
495 | - $searchParams->lng = -95.358473; |
|
496 | - |
|
497 | - $result = $vehicle->searchVehicles($searchParams); |
|
498 | - |
|
499 | - self::assertNotNull($result); |
|
500 | - self::assertInstanceOf( |
|
501 | - Vehicle::class, |
|
502 | - VehicleResponse::fromArray($result[0]) |
|
503 | - ); |
|
504 | - } |
|
505 | - |
|
506 | - public function testUpdateVehicle() |
|
507 | - { |
|
508 | - $vehicle = new Vehicle(); |
|
509 | - |
|
510 | - $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'] .' Updated'; |
|
511 | - $vehicle->vehicle_vin = '11111111111111111'; |
|
512 | - $vehicle->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
478 | + self::assertNotNull($result); |
|
479 | + self::assertInstanceOf( |
|
480 | + VehicleResponse::class, |
|
481 | + VehicleResponse::fromArray($result) |
|
482 | + ); |
|
483 | + } |
|
484 | + |
|
485 | + public function testSearchVehicles() |
|
486 | + { |
|
487 | + $this->markTestSkipped('This method is deprecated until resolving the response issue.'); |
|
488 | + |
|
489 | + $vehicle = new Vehicle(); |
|
490 | + |
|
491 | + $searchParams = new VehicleSearchParameters(); |
|
492 | + |
|
493 | + $searchParams->vehicle_ids = array_column(self::$createdVehicles, 'vehicle_id'); |
|
494 | + $searchParams->lat = 29.748868; |
|
495 | + $searchParams->lng = -95.358473; |
|
496 | + |
|
497 | + $result = $vehicle->searchVehicles($searchParams); |
|
498 | + |
|
499 | + self::assertNotNull($result); |
|
500 | + self::assertInstanceOf( |
|
501 | + Vehicle::class, |
|
502 | + VehicleResponse::fromArray($result[0]) |
|
503 | + ); |
|
504 | + } |
|
505 | + |
|
506 | + public function testUpdateVehicle() |
|
507 | + { |
|
508 | + $vehicle = new Vehicle(); |
|
509 | + |
|
510 | + $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'] .' Updated'; |
|
511 | + $vehicle->vehicle_vin = '11111111111111111'; |
|
512 | + $vehicle->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
|
513 | 513 | |
514 | - $result = $vehicle->updateVehicle($vehicle->toArray()); |
|
514 | + $result = $vehicle->updateVehicle($vehicle->toArray()); |
|
515 | 515 | |
516 | - self::assertNotNull($result); |
|
517 | - self::assertInstanceOf( |
|
518 | - Vehicle::class, |
|
519 | - Vehicle::fromArray($result) |
|
520 | - ); |
|
521 | - } |
|
516 | + self::assertNotNull($result); |
|
517 | + self::assertInstanceOf( |
|
518 | + Vehicle::class, |
|
519 | + Vehicle::fromArray($result) |
|
520 | + ); |
|
521 | + } |
|
522 | 522 | |
523 | - public function testUpdateVehicleProfile() |
|
524 | - { |
|
525 | - $vehicleProfile = new VehicleProfile(); |
|
523 | + public function testUpdateVehicleProfile() |
|
524 | + { |
|
525 | + $vehicleProfile = new VehicleProfile(); |
|
526 | 526 | |
527 | - $vehProfileId = self::$createdVehicleProfiles[0]['vehicle_profile_id']; |
|
527 | + $vehProfileId = self::$createdVehicleProfiles[0]['vehicle_profile_id']; |
|
528 | 528 | |
529 | - $vehicleProfile->name = self::$createdVehicleProfiles[0]['name'].'Updated'; |
|
530 | - $vehicleProfile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
531 | - $vehicleProfile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
532 | - $vehicleProfile->vehicle_profile_id = self::$createdVehicleProfiles[0]['vehicle_profile_id']; |
|
529 | + $vehicleProfile->name = self::$createdVehicleProfiles[0]['name'].'Updated'; |
|
530 | + $vehicleProfile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
531 | + $vehicleProfile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US; |
|
532 | + $vehicleProfile->vehicle_profile_id = self::$createdVehicleProfiles[0]['vehicle_profile_id']; |
|
533 | 533 | |
534 | - $result = $vehicleProfile->updateVehicleProfile($vehicleProfile->toArray()); |
|
534 | + $result = $vehicleProfile->updateVehicleProfile($vehicleProfile->toArray()); |
|
535 | 535 | |
536 | - self::assertNotNull($result); |
|
537 | - self::assertInstanceOf( |
|
538 | - VehicleProfile::class, |
|
539 | - VehicleProfile::fromArray($result) |
|
540 | - ); |
|
541 | - } |
|
536 | + self::assertNotNull($result); |
|
537 | + self::assertInstanceOf( |
|
538 | + VehicleProfile::class, |
|
539 | + VehicleProfile::fromArray($result) |
|
540 | + ); |
|
541 | + } |
|
542 | 542 | |
543 | - public static function tearDownAfterClass() |
|
544 | - { |
|
545 | - $vehicle = new Vehicle(); |
|
543 | + public static function tearDownAfterClass() |
|
544 | + { |
|
545 | + $vehicle = new Vehicle(); |
|
546 | 546 | |
547 | - $vehParams = new VehicleParameters(); |
|
547 | + $vehParams = new VehicleParameters(); |
|
548 | 548 | |
549 | - foreach (self::$createdVehicles as $veh1) { |
|
550 | - if (isset($veh1['vehicle_id'])) { |
|
551 | - $vehParams->vehicle_id = $veh1['vehicle_id']; |
|
552 | - $result1 = $vehicle->removeVehicle($vehParams->toArray()); |
|
553 | - } |
|
554 | - } |
|
549 | + foreach (self::$createdVehicles as $veh1) { |
|
550 | + if (isset($veh1['vehicle_id'])) { |
|
551 | + $vehParams->vehicle_id = $veh1['vehicle_id']; |
|
552 | + $result1 = $vehicle->removeVehicle($vehParams->toArray()); |
|
553 | + } |
|
554 | + } |
|
555 | 555 | |
556 | - $vehProfile = new VehicleProfile(); |
|
556 | + $vehProfile = new VehicleProfile(); |
|
557 | 557 | |
558 | - foreach (self::$createdVehicleProfiles as $prof1) { |
|
559 | - if (isset($prof1['vehicle_profile_id'])) { |
|
560 | - $result2 = $vehProfile->removeVehicleProfile($prof1['vehicle_profile_id']); |
|
561 | - } |
|
562 | - } |
|
563 | - } |
|
558 | + foreach (self::$createdVehicleProfiles as $prof1) { |
|
559 | + if (isset($prof1['vehicle_profile_id'])) { |
|
560 | + $result2 = $vehProfile->removeVehicleProfile($prof1['vehicle_profile_id']); |
|
561 | + } |
|
562 | + } |
|
563 | + } |
|
564 | 564 | } |
@@ -16,258 +16,258 @@ |
||
16 | 16 | */ |
17 | 17 | class VehicleProfile extends Common |
18 | 18 | { |
19 | - /** Vehicle profile ID |
|
20 | - * @var integer $vehicle_profile_id |
|
21 | - */ |
|
22 | - public $vehicle_profile_id; |
|
23 | - |
|
24 | - /** Root member ID |
|
25 | - * @var integer $root_member_id |
|
26 | - */ |
|
27 | - public $root_member_id; |
|
28 | - |
|
29 | - /** Vehicle profile name |
|
30 | - * @var string $name |
|
31 | - */ |
|
32 | - public $name; |
|
33 | - |
|
34 | - /** Vehicle height |
|
35 | - * @var float $height |
|
36 | - */ |
|
37 | - public $height; |
|
38 | - |
|
39 | - /** Vehicle width |
|
40 | - * @var float $width |
|
41 | - */ |
|
42 | - public $width; |
|
43 | - |
|
44 | - /** Vehicle length |
|
45 | - * @var float $length |
|
46 | - */ |
|
47 | - public $length; |
|
48 | - |
|
49 | - /** Vehicle weight |
|
50 | - * @var float $weight |
|
51 | - */ |
|
52 | - public $weight; |
|
53 | - |
|
54 | - /** Maximum weight per axle. |
|
55 | - * @var float $max_weight_per_axle |
|
56 | - */ |
|
57 | - public $max_weight_per_axle; |
|
58 | - |
|
59 | - /** When the profile deleted |
|
60 | - * @var string $deleted_at |
|
61 | - */ |
|
62 | - public $deleted_at; |
|
63 | - |
|
64 | - /** When the profile created |
|
65 | - * @var string $created_at |
|
66 | - */ |
|
67 | - public $created_at; |
|
68 | - |
|
69 | - /** When the profile updated |
|
70 | - * @var string $updated_at |
|
71 | - */ |
|
72 | - public $updated_at; |
|
73 | - |
|
74 | - /** A type of the fuel |
|
75 | - * enum: ['unleaded 87','unleaded 89','unleaded 91', |
|
76 | - * 'unleaded 93','diesel','electric','hybrid'] |
|
77 | - * @var string $fuel_type |
|
78 | - */ |
|
79 | - public $fuel_type; |
|
80 | - |
|
81 | - /** Fuel consumption city |
|
82 | - * @var float $fuel_consumption_city |
|
83 | - */ |
|
84 | - public $fuel_consumption_city; |
|
85 | - |
|
86 | - /** Fuel consumption in the highway area |
|
87 | - * @var float $fuel_consumption_highway |
|
88 | - */ |
|
89 | - public $fuel_consumption_highway; |
|
90 | - |
|
91 | - /** Type of a hazardous material. |
|
92 | - * enum: ['general', 'explosives', 'flammable', 'inhalants', 'caustic', 'radioactive'] |
|
93 | - * @var string $hazmat_type |
|
94 | - */ |
|
95 | - public $hazmat_type; |
|
96 | - |
|
97 | - /** If true, the profile is predefined. |
|
98 | - * @var boolean $is_predefined |
|
99 | - */ |
|
100 | - public $is_predefined; |
|
101 | - |
|
102 | - /** If true, the profile is default. |
|
103 | - * @var boolean $is_default |
|
104 | - */ |
|
105 | - public $is_default; |
|
106 | - |
|
107 | - /** Height units (e.g. 'ft', 'm') |
|
108 | - * @var string $height_units |
|
109 | - */ |
|
110 | - public $height_units; |
|
111 | - |
|
112 | - /** Width units (e.g. 'ft', 'm') |
|
113 | - * @var string $width_units |
|
114 | - */ |
|
115 | - public $width_units; |
|
116 | - |
|
117 | - /** Length units (e.g. 'ft', 'm') |
|
118 | - * @var string $length_units |
|
119 | - */ |
|
120 | - public $length_units; |
|
121 | - |
|
122 | - /** Weight units (e.g. 'lb', 'kg') |
|
123 | - * @var string $weight_units |
|
124 | - */ |
|
125 | - public $weight_units; |
|
126 | - |
|
127 | - /** Maximum weight per axle units (e.g. 'lb', 'kg') |
|
128 | - * @var string $max_weight_per_axle_units |
|
129 | - */ |
|
130 | - public $max_weight_per_axle_units; |
|
131 | - |
|
132 | - /** Fuel consumption units in the city area (e.g. mpg) |
|
133 | - * @var string $fuel_consumption_city_unit |
|
134 | - */ |
|
135 | - public $fuel_consumption_city_unit; |
|
136 | - |
|
137 | - /** Fuel consumption units in the highway area (e.g. mpg) |
|
138 | - * @var string $fuel_consumption_highway_unit |
|
139 | - */ |
|
140 | - public $fuel_consumption_highway_unit; |
|
141 | - |
|
142 | - /** Height UF value (e.g. "7'") |
|
143 | - * @var string $height_uf_value |
|
144 | - */ |
|
145 | - public $height_uf_value; |
|
146 | - |
|
147 | - /** Width UF value (e.g. "8'") |
|
148 | - * @var string $width_uf_value |
|
149 | - */ |
|
150 | - public $width_uf_value; |
|
151 | - |
|
152 | - /** Length UF value (e.g. "20'") |
|
153 | - * @var string $length_uf_value |
|
154 | - */ |
|
155 | - public $length_uf_value; |
|
156 | - |
|
157 | - /** Weight UF value (e.g. "8,500lb") |
|
158 | - * @var string $weight_uf_value |
|
159 | - */ |
|
160 | - public $weight_uf_value; |
|
161 | - |
|
162 | - /** Maximum weight per axle (UF value, e.g. "8,500lb") |
|
163 | - * @var string $max_weight_per_axle_uf_value |
|
164 | - */ |
|
165 | - public $max_weight_per_axle_uf_value; |
|
166 | - |
|
167 | - /** Fuel consumption city (UF value, e.g. "20.01 mi/l") |
|
168 | - * @var string $fuel_consumption_city_uf_value |
|
169 | - */ |
|
170 | - public $fuel_consumption_city_uf_value; |
|
171 | - |
|
172 | - /** Fuel consumption highway (UF value, e.g. "2,000.01 mpg") |
|
173 | - * @var string $fuel_consumption_highway_uf_value |
|
174 | - */ |
|
175 | - public $fuel_consumption_highway_uf_value; |
|
176 | - |
|
177 | - public static function fromArray(array $params) |
|
178 | - { |
|
179 | - $vehicleProfile = new self(); |
|
180 | - |
|
181 | - foreach ($params as $key => $value) { |
|
182 | - if (is_null(Common::getValue($params, $key))) { |
|
183 | - continue; |
|
184 | - } |
|
185 | - if (property_exists($vehicleProfile, $key)) { |
|
186 | - $vehicleProfile->$key = $value; |
|
187 | - } |
|
188 | - } |
|
189 | - |
|
190 | - return $vehicleProfile; |
|
191 | - } |
|
192 | - |
|
193 | - public function __construct() |
|
194 | - { |
|
195 | - Route4Me::setBaseUrl(""); |
|
196 | - } |
|
197 | - |
|
198 | - public function removeVehicleProfile($vehicleProfileId) |
|
199 | - { |
|
200 | - //$vehicleProfileID = isset($params['vehicle_profile_id']) ? $params['vehicle_profile_id'] : null; |
|
201 | - |
|
202 | - $response = Route4Me::makeRequst([ |
|
203 | - 'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId, |
|
204 | - 'method' => 'DELETE', |
|
205 | - 'HTTPHEADER' => 'Content-Type: application/json; Accept: application/json', |
|
206 | - ]); |
|
207 | - |
|
208 | - return $response; |
|
209 | - } |
|
210 | - |
|
211 | - /** |
|
212 | - * @param $profileParams - an array from the VehicleParameters object. |
|
213 | - * @return The data including list of the vehicle profiles. |
|
214 | - * @throws \Route4Me\Exception\ApiError |
|
215 | - */ |
|
216 | - public function getVehicleProfiles($profileParams) |
|
217 | - { |
|
218 | - $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
219 | - |
|
220 | - $response = Route4Me::makeRequst([ |
|
221 | - 'url' => Endpoint::VehicleProfiles, |
|
222 | - 'method' => 'GET', |
|
223 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $profileParams), |
|
224 | - ]); |
|
225 | - |
|
226 | - return $response; |
|
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * @param $profileParams - Vehicle profile body parameters |
|
231 | - * @return Created vehicle profile |
|
232 | - * @throws \Route4Me\Exception\ApiError |
|
233 | - */ |
|
234 | - public function createVehicleProfile($profileParams) |
|
235 | - { |
|
236 | - $excludeFields = []; |
|
237 | - $allBodyFields = Route4Me::getObjectProperties(new VehicleProfile(), $excludeFields); |
|
238 | - |
|
239 | - $response = Route4Me::makeRequst([ |
|
240 | - 'url' => Endpoint::VehicleProfiles, |
|
241 | - 'method' => 'POST', |
|
242 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $profileParams), |
|
243 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
244 | - ]); |
|
245 | - |
|
246 | - return $response; |
|
247 | - } |
|
248 | - |
|
249 | - public function getVehicleProfileById($vehicleProfileId) |
|
250 | - { |
|
251 | - $response = Route4Me::makeRequst([ |
|
252 | - 'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId, |
|
253 | - 'method' => 'GET', |
|
254 | - ]); |
|
255 | - |
|
256 | - return $response; |
|
257 | - } |
|
258 | - |
|
259 | - public function updateVehicleProfile($vehicleProfile) |
|
260 | - { |
|
261 | - $excludeFields = ['vehicle_profile_id', 'deleted_at', 'created_at', 'updated_at']; |
|
262 | - $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
263 | - |
|
264 | - $response = Route4Me::makeRequst([ |
|
265 | - 'url' => Endpoint::VehicleProfiles.'/'.$vehicleProfile['vehicle_profile_id'], |
|
266 | - 'method' => 'PATCH', |
|
267 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleProfile), |
|
268 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
269 | - ]); |
|
270 | - |
|
271 | - return $response; |
|
272 | - } |
|
19 | + /** Vehicle profile ID |
|
20 | + * @var integer $vehicle_profile_id |
|
21 | + */ |
|
22 | + public $vehicle_profile_id; |
|
23 | + |
|
24 | + /** Root member ID |
|
25 | + * @var integer $root_member_id |
|
26 | + */ |
|
27 | + public $root_member_id; |
|
28 | + |
|
29 | + /** Vehicle profile name |
|
30 | + * @var string $name |
|
31 | + */ |
|
32 | + public $name; |
|
33 | + |
|
34 | + /** Vehicle height |
|
35 | + * @var float $height |
|
36 | + */ |
|
37 | + public $height; |
|
38 | + |
|
39 | + /** Vehicle width |
|
40 | + * @var float $width |
|
41 | + */ |
|
42 | + public $width; |
|
43 | + |
|
44 | + /** Vehicle length |
|
45 | + * @var float $length |
|
46 | + */ |
|
47 | + public $length; |
|
48 | + |
|
49 | + /** Vehicle weight |
|
50 | + * @var float $weight |
|
51 | + */ |
|
52 | + public $weight; |
|
53 | + |
|
54 | + /** Maximum weight per axle. |
|
55 | + * @var float $max_weight_per_axle |
|
56 | + */ |
|
57 | + public $max_weight_per_axle; |
|
58 | + |
|
59 | + /** When the profile deleted |
|
60 | + * @var string $deleted_at |
|
61 | + */ |
|
62 | + public $deleted_at; |
|
63 | + |
|
64 | + /** When the profile created |
|
65 | + * @var string $created_at |
|
66 | + */ |
|
67 | + public $created_at; |
|
68 | + |
|
69 | + /** When the profile updated |
|
70 | + * @var string $updated_at |
|
71 | + */ |
|
72 | + public $updated_at; |
|
73 | + |
|
74 | + /** A type of the fuel |
|
75 | + * enum: ['unleaded 87','unleaded 89','unleaded 91', |
|
76 | + * 'unleaded 93','diesel','electric','hybrid'] |
|
77 | + * @var string $fuel_type |
|
78 | + */ |
|
79 | + public $fuel_type; |
|
80 | + |
|
81 | + /** Fuel consumption city |
|
82 | + * @var float $fuel_consumption_city |
|
83 | + */ |
|
84 | + public $fuel_consumption_city; |
|
85 | + |
|
86 | + /** Fuel consumption in the highway area |
|
87 | + * @var float $fuel_consumption_highway |
|
88 | + */ |
|
89 | + public $fuel_consumption_highway; |
|
90 | + |
|
91 | + /** Type of a hazardous material. |
|
92 | + * enum: ['general', 'explosives', 'flammable', 'inhalants', 'caustic', 'radioactive'] |
|
93 | + * @var string $hazmat_type |
|
94 | + */ |
|
95 | + public $hazmat_type; |
|
96 | + |
|
97 | + /** If true, the profile is predefined. |
|
98 | + * @var boolean $is_predefined |
|
99 | + */ |
|
100 | + public $is_predefined; |
|
101 | + |
|
102 | + /** If true, the profile is default. |
|
103 | + * @var boolean $is_default |
|
104 | + */ |
|
105 | + public $is_default; |
|
106 | + |
|
107 | + /** Height units (e.g. 'ft', 'm') |
|
108 | + * @var string $height_units |
|
109 | + */ |
|
110 | + public $height_units; |
|
111 | + |
|
112 | + /** Width units (e.g. 'ft', 'm') |
|
113 | + * @var string $width_units |
|
114 | + */ |
|
115 | + public $width_units; |
|
116 | + |
|
117 | + /** Length units (e.g. 'ft', 'm') |
|
118 | + * @var string $length_units |
|
119 | + */ |
|
120 | + public $length_units; |
|
121 | + |
|
122 | + /** Weight units (e.g. 'lb', 'kg') |
|
123 | + * @var string $weight_units |
|
124 | + */ |
|
125 | + public $weight_units; |
|
126 | + |
|
127 | + /** Maximum weight per axle units (e.g. 'lb', 'kg') |
|
128 | + * @var string $max_weight_per_axle_units |
|
129 | + */ |
|
130 | + public $max_weight_per_axle_units; |
|
131 | + |
|
132 | + /** Fuel consumption units in the city area (e.g. mpg) |
|
133 | + * @var string $fuel_consumption_city_unit |
|
134 | + */ |
|
135 | + public $fuel_consumption_city_unit; |
|
136 | + |
|
137 | + /** Fuel consumption units in the highway area (e.g. mpg) |
|
138 | + * @var string $fuel_consumption_highway_unit |
|
139 | + */ |
|
140 | + public $fuel_consumption_highway_unit; |
|
141 | + |
|
142 | + /** Height UF value (e.g. "7'") |
|
143 | + * @var string $height_uf_value |
|
144 | + */ |
|
145 | + public $height_uf_value; |
|
146 | + |
|
147 | + /** Width UF value (e.g. "8'") |
|
148 | + * @var string $width_uf_value |
|
149 | + */ |
|
150 | + public $width_uf_value; |
|
151 | + |
|
152 | + /** Length UF value (e.g. "20'") |
|
153 | + * @var string $length_uf_value |
|
154 | + */ |
|
155 | + public $length_uf_value; |
|
156 | + |
|
157 | + /** Weight UF value (e.g. "8,500lb") |
|
158 | + * @var string $weight_uf_value |
|
159 | + */ |
|
160 | + public $weight_uf_value; |
|
161 | + |
|
162 | + /** Maximum weight per axle (UF value, e.g. "8,500lb") |
|
163 | + * @var string $max_weight_per_axle_uf_value |
|
164 | + */ |
|
165 | + public $max_weight_per_axle_uf_value; |
|
166 | + |
|
167 | + /** Fuel consumption city (UF value, e.g. "20.01 mi/l") |
|
168 | + * @var string $fuel_consumption_city_uf_value |
|
169 | + */ |
|
170 | + public $fuel_consumption_city_uf_value; |
|
171 | + |
|
172 | + /** Fuel consumption highway (UF value, e.g. "2,000.01 mpg") |
|
173 | + * @var string $fuel_consumption_highway_uf_value |
|
174 | + */ |
|
175 | + public $fuel_consumption_highway_uf_value; |
|
176 | + |
|
177 | + public static function fromArray(array $params) |
|
178 | + { |
|
179 | + $vehicleProfile = new self(); |
|
180 | + |
|
181 | + foreach ($params as $key => $value) { |
|
182 | + if (is_null(Common::getValue($params, $key))) { |
|
183 | + continue; |
|
184 | + } |
|
185 | + if (property_exists($vehicleProfile, $key)) { |
|
186 | + $vehicleProfile->$key = $value; |
|
187 | + } |
|
188 | + } |
|
189 | + |
|
190 | + return $vehicleProfile; |
|
191 | + } |
|
192 | + |
|
193 | + public function __construct() |
|
194 | + { |
|
195 | + Route4Me::setBaseUrl(""); |
|
196 | + } |
|
197 | + |
|
198 | + public function removeVehicleProfile($vehicleProfileId) |
|
199 | + { |
|
200 | + //$vehicleProfileID = isset($params['vehicle_profile_id']) ? $params['vehicle_profile_id'] : null; |
|
201 | + |
|
202 | + $response = Route4Me::makeRequst([ |
|
203 | + 'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId, |
|
204 | + 'method' => 'DELETE', |
|
205 | + 'HTTPHEADER' => 'Content-Type: application/json; Accept: application/json', |
|
206 | + ]); |
|
207 | + |
|
208 | + return $response; |
|
209 | + } |
|
210 | + |
|
211 | + /** |
|
212 | + * @param $profileParams - an array from the VehicleParameters object. |
|
213 | + * @return The data including list of the vehicle profiles. |
|
214 | + * @throws \Route4Me\Exception\ApiError |
|
215 | + */ |
|
216 | + public function getVehicleProfiles($profileParams) |
|
217 | + { |
|
218 | + $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
219 | + |
|
220 | + $response = Route4Me::makeRequst([ |
|
221 | + 'url' => Endpoint::VehicleProfiles, |
|
222 | + 'method' => 'GET', |
|
223 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $profileParams), |
|
224 | + ]); |
|
225 | + |
|
226 | + return $response; |
|
227 | + } |
|
228 | + |
|
229 | + /** |
|
230 | + * @param $profileParams - Vehicle profile body parameters |
|
231 | + * @return Created vehicle profile |
|
232 | + * @throws \Route4Me\Exception\ApiError |
|
233 | + */ |
|
234 | + public function createVehicleProfile($profileParams) |
|
235 | + { |
|
236 | + $excludeFields = []; |
|
237 | + $allBodyFields = Route4Me::getObjectProperties(new VehicleProfile(), $excludeFields); |
|
238 | + |
|
239 | + $response = Route4Me::makeRequst([ |
|
240 | + 'url' => Endpoint::VehicleProfiles, |
|
241 | + 'method' => 'POST', |
|
242 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $profileParams), |
|
243 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
244 | + ]); |
|
245 | + |
|
246 | + return $response; |
|
247 | + } |
|
248 | + |
|
249 | + public function getVehicleProfileById($vehicleProfileId) |
|
250 | + { |
|
251 | + $response = Route4Me::makeRequst([ |
|
252 | + 'url' => Endpoint::VehicleProfiles . '/' . $vehicleProfileId, |
|
253 | + 'method' => 'GET', |
|
254 | + ]); |
|
255 | + |
|
256 | + return $response; |
|
257 | + } |
|
258 | + |
|
259 | + public function updateVehicleProfile($vehicleProfile) |
|
260 | + { |
|
261 | + $excludeFields = ['vehicle_profile_id', 'deleted_at', 'created_at', 'updated_at']; |
|
262 | + $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
263 | + |
|
264 | + $response = Route4Me::makeRequst([ |
|
265 | + 'url' => Endpoint::VehicleProfiles.'/'.$vehicleProfile['vehicle_profile_id'], |
|
266 | + 'method' => 'PATCH', |
|
267 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleProfile), |
|
268 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
269 | + ]); |
|
270 | + |
|
271 | + return $response; |
|
272 | + } |
|
273 | 273 | } |
@@ -19,379 +19,379 @@ |
||
19 | 19 | */ |
20 | 20 | class Vehicle extends Common |
21 | 21 | { |
22 | - /** The vehicle ID |
|
23 | - * @var string $vehicle_id |
|
24 | - */ |
|
25 | - public $vehicle_id; |
|
26 | - |
|
27 | - /** Member ID assigned to the vehicle. |
|
28 | - * @var integer $member_id |
|
29 | - */ |
|
30 | - public $member_id; |
|
31 | - |
|
32 | - /** If true, the vehicle is marked as deleted. |
|
33 | - * @var boolean $is_deleted |
|
34 | - */ |
|
35 | - public $is_deleted; |
|
36 | - |
|
37 | - /** Vehicle alias |
|
38 | - * @var string $vehicle_alias |
|
39 | - */ |
|
40 | - public $vehicle_alias; |
|
41 | - |
|
42 | - /** Vehicle VIN |
|
43 | - * @var string $vehicle_vin |
|
44 | - */ |
|
45 | - public $vehicle_vin; |
|
46 | - |
|
47 | - /** Vehicle registration state ID. |
|
48 | - * @var integer $vehicle_reg_state_id |
|
49 | - */ |
|
50 | - public $vehicle_reg_state_id; |
|
51 | - |
|
52 | - /** Vehicle registration country ID. |
|
53 | - * @var integer $vehicle_reg_country_id |
|
54 | - */ |
|
55 | - public $vehicle_reg_country_id; |
|
56 | - |
|
57 | - /** A license plate of the vehicle. |
|
58 | - * @var string $vehicle_license_plate |
|
59 | - */ |
|
60 | - public $vehicle_license_plate; |
|
61 | - |
|
62 | - /** Vehicle type. |
|
63 | - * <para>Availbale values:</para> |
|
64 | - * sedan', 'suv', 'pickup_truck', 'van', '18wheeler', 'cabin', 'hatchback', |
|
65 | - * '<para>motorcyle', 'waste_disposal', 'tree_cutting', 'bigrig', 'cement_mixer', </para> |
|
66 | - * 'livestock_carrier', 'dairy','tractor_trailer'. |
|
67 | - * @var string $vehicle_type_id |
|
68 | - */ |
|
69 | - public $vehicle_type_id; |
|
70 | - |
|
71 | - /** When the vehicle was added. |
|
72 | - * @var string $timestamp_added |
|
73 | - */ |
|
74 | - public $timestamp_added; |
|
75 | - |
|
76 | - /** Vehicle maker brend. |
|
77 | - * <para>Available values:</para> |
|
78 | - * "american coleman", "bmw", "chevrolet", "ford", "freightliner", "gmc", |
|
79 | - * <para>"hino", "honda", "isuzu", "kenworth", "mack", "mercedes-benz", "mitsubishi", </para> |
|
80 | - * "navistar", "nissan", "peterbilt", "renault", "scania", "sterling", "toyota", |
|
81 | - * <para>"volvo", "western star" </para> |
|
82 | - * </value>" |
|
83 | - * @var string $vehicle_make |
|
84 | - */ |
|
85 | - public $vehicle_make; |
|
86 | - |
|
87 | - /** Vehicle model year |
|
88 | - * @var integer $vehicle_model_year |
|
89 | - */ |
|
90 | - public $vehicle_model_year; |
|
91 | - |
|
92 | - /** Vehicle model |
|
93 | - * @var string $vehicle_model |
|
94 | - */ |
|
95 | - public $vehicle_model; |
|
96 | - |
|
97 | - /** The year, vehicle was acquired |
|
98 | - * @var integer $vehicle_year_acquired |
|
99 | - */ |
|
100 | - public $vehicle_year_acquired; |
|
101 | - |
|
102 | - /** A cost of the new vehicle |
|
103 | - * @var float $vehicle_cost_new |
|
104 | - */ |
|
105 | - public $vehicle_cost_new; |
|
106 | - |
|
107 | - /** If true, the vehicle was purchased new. |
|
108 | - * @var boolean $purchased_new |
|
109 | - */ |
|
110 | - public $purchased_new; |
|
111 | - |
|
112 | - /** Start date of the license |
|
113 | - * @var string $license_start_date |
|
114 | - */ |
|
115 | - public $license_start_date; |
|
116 | - |
|
117 | - /** End date of the license |
|
118 | - * @var string $license_end_date |
|
119 | - */ |
|
120 | - public $license_end_date; |
|
121 | - |
|
122 | - /** If equal to '1', the vehicle is operational. |
|
123 | - * @var boolean $is_operational |
|
124 | - */ |
|
125 | - public $is_operational; |
|
126 | - |
|
127 | - /** A type of the fuel |
|
128 | - * @var string $fuel_type |
|
129 | - * enum: ['unleaded 87','unleaded 89','unleaded 91','unleaded 93','diesel','electric','hybrid'] |
|
130 | - */ |
|
131 | - public $fuel_type; |
|
132 | - |
|
133 | - /** External telematics vehicle IDs |
|
134 | - * @var integer $external_telematics_vehicle_ids |
|
135 | - */ |
|
136 | - public $external_telematics_vehicle_id; |
|
137 | - |
|
138 | - /** When the vehcile was marked as deleted. |
|
139 | - * @var integer $timestamp_removed |
|
140 | - */ |
|
141 | - public $timestamp_removed; |
|
142 | - |
|
143 | - /** Vehicle profile ID |
|
144 | - * @var integer $vehicle_profile_id |
|
145 | - */ |
|
146 | - public $vehicle_profile_id; |
|
147 | - |
|
148 | - /** Fuel consumption city |
|
149 | - * @var float $fuel_consumption_city |
|
150 | - */ |
|
151 | - public $fuel_consumption_city; |
|
152 | - |
|
153 | - /** Fuel consumption in the highway area |
|
154 | - * @var float $fuel_consumption_highway |
|
155 | - */ |
|
156 | - public $fuel_consumption_highway; |
|
157 | - |
|
158 | - /** Fuel consumption units in the city area (e.g. mi/l) |
|
159 | - * @var string $fuel_consumption_city_unit |
|
160 | - */ |
|
161 | - public $fuel_consumption_city_unit; |
|
162 | - |
|
163 | - /** Fuel consumption units in the highway area (e.g. mi/l) |
|
164 | - * @var string $fuel_consumption_highway_unit |
|
165 | - */ |
|
166 | - public $fuel_consumption_highway_unit; |
|
167 | - |
|
168 | - /** Miles per gallon in the city area |
|
169 | - * @var float $mpg_city |
|
170 | - */ |
|
171 | - public $mpg_city; |
|
172 | - |
|
173 | - /** Miles per gallon in the highway area |
|
174 | - * @var float $mpg_highway |
|
175 | - */ |
|
176 | - public $mpg_highway; |
|
177 | - |
|
178 | - /** Fuel consumption UF value in the city area (e.g. '20.01 mi/l') |
|
179 | - * @var string $fuel_consumption_city_uf_value |
|
180 | - */ |
|
181 | - public $fuel_consumption_city_uf_value; |
|
182 | - |
|
183 | - /** Fuel consumption UF value in the highway area (e.g. '2,000.01 mpg') |
|
184 | - * @var string $fuel_consumption_highway_uf_value |
|
185 | - */ |
|
186 | - public $fuel_consumption_highway_uf_value; |
|
187 | - |
|
188 | - public static function fromArray(array $params) |
|
189 | - { |
|
190 | - $vehicle = new self(); |
|
191 | - |
|
192 | - foreach ($params as $key => $value) { |
|
193 | - if (is_null(Common::getValue($params, $key))) { |
|
194 | - continue; |
|
195 | - } |
|
196 | - if (property_exists($vehicle, $key)) { |
|
197 | - $vehicle->$key = $value; |
|
198 | - } |
|
199 | - } |
|
200 | - |
|
201 | - return $vehicle; |
|
202 | - } |
|
203 | - |
|
204 | - public function __construct() |
|
205 | - { |
|
206 | - Route4Me::setBaseUrl(""); |
|
207 | - } |
|
208 | - |
|
209 | - /** Creates a vehicle |
|
210 | - * @param $vehicleParams |
|
211 | - * Returns a vehicle object or failure info. |
|
212 | - */ |
|
213 | - public function createVehicle($vehicleParams) |
|
214 | - { |
|
215 | - $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
216 | - $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
217 | - |
|
218 | - $response = Route4Me::makeRequst([ |
|
219 | - 'url' => Endpoint::Vehicles, |
|
220 | - 'method' => 'POST', |
|
221 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
222 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
223 | - ]); |
|
224 | - |
|
225 | - return $response; |
|
226 | - } |
|
227 | - |
|
228 | - /** Removes a vehicle by specified vehicle ID. |
|
229 | - * @param string $vehicleID - Vehicle ID |
|
230 | - * @return Vehicle object - removed vehicle object. |
|
231 | - * @throws \Route4Me\Exception\ApiError |
|
232 | - */ |
|
233 | - public function removeVehicle($vehicleParams) |
|
234 | - { |
|
235 | - $vehicleId = $vehicleParams['vehicle_id']; |
|
236 | - |
|
237 | - $response = Route4Me::makeRequst([ |
|
238 | - 'url' => Endpoint::Vehicles . '/' . $vehicleId, |
|
239 | - 'method' => 'DELETE' |
|
240 | - ]); |
|
241 | - |
|
242 | - return $response; |
|
243 | - } |
|
244 | - |
|
245 | - /** Returns the VehiclesPaginated type object containing an array of the vehicles. |
|
246 | - * @param array $params - an array from the VehicleParameters object. |
|
247 | - * @return an array of the Vehicle objects. |
|
248 | - * @throws \Route4Me\Exception\ApiError |
|
249 | - */ |
|
250 | - public function getVehiclesPaginatedList($params) |
|
251 | - { |
|
252 | - $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
253 | - |
|
254 | - $response = Route4Me::makeRequst([ |
|
255 | - 'url' => Endpoint::Vehicles, |
|
256 | - 'method' => 'GET', |
|
257 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
258 | - ]); |
|
259 | - |
|
260 | - return $response; |
|
261 | - } |
|
262 | - |
|
263 | - /** Creates temporary vehicle in the database. |
|
264 | - * @param $vehicleParams - an array from the VehicleTemporary object. |
|
265 | - * @return an object of the type VehicleTemporary. |
|
266 | - * @throws \Route4Me\Exception\ApiError |
|
267 | - */ |
|
268 | - public function createTemporaryVehicle($vehicleParams) |
|
269 | - { |
|
270 | - $excludeFields = []; |
|
271 | - $allBodyFields = Route4Me::getObjectProperties(new VehicleTemporary(), $excludeFields); |
|
272 | - |
|
273 | - $response = Route4Me::makeRequst([ |
|
274 | - 'url' => Endpoint::VehicleTemporary, |
|
275 | - 'method' => 'POST', |
|
276 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
277 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
278 | - ]); |
|
279 | - |
|
280 | - return $response; |
|
281 | - } |
|
282 | - |
|
283 | - /** Execute a vehicle order. |
|
284 | - * @param $vehicleParams - Vehicle order parameters. |
|
285 | - * @return an object of the type VehicleOrderResponse |
|
286 | - * @throws \Route4Me\Exception\ApiError |
|
287 | - */ |
|
288 | - public function executeVehicleOrder($vehicleParams) |
|
289 | - { |
|
290 | - $excludeFields = []; |
|
291 | - $allBodyFields = Route4Me::getObjectProperties(new VehicleOrderParameters(), $excludeFields); |
|
292 | - |
|
293 | - $response = Route4Me::makeRequst([ |
|
294 | - 'url' => Endpoint::VehicleExecuteOrder, |
|
295 | - 'method' => 'POST', |
|
296 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
297 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
298 | - ]); |
|
299 | - |
|
300 | - return $response; |
|
301 | - } |
|
302 | - |
|
303 | - /** Get latest vehicle locations by specified vehicle IDs. |
|
304 | - * @param $vehicleParams - Vehicle query parameters containing vehicle IDs |
|
305 | - * @return Data with vehicles |
|
306 | - * @throws \Route4Me\Exception\ApiError |
|
307 | - */ |
|
308 | - public function getVehicleLocations($vehicleParams) |
|
309 | - { |
|
310 | - $allQueryFields = ['ids']; |
|
311 | - |
|
312 | - $response = Route4Me::makeRequst([ |
|
313 | - 'url' => Endpoint::VehicleLocation, |
|
314 | - 'method' => 'GET', |
|
315 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $vehicleParams), |
|
316 | - ]); |
|
317 | - |
|
318 | - return $response; |
|
319 | - } |
|
320 | - |
|
321 | - /** Get the Vehicle by specifying vehicle ID. |
|
322 | - * @param $vehicleParams - Vehicle query parameters containing vehicle ID. |
|
323 | - * @return an object of the type Vehicle |
|
324 | - * @throws \Route4Me\Exception\ApiError |
|
325 | - */ |
|
326 | - public function getVehicleById($vehicleParams) |
|
327 | - { |
|
328 | - $allQueryFields = ['vehicle_id']; |
|
329 | - |
|
330 | - $response = Route4Me::makeRequst([ |
|
331 | - 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'], |
|
332 | - 'method' => 'GET', |
|
333 | - 'query' => null, |
|
334 | - ]); |
|
335 | - |
|
336 | - return $response; |
|
337 | - } |
|
338 | - |
|
339 | - /** Get the Vehicle track by specifying vehicle ID. |
|
340 | - * @param $vehicleParams - Vehicle query parameters containing vehicle ID. |
|
341 | - * @return Vehicle track object |
|
342 | - * @throws \Route4Me\Exception\ApiError |
|
343 | - */ |
|
344 | - public function getVehicleTrack($vehicleParams) |
|
345 | - { |
|
346 | - $response = Route4Me::makeRequst([ |
|
347 | - 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'].'/track', |
|
348 | - 'method' => 'GET', |
|
349 | - 'query' => null, |
|
350 | - ]); |
|
351 | - |
|
352 | - return $response; |
|
353 | - } |
|
354 | - |
|
355 | - public function getVehicleByLicensePlate($vehicleParams) |
|
356 | - { |
|
357 | - $allQueryFields = ['vehicle_license_plate']; |
|
358 | - |
|
359 | - $response = Route4Me::makeRequst([ |
|
360 | - 'url' => Endpoint::VehicleLicense, |
|
361 | - 'method' => 'GET', |
|
362 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $vehicleParams), |
|
363 | - ]); |
|
364 | - |
|
365 | - return $response; |
|
366 | - } |
|
367 | - |
|
368 | - public function searchVehicles($searchParams) |
|
369 | - { |
|
370 | - $excludeFields = []; |
|
371 | - $allBodyFields = Route4Me::getObjectProperties(new VehicleSearchParameters(), $excludeFields); |
|
372 | - |
|
373 | - $response = Route4Me::makeRequst([ |
|
374 | - 'url' => Endpoint::VehicleSearch, |
|
375 | - 'method' => 'POST', |
|
376 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $searchParams), |
|
377 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
378 | - ]); |
|
379 | - |
|
380 | - return $response; |
|
381 | - } |
|
382 | - |
|
383 | - public function updateVehicle($vehicleParams) |
|
384 | - { |
|
385 | - $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
386 | - $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
387 | - |
|
388 | - $response = Route4Me::makeRequst([ |
|
389 | - 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'], |
|
390 | - 'method' => 'PATCH', |
|
391 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
392 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
393 | - ]); |
|
394 | - |
|
395 | - return $response; |
|
396 | - } |
|
22 | + /** The vehicle ID |
|
23 | + * @var string $vehicle_id |
|
24 | + */ |
|
25 | + public $vehicle_id; |
|
26 | + |
|
27 | + /** Member ID assigned to the vehicle. |
|
28 | + * @var integer $member_id |
|
29 | + */ |
|
30 | + public $member_id; |
|
31 | + |
|
32 | + /** If true, the vehicle is marked as deleted. |
|
33 | + * @var boolean $is_deleted |
|
34 | + */ |
|
35 | + public $is_deleted; |
|
36 | + |
|
37 | + /** Vehicle alias |
|
38 | + * @var string $vehicle_alias |
|
39 | + */ |
|
40 | + public $vehicle_alias; |
|
41 | + |
|
42 | + /** Vehicle VIN |
|
43 | + * @var string $vehicle_vin |
|
44 | + */ |
|
45 | + public $vehicle_vin; |
|
46 | + |
|
47 | + /** Vehicle registration state ID. |
|
48 | + * @var integer $vehicle_reg_state_id |
|
49 | + */ |
|
50 | + public $vehicle_reg_state_id; |
|
51 | + |
|
52 | + /** Vehicle registration country ID. |
|
53 | + * @var integer $vehicle_reg_country_id |
|
54 | + */ |
|
55 | + public $vehicle_reg_country_id; |
|
56 | + |
|
57 | + /** A license plate of the vehicle. |
|
58 | + * @var string $vehicle_license_plate |
|
59 | + */ |
|
60 | + public $vehicle_license_plate; |
|
61 | + |
|
62 | + /** Vehicle type. |
|
63 | + * <para>Availbale values:</para> |
|
64 | + * sedan', 'suv', 'pickup_truck', 'van', '18wheeler', 'cabin', 'hatchback', |
|
65 | + * '<para>motorcyle', 'waste_disposal', 'tree_cutting', 'bigrig', 'cement_mixer', </para> |
|
66 | + * 'livestock_carrier', 'dairy','tractor_trailer'. |
|
67 | + * @var string $vehicle_type_id |
|
68 | + */ |
|
69 | + public $vehicle_type_id; |
|
70 | + |
|
71 | + /** When the vehicle was added. |
|
72 | + * @var string $timestamp_added |
|
73 | + */ |
|
74 | + public $timestamp_added; |
|
75 | + |
|
76 | + /** Vehicle maker brend. |
|
77 | + * <para>Available values:</para> |
|
78 | + * "american coleman", "bmw", "chevrolet", "ford", "freightliner", "gmc", |
|
79 | + * <para>"hino", "honda", "isuzu", "kenworth", "mack", "mercedes-benz", "mitsubishi", </para> |
|
80 | + * "navistar", "nissan", "peterbilt", "renault", "scania", "sterling", "toyota", |
|
81 | + * <para>"volvo", "western star" </para> |
|
82 | + * </value>" |
|
83 | + * @var string $vehicle_make |
|
84 | + */ |
|
85 | + public $vehicle_make; |
|
86 | + |
|
87 | + /** Vehicle model year |
|
88 | + * @var integer $vehicle_model_year |
|
89 | + */ |
|
90 | + public $vehicle_model_year; |
|
91 | + |
|
92 | + /** Vehicle model |
|
93 | + * @var string $vehicle_model |
|
94 | + */ |
|
95 | + public $vehicle_model; |
|
96 | + |
|
97 | + /** The year, vehicle was acquired |
|
98 | + * @var integer $vehicle_year_acquired |
|
99 | + */ |
|
100 | + public $vehicle_year_acquired; |
|
101 | + |
|
102 | + /** A cost of the new vehicle |
|
103 | + * @var float $vehicle_cost_new |
|
104 | + */ |
|
105 | + public $vehicle_cost_new; |
|
106 | + |
|
107 | + /** If true, the vehicle was purchased new. |
|
108 | + * @var boolean $purchased_new |
|
109 | + */ |
|
110 | + public $purchased_new; |
|
111 | + |
|
112 | + /** Start date of the license |
|
113 | + * @var string $license_start_date |
|
114 | + */ |
|
115 | + public $license_start_date; |
|
116 | + |
|
117 | + /** End date of the license |
|
118 | + * @var string $license_end_date |
|
119 | + */ |
|
120 | + public $license_end_date; |
|
121 | + |
|
122 | + /** If equal to '1', the vehicle is operational. |
|
123 | + * @var boolean $is_operational |
|
124 | + */ |
|
125 | + public $is_operational; |
|
126 | + |
|
127 | + /** A type of the fuel |
|
128 | + * @var string $fuel_type |
|
129 | + * enum: ['unleaded 87','unleaded 89','unleaded 91','unleaded 93','diesel','electric','hybrid'] |
|
130 | + */ |
|
131 | + public $fuel_type; |
|
132 | + |
|
133 | + /** External telematics vehicle IDs |
|
134 | + * @var integer $external_telematics_vehicle_ids |
|
135 | + */ |
|
136 | + public $external_telematics_vehicle_id; |
|
137 | + |
|
138 | + /** When the vehcile was marked as deleted. |
|
139 | + * @var integer $timestamp_removed |
|
140 | + */ |
|
141 | + public $timestamp_removed; |
|
142 | + |
|
143 | + /** Vehicle profile ID |
|
144 | + * @var integer $vehicle_profile_id |
|
145 | + */ |
|
146 | + public $vehicle_profile_id; |
|
147 | + |
|
148 | + /** Fuel consumption city |
|
149 | + * @var float $fuel_consumption_city |
|
150 | + */ |
|
151 | + public $fuel_consumption_city; |
|
152 | + |
|
153 | + /** Fuel consumption in the highway area |
|
154 | + * @var float $fuel_consumption_highway |
|
155 | + */ |
|
156 | + public $fuel_consumption_highway; |
|
157 | + |
|
158 | + /** Fuel consumption units in the city area (e.g. mi/l) |
|
159 | + * @var string $fuel_consumption_city_unit |
|
160 | + */ |
|
161 | + public $fuel_consumption_city_unit; |
|
162 | + |
|
163 | + /** Fuel consumption units in the highway area (e.g. mi/l) |
|
164 | + * @var string $fuel_consumption_highway_unit |
|
165 | + */ |
|
166 | + public $fuel_consumption_highway_unit; |
|
167 | + |
|
168 | + /** Miles per gallon in the city area |
|
169 | + * @var float $mpg_city |
|
170 | + */ |
|
171 | + public $mpg_city; |
|
172 | + |
|
173 | + /** Miles per gallon in the highway area |
|
174 | + * @var float $mpg_highway |
|
175 | + */ |
|
176 | + public $mpg_highway; |
|
177 | + |
|
178 | + /** Fuel consumption UF value in the city area (e.g. '20.01 mi/l') |
|
179 | + * @var string $fuel_consumption_city_uf_value |
|
180 | + */ |
|
181 | + public $fuel_consumption_city_uf_value; |
|
182 | + |
|
183 | + /** Fuel consumption UF value in the highway area (e.g. '2,000.01 mpg') |
|
184 | + * @var string $fuel_consumption_highway_uf_value |
|
185 | + */ |
|
186 | + public $fuel_consumption_highway_uf_value; |
|
187 | + |
|
188 | + public static function fromArray(array $params) |
|
189 | + { |
|
190 | + $vehicle = new self(); |
|
191 | + |
|
192 | + foreach ($params as $key => $value) { |
|
193 | + if (is_null(Common::getValue($params, $key))) { |
|
194 | + continue; |
|
195 | + } |
|
196 | + if (property_exists($vehicle, $key)) { |
|
197 | + $vehicle->$key = $value; |
|
198 | + } |
|
199 | + } |
|
200 | + |
|
201 | + return $vehicle; |
|
202 | + } |
|
203 | + |
|
204 | + public function __construct() |
|
205 | + { |
|
206 | + Route4Me::setBaseUrl(""); |
|
207 | + } |
|
208 | + |
|
209 | + /** Creates a vehicle |
|
210 | + * @param $vehicleParams |
|
211 | + * Returns a vehicle object or failure info. |
|
212 | + */ |
|
213 | + public function createVehicle($vehicleParams) |
|
214 | + { |
|
215 | + $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
216 | + $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
217 | + |
|
218 | + $response = Route4Me::makeRequst([ |
|
219 | + 'url' => Endpoint::Vehicles, |
|
220 | + 'method' => 'POST', |
|
221 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
222 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
223 | + ]); |
|
224 | + |
|
225 | + return $response; |
|
226 | + } |
|
227 | + |
|
228 | + /** Removes a vehicle by specified vehicle ID. |
|
229 | + * @param string $vehicleID - Vehicle ID |
|
230 | + * @return Vehicle object - removed vehicle object. |
|
231 | + * @throws \Route4Me\Exception\ApiError |
|
232 | + */ |
|
233 | + public function removeVehicle($vehicleParams) |
|
234 | + { |
|
235 | + $vehicleId = $vehicleParams['vehicle_id']; |
|
236 | + |
|
237 | + $response = Route4Me::makeRequst([ |
|
238 | + 'url' => Endpoint::Vehicles . '/' . $vehicleId, |
|
239 | + 'method' => 'DELETE' |
|
240 | + ]); |
|
241 | + |
|
242 | + return $response; |
|
243 | + } |
|
244 | + |
|
245 | + /** Returns the VehiclesPaginated type object containing an array of the vehicles. |
|
246 | + * @param array $params - an array from the VehicleParameters object. |
|
247 | + * @return an array of the Vehicle objects. |
|
248 | + * @throws \Route4Me\Exception\ApiError |
|
249 | + */ |
|
250 | + public function getVehiclesPaginatedList($params) |
|
251 | + { |
|
252 | + $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
253 | + |
|
254 | + $response = Route4Me::makeRequst([ |
|
255 | + 'url' => Endpoint::Vehicles, |
|
256 | + 'method' => 'GET', |
|
257 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
258 | + ]); |
|
259 | + |
|
260 | + return $response; |
|
261 | + } |
|
262 | + |
|
263 | + /** Creates temporary vehicle in the database. |
|
264 | + * @param $vehicleParams - an array from the VehicleTemporary object. |
|
265 | + * @return an object of the type VehicleTemporary. |
|
266 | + * @throws \Route4Me\Exception\ApiError |
|
267 | + */ |
|
268 | + public function createTemporaryVehicle($vehicleParams) |
|
269 | + { |
|
270 | + $excludeFields = []; |
|
271 | + $allBodyFields = Route4Me::getObjectProperties(new VehicleTemporary(), $excludeFields); |
|
272 | + |
|
273 | + $response = Route4Me::makeRequst([ |
|
274 | + 'url' => Endpoint::VehicleTemporary, |
|
275 | + 'method' => 'POST', |
|
276 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
277 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
278 | + ]); |
|
279 | + |
|
280 | + return $response; |
|
281 | + } |
|
282 | + |
|
283 | + /** Execute a vehicle order. |
|
284 | + * @param $vehicleParams - Vehicle order parameters. |
|
285 | + * @return an object of the type VehicleOrderResponse |
|
286 | + * @throws \Route4Me\Exception\ApiError |
|
287 | + */ |
|
288 | + public function executeVehicleOrder($vehicleParams) |
|
289 | + { |
|
290 | + $excludeFields = []; |
|
291 | + $allBodyFields = Route4Me::getObjectProperties(new VehicleOrderParameters(), $excludeFields); |
|
292 | + |
|
293 | + $response = Route4Me::makeRequst([ |
|
294 | + 'url' => Endpoint::VehicleExecuteOrder, |
|
295 | + 'method' => 'POST', |
|
296 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
297 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
298 | + ]); |
|
299 | + |
|
300 | + return $response; |
|
301 | + } |
|
302 | + |
|
303 | + /** Get latest vehicle locations by specified vehicle IDs. |
|
304 | + * @param $vehicleParams - Vehicle query parameters containing vehicle IDs |
|
305 | + * @return Data with vehicles |
|
306 | + * @throws \Route4Me\Exception\ApiError |
|
307 | + */ |
|
308 | + public function getVehicleLocations($vehicleParams) |
|
309 | + { |
|
310 | + $allQueryFields = ['ids']; |
|
311 | + |
|
312 | + $response = Route4Me::makeRequst([ |
|
313 | + 'url' => Endpoint::VehicleLocation, |
|
314 | + 'method' => 'GET', |
|
315 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $vehicleParams), |
|
316 | + ]); |
|
317 | + |
|
318 | + return $response; |
|
319 | + } |
|
320 | + |
|
321 | + /** Get the Vehicle by specifying vehicle ID. |
|
322 | + * @param $vehicleParams - Vehicle query parameters containing vehicle ID. |
|
323 | + * @return an object of the type Vehicle |
|
324 | + * @throws \Route4Me\Exception\ApiError |
|
325 | + */ |
|
326 | + public function getVehicleById($vehicleParams) |
|
327 | + { |
|
328 | + $allQueryFields = ['vehicle_id']; |
|
329 | + |
|
330 | + $response = Route4Me::makeRequst([ |
|
331 | + 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'], |
|
332 | + 'method' => 'GET', |
|
333 | + 'query' => null, |
|
334 | + ]); |
|
335 | + |
|
336 | + return $response; |
|
337 | + } |
|
338 | + |
|
339 | + /** Get the Vehicle track by specifying vehicle ID. |
|
340 | + * @param $vehicleParams - Vehicle query parameters containing vehicle ID. |
|
341 | + * @return Vehicle track object |
|
342 | + * @throws \Route4Me\Exception\ApiError |
|
343 | + */ |
|
344 | + public function getVehicleTrack($vehicleParams) |
|
345 | + { |
|
346 | + $response = Route4Me::makeRequst([ |
|
347 | + 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'].'/track', |
|
348 | + 'method' => 'GET', |
|
349 | + 'query' => null, |
|
350 | + ]); |
|
351 | + |
|
352 | + return $response; |
|
353 | + } |
|
354 | + |
|
355 | + public function getVehicleByLicensePlate($vehicleParams) |
|
356 | + { |
|
357 | + $allQueryFields = ['vehicle_license_plate']; |
|
358 | + |
|
359 | + $response = Route4Me::makeRequst([ |
|
360 | + 'url' => Endpoint::VehicleLicense, |
|
361 | + 'method' => 'GET', |
|
362 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $vehicleParams), |
|
363 | + ]); |
|
364 | + |
|
365 | + return $response; |
|
366 | + } |
|
367 | + |
|
368 | + public function searchVehicles($searchParams) |
|
369 | + { |
|
370 | + $excludeFields = []; |
|
371 | + $allBodyFields = Route4Me::getObjectProperties(new VehicleSearchParameters(), $excludeFields); |
|
372 | + |
|
373 | + $response = Route4Me::makeRequst([ |
|
374 | + 'url' => Endpoint::VehicleSearch, |
|
375 | + 'method' => 'POST', |
|
376 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $searchParams), |
|
377 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
378 | + ]); |
|
379 | + |
|
380 | + return $response; |
|
381 | + } |
|
382 | + |
|
383 | + public function updateVehicle($vehicleParams) |
|
384 | + { |
|
385 | + $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
386 | + $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
387 | + |
|
388 | + $response = Route4Me::makeRequst([ |
|
389 | + 'url' => Endpoint::Vehicles.'/'.$vehicleParams['vehicle_id'], |
|
390 | + 'method' => 'PATCH', |
|
391 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $vehicleParams), |
|
392 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
393 | + ]); |
|
394 | + |
|
395 | + return $response; |
|
396 | + } |
|
397 | 397 | } |
@@ -16,279 +16,279 @@ |
||
16 | 16 | */ |
17 | 17 | class VehicleV4 extends \Route4Me\Common |
18 | 18 | { |
19 | - /** @var string $vehicle_id |
|
20 | - * Vehicle unique 32-chars ID |
|
21 | - */ |
|
22 | - public $vehicle_id; |
|
23 | - |
|
24 | - /** @var int $member_id |
|
25 | - * Member unique ID |
|
26 | - */ |
|
27 | - public $member_id; |
|
28 | - |
|
29 | - /** @var boolean $is_deleted |
|
30 | - * True, if the vehicle was deleted. |
|
31 | - */ |
|
32 | - public $is_deleted; |
|
33 | - |
|
34 | - /** @var string $vehicle_alias |
|
35 | - * Vehicle alias |
|
36 | - */ |
|
37 | - public $vehicle_alias; |
|
38 | - |
|
39 | - /** @var string $vehicle_vin |
|
40 | - * Vehicle VIN (vehicle identification number) |
|
41 | - */ |
|
42 | - public $vehicle_vin; |
|
43 | - |
|
44 | - /** @var int $vehicle_reg_state_id |
|
45 | - * The ID of a state the vehicle was registered. |
|
46 | - */ |
|
47 | - public $vehicle_reg_state_id; |
|
48 | - |
|
49 | - /** @var int $vehicle_reg_country_id |
|
50 | - * The ID of a country the vehicle was registered. |
|
51 | - */ |
|
52 | - public $vehicle_reg_country_id; |
|
53 | - |
|
54 | - /** @var string $vehicle_license_plate |
|
55 | - * A license plate of the vehicle. |
|
56 | - */ |
|
57 | - public $vehicle_license_plate; |
|
58 | - |
|
59 | - /** @var string $vehicle_type_id |
|
60 | - * Vehicle type ID. |
|
61 | - * Available values: |
|
62 | - * 'sedan', 'suv', 'pickup_truck', 'van', '18wheeler', 'cabin', 'hatchback', |
|
63 | - * 'motorcyle', 'waste_disposal', 'tree_cutting', 'bigrig', 'cement_mixer', |
|
64 | - * 'livestock_carrier', 'dairy','tractor_trailer' |
|
65 | - */ |
|
66 | - public $vehicle_type_id; |
|
67 | - |
|
68 | - /** @var string $timestamp_added |
|
69 | - * When the vehicle was added. |
|
70 | - */ |
|
71 | - public $timestamp_added; |
|
72 | - |
|
73 | - /** @var string $vehicle_make |
|
74 | - * Vehicle maker brend. |
|
75 | - * Available values: |
|
76 | - * 'american coleman', 'bmw', 'chevrolet', 'ford', 'freightliner', 'gmc', |
|
77 | - * 'hino', 'honda', 'isuzu', 'kenworth', 'mack', 'mercedes-benz', 'mitsubishi', |
|
78 | - * 'navistar', 'nissan', 'peterbilt', 'renault', 'scania', 'sterling', 'toyota', |
|
79 | - * 'volvo', 'western star' |
|
80 | - */ |
|
81 | - public $vehicle_make; |
|
82 | - |
|
83 | - /** @var int $vehicle_model_year |
|
84 | - * A year of the vehicle model. |
|
85 | - */ |
|
86 | - public $vehicle_model_year; |
|
87 | - |
|
88 | - /** @var string $vehicle_model |
|
89 | - * A model of the vehicle. |
|
90 | - */ |
|
91 | - public $vehicle_model; |
|
92 | - |
|
93 | - /** @var int $vehicle_year_acquired |
|
94 | - * A year, the vehicle was acquired. |
|
95 | - */ |
|
96 | - public $vehicle_year_acquired; |
|
97 | - |
|
98 | - /** @var string $vehicle_cost_new |
|
99 | - * A cost of the new vehicle. |
|
100 | - */ |
|
101 | - public $vehicle_cost_new; |
|
102 | - |
|
103 | - /** @var string $purchased_new |
|
104 | - * If true, the vehicle was purchased new. |
|
105 | - */ |
|
106 | - public $purchased_new; |
|
107 | - |
|
108 | - /** @var string $license_start_date |
|
109 | - * Start date of the license (e.g. '2020-12-20'). |
|
110 | - */ |
|
111 | - public $license_start_date; |
|
112 | - |
|
113 | - /** @var string $license_end_date |
|
114 | - * End date of the license (e.g. '2020-12-20'). |
|
115 | - */ |
|
116 | - public $license_end_date; |
|
117 | - |
|
118 | - /** @var boolean $is_operational |
|
119 | - * If true, the vehicle is operational. |
|
120 | - */ |
|
121 | - public $is_operational; |
|
122 | - |
|
123 | - /** @var string $fuel_type |
|
124 | - * A type of the fuel. |
|
125 | - * Available values: |
|
126 | - * 'unleaded 87', 'unleaded 89', 'unleaded 91', 'unleaded 93', 'diesel', 'electric', 'hybrid' |
|
127 | - */ |
|
128 | - public $fuel_type; |
|
129 | - |
|
130 | - /** @var string $external_telematics_vehicle_id |
|
131 | - * External telematics vehicle ID. |
|
132 | - */ |
|
133 | - public $external_telematics_vehicle_id; |
|
134 | - |
|
135 | - /** @var string $timestamp_removed |
|
136 | - * When the vehicle was removed. |
|
137 | - */ |
|
138 | - public $timestamp_removed; |
|
139 | - |
|
140 | - /** @var string $vehicle_profile_id |
|
141 | - * Vehicle profile ID |
|
142 | - */ |
|
143 | - public $vehicle_profile_id; |
|
144 | - |
|
145 | - /** @var double $fuel_consumption_city |
|
146 | - * Fuel consumption in the city area. |
|
147 | - */ |
|
148 | - public $fuel_consumption_city; |
|
149 | - |
|
150 | - /** @var double $fuel_consumption_highway |
|
151 | - * Fuel consumption in the highway area. |
|
152 | - */ |
|
153 | - public $fuel_consumption_highway; |
|
154 | - |
|
155 | - /** @var string $fuel_consumption_city_unit |
|
156 | - * Fuel consumption unit in the city area (e.g. 'mi/l'). |
|
157 | - */ |
|
158 | - public $fuel_consumption_city_unit; |
|
159 | - |
|
160 | - /** @var string $fuel_consumption_highway_unit |
|
161 | - * Fuel consumption unit in the highway area (e.g. 'mi/l'). |
|
162 | - */ |
|
163 | - public $fuel_consumption_highway_unit; |
|
164 | - |
|
165 | - /** @var double $mpg_city |
|
166 | - * Miles per gallon in the city area. |
|
167 | - */ |
|
168 | - public $mpg_city; |
|
169 | - |
|
170 | - /** @var double $mpg_highway |
|
171 | - * Miles per gallon in the highway area. |
|
172 | - */ |
|
173 | - public $mpg_highway; |
|
174 | - |
|
175 | - /** @var string $fuel_consumption_city_uf_value |
|
176 | - * Fuel consumption UF (utility factor) value in the city area. |
|
177 | - */ |
|
178 | - public $fuel_consumption_city_uf_value; |
|
179 | - |
|
180 | - /** @var string $fuel_consumption_highway_uf_value |
|
181 | - * Fuel consumption UF (utility factor) value in the highway area. |
|
182 | - */ |
|
183 | - public $fuel_consumption_highway_uf_value; |
|
184 | - |
|
185 | - public function __construct() |
|
186 | - { |
|
187 | - Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
|
188 | - } |
|
189 | - |
|
190 | - public static function fromArray(array $params) |
|
191 | - { |
|
192 | - $vehicle = new self(); |
|
193 | - |
|
194 | - foreach ($params as $key => $value) { |
|
195 | - if (is_null(Common::getValue($params, $key))) { |
|
196 | - continue; |
|
197 | - } |
|
198 | - if (property_exists($vehicle, $key)) { |
|
199 | - $vehicle->$key = $value; |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - return $vehicle; |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * @deprecated 1.2.6 |
|
208 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::getVehiclesPaginatedList() |
|
209 | - */ |
|
210 | - public static function getVehicles($params) |
|
211 | - { |
|
212 | - $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
213 | - |
|
214 | - $response = Route4Me::makeRequst([ |
|
215 | - 'url' => Endpoint::VEHICLE_V4, |
|
216 | - 'method' => 'GET', |
|
217 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
218 | - ]); |
|
219 | - |
|
220 | - return $response; |
|
221 | - } |
|
222 | - |
|
223 | - /** |
|
224 | - * @deprecated 1.2.6 |
|
225 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::getVehicleById() |
|
226 | - */ |
|
227 | - public function getVehicleByID($vehicleID) |
|
228 | - { |
|
229 | - $response = Route4Me::makeRequst([ |
|
230 | - 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
231 | - 'method' => 'GET', |
|
232 | - ]); |
|
233 | - |
|
234 | - return $response; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * @deprecated 1.2.6 |
|
239 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::updateVehicle() |
|
240 | - */ |
|
241 | - public function updateVehicle($params) |
|
242 | - { |
|
243 | - $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
244 | - |
|
245 | - $allBodyFields = Route4Me::getObjectProperties(new self(), ['vehicle_id']); |
|
246 | - |
|
247 | - $response = Route4Me::makeRequst([ |
|
248 | - 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
249 | - 'method' => 'PUT', |
|
250 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
251 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
252 | - ]); |
|
253 | - |
|
254 | - return $response; |
|
255 | - } |
|
256 | - |
|
257 | - /** |
|
258 | - * @deprecated 1.2.6 |
|
259 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::createVehicle() |
|
260 | - */ |
|
261 | - public function createVehicle($params) |
|
262 | - { |
|
263 | - $excludeFields = ['vehicle_id','is_deleted','created_time','timestamp_added','timestamp_removed']; |
|
264 | - $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
265 | - |
|
266 | - //Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
267 | - |
|
268 | - $response = Route4Me::makeRequst([ |
|
269 | - 'url' => Endpoint::VEHICLE_V4, |
|
270 | - 'method' => 'POST', |
|
271 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
272 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
273 | - ]); |
|
274 | - |
|
275 | - return $response; |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * @deprecated 1.2.6 |
|
280 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::removeVehicle() |
|
281 | - */ |
|
282 | - public function removeVehicle($params) |
|
283 | - { |
|
284 | - $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
285 | - |
|
286 | - $response = Route4Me::makeRequst([ |
|
287 | - 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
288 | - 'method' => 'DELETE', |
|
289 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
290 | - ]); |
|
291 | - |
|
292 | - return $response; |
|
293 | - } |
|
19 | + /** @var string $vehicle_id |
|
20 | + * Vehicle unique 32-chars ID |
|
21 | + */ |
|
22 | + public $vehicle_id; |
|
23 | + |
|
24 | + /** @var int $member_id |
|
25 | + * Member unique ID |
|
26 | + */ |
|
27 | + public $member_id; |
|
28 | + |
|
29 | + /** @var boolean $is_deleted |
|
30 | + * True, if the vehicle was deleted. |
|
31 | + */ |
|
32 | + public $is_deleted; |
|
33 | + |
|
34 | + /** @var string $vehicle_alias |
|
35 | + * Vehicle alias |
|
36 | + */ |
|
37 | + public $vehicle_alias; |
|
38 | + |
|
39 | + /** @var string $vehicle_vin |
|
40 | + * Vehicle VIN (vehicle identification number) |
|
41 | + */ |
|
42 | + public $vehicle_vin; |
|
43 | + |
|
44 | + /** @var int $vehicle_reg_state_id |
|
45 | + * The ID of a state the vehicle was registered. |
|
46 | + */ |
|
47 | + public $vehicle_reg_state_id; |
|
48 | + |
|
49 | + /** @var int $vehicle_reg_country_id |
|
50 | + * The ID of a country the vehicle was registered. |
|
51 | + */ |
|
52 | + public $vehicle_reg_country_id; |
|
53 | + |
|
54 | + /** @var string $vehicle_license_plate |
|
55 | + * A license plate of the vehicle. |
|
56 | + */ |
|
57 | + public $vehicle_license_plate; |
|
58 | + |
|
59 | + /** @var string $vehicle_type_id |
|
60 | + * Vehicle type ID. |
|
61 | + * Available values: |
|
62 | + * 'sedan', 'suv', 'pickup_truck', 'van', '18wheeler', 'cabin', 'hatchback', |
|
63 | + * 'motorcyle', 'waste_disposal', 'tree_cutting', 'bigrig', 'cement_mixer', |
|
64 | + * 'livestock_carrier', 'dairy','tractor_trailer' |
|
65 | + */ |
|
66 | + public $vehicle_type_id; |
|
67 | + |
|
68 | + /** @var string $timestamp_added |
|
69 | + * When the vehicle was added. |
|
70 | + */ |
|
71 | + public $timestamp_added; |
|
72 | + |
|
73 | + /** @var string $vehicle_make |
|
74 | + * Vehicle maker brend. |
|
75 | + * Available values: |
|
76 | + * 'american coleman', 'bmw', 'chevrolet', 'ford', 'freightliner', 'gmc', |
|
77 | + * 'hino', 'honda', 'isuzu', 'kenworth', 'mack', 'mercedes-benz', 'mitsubishi', |
|
78 | + * 'navistar', 'nissan', 'peterbilt', 'renault', 'scania', 'sterling', 'toyota', |
|
79 | + * 'volvo', 'western star' |
|
80 | + */ |
|
81 | + public $vehicle_make; |
|
82 | + |
|
83 | + /** @var int $vehicle_model_year |
|
84 | + * A year of the vehicle model. |
|
85 | + */ |
|
86 | + public $vehicle_model_year; |
|
87 | + |
|
88 | + /** @var string $vehicle_model |
|
89 | + * A model of the vehicle. |
|
90 | + */ |
|
91 | + public $vehicle_model; |
|
92 | + |
|
93 | + /** @var int $vehicle_year_acquired |
|
94 | + * A year, the vehicle was acquired. |
|
95 | + */ |
|
96 | + public $vehicle_year_acquired; |
|
97 | + |
|
98 | + /** @var string $vehicle_cost_new |
|
99 | + * A cost of the new vehicle. |
|
100 | + */ |
|
101 | + public $vehicle_cost_new; |
|
102 | + |
|
103 | + /** @var string $purchased_new |
|
104 | + * If true, the vehicle was purchased new. |
|
105 | + */ |
|
106 | + public $purchased_new; |
|
107 | + |
|
108 | + /** @var string $license_start_date |
|
109 | + * Start date of the license (e.g. '2020-12-20'). |
|
110 | + */ |
|
111 | + public $license_start_date; |
|
112 | + |
|
113 | + /** @var string $license_end_date |
|
114 | + * End date of the license (e.g. '2020-12-20'). |
|
115 | + */ |
|
116 | + public $license_end_date; |
|
117 | + |
|
118 | + /** @var boolean $is_operational |
|
119 | + * If true, the vehicle is operational. |
|
120 | + */ |
|
121 | + public $is_operational; |
|
122 | + |
|
123 | + /** @var string $fuel_type |
|
124 | + * A type of the fuel. |
|
125 | + * Available values: |
|
126 | + * 'unleaded 87', 'unleaded 89', 'unleaded 91', 'unleaded 93', 'diesel', 'electric', 'hybrid' |
|
127 | + */ |
|
128 | + public $fuel_type; |
|
129 | + |
|
130 | + /** @var string $external_telematics_vehicle_id |
|
131 | + * External telematics vehicle ID. |
|
132 | + */ |
|
133 | + public $external_telematics_vehicle_id; |
|
134 | + |
|
135 | + /** @var string $timestamp_removed |
|
136 | + * When the vehicle was removed. |
|
137 | + */ |
|
138 | + public $timestamp_removed; |
|
139 | + |
|
140 | + /** @var string $vehicle_profile_id |
|
141 | + * Vehicle profile ID |
|
142 | + */ |
|
143 | + public $vehicle_profile_id; |
|
144 | + |
|
145 | + /** @var double $fuel_consumption_city |
|
146 | + * Fuel consumption in the city area. |
|
147 | + */ |
|
148 | + public $fuel_consumption_city; |
|
149 | + |
|
150 | + /** @var double $fuel_consumption_highway |
|
151 | + * Fuel consumption in the highway area. |
|
152 | + */ |
|
153 | + public $fuel_consumption_highway; |
|
154 | + |
|
155 | + /** @var string $fuel_consumption_city_unit |
|
156 | + * Fuel consumption unit in the city area (e.g. 'mi/l'). |
|
157 | + */ |
|
158 | + public $fuel_consumption_city_unit; |
|
159 | + |
|
160 | + /** @var string $fuel_consumption_highway_unit |
|
161 | + * Fuel consumption unit in the highway area (e.g. 'mi/l'). |
|
162 | + */ |
|
163 | + public $fuel_consumption_highway_unit; |
|
164 | + |
|
165 | + /** @var double $mpg_city |
|
166 | + * Miles per gallon in the city area. |
|
167 | + */ |
|
168 | + public $mpg_city; |
|
169 | + |
|
170 | + /** @var double $mpg_highway |
|
171 | + * Miles per gallon in the highway area. |
|
172 | + */ |
|
173 | + public $mpg_highway; |
|
174 | + |
|
175 | + /** @var string $fuel_consumption_city_uf_value |
|
176 | + * Fuel consumption UF (utility factor) value in the city area. |
|
177 | + */ |
|
178 | + public $fuel_consumption_city_uf_value; |
|
179 | + |
|
180 | + /** @var string $fuel_consumption_highway_uf_value |
|
181 | + * Fuel consumption UF (utility factor) value in the highway area. |
|
182 | + */ |
|
183 | + public $fuel_consumption_highway_uf_value; |
|
184 | + |
|
185 | + public function __construct() |
|
186 | + { |
|
187 | + Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
|
188 | + } |
|
189 | + |
|
190 | + public static function fromArray(array $params) |
|
191 | + { |
|
192 | + $vehicle = new self(); |
|
193 | + |
|
194 | + foreach ($params as $key => $value) { |
|
195 | + if (is_null(Common::getValue($params, $key))) { |
|
196 | + continue; |
|
197 | + } |
|
198 | + if (property_exists($vehicle, $key)) { |
|
199 | + $vehicle->$key = $value; |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + return $vehicle; |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * @deprecated 1.2.6 |
|
208 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::getVehiclesPaginatedList() |
|
209 | + */ |
|
210 | + public static function getVehicles($params) |
|
211 | + { |
|
212 | + $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
213 | + |
|
214 | + $response = Route4Me::makeRequst([ |
|
215 | + 'url' => Endpoint::VEHICLE_V4, |
|
216 | + 'method' => 'GET', |
|
217 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
218 | + ]); |
|
219 | + |
|
220 | + return $response; |
|
221 | + } |
|
222 | + |
|
223 | + /** |
|
224 | + * @deprecated 1.2.6 |
|
225 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::getVehicleById() |
|
226 | + */ |
|
227 | + public function getVehicleByID($vehicleID) |
|
228 | + { |
|
229 | + $response = Route4Me::makeRequst([ |
|
230 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
231 | + 'method' => 'GET', |
|
232 | + ]); |
|
233 | + |
|
234 | + return $response; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * @deprecated 1.2.6 |
|
239 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::updateVehicle() |
|
240 | + */ |
|
241 | + public function updateVehicle($params) |
|
242 | + { |
|
243 | + $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
244 | + |
|
245 | + $allBodyFields = Route4Me::getObjectProperties(new self(), ['vehicle_id']); |
|
246 | + |
|
247 | + $response = Route4Me::makeRequst([ |
|
248 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
249 | + 'method' => 'PUT', |
|
250 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
251 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
252 | + ]); |
|
253 | + |
|
254 | + return $response; |
|
255 | + } |
|
256 | + |
|
257 | + /** |
|
258 | + * @deprecated 1.2.6 |
|
259 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::createVehicle() |
|
260 | + */ |
|
261 | + public function createVehicle($params) |
|
262 | + { |
|
263 | + $excludeFields = ['vehicle_id','is_deleted','created_time','timestamp_added','timestamp_removed']; |
|
264 | + $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
265 | + |
|
266 | + //Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
267 | + |
|
268 | + $response = Route4Me::makeRequst([ |
|
269 | + 'url' => Endpoint::VEHICLE_V4, |
|
270 | + 'method' => 'POST', |
|
271 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
272 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
273 | + ]); |
|
274 | + |
|
275 | + return $response; |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * @deprecated 1.2.6 |
|
280 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::removeVehicle() |
|
281 | + */ |
|
282 | + public function removeVehicle($params) |
|
283 | + { |
|
284 | + $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
285 | + |
|
286 | + $response = Route4Me::makeRequst([ |
|
287 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
288 | + 'method' => 'DELETE', |
|
289 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
290 | + ]); |
|
291 | + |
|
292 | + return $response; |
|
293 | + } |
|
294 | 294 | } |
@@ -16,192 +16,192 @@ |
||
16 | 16 | */ |
17 | 17 | class Vehicle extends \Route4Me\Common |
18 | 18 | { |
19 | - public $vehicle_id; |
|
20 | - public $member_id; |
|
21 | - public $is_deleted; |
|
22 | - public $vehicle_name; |
|
23 | - public $vehicle_alias; |
|
24 | - public $vehicle_vin; |
|
25 | - //public $created_time; |
|
26 | - public $vehicle_reg_state_id; |
|
27 | - public $vehicle_reg_country_id; |
|
28 | - public $vehicle_license_plate; |
|
29 | - public $vehicle_type_id; |
|
30 | - public $timestamp_added; |
|
31 | - public $vehicle_make; |
|
32 | - public $vehicle_model_year; |
|
33 | - public $vehicle_model; |
|
34 | - public $vehicle_year_acquired; |
|
35 | - public $vehicle_cost_new; |
|
36 | - public $purchased_new; |
|
37 | - public $license_start_date; |
|
38 | - public $license_end_date; |
|
39 | - public $vehicle_axle_count; |
|
40 | - public $mpg_city; |
|
41 | - public $mpg_highway; |
|
42 | - public $fuel_type; |
|
43 | - public $height_inches; |
|
44 | - public $weight_lb; |
|
45 | - public $route4me_telematics_internal_api_key; |
|
46 | - public $is_operational; |
|
47 | - public $external_telematics_vehicle_id; |
|
48 | - public $r4m_telematics_gateway_connection_id; |
|
49 | - public $r4m_telematics_gateway_vehicle_id; |
|
50 | - public $has_trailer; |
|
51 | - public $heightInInches; |
|
52 | - public $lengthInInches; |
|
53 | - public $widthInInches; |
|
54 | - public $maxWeightPerAxleGroupInPounds; |
|
55 | - public $numAxles; |
|
56 | - public $weightInPounds; |
|
57 | - public $HazmatType; |
|
58 | - public $LowEmissionZonePref; |
|
59 | - public $Use53FootTrailerRouting; |
|
60 | - public $UseNationalNetwork; |
|
61 | - public $UseTruckRestrictions; |
|
62 | - public $AvoidFerries; |
|
63 | - public $DividedHighwayAvoidPreference; |
|
64 | - public $FreewayAvoidPreference; |
|
65 | - public $InternationalBordersOpen; |
|
66 | - public $TollRoadUsage; |
|
67 | - public $hwy_only; |
|
68 | - public $long_combination_vehicle; |
|
69 | - public $avoid_highways; |
|
70 | - public $side_street_adherence; |
|
71 | - public $truck_config; |
|
72 | - public $height_metric; |
|
73 | - public $length_metric; |
|
74 | - public $width_metric; |
|
75 | - public $weight_metric; |
|
76 | - public $max_weight_per_axle_group_metric; |
|
77 | - public $timestamp_removed; |
|
78 | - |
|
79 | - public function __construct() |
|
80 | - { |
|
81 | - Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
|
82 | - } |
|
83 | - |
|
84 | - public static function fromArray(array $params) |
|
85 | - { |
|
86 | - $vehicle = new self(); |
|
87 | - |
|
88 | - foreach ($params as $key => $value) { |
|
89 | - if (is_null(Common::getValue($params, $key))) { |
|
90 | - continue; |
|
91 | - } |
|
92 | - if (property_exists($vehicle, $key)) { |
|
93 | - $vehicle->$key = $value; |
|
94 | - } |
|
95 | - } |
|
96 | - |
|
97 | - return $vehicle; |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * @deprecated 1.2.6 |
|
102 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::getVehiclesPaginatedList() |
|
103 | - */ |
|
104 | - public static function getVehicles($params) |
|
105 | - { |
|
106 | - $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
107 | - |
|
108 | - $response = Route4Me::makeRequst([ |
|
109 | - 'url' => Endpoint::VEHICLE_V4, |
|
110 | - 'method' => 'GET', |
|
111 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
112 | - ]); |
|
113 | - |
|
114 | - return $response; |
|
115 | - } |
|
116 | - |
|
117 | - public function getRandomVehicleId($page, $perPage) |
|
118 | - { |
|
119 | - $params = [ |
|
120 | - 'page' => isset($page) ? $page : 1, |
|
121 | - 'perPage' => isset($perPage) ? $perPage : 10, |
|
122 | - 'with_pagination' => true, |
|
123 | - ]; |
|
124 | - |
|
125 | - $vehicles = $this->getVehicles($params); |
|
126 | - |
|
127 | - if (is_null($vehicles) || !isset($vehicles['data']) || sizeof($vehicles['data']) < 1) { |
|
128 | - return null; |
|
129 | - } |
|
130 | - |
|
131 | - $randomIndex = rand(0, sizeof($vehicles['data']) - 1); |
|
132 | - |
|
133 | - return $vehicles['data'][$randomIndex]['vehicle_id']; |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * @deprecated 1.2.6 |
|
138 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::getVehicleById() |
|
139 | - */ |
|
140 | - public function getVehicleByID($vehicleID) |
|
141 | - { |
|
142 | - $response = Route4Me::makeRequst([ |
|
143 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
144 | - 'method' => 'GET', |
|
145 | - ]); |
|
146 | - |
|
147 | - return $response; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @deprecated 1.2.6 |
|
152 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::updateVehicle() |
|
153 | - */ |
|
154 | - public function updateVehicle($params) |
|
155 | - { |
|
156 | - $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
157 | - |
|
158 | - $allBodyFields = Route4Me::getObjectProperties(new self(), ['vehicle_id']); |
|
159 | - |
|
160 | - $response = Route4Me::makeRequst([ |
|
161 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
162 | - 'method' => 'PUT', |
|
163 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
164 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
165 | - ]); |
|
166 | - |
|
167 | - return $response; |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * @deprecated 1.2.6 |
|
172 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::createVehicle() |
|
173 | - */ |
|
174 | - public function createVehicle($params) |
|
175 | - { |
|
176 | - $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
177 | - $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
178 | - |
|
179 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
180 | - |
|
181 | - $response = Route4Me::makeRequst([ |
|
182 | - 'url' => Endpoint::VEHICLE_V4_API, |
|
183 | - 'method' => 'POST', |
|
184 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
185 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
186 | - ]); |
|
187 | - |
|
188 | - return $response; |
|
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * @deprecated 1.2.6 |
|
193 | - * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::removeVehicle() |
|
194 | - */ |
|
195 | - public function removeVehicle($params) |
|
196 | - { |
|
197 | - $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
198 | - |
|
199 | - $response = Route4Me::makeRequst([ |
|
200 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
201 | - 'method' => 'DELETE', |
|
202 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
203 | - ]); |
|
204 | - |
|
205 | - return $response; |
|
206 | - } |
|
19 | + public $vehicle_id; |
|
20 | + public $member_id; |
|
21 | + public $is_deleted; |
|
22 | + public $vehicle_name; |
|
23 | + public $vehicle_alias; |
|
24 | + public $vehicle_vin; |
|
25 | + //public $created_time; |
|
26 | + public $vehicle_reg_state_id; |
|
27 | + public $vehicle_reg_country_id; |
|
28 | + public $vehicle_license_plate; |
|
29 | + public $vehicle_type_id; |
|
30 | + public $timestamp_added; |
|
31 | + public $vehicle_make; |
|
32 | + public $vehicle_model_year; |
|
33 | + public $vehicle_model; |
|
34 | + public $vehicle_year_acquired; |
|
35 | + public $vehicle_cost_new; |
|
36 | + public $purchased_new; |
|
37 | + public $license_start_date; |
|
38 | + public $license_end_date; |
|
39 | + public $vehicle_axle_count; |
|
40 | + public $mpg_city; |
|
41 | + public $mpg_highway; |
|
42 | + public $fuel_type; |
|
43 | + public $height_inches; |
|
44 | + public $weight_lb; |
|
45 | + public $route4me_telematics_internal_api_key; |
|
46 | + public $is_operational; |
|
47 | + public $external_telematics_vehicle_id; |
|
48 | + public $r4m_telematics_gateway_connection_id; |
|
49 | + public $r4m_telematics_gateway_vehicle_id; |
|
50 | + public $has_trailer; |
|
51 | + public $heightInInches; |
|
52 | + public $lengthInInches; |
|
53 | + public $widthInInches; |
|
54 | + public $maxWeightPerAxleGroupInPounds; |
|
55 | + public $numAxles; |
|
56 | + public $weightInPounds; |
|
57 | + public $HazmatType; |
|
58 | + public $LowEmissionZonePref; |
|
59 | + public $Use53FootTrailerRouting; |
|
60 | + public $UseNationalNetwork; |
|
61 | + public $UseTruckRestrictions; |
|
62 | + public $AvoidFerries; |
|
63 | + public $DividedHighwayAvoidPreference; |
|
64 | + public $FreewayAvoidPreference; |
|
65 | + public $InternationalBordersOpen; |
|
66 | + public $TollRoadUsage; |
|
67 | + public $hwy_only; |
|
68 | + public $long_combination_vehicle; |
|
69 | + public $avoid_highways; |
|
70 | + public $side_street_adherence; |
|
71 | + public $truck_config; |
|
72 | + public $height_metric; |
|
73 | + public $length_metric; |
|
74 | + public $width_metric; |
|
75 | + public $weight_metric; |
|
76 | + public $max_weight_per_axle_group_metric; |
|
77 | + public $timestamp_removed; |
|
78 | + |
|
79 | + public function __construct() |
|
80 | + { |
|
81 | + Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
|
82 | + } |
|
83 | + |
|
84 | + public static function fromArray(array $params) |
|
85 | + { |
|
86 | + $vehicle = new self(); |
|
87 | + |
|
88 | + foreach ($params as $key => $value) { |
|
89 | + if (is_null(Common::getValue($params, $key))) { |
|
90 | + continue; |
|
91 | + } |
|
92 | + if (property_exists($vehicle, $key)) { |
|
93 | + $vehicle->$key = $value; |
|
94 | + } |
|
95 | + } |
|
96 | + |
|
97 | + return $vehicle; |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * @deprecated 1.2.6 |
|
102 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::getVehiclesPaginatedList() |
|
103 | + */ |
|
104 | + public static function getVehicles($params) |
|
105 | + { |
|
106 | + $allQueryFields = ['with_pagination', 'page', 'perPage']; |
|
107 | + |
|
108 | + $response = Route4Me::makeRequst([ |
|
109 | + 'url' => Endpoint::VEHICLE_V4, |
|
110 | + 'method' => 'GET', |
|
111 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
112 | + ]); |
|
113 | + |
|
114 | + return $response; |
|
115 | + } |
|
116 | + |
|
117 | + public function getRandomVehicleId($page, $perPage) |
|
118 | + { |
|
119 | + $params = [ |
|
120 | + 'page' => isset($page) ? $page : 1, |
|
121 | + 'perPage' => isset($perPage) ? $perPage : 10, |
|
122 | + 'with_pagination' => true, |
|
123 | + ]; |
|
124 | + |
|
125 | + $vehicles = $this->getVehicles($params); |
|
126 | + |
|
127 | + if (is_null($vehicles) || !isset($vehicles['data']) || sizeof($vehicles['data']) < 1) { |
|
128 | + return null; |
|
129 | + } |
|
130 | + |
|
131 | + $randomIndex = rand(0, sizeof($vehicles['data']) - 1); |
|
132 | + |
|
133 | + return $vehicles['data'][$randomIndex]['vehicle_id']; |
|
134 | + } |
|
135 | + |
|
136 | + /** |
|
137 | + * @deprecated 1.2.6 |
|
138 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::getVehicleById() |
|
139 | + */ |
|
140 | + public function getVehicleByID($vehicleID) |
|
141 | + { |
|
142 | + $response = Route4Me::makeRequst([ |
|
143 | + 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
144 | + 'method' => 'GET', |
|
145 | + ]); |
|
146 | + |
|
147 | + return $response; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @deprecated 1.2.6 |
|
152 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::updateVehicle() |
|
153 | + */ |
|
154 | + public function updateVehicle($params) |
|
155 | + { |
|
156 | + $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
157 | + |
|
158 | + $allBodyFields = Route4Me::getObjectProperties(new self(), ['vehicle_id']); |
|
159 | + |
|
160 | + $response = Route4Me::makeRequst([ |
|
161 | + 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
162 | + 'method' => 'PUT', |
|
163 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
164 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
165 | + ]); |
|
166 | + |
|
167 | + return $response; |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * @deprecated 1.2.6 |
|
172 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::createVehicle() |
|
173 | + */ |
|
174 | + public function createVehicle($params) |
|
175 | + { |
|
176 | + $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
177 | + $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
|
178 | + |
|
179 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
180 | + |
|
181 | + $response = Route4Me::makeRequst([ |
|
182 | + 'url' => Endpoint::VEHICLE_V4_API, |
|
183 | + 'method' => 'POST', |
|
184 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
185 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
186 | + ]); |
|
187 | + |
|
188 | + return $response; |
|
189 | + } |
|
190 | + |
|
191 | + /** |
|
192 | + * @deprecated 1.2.6 |
|
193 | + * @see \Route4Me\V5\Vehicles\DataTypes\Vehicle::removeVehicle() |
|
194 | + */ |
|
195 | + public function removeVehicle($params) |
|
196 | + { |
|
197 | + $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
198 | + |
|
199 | + $response = Route4Me::makeRequst([ |
|
200 | + 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
201 | + 'method' => 'DELETE', |
|
202 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
203 | + ]); |
|
204 | + |
|
205 | + return $response; |
|
206 | + } |
|
207 | 207 | } |
@@ -6,185 +6,185 @@ discard block |
||
6 | 6 | |
7 | 7 | class OptimizationProblem extends Common |
8 | 8 | { |
9 | - /** |
|
10 | - * Optimization problem ID |
|
11 | - * @var string |
|
12 | - */ |
|
13 | - public $optimization_problem_id; |
|
14 | - |
|
15 | - /** |
|
16 | - * Smart Optimization Problem ID |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - public $smart_optimization_id; |
|
20 | - |
|
21 | - /** |
|
22 | - * An array of the user errors. |
|
23 | - * @var string[] |
|
24 | - */ |
|
25 | - public $user_errors = []; |
|
26 | - |
|
27 | - /** |
|
28 | - * An optimization problem state.<br> |
|
29 | - * Available values: |
|
30 | - * - OptimizationStateNew = 0, |
|
31 | - * - Initial = 1, |
|
32 | - * - MatrixProcessing = 2, |
|
33 | - * - Optimizing = 3, |
|
34 | - * - Optimized = 4, |
|
35 | - * - Error = 5, |
|
36 | - * - ComputingDirections = 6, |
|
37 | - * - OptimizationStateInQueue = 7 |
|
38 | - * @var int |
|
39 | - */ |
|
40 | - public $state; |
|
41 | - |
|
42 | - /** |
|
43 | - * An array of the optimization errors. |
|
44 | - * @var string[] |
|
45 | - */ |
|
46 | - public $optimization_errors = []; |
|
47 | - |
|
48 | - /** |
|
49 | - * Route Parameters. |
|
50 | - * @var RouteParameters |
|
51 | - */ |
|
52 | - public $parameters; |
|
53 | - |
|
54 | - /** |
|
55 | - * If true it means the solution was not returned (it is being computed in the background). |
|
56 | - * @var boolean |
|
57 | - */ |
|
58 | - public $sent_to_background; |
|
59 | - |
|
60 | - /** |
|
61 | - * When the optimization problem was created. |
|
62 | - * @var long |
|
63 | - */ |
|
64 | - public $created_timestamp; |
|
65 | - |
|
66 | - /** |
|
67 | - * An Unix Timestamp the Optimization Problem was scheduled for. |
|
68 | - * @var long |
|
69 | - */ |
|
70 | - public $scheduled_for; |
|
71 | - |
|
72 | - /** |
|
73 | - * When the optimization completed. |
|
74 | - * @var long |
|
75 | - */ |
|
76 | - public $optimization_completed_timestamp; |
|
77 | - |
|
78 | - /** |
|
79 | - * An array ot the Address type objects. |
|
80 | - * @var Address[] |
|
81 | - */ |
|
82 | - public $addresses = []; |
|
83 | - |
|
84 | - /** |
|
85 | - * An array ot the DataObjectRoute type objects.<br> |
|
86 | - * The routes included in the optimization problem. |
|
87 | - * @var Route[] |
|
88 | - */ |
|
89 | - public $routes = []; |
|
90 | - |
|
91 | - /** @var string[] $links |
|
92 | - * The links to the GET operations for the optimization problem. |
|
93 | - */ |
|
94 | - public $links = []; |
|
95 | - |
|
96 | - public function __construct() |
|
97 | - { |
|
98 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
99 | - $this->parameters = new RouteParameters(); |
|
100 | - } |
|
101 | - |
|
102 | - public static function fromArray(array $params) |
|
103 | - { |
|
104 | - $problem = new self(); |
|
105 | - $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
106 | - $problem->user_errors = Common::getValue($params, 'user_errors', []); |
|
107 | - $problem->state = Common::getValue($params, 'state', []); |
|
108 | - $problem->sent_to_background = Common::getValue($params, 'sent_to_background', []); |
|
109 | - $problem->links = Common::getValue($params, 'links', []); |
|
110 | - |
|
111 | - if (isset($params['parameters'])) { |
|
112 | - $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
113 | - } |
|
114 | - |
|
115 | - if (isset($params['addresses'])) { |
|
116 | - $addresses = []; |
|
117 | - |
|
118 | - foreach ($params['addresses'] as $address) { |
|
119 | - $addresses[] = Address::fromArray($address); |
|
120 | - } |
|
121 | - |
|
122 | - $problem->addresses = $addresses; |
|
123 | - } |
|
124 | - |
|
125 | - if (isset($params['routes'])) { |
|
126 | - $routes = []; |
|
127 | - |
|
128 | - foreach ($params['routes'] as $route) { |
|
129 | - $routes[] = Route::fromArray($route); |
|
130 | - } |
|
131 | - |
|
132 | - $problem->routes = $routes; |
|
133 | - } |
|
134 | - |
|
135 | - return $problem; |
|
136 | - } |
|
137 | - |
|
138 | - public static function optimize(OptimizationProblemParams $params) |
|
139 | - { |
|
140 | - $allQueryFields = ['redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url']; |
|
141 | - |
|
142 | - $optimize = Route4Me::makeRequst([ |
|
143 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
144 | - 'method' => 'POST', |
|
145 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
146 | - 'body' => [ |
|
147 | - 'addresses' => $params->getAddressesArray(), |
|
148 | - 'depots' => $params->getDepotsArray(), |
|
149 | - 'parameters' => $params->getParametersArray(), |
|
150 | - ], |
|
151 | - ]); |
|
152 | - |
|
153 | - return self::fromArray($optimize); |
|
154 | - } |
|
155 | - |
|
156 | - public static function get($params) |
|
157 | - { |
|
158 | - $allQueryFields = ['state', 'limit', 'format', 'offset', |
|
159 | - 'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ]; |
|
160 | - |
|
161 | - $result = Route4Me::makeRequst([ |
|
162 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
163 | - 'method' => 'GET', |
|
164 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
165 | - ]); |
|
166 | - |
|
167 | - if (isset($result['optimizations'])) { |
|
168 | - $problems = []; |
|
169 | - |
|
170 | - foreach ($result['optimizations'] as $problem) { |
|
171 | - $problems[] = self::fromArray($problem); |
|
172 | - } |
|
173 | - |
|
174 | - return $problems; |
|
175 | - } else { |
|
176 | - return self::fromArray($result); |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - public function reoptimize($params) |
|
181 | - { |
|
182 | - $param['reoptimize'] = 1; |
|
183 | - |
|
184 | - return self::update($params); |
|
185 | - } |
|
186 | - |
|
187 | - /* |
|
9 | + /** |
|
10 | + * Optimization problem ID |
|
11 | + * @var string |
|
12 | + */ |
|
13 | + public $optimization_problem_id; |
|
14 | + |
|
15 | + /** |
|
16 | + * Smart Optimization Problem ID |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + public $smart_optimization_id; |
|
20 | + |
|
21 | + /** |
|
22 | + * An array of the user errors. |
|
23 | + * @var string[] |
|
24 | + */ |
|
25 | + public $user_errors = []; |
|
26 | + |
|
27 | + /** |
|
28 | + * An optimization problem state.<br> |
|
29 | + * Available values: |
|
30 | + * - OptimizationStateNew = 0, |
|
31 | + * - Initial = 1, |
|
32 | + * - MatrixProcessing = 2, |
|
33 | + * - Optimizing = 3, |
|
34 | + * - Optimized = 4, |
|
35 | + * - Error = 5, |
|
36 | + * - ComputingDirections = 6, |
|
37 | + * - OptimizationStateInQueue = 7 |
|
38 | + * @var int |
|
39 | + */ |
|
40 | + public $state; |
|
41 | + |
|
42 | + /** |
|
43 | + * An array of the optimization errors. |
|
44 | + * @var string[] |
|
45 | + */ |
|
46 | + public $optimization_errors = []; |
|
47 | + |
|
48 | + /** |
|
49 | + * Route Parameters. |
|
50 | + * @var RouteParameters |
|
51 | + */ |
|
52 | + public $parameters; |
|
53 | + |
|
54 | + /** |
|
55 | + * If true it means the solution was not returned (it is being computed in the background). |
|
56 | + * @var boolean |
|
57 | + */ |
|
58 | + public $sent_to_background; |
|
59 | + |
|
60 | + /** |
|
61 | + * When the optimization problem was created. |
|
62 | + * @var long |
|
63 | + */ |
|
64 | + public $created_timestamp; |
|
65 | + |
|
66 | + /** |
|
67 | + * An Unix Timestamp the Optimization Problem was scheduled for. |
|
68 | + * @var long |
|
69 | + */ |
|
70 | + public $scheduled_for; |
|
71 | + |
|
72 | + /** |
|
73 | + * When the optimization completed. |
|
74 | + * @var long |
|
75 | + */ |
|
76 | + public $optimization_completed_timestamp; |
|
77 | + |
|
78 | + /** |
|
79 | + * An array ot the Address type objects. |
|
80 | + * @var Address[] |
|
81 | + */ |
|
82 | + public $addresses = []; |
|
83 | + |
|
84 | + /** |
|
85 | + * An array ot the DataObjectRoute type objects.<br> |
|
86 | + * The routes included in the optimization problem. |
|
87 | + * @var Route[] |
|
88 | + */ |
|
89 | + public $routes = []; |
|
90 | + |
|
91 | + /** @var string[] $links |
|
92 | + * The links to the GET operations for the optimization problem. |
|
93 | + */ |
|
94 | + public $links = []; |
|
95 | + |
|
96 | + public function __construct() |
|
97 | + { |
|
98 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
99 | + $this->parameters = new RouteParameters(); |
|
100 | + } |
|
101 | + |
|
102 | + public static function fromArray(array $params) |
|
103 | + { |
|
104 | + $problem = new self(); |
|
105 | + $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
106 | + $problem->user_errors = Common::getValue($params, 'user_errors', []); |
|
107 | + $problem->state = Common::getValue($params, 'state', []); |
|
108 | + $problem->sent_to_background = Common::getValue($params, 'sent_to_background', []); |
|
109 | + $problem->links = Common::getValue($params, 'links', []); |
|
110 | + |
|
111 | + if (isset($params['parameters'])) { |
|
112 | + $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
113 | + } |
|
114 | + |
|
115 | + if (isset($params['addresses'])) { |
|
116 | + $addresses = []; |
|
117 | + |
|
118 | + foreach ($params['addresses'] as $address) { |
|
119 | + $addresses[] = Address::fromArray($address); |
|
120 | + } |
|
121 | + |
|
122 | + $problem->addresses = $addresses; |
|
123 | + } |
|
124 | + |
|
125 | + if (isset($params['routes'])) { |
|
126 | + $routes = []; |
|
127 | + |
|
128 | + foreach ($params['routes'] as $route) { |
|
129 | + $routes[] = Route::fromArray($route); |
|
130 | + } |
|
131 | + |
|
132 | + $problem->routes = $routes; |
|
133 | + } |
|
134 | + |
|
135 | + return $problem; |
|
136 | + } |
|
137 | + |
|
138 | + public static function optimize(OptimizationProblemParams $params) |
|
139 | + { |
|
140 | + $allQueryFields = ['redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url']; |
|
141 | + |
|
142 | + $optimize = Route4Me::makeRequst([ |
|
143 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
144 | + 'method' => 'POST', |
|
145 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
146 | + 'body' => [ |
|
147 | + 'addresses' => $params->getAddressesArray(), |
|
148 | + 'depots' => $params->getDepotsArray(), |
|
149 | + 'parameters' => $params->getParametersArray(), |
|
150 | + ], |
|
151 | + ]); |
|
152 | + |
|
153 | + return self::fromArray($optimize); |
|
154 | + } |
|
155 | + |
|
156 | + public static function get($params) |
|
157 | + { |
|
158 | + $allQueryFields = ['state', 'limit', 'format', 'offset', |
|
159 | + 'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ]; |
|
160 | + |
|
161 | + $result = Route4Me::makeRequst([ |
|
162 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
163 | + 'method' => 'GET', |
|
164 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
165 | + ]); |
|
166 | + |
|
167 | + if (isset($result['optimizations'])) { |
|
168 | + $problems = []; |
|
169 | + |
|
170 | + foreach ($result['optimizations'] as $problem) { |
|
171 | + $problems[] = self::fromArray($problem); |
|
172 | + } |
|
173 | + |
|
174 | + return $problems; |
|
175 | + } else { |
|
176 | + return self::fromArray($result); |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + public function reoptimize($params) |
|
181 | + { |
|
182 | + $param['reoptimize'] = 1; |
|
183 | + |
|
184 | + return self::update($params); |
|
185 | + } |
|
186 | + |
|
187 | + /* |
|
188 | 188 | * Updates an existing optimization problem.<br> |
189 | 189 | * @param array $params with items: |
190 | 190 | * - optimization_problem_id : query parameter. ID of an updated optimization; |
@@ -193,157 +193,157 @@ discard block |
||
193 | 193 | * - parameters : body parameter. Modified route parameters; |
194 | 194 | * @return Optimization problem |
195 | 195 | */ |
196 | - public static function update($params) |
|
197 | - { |
|
198 | - $allQueryFields = ['optimization_problem_id', 'reoptimize']; |
|
199 | - $allBodyFields = ['addresses', 'parameters']; |
|
200 | - $query = null; |
|
201 | - $body = null; |
|
202 | - |
|
203 | - if (is_array($params)) { |
|
204 | - if (isset($params['optimization_problem_id']) || isset($params['parameters'])) { |
|
205 | - $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
|
206 | - } |
|
207 | - |
|
208 | - if ((isset($params['addresses']) && sizeof($params['addresses']) > 0) |
|
209 | - || (isset($params['parameters']) && sizeof($params['parameters']) > 0) |
|
210 | - ) { |
|
211 | - $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
|
212 | - } |
|
213 | - } else { |
|
214 | - if (isset($params->optimization_problem_id) || isset($params->parameters)) { |
|
215 | - $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
|
216 | - } |
|
217 | - |
|
218 | - if ((isset($params->addresses) && sizeof($params->addresses) > 0) |
|
219 | - || (isset($params->parameters) && sizeof($params->parameters) > 0) |
|
220 | - ) { |
|
221 | - $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
|
222 | - } |
|
223 | - } |
|
224 | - |
|
225 | - $optimize = Route4Me::makeRequst([ |
|
226 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
227 | - 'method' => 'PUT', |
|
228 | - 'query' => $query, |
|
229 | - 'body' => $body, |
|
230 | - ]); |
|
231 | - |
|
232 | - return $optimize; |
|
233 | - } |
|
234 | - |
|
235 | - public function getOptimizationId() |
|
236 | - { |
|
237 | - return $this->optimization_problem_id; |
|
238 | - } |
|
239 | - |
|
240 | - public function getRoutes() |
|
241 | - { |
|
242 | - return $this->routes; |
|
243 | - } |
|
244 | - |
|
245 | - public function getRandomOptimizationId($offset, $limit) |
|
246 | - { |
|
247 | - $optimizations = self::get(['offset' => $offset, 'limit' => $limit]); |
|
248 | - |
|
249 | - $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
250 | - |
|
251 | - if (!isset($rOptimization->optimization_problem_id)) { |
|
252 | - if (sizeof($optimizations) > 9) { |
|
253 | - $this->getRandomOptimizationId($offset, $limit); |
|
254 | - } else { |
|
255 | - return null; |
|
256 | - } |
|
257 | - } |
|
258 | - |
|
259 | - return $rOptimization->optimization_problem_id; |
|
260 | - } |
|
261 | - |
|
262 | - public function getAddresses($opt_id) |
|
263 | - { |
|
264 | - if (null == $opt_id) { |
|
265 | - return null; |
|
266 | - } |
|
267 | - |
|
268 | - $params = ['optimization_problem_id' => $opt_id]; |
|
269 | - |
|
270 | - $optimization = (array) $this->get($params); |
|
271 | - |
|
272 | - $addresses = $optimization['addresses']; |
|
273 | - |
|
274 | - return $addresses; |
|
275 | - } |
|
276 | - |
|
277 | - public function getRandomAddressFromOptimization($opt_id) |
|
278 | - { |
|
279 | - $addresses = (array) $this->getAddresses($opt_id); |
|
280 | - |
|
281 | - if (null == $addresses) { |
|
282 | - echo 'There are no addresses in this optimization!.. Try again.'; |
|
283 | - |
|
284 | - return null; |
|
285 | - } |
|
286 | - |
|
287 | - $num = rand(0, sizeof($addresses) - 1); |
|
288 | - |
|
289 | - $rAddress = $addresses[$num]; |
|
290 | - |
|
291 | - return $rAddress; |
|
292 | - } |
|
293 | - |
|
294 | - public function removeAddress($params) |
|
295 | - { |
|
296 | - $allQueryFields = ['optimization_problem_id', 'route_destination_id']; |
|
297 | - |
|
298 | - $response = Route4Me::makeRequst([ |
|
299 | - 'url' => Endpoint::ADDRESS_V4, |
|
300 | - 'method' => 'DELETE', |
|
301 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
302 | - ]); |
|
303 | - |
|
304 | - return $response; |
|
305 | - } |
|
306 | - |
|
307 | - public function removeOptimization($params) |
|
308 | - { |
|
309 | - $allQueryFields = ['redirect']; |
|
310 | - $allBodyFields = ['optimization_problem_ids']; |
|
311 | - |
|
312 | - $response = Route4Me::makeRequst([ |
|
313 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
314 | - 'method' => 'DELETE', |
|
315 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
316 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
317 | - ]); |
|
318 | - |
|
319 | - return $response; |
|
320 | - } |
|
321 | - |
|
322 | - public function getHybridOptimization($params) |
|
323 | - { |
|
324 | - $allQueryFields = ['target_date_string', 'timezone_offset_minutes']; |
|
325 | - |
|
326 | - $optimize = Route4Me::makeRequst([ |
|
327 | - 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
328 | - 'method' => 'GET', |
|
329 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
330 | - ]); |
|
196 | + public static function update($params) |
|
197 | + { |
|
198 | + $allQueryFields = ['optimization_problem_id', 'reoptimize']; |
|
199 | + $allBodyFields = ['addresses', 'parameters']; |
|
200 | + $query = null; |
|
201 | + $body = null; |
|
202 | + |
|
203 | + if (is_array($params)) { |
|
204 | + if (isset($params['optimization_problem_id']) || isset($params['parameters'])) { |
|
205 | + $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
|
206 | + } |
|
207 | + |
|
208 | + if ((isset($params['addresses']) && sizeof($params['addresses']) > 0) |
|
209 | + || (isset($params['parameters']) && sizeof($params['parameters']) > 0) |
|
210 | + ) { |
|
211 | + $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
|
212 | + } |
|
213 | + } else { |
|
214 | + if (isset($params->optimization_problem_id) || isset($params->parameters)) { |
|
215 | + $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
|
216 | + } |
|
217 | + |
|
218 | + if ((isset($params->addresses) && sizeof($params->addresses) > 0) |
|
219 | + || (isset($params->parameters) && sizeof($params->parameters) > 0) |
|
220 | + ) { |
|
221 | + $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
|
222 | + } |
|
223 | + } |
|
224 | + |
|
225 | + $optimize = Route4Me::makeRequst([ |
|
226 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
227 | + 'method' => 'PUT', |
|
228 | + 'query' => $query, |
|
229 | + 'body' => $body, |
|
230 | + ]); |
|
231 | + |
|
232 | + return $optimize; |
|
233 | + } |
|
234 | + |
|
235 | + public function getOptimizationId() |
|
236 | + { |
|
237 | + return $this->optimization_problem_id; |
|
238 | + } |
|
239 | + |
|
240 | + public function getRoutes() |
|
241 | + { |
|
242 | + return $this->routes; |
|
243 | + } |
|
244 | + |
|
245 | + public function getRandomOptimizationId($offset, $limit) |
|
246 | + { |
|
247 | + $optimizations = self::get(['offset' => $offset, 'limit' => $limit]); |
|
248 | + |
|
249 | + $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
250 | + |
|
251 | + if (!isset($rOptimization->optimization_problem_id)) { |
|
252 | + if (sizeof($optimizations) > 9) { |
|
253 | + $this->getRandomOptimizationId($offset, $limit); |
|
254 | + } else { |
|
255 | + return null; |
|
256 | + } |
|
257 | + } |
|
258 | + |
|
259 | + return $rOptimization->optimization_problem_id; |
|
260 | + } |
|
261 | + |
|
262 | + public function getAddresses($opt_id) |
|
263 | + { |
|
264 | + if (null == $opt_id) { |
|
265 | + return null; |
|
266 | + } |
|
267 | + |
|
268 | + $params = ['optimization_problem_id' => $opt_id]; |
|
269 | + |
|
270 | + $optimization = (array) $this->get($params); |
|
271 | + |
|
272 | + $addresses = $optimization['addresses']; |
|
273 | + |
|
274 | + return $addresses; |
|
275 | + } |
|
276 | + |
|
277 | + public function getRandomAddressFromOptimization($opt_id) |
|
278 | + { |
|
279 | + $addresses = (array) $this->getAddresses($opt_id); |
|
280 | + |
|
281 | + if (null == $addresses) { |
|
282 | + echo 'There are no addresses in this optimization!.. Try again.'; |
|
283 | + |
|
284 | + return null; |
|
285 | + } |
|
286 | + |
|
287 | + $num = rand(0, sizeof($addresses) - 1); |
|
288 | + |
|
289 | + $rAddress = $addresses[$num]; |
|
290 | + |
|
291 | + return $rAddress; |
|
292 | + } |
|
293 | + |
|
294 | + public function removeAddress($params) |
|
295 | + { |
|
296 | + $allQueryFields = ['optimization_problem_id', 'route_destination_id']; |
|
297 | + |
|
298 | + $response = Route4Me::makeRequst([ |
|
299 | + 'url' => Endpoint::ADDRESS_V4, |
|
300 | + 'method' => 'DELETE', |
|
301 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
302 | + ]); |
|
303 | + |
|
304 | + return $response; |
|
305 | + } |
|
306 | + |
|
307 | + public function removeOptimization($params) |
|
308 | + { |
|
309 | + $allQueryFields = ['redirect']; |
|
310 | + $allBodyFields = ['optimization_problem_ids']; |
|
311 | + |
|
312 | + $response = Route4Me::makeRequst([ |
|
313 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
314 | + 'method' => 'DELETE', |
|
315 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
316 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
317 | + ]); |
|
318 | + |
|
319 | + return $response; |
|
320 | + } |
|
321 | + |
|
322 | + public function getHybridOptimization($params) |
|
323 | + { |
|
324 | + $allQueryFields = ['target_date_string', 'timezone_offset_minutes']; |
|
325 | + |
|
326 | + $optimize = Route4Me::makeRequst([ |
|
327 | + 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
328 | + 'method' => 'GET', |
|
329 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
330 | + ]); |
|
331 | 331 | |
332 | - return $optimize; |
|
333 | - } |
|
332 | + return $optimize; |
|
333 | + } |
|
334 | 334 | |
335 | - public function addDepotsToHybrid($params) |
|
336 | - { |
|
337 | - $allQueryFields = ['optimization_problem_id']; |
|
338 | - $allBodyFields = ['optimization_problem_id', 'delete_old_depots', 'new_depots']; |
|
335 | + public function addDepotsToHybrid($params) |
|
336 | + { |
|
337 | + $allQueryFields = ['optimization_problem_id']; |
|
338 | + $allBodyFields = ['optimization_problem_id', 'delete_old_depots', 'new_depots']; |
|
339 | 339 | |
340 | - $depots = Route4Me::makeRequst([ |
|
341 | - 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
342 | - 'method' => 'POST', |
|
343 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
344 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
345 | - ]); |
|
340 | + $depots = Route4Me::makeRequst([ |
|
341 | + 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
342 | + 'method' => 'POST', |
|
343 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
344 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
345 | + ]); |
|
346 | 346 | |
347 | - return $depots; |
|
348 | - } |
|
347 | + return $depots; |
|
348 | + } |
|
349 | 349 | } |
@@ -12,184 +12,184 @@ |
||
12 | 12 | |
13 | 13 | final class TeamManagementUnitTests extends \PHPUnit\Framework\TestCase |
14 | 14 | { |
15 | - public static ?int $member_id = null; |
|
16 | - public static ?int $owner_member_id = null; |
|
17 | - |
|
18 | - public static function setUpBeforeClass() : void |
|
19 | - { |
|
20 | - Route4Me::setApiKey(Constants::API_KEY); |
|
21 | - } |
|
22 | - |
|
23 | - public function testOwnerMemberMustExists() : void |
|
24 | - { |
|
25 | - $member = new Member(); |
|
26 | - $res_members = $member->getUsers(); |
|
15 | + public static ?int $member_id = null; |
|
16 | + public static ?int $owner_member_id = null; |
|
17 | + |
|
18 | + public static function setUpBeforeClass() : void |
|
19 | + { |
|
20 | + Route4Me::setApiKey(Constants::API_KEY); |
|
21 | + } |
|
22 | + |
|
23 | + public function testOwnerMemberMustExists() : void |
|
24 | + { |
|
25 | + $member = new Member(); |
|
26 | + $res_members = $member->getUsers(); |
|
27 | 27 | |
28 | - if (is_array($res_members) && isset($res_members['results'])) { |
|
29 | - foreach ($res_members['results'] as $key => $value) { |
|
30 | - if ($value['OWNER_MEMBER_ID'] == 0) { |
|
31 | - self::$owner_member_id = $value['member_id']; |
|
32 | - break; |
|
33 | - } |
|
34 | - } |
|
35 | - } |
|
36 | - $this->assertNotNull(self::$owner_member_id); |
|
37 | - } |
|
38 | - |
|
39 | - public function testOptionCanBeCreateEmpty() : void |
|
40 | - { |
|
41 | - $this->assertInstanceOf(Option::class, new Option()); |
|
42 | - } |
|
43 | - |
|
44 | - public function testOptionCanBeCreateFromArray() : void |
|
45 | - { |
|
46 | - $this->assertInstanceOf(Option::class, new Option([ |
|
47 | - 'value' => '1', |
|
48 | - 'title' => '2' |
|
49 | - ])); |
|
50 | - } |
|
51 | - |
|
52 | - public function testPermissionCanBeCreateEmpty() : void |
|
53 | - { |
|
54 | - $this->assertInstanceOf(Permission::class, new Permission()); |
|
55 | - } |
|
56 | - |
|
57 | - public function testPermissionCanBeCreateFromArray() : void |
|
58 | - { |
|
59 | - $this->assertInstanceOf(Permission::class, new Permission([ |
|
60 | - 'id' => '1', |
|
61 | - 'options' => [ |
|
62 | - [ |
|
63 | - 'value' => '2', |
|
64 | - 'title' => '3' |
|
65 | - ], [ |
|
66 | - 'value' => '4', |
|
67 | - 'title' => '5' |
|
68 | - ] |
|
69 | - ] |
|
70 | - ])); |
|
71 | - } |
|
72 | - |
|
73 | - public function testResponseTeamCanBeCreateEmpty() : void |
|
74 | - { |
|
75 | - $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam()); |
|
76 | - } |
|
77 | - |
|
78 | - public function testResponseTeamCanBeCreateFromArray() : void |
|
79 | - { |
|
80 | - $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam([ |
|
81 | - 'member_id' => '1', |
|
82 | - 'member_first_name' => '2' |
|
83 | - ])); |
|
84 | - } |
|
85 | - |
|
86 | - public function testTeamManagementCanBeCreateEmpty() : void |
|
87 | - { |
|
88 | - $this->assertInstanceOf(TeamManagement::class, new TeamManagement()); |
|
89 | - } |
|
90 | - |
|
91 | - public function testCreateMustReturnResponseTeam() : void |
|
92 | - { |
|
93 | - $team_mng = new TeamManagement(); |
|
94 | - $res_team = $team_mng->create([ |
|
95 | - 'new_password' => '12345&Qwerty', |
|
96 | - 'member_first_name' => 'Tusha I', |
|
97 | - 'member_last_name' => 'Pupkindzes', |
|
98 | - 'member_email' => '[email protected]', |
|
99 | - 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
100 | - 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
101 | - ]); |
|
102 | - |
|
103 | - $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
104 | - $this->assertNotNull($res_team->member_id); |
|
105 | - $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
28 | + if (is_array($res_members) && isset($res_members['results'])) { |
|
29 | + foreach ($res_members['results'] as $key => $value) { |
|
30 | + if ($value['OWNER_MEMBER_ID'] == 0) { |
|
31 | + self::$owner_member_id = $value['member_id']; |
|
32 | + break; |
|
33 | + } |
|
34 | + } |
|
35 | + } |
|
36 | + $this->assertNotNull(self::$owner_member_id); |
|
37 | + } |
|
38 | + |
|
39 | + public function testOptionCanBeCreateEmpty() : void |
|
40 | + { |
|
41 | + $this->assertInstanceOf(Option::class, new Option()); |
|
42 | + } |
|
43 | + |
|
44 | + public function testOptionCanBeCreateFromArray() : void |
|
45 | + { |
|
46 | + $this->assertInstanceOf(Option::class, new Option([ |
|
47 | + 'value' => '1', |
|
48 | + 'title' => '2' |
|
49 | + ])); |
|
50 | + } |
|
51 | + |
|
52 | + public function testPermissionCanBeCreateEmpty() : void |
|
53 | + { |
|
54 | + $this->assertInstanceOf(Permission::class, new Permission()); |
|
55 | + } |
|
56 | + |
|
57 | + public function testPermissionCanBeCreateFromArray() : void |
|
58 | + { |
|
59 | + $this->assertInstanceOf(Permission::class, new Permission([ |
|
60 | + 'id' => '1', |
|
61 | + 'options' => [ |
|
62 | + [ |
|
63 | + 'value' => '2', |
|
64 | + 'title' => '3' |
|
65 | + ], [ |
|
66 | + 'value' => '4', |
|
67 | + 'title' => '5' |
|
68 | + ] |
|
69 | + ] |
|
70 | + ])); |
|
71 | + } |
|
72 | + |
|
73 | + public function testResponseTeamCanBeCreateEmpty() : void |
|
74 | + { |
|
75 | + $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam()); |
|
76 | + } |
|
77 | + |
|
78 | + public function testResponseTeamCanBeCreateFromArray() : void |
|
79 | + { |
|
80 | + $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam([ |
|
81 | + 'member_id' => '1', |
|
82 | + 'member_first_name' => '2' |
|
83 | + ])); |
|
84 | + } |
|
85 | + |
|
86 | + public function testTeamManagementCanBeCreateEmpty() : void |
|
87 | + { |
|
88 | + $this->assertInstanceOf(TeamManagement::class, new TeamManagement()); |
|
89 | + } |
|
90 | + |
|
91 | + public function testCreateMustReturnResponseTeam() : void |
|
92 | + { |
|
93 | + $team_mng = new TeamManagement(); |
|
94 | + $res_team = $team_mng->create([ |
|
95 | + 'new_password' => '12345&Qwerty', |
|
96 | + 'member_first_name' => 'Tusha I', |
|
97 | + 'member_last_name' => 'Pupkindzes', |
|
98 | + 'member_email' => '[email protected]', |
|
99 | + 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
100 | + 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
101 | + ]); |
|
102 | + |
|
103 | + $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
104 | + $this->assertNotNull($res_team->member_id); |
|
105 | + $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
106 | 106 | |
107 | - self::$member_id = $res_team->member_id; |
|
108 | - } |
|
109 | - |
|
110 | - public function testGetUserMustReturnResponseTeam() : void |
|
111 | - { |
|
112 | - $team_mng = new TeamManagement(); |
|
113 | - $res_team = $team_mng->getUser(self::$member_id); |
|
114 | - |
|
115 | - $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
116 | - $this->assertNotNull($res_team->member_id); |
|
117 | - $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
118 | - } |
|
119 | - |
|
120 | - public function testGetUsersMustReturnArrayOfResponseTeam() : void |
|
121 | - { |
|
122 | - $team_mng = new TeamManagement(); |
|
123 | - $result = $team_mng->getUsers(); |
|
124 | - |
|
125 | - $this->assertIsArray($result); |
|
126 | - if (count($result) > 0) { |
|
127 | - $this->assertInstanceOf(ResponseTeam::class, $result[0]); |
|
128 | - } |
|
129 | - } |
|
130 | - |
|
131 | - public function testUpdateMustReturnUpdatedResponseTeam() : void |
|
132 | - { |
|
133 | - $team_mng = new TeamManagement(); |
|
134 | - $res_team = $team_mng->update(self::$member_id, [ |
|
135 | - 'HIDE_ROUTED_ADDRESSES' => true, |
|
136 | - 'member_type' => 'SUB_ACCOUNT_DISPATCHER' |
|
137 | - ]); |
|
138 | - |
|
139 | - $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
140 | - $this->assertEquals($res_team->HIDE_ROUTED_ADDRESSES, 1); |
|
141 | - $this->assertEquals($res_team->member_type, 'SUB_ACCOUNT_DISPATCHER'); |
|
142 | - } |
|
143 | - |
|
144 | - public function testDeleteMustReturnDeletedResponseTeam() : void |
|
145 | - { |
|
146 | - $team_mng = new TeamManagement(); |
|
147 | - $res_team = $team_mng->delete(self::$member_id); |
|
148 | - |
|
149 | - $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
150 | - $this->assertNotNull($res_team->member_id); |
|
151 | - $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
152 | - } |
|
153 | - |
|
154 | - public function testBulkInsertMustAddNewMembers() : void |
|
155 | - { |
|
156 | - $team_mng = new TeamManagement(); |
|
157 | - $result = $team_mng->bulkInsert([ |
|
158 | - [ |
|
159 | - 'new_password' => '12345&Qwerty', |
|
160 | - 'member_first_name' => 'Tusha I', |
|
161 | - 'member_last_name' => 'Pupkindzes', |
|
162 | - 'member_email' => '[email protected]', |
|
163 | - 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
164 | - 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
165 | - ], [ |
|
166 | - 'new_password' => '12345&Qwerty', |
|
167 | - 'member_first_name' => 'Tusha II', |
|
168 | - 'member_last_name' => 'Pupkindzes', |
|
169 | - 'member_email' => '[email protected]', |
|
170 | - 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
171 | - 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
172 | - ] |
|
173 | - ], [ |
|
174 | - 'conflicts' => 'overwrite' |
|
175 | - ]); |
|
176 | - |
|
177 | - $this->assertIsArray($result); |
|
178 | - } |
|
107 | + self::$member_id = $res_team->member_id; |
|
108 | + } |
|
109 | + |
|
110 | + public function testGetUserMustReturnResponseTeam() : void |
|
111 | + { |
|
112 | + $team_mng = new TeamManagement(); |
|
113 | + $res_team = $team_mng->getUser(self::$member_id); |
|
114 | + |
|
115 | + $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
116 | + $this->assertNotNull($res_team->member_id); |
|
117 | + $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
118 | + } |
|
119 | + |
|
120 | + public function testGetUsersMustReturnArrayOfResponseTeam() : void |
|
121 | + { |
|
122 | + $team_mng = new TeamManagement(); |
|
123 | + $result = $team_mng->getUsers(); |
|
124 | + |
|
125 | + $this->assertIsArray($result); |
|
126 | + if (count($result) > 0) { |
|
127 | + $this->assertInstanceOf(ResponseTeam::class, $result[0]); |
|
128 | + } |
|
129 | + } |
|
130 | + |
|
131 | + public function testUpdateMustReturnUpdatedResponseTeam() : void |
|
132 | + { |
|
133 | + $team_mng = new TeamManagement(); |
|
134 | + $res_team = $team_mng->update(self::$member_id, [ |
|
135 | + 'HIDE_ROUTED_ADDRESSES' => true, |
|
136 | + 'member_type' => 'SUB_ACCOUNT_DISPATCHER' |
|
137 | + ]); |
|
138 | + |
|
139 | + $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
140 | + $this->assertEquals($res_team->HIDE_ROUTED_ADDRESSES, 1); |
|
141 | + $this->assertEquals($res_team->member_type, 'SUB_ACCOUNT_DISPATCHER'); |
|
142 | + } |
|
143 | + |
|
144 | + public function testDeleteMustReturnDeletedResponseTeam() : void |
|
145 | + { |
|
146 | + $team_mng = new TeamManagement(); |
|
147 | + $res_team = $team_mng->delete(self::$member_id); |
|
148 | + |
|
149 | + $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
150 | + $this->assertNotNull($res_team->member_id); |
|
151 | + $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
152 | + } |
|
153 | + |
|
154 | + public function testBulkInsertMustAddNewMembers() : void |
|
155 | + { |
|
156 | + $team_mng = new TeamManagement(); |
|
157 | + $result = $team_mng->bulkInsert([ |
|
158 | + [ |
|
159 | + 'new_password' => '12345&Qwerty', |
|
160 | + 'member_first_name' => 'Tusha I', |
|
161 | + 'member_last_name' => 'Pupkindzes', |
|
162 | + 'member_email' => '[email protected]', |
|
163 | + 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
164 | + 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
165 | + ], [ |
|
166 | + 'new_password' => '12345&Qwerty', |
|
167 | + 'member_first_name' => 'Tusha II', |
|
168 | + 'member_last_name' => 'Pupkindzes', |
|
169 | + 'member_email' => '[email protected]', |
|
170 | + 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
171 | + 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
172 | + ] |
|
173 | + ], [ |
|
174 | + 'conflicts' => 'overwrite' |
|
175 | + ]); |
|
176 | + |
|
177 | + $this->assertIsArray($result); |
|
178 | + } |
|
179 | 179 | |
180 | - public static function tearDownAfterClass() : void |
|
181 | - { |
|
182 | - sleep(5); |
|
183 | - |
|
184 | - $team_mng = new TeamManagement(); |
|
185 | - $result = $team_mng->getUsers(); |
|
186 | - |
|
187 | - if (is_array($result)) { |
|
188 | - foreach ($result as $key => $member) { |
|
189 | - if ($member->member_last_name == 'Pupkindzes') { |
|
190 | - $team_mng->delete($member->member_id); |
|
191 | - } |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
180 | + public static function tearDownAfterClass() : void |
|
181 | + { |
|
182 | + sleep(5); |
|
183 | + |
|
184 | + $team_mng = new TeamManagement(); |
|
185 | + $result = $team_mng->getUsers(); |
|
186 | + |
|
187 | + if (is_array($result)) { |
|
188 | + foreach ($result as $key => $member) { |
|
189 | + if ($member->member_last_name == 'Pupkindzes') { |
|
190 | + $team_mng->delete($member->member_id); |
|
191 | + } |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | 195 | } |
@@ -13,13 +13,13 @@ |
||
13 | 13 | */ |
14 | 14 | class Option extends Common |
15 | 15 | { |
16 | - public ?string $value = null; |
|
17 | - public ?string $title = null; |
|
16 | + public ?string $value = null; |
|
17 | + public ?string $title = null; |
|
18 | 18 | |
19 | - public function __construct(?array $params = null) |
|
20 | - { |
|
21 | - if ($params !== null) { |
|
22 | - $this->fillFromArray($params); |
|
23 | - } |
|
24 | - } |
|
19 | + public function __construct(?array $params = null) |
|
20 | + { |
|
21 | + if ($params !== null) { |
|
22 | + $this->fillFromArray($params); |
|
23 | + } |
|
24 | + } |
|
25 | 25 | } |