@@ -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 | } |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | { |
438 | 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 | 442 | $result = $vehicleProfile->removeVehicleProfile($vehProfileId); |
443 | 443 | |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | { |
455 | 455 | $vehicleProfile = new VehicleProfile(); |
456 | 456 | |
457 | - $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id']; |
|
457 | + $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles) - 1]['vehicle_profile_id']; |
|
458 | 458 | |
459 | 459 | $result = $vehicleProfile->getVehicleProfileById($vehProfileId); |
460 | 460 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | { |
508 | 508 | $vehicle = new Vehicle(); |
509 | 509 | |
510 | - $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'] .' Updated'; |
|
510 | + $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'].' Updated'; |
|
511 | 511 | $vehicle->vehicle_vin = '11111111111111111'; |
512 | 512 | $vehicle->vehicle_id = self::$createdVehicles[0]['vehicle_id']; |
513 | 513 |
@@ -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 | } |
@@ -235,7 +235,7 @@ |
||
235 | 235 | $vehicleId = $vehicleParams['vehicle_id']; |
236 | 236 | |
237 | 237 | $response = Route4Me::makeRequst([ |
238 | - 'url' => Endpoint::Vehicles . '/' . $vehicleId, |
|
238 | + 'url' => Endpoint::Vehicles.'/'.$vehicleId, |
|
239 | 239 | 'method' => 'DELETE' |
240 | 240 | ]); |
241 | 241 |
@@ -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 | } |
@@ -260,7 +260,7 @@ |
||
260 | 260 | */ |
261 | 261 | public function createVehicle($params) |
262 | 262 | { |
263 | - $excludeFields = ['vehicle_id','is_deleted','created_time','timestamp_added','timestamp_removed']; |
|
263 | + $excludeFields = ['vehicle_id', 'is_deleted', 'created_time', 'timestamp_added', 'timestamp_removed']; |
|
264 | 264 | $allBodyFields = Route4Me::getObjectProperties(new self(), $excludeFields); |
265 | 265 | |
266 | 266 | //Route4Me::setBaseUrl(Endpoint::BASE_URL); |
@@ -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 | } |