GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( e5b8eb...47d764 )
by Igor
01:54 queued 12s
created
examples/RecurringRoutes/GetRouteSchedulePreview.php 2 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -15,13 +15,13 @@
 block discarded – undo
15 15
 Route4Me::setApiKey(Constants::API_KEY);
16 16
 
17 17
 try {
18
-    $schedules = new Schedules();
19
-    $route_id = '66C2AC4A323053FF0A40FEB6918ACF5E';
20
-    $start = '2022-01-01';
21
-    $end = '2023-12-31';
18
+	$schedules = new Schedules();
19
+	$route_id = '66C2AC4A323053FF0A40FEB6918ACF5E';
20
+	$start = '2022-01-01';
21
+	$end = '2023-12-31';
22 22
 
23
-    $schedule = $schedules->getRouteSchedulePreview($route_id, $start, $end);
24
-    print_r($schedule);
23
+	$schedule = $schedules->getRouteSchedulePreview($route_id, $start, $end);
24
+	print_r($schedule);
25 25
 } catch (\Exception $e) {
26
-    echo $e->getMessage() . PHP_EOL;
26
+	echo $e->getMessage() . PHP_EOL;
27 27
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,5 +23,5 @@
 block discarded – undo
23 23
     $schedule = $schedules->getRouteSchedulePreview($route_id, $start, $end);
24 24
     print_r($schedule);
25 25
 } catch (\Exception $e) {
26
-    echo $e->getMessage() . PHP_EOL;
26
+    echo $e->getMessage().PHP_EOL;
27 27
 }
Please login to merge, or discard this patch.
UnitTestFiles/Test/V5/RecurringRoutesUnitTests.php 2 patches
Indentation   +299 added lines, -299 removed lines patch added patch discarded remove patch
@@ -13,308 +13,308 @@
 block discarded – undo
13 13
 
14 14
 final class RecurringRoutesUnitTests extends \PHPUnit\Framework\TestCase
15 15
 {
16
-    public static ?Schedule $schedule;
17
-    public static ?RouteSchedule $route_schedule;
18
-    public static ?string $route_id;
19
-    public static ?string $member_id;
20
-    public static ?string $vehicle_id;
21
-
22
-    public static function setUpBeforeClass() : void
23
-    {
24
-        Route4Me::setApiKey(Constants::API_KEY);
25
-        self::$schedule = null;
26
-        self::$route_schedule = null;
27
-        self::$route_id = null;
28
-        self::$member_id = null;
29
-        self::$vehicle_id = null;
30
-    }
31
-
32
-    public function testScheduleCanBeCreateEmpty() : void
33
-    {
34
-        $this->assertInstanceOf(Schedule::class, new Schedule());
35
-    }
36
-
37
-    public function testScheduleCanBeCreateFromArray() : void
38
-    {
39
-        $this->assertInstanceOf(Schedule::class, new Schedule([
40
-            'schedule_uid' => '1',
41
-            'name' => 'The best Schedule'
42
-        ]));
43
-    }
44
-
45
-    public function testRouteScheduleCanBeCreateEmpty() : void
46
-    {
47
-        $this->assertInstanceOf(RouteSchedule::class, new RouteSchedule());
48
-    }
49
-
50
-    public function testRouteScheduleCanBeCreateFromArray() : void
51
-    {
52
-        $this->assertInstanceOf(RouteSchedule::class, new RouteSchedule([
53
-            'route_id' => '1',
54
-            'schedule_uid' => '2'
55
-        ]));
56
-    }
57
-
58
-    public function testPageInfoCanBeCreateEmpty() : void
59
-    {
60
-        $this->assertInstanceOf(PageInfo::class, new PageInfo());
61
-    }
62
-
63
-    public function testPageInfoCanBeCreateFromArray() : void
64
-    {
65
-        $this->assertInstanceOf(PageInfo::class, new PageInfo([
66
-            'first' => 'URL_first',
67
-            'last' => 'URL_last'
68
-        ], [
69
-            'current_page' => 1,
70
-            'last_page' => 15
71
-        ]));
72
-    }
73
-
74
-    public function testSchedulesCanBeCreateEmpty() : void
75
-    {
76
-        $this->assertInstanceOf(Schedules::class, new Schedules());
77
-    }
78
-
79
-    public function testCreateScheduleMustReturnScahedule() : void
80
-    {
81
-        $schedules = new Schedules();
82
-        self::$schedule = $schedules->createSchedule([
83
-            'name' => 'The bestest schedule',
84
-            'schedule_blacklist' => [],
85
-            'schedule' => null,
86
-            'timezone' => 'UTC'
87
-        ]);
88
-
89
-        $this->assertInstanceOf(Schedule::class, self::$schedule);
90
-        $this->assertNotNull(self::$schedule->schedule_uid);
91
-        $this->assertEquals(self::$schedule->name, 'The bestest schedule');
92
-    }
93
-
94
-    public function testGetScheduleMustReturnScahedule() : void
95
-    {
96
-        $schedules = new Schedules();
97
-        $schedule = $schedules->getSchedule(self::$schedule->schedule_uid);
98
-
99
-        $this->assertInstanceOf(Schedule::class, $schedule);
100
-        $this->assertNotNull(self::$schedule->schedule_uid);
101
-        $this->assertEquals(self::$schedule->name, 'The bestest schedule');
102
-    }
103
-
104
-    public function testGetAllSchedulesMustReturnArrayOfScahedules() : void
105
-    {
106
-        $schedules = new Schedules();
107
-        $result = $schedules->getAllSchedules();
108
-
109
-        $this->assertIsArray($result);
110
-        if (count($result) > 0) {
111
-            $this->assertInstanceOf(Schedule::class, $result[0]);
112
-        }
113
-    }
114
-
115
-    public function testGetSchedulesMustReturnOnePage() : void
116
-    {
117
-        $schedules = new Schedules();
118
-        $result = $schedules->getSchedules();
119
-
120
-        $this->assertIsArray($result);
121
-        $this->assertArrayHasKey('schedules', $result);
122
-        if (count($result['schedules']) > 0) {
123
-            $this->assertInstanceOf(Schedule::class, $result['schedules'][0]);
124
-        }
125
-        $this->assertArrayHasKey('page_info', $result);
126
-        $this->assertInstanceOf(PageInfo::class, $result['page_info']);
127
-    }
128
-
129
-    public function testUpdateScheduleMustReturnUpdatedScahedule() : void
130
-    {
131
-        $schedules = new Schedules();
132
-        self::$schedule = $schedules->updateSchedule(self::$schedule->schedule_uid, [
133
-            'name' => 'The bestest schedule 1'
134
-        ]);
135
-
136
-        $this->assertInstanceOf(Schedule::class, self::$schedule);
137
-        $this->assertEquals(self::$schedule->name, 'The bestest schedule 1');
138
-    }
139
-
140
-    public function testCreateRouteScheduleMustReturnRouteScahedule() : void
141
-    {
142
-        $route = new Route;
143
-        $routes = $route->getRoutes([
144
-            'limit' => 1,
145
-            'offset' => 0
146
-        ]);
16
+	public static ?Schedule $schedule;
17
+	public static ?RouteSchedule $route_schedule;
18
+	public static ?string $route_id;
19
+	public static ?string $member_id;
20
+	public static ?string $vehicle_id;
21
+
22
+	public static function setUpBeforeClass() : void
23
+	{
24
+		Route4Me::setApiKey(Constants::API_KEY);
25
+		self::$schedule = null;
26
+		self::$route_schedule = null;
27
+		self::$route_id = null;
28
+		self::$member_id = null;
29
+		self::$vehicle_id = null;
30
+	}
31
+
32
+	public function testScheduleCanBeCreateEmpty() : void
33
+	{
34
+		$this->assertInstanceOf(Schedule::class, new Schedule());
35
+	}
36
+
37
+	public function testScheduleCanBeCreateFromArray() : void
38
+	{
39
+		$this->assertInstanceOf(Schedule::class, new Schedule([
40
+			'schedule_uid' => '1',
41
+			'name' => 'The best Schedule'
42
+		]));
43
+	}
44
+
45
+	public function testRouteScheduleCanBeCreateEmpty() : void
46
+	{
47
+		$this->assertInstanceOf(RouteSchedule::class, new RouteSchedule());
48
+	}
49
+
50
+	public function testRouteScheduleCanBeCreateFromArray() : void
51
+	{
52
+		$this->assertInstanceOf(RouteSchedule::class, new RouteSchedule([
53
+			'route_id' => '1',
54
+			'schedule_uid' => '2'
55
+		]));
56
+	}
57
+
58
+	public function testPageInfoCanBeCreateEmpty() : void
59
+	{
60
+		$this->assertInstanceOf(PageInfo::class, new PageInfo());
61
+	}
62
+
63
+	public function testPageInfoCanBeCreateFromArray() : void
64
+	{
65
+		$this->assertInstanceOf(PageInfo::class, new PageInfo([
66
+			'first' => 'URL_first',
67
+			'last' => 'URL_last'
68
+		], [
69
+			'current_page' => 1,
70
+			'last_page' => 15
71
+		]));
72
+	}
73
+
74
+	public function testSchedulesCanBeCreateEmpty() : void
75
+	{
76
+		$this->assertInstanceOf(Schedules::class, new Schedules());
77
+	}
78
+
79
+	public function testCreateScheduleMustReturnScahedule() : void
80
+	{
81
+		$schedules = new Schedules();
82
+		self::$schedule = $schedules->createSchedule([
83
+			'name' => 'The bestest schedule',
84
+			'schedule_blacklist' => [],
85
+			'schedule' => null,
86
+			'timezone' => 'UTC'
87
+		]);
88
+
89
+		$this->assertInstanceOf(Schedule::class, self::$schedule);
90
+		$this->assertNotNull(self::$schedule->schedule_uid);
91
+		$this->assertEquals(self::$schedule->name, 'The bestest schedule');
92
+	}
93
+
94
+	public function testGetScheduleMustReturnScahedule() : void
95
+	{
96
+		$schedules = new Schedules();
97
+		$schedule = $schedules->getSchedule(self::$schedule->schedule_uid);
98
+
99
+		$this->assertInstanceOf(Schedule::class, $schedule);
100
+		$this->assertNotNull(self::$schedule->schedule_uid);
101
+		$this->assertEquals(self::$schedule->name, 'The bestest schedule');
102
+	}
103
+
104
+	public function testGetAllSchedulesMustReturnArrayOfScahedules() : void
105
+	{
106
+		$schedules = new Schedules();
107
+		$result = $schedules->getAllSchedules();
108
+
109
+		$this->assertIsArray($result);
110
+		if (count($result) > 0) {
111
+			$this->assertInstanceOf(Schedule::class, $result[0]);
112
+		}
113
+	}
114
+
115
+	public function testGetSchedulesMustReturnOnePage() : void
116
+	{
117
+		$schedules = new Schedules();
118
+		$result = $schedules->getSchedules();
119
+
120
+		$this->assertIsArray($result);
121
+		$this->assertArrayHasKey('schedules', $result);
122
+		if (count($result['schedules']) > 0) {
123
+			$this->assertInstanceOf(Schedule::class, $result['schedules'][0]);
124
+		}
125
+		$this->assertArrayHasKey('page_info', $result);
126
+		$this->assertInstanceOf(PageInfo::class, $result['page_info']);
127
+	}
128
+
129
+	public function testUpdateScheduleMustReturnUpdatedScahedule() : void
130
+	{
131
+		$schedules = new Schedules();
132
+		self::$schedule = $schedules->updateSchedule(self::$schedule->schedule_uid, [
133
+			'name' => 'The bestest schedule 1'
134
+		]);
135
+
136
+		$this->assertInstanceOf(Schedule::class, self::$schedule);
137
+		$this->assertEquals(self::$schedule->name, 'The bestest schedule 1');
138
+	}
139
+
140
+	public function testCreateRouteScheduleMustReturnRouteScahedule() : void
141
+	{
142
+		$route = new Route;
143
+		$routes = $route->getRoutes([
144
+			'limit' => 1,
145
+			'offset' => 0
146
+		]);
147 147
     
148
-        if (is_array($routes) && isset($routes[0])) {
149
-            self::$route_id = $routes[0]->route_id;
150
-            self::$member_id = $routes[0]->member_id;
151
-        }
152
-        $route = null;
148
+		if (is_array($routes) && isset($routes[0])) {
149
+			self::$route_id = $routes[0]->route_id;
150
+			self::$member_id = $routes[0]->member_id;
151
+		}
152
+		$route = null;
153 153
 
154
-        $this->assertNotNull(self::$route_id);
154
+		$this->assertNotNull(self::$route_id);
155 155
     
156
-        $schedules = new Schedules();
157
-        self::$route_schedule = $schedules->createRouteSchedule([
158
-            'route_id' => self::$route_id,
159
-            'schedule_uid' => self::$schedule->schedule_uid
160
-        ]);
161
-
162
-        $this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
163
-        $this->assertNotNull(self::$route_schedule->schedule_uid);
164
-        $this->assertEquals(self::$route_schedule->schedule_uid, self::$schedule->schedule_uid);
165
-    }
166
-
167
-    public function testGetRouteScheduleMustReturnRouteScahedule() : void
168
-    {
169
-        $schedules = new Schedules();
170
-        $route_schedule = $schedules->getRouteSchedule(self::$route_id);
171
-
172
-        $this->assertInstanceOf(RouteSchedule::class, $route_schedule);
173
-        $this->assertNotNull($route_schedule->schedule_uid);
174
-    }
175
-
176
-    public function testGetAllRouteSchedulesMustReturnArrayOfRouteScahedules() : void
177
-    {
178
-        $schedules = new Schedules();
179
-        $result = $schedules->getAllRouteSchedules();
180
-
181
-        $this->assertIsArray($result);
182
-        if (count($result) > 0) {
183
-            $this->assertInstanceOf(RouteSchedule::class, $result[0]);
184
-        }
185
-    }
186
-
187
-    public function testGetRouteSchedulesMustReturnOnePage() : void
188
-    {
189
-        $schedules = new Schedules();
190
-        $result = $schedules->getRouteSchedules();
191
-
192
-        $this->assertIsArray($result);
193
-        $this->assertArrayHasKey('route_schedules', $result);
194
-        if (count($result['route_schedules']) > 0) {
195
-            $this->assertInstanceOf(RouteSchedule::class, $result['route_schedules'][0]);
196
-        }
197
-        $this->assertArrayHasKey('page_info', $result);
198
-        $this->assertInstanceOf(PageInfo::class, $result['page_info']);
199
-    }
200
-
201
-    public function testUpdateRouteScheduleMustReturnUpdatedRouteScahedule() : void
202
-    {
203
-        $vehicle = new Vehicle();
204
-        $vehicles = $vehicle->getVehiclesPaginatedList([
205
-            'with_pagination' => true,
206
-            'page' => 1,
207
-            'perPage' => 1
208
-        ]);
156
+		$schedules = new Schedules();
157
+		self::$route_schedule = $schedules->createRouteSchedule([
158
+			'route_id' => self::$route_id,
159
+			'schedule_uid' => self::$schedule->schedule_uid
160
+		]);
161
+
162
+		$this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
163
+		$this->assertNotNull(self::$route_schedule->schedule_uid);
164
+		$this->assertEquals(self::$route_schedule->schedule_uid, self::$schedule->schedule_uid);
165
+	}
166
+
167
+	public function testGetRouteScheduleMustReturnRouteScahedule() : void
168
+	{
169
+		$schedules = new Schedules();
170
+		$route_schedule = $schedules->getRouteSchedule(self::$route_id);
171
+
172
+		$this->assertInstanceOf(RouteSchedule::class, $route_schedule);
173
+		$this->assertNotNull($route_schedule->schedule_uid);
174
+	}
175
+
176
+	public function testGetAllRouteSchedulesMustReturnArrayOfRouteScahedules() : void
177
+	{
178
+		$schedules = new Schedules();
179
+		$result = $schedules->getAllRouteSchedules();
180
+
181
+		$this->assertIsArray($result);
182
+		if (count($result) > 0) {
183
+			$this->assertInstanceOf(RouteSchedule::class, $result[0]);
184
+		}
185
+	}
186
+
187
+	public function testGetRouteSchedulesMustReturnOnePage() : void
188
+	{
189
+		$schedules = new Schedules();
190
+		$result = $schedules->getRouteSchedules();
191
+
192
+		$this->assertIsArray($result);
193
+		$this->assertArrayHasKey('route_schedules', $result);
194
+		if (count($result['route_schedules']) > 0) {
195
+			$this->assertInstanceOf(RouteSchedule::class, $result['route_schedules'][0]);
196
+		}
197
+		$this->assertArrayHasKey('page_info', $result);
198
+		$this->assertInstanceOf(PageInfo::class, $result['page_info']);
199
+	}
200
+
201
+	public function testUpdateRouteScheduleMustReturnUpdatedRouteScahedule() : void
202
+	{
203
+		$vehicle = new Vehicle();
204
+		$vehicles = $vehicle->getVehiclesPaginatedList([
205
+			'with_pagination' => true,
206
+			'page' => 1,
207
+			'perPage' => 1
208
+		]);
209 209
     
210
-        if (is_array($vehicles) && isset($vehicles[0]) && is_array($vehicles[0]) && isset($vehicles[0]['vehicle_id'])) {
211
-            self::$vehicle_id = $vehicles[0]['vehicle_id'];
212
-        }
213
-        $vehicle = null;
210
+		if (is_array($vehicles) && isset($vehicles[0]) && is_array($vehicles[0]) && isset($vehicles[0]['vehicle_id'])) {
211
+			self::$vehicle_id = $vehicles[0]['vehicle_id'];
212
+		}
213
+		$vehicle = null;
214 214
     
215
-        $this->assertNotNull(self::$vehicle_id);
216
-
217
-        $schedules = new Schedules();
218
-        self::$route_schedule = $schedules->updateRouteSchedule(self::$route_id, [
219
-            'schedule_uid' => self::$route_schedule->schedule_uid,
220
-            'member_id' => self::$member_id,
221
-            'vehicle_id' => self::$vehicle_id
222
-        ]);
223
-
224
-        $this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
225
-        $this->assertEquals(self::$route_schedule->member_id, self::$member_id);
226
-    }
227
-
228
-    public function testrReplaceRouteScheduleMustReturnRouteScahedule() : void
229
-    {
230
-        $schedules = new Schedules();
231
-        self::$route_schedule = $schedules->replaceRouteSchedule(self::$route_id, [
232
-            'schedule_uid' => self::$route_schedule->schedule_uid,
233
-            'member_id' => self::$member_id,
234
-            'vehicle_id' => self::$vehicle_id
235
-        ]);
236
-
237
-        $this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
238
-        $this->assertEquals(self::$route_schedule->member_id, self::$member_id);
239
-    }
240
-
241
-    public function testGetRouteSchedulePreviewMustReturnArray() : void
242
-    {
243
-        $schedules = new Schedules();
244
-        $start = '2022-01-01';
245
-        $end = '2023-12-31';
246
-        $result = $schedules->getRouteSchedulePreview(self::$route_id, $start, $end);
247
-
248
-        $this->assertIsArray($result);
249
-    }
250
-
251
-    public function testIsScheduledRouteCopyMustReturnBool() : void
252
-    {
253
-        $schedules = new Schedules();
254
-        $result = $schedules->isScheduledRouteCopy(self::$route_id);
255
-
256
-        $this->assertIsBool($result);
257
-    }
258
-
259
-    public function testGetScheduledRoutesCopiesMustReturnArray() : void
260
-    {
261
-        $schedules = new Schedules();
262
-        $route_date = '2023-01-01';
263
-        $result = $schedules->getScheduledRoutesCopies(
264
-            self::$route_id,
265
-            self::$route_schedule->schedule_uid,
266
-            $route_date
267
-        );
268
-
269
-        $this->assertIsArray($result);
270
-    }
271
-
272
-    public function testCreateMasterRouteMustReturnBool() : void
273
-    {
274
-        $schedules = new Schedules();
275
-        $result = $schedules->createMasterRoute([
276
-            'route_id' => self::$route_id,
277
-            'route_name' => 'The Bestest route',
278
-            'member_id' => self::$member_id,
279
-            'vehicle_id' => self::$vehicle_id,
280
-            'name' => 'The bestest schedule',
281
-            'schedule_blacklist' => [],
282
-            'schedule' => null,
283
-            'timezone' => 'UTC'
284
-        ]);
285
-
286
-        $this->assertIsBool($result);
287
-    }
288
-
289
-    public function testDeleteRouteScheduleMustReturnTrue() : void
290
-    {
291
-        $schedules = new Schedules();
292
-        $result = $schedules->deleteRouteSchedules(self::$route_id);
293
-
294
-        $this->assertTrue($result);
295
-        self::$route_schedule = null;
296
-    }
297
-
298
-    public function testDeleteScheduleMustReturnDeletedScahedule() : void
299
-    {
300
-        $schedules = new Schedules();
301
-        self::$schedule = $schedules->deleteSchedule(self::$schedule->schedule_uid);
302
-
303
-        $this->assertInstanceOf(Schedule::class, self::$schedule);
304
-        self::$schedule = null;
305
-    }
306
-
307
-    public static function tearDownAfterClass() : void
308
-    {
309
-        if (!is_null(self::$schedule)) {
310
-            $schedules = new Schedules();
311
-            $result = $schedules->deleteSchedule(self::$schedule->schedule_uid);
312
-            self::assertInstanceOf(Schedule::class, $result);
313
-        }
314
-        if (!is_null(self::$route_schedule)) {
315
-            $schedules = new Schedules();
316
-            $result = $schedules->deleteRouteSchedule(self::$route_schedule->route_id);
317
-            self::assertInstanceOf(RouteSchedule::class, $result);
318
-        }
319
-    }
215
+		$this->assertNotNull(self::$vehicle_id);
216
+
217
+		$schedules = new Schedules();
218
+		self::$route_schedule = $schedules->updateRouteSchedule(self::$route_id, [
219
+			'schedule_uid' => self::$route_schedule->schedule_uid,
220
+			'member_id' => self::$member_id,
221
+			'vehicle_id' => self::$vehicle_id
222
+		]);
223
+
224
+		$this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
225
+		$this->assertEquals(self::$route_schedule->member_id, self::$member_id);
226
+	}
227
+
228
+	public function testrReplaceRouteScheduleMustReturnRouteScahedule() : void
229
+	{
230
+		$schedules = new Schedules();
231
+		self::$route_schedule = $schedules->replaceRouteSchedule(self::$route_id, [
232
+			'schedule_uid' => self::$route_schedule->schedule_uid,
233
+			'member_id' => self::$member_id,
234
+			'vehicle_id' => self::$vehicle_id
235
+		]);
236
+
237
+		$this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
238
+		$this->assertEquals(self::$route_schedule->member_id, self::$member_id);
239
+	}
240
+
241
+	public function testGetRouteSchedulePreviewMustReturnArray() : void
242
+	{
243
+		$schedules = new Schedules();
244
+		$start = '2022-01-01';
245
+		$end = '2023-12-31';
246
+		$result = $schedules->getRouteSchedulePreview(self::$route_id, $start, $end);
247
+
248
+		$this->assertIsArray($result);
249
+	}
250
+
251
+	public function testIsScheduledRouteCopyMustReturnBool() : void
252
+	{
253
+		$schedules = new Schedules();
254
+		$result = $schedules->isScheduledRouteCopy(self::$route_id);
255
+
256
+		$this->assertIsBool($result);
257
+	}
258
+
259
+	public function testGetScheduledRoutesCopiesMustReturnArray() : void
260
+	{
261
+		$schedules = new Schedules();
262
+		$route_date = '2023-01-01';
263
+		$result = $schedules->getScheduledRoutesCopies(
264
+			self::$route_id,
265
+			self::$route_schedule->schedule_uid,
266
+			$route_date
267
+		);
268
+
269
+		$this->assertIsArray($result);
270
+	}
271
+
272
+	public function testCreateMasterRouteMustReturnBool() : void
273
+	{
274
+		$schedules = new Schedules();
275
+		$result = $schedules->createMasterRoute([
276
+			'route_id' => self::$route_id,
277
+			'route_name' => 'The Bestest route',
278
+			'member_id' => self::$member_id,
279
+			'vehicle_id' => self::$vehicle_id,
280
+			'name' => 'The bestest schedule',
281
+			'schedule_blacklist' => [],
282
+			'schedule' => null,
283
+			'timezone' => 'UTC'
284
+		]);
285
+
286
+		$this->assertIsBool($result);
287
+	}
288
+
289
+	public function testDeleteRouteScheduleMustReturnTrue() : void
290
+	{
291
+		$schedules = new Schedules();
292
+		$result = $schedules->deleteRouteSchedules(self::$route_id);
293
+
294
+		$this->assertTrue($result);
295
+		self::$route_schedule = null;
296
+	}
297
+
298
+	public function testDeleteScheduleMustReturnDeletedScahedule() : void
299
+	{
300
+		$schedules = new Schedules();
301
+		self::$schedule = $schedules->deleteSchedule(self::$schedule->schedule_uid);
302
+
303
+		$this->assertInstanceOf(Schedule::class, self::$schedule);
304
+		self::$schedule = null;
305
+	}
306
+
307
+	public static function tearDownAfterClass() : void
308
+	{
309
+		if (!is_null(self::$schedule)) {
310
+			$schedules = new Schedules();
311
+			$result = $schedules->deleteSchedule(self::$schedule->schedule_uid);
312
+			self::assertInstanceOf(Schedule::class, $result);
313
+		}
314
+		if (!is_null(self::$route_schedule)) {
315
+			$schedules = new Schedules();
316
+			$result = $schedules->deleteRouteSchedule(self::$route_schedule->route_id);
317
+			self::assertInstanceOf(RouteSchedule::class, $result);
318
+		}
319
+	}
320 320
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
         $result = $schedules->getAllSchedules();
108 108
 
109 109
         $this->assertIsArray($result);
110
-        if (count($result) > 0) {
110
+        if (count($result)>0) {
111 111
             $this->assertInstanceOf(Schedule::class, $result[0]);
112 112
         }
113 113
     }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
         $this->assertIsArray($result);
121 121
         $this->assertArrayHasKey('schedules', $result);
122
-        if (count($result['schedules']) > 0) {
122
+        if (count($result['schedules'])>0) {
123 123
             $this->assertInstanceOf(Schedule::class, $result['schedules'][0]);
124 124
         }
125 125
         $this->assertArrayHasKey('page_info', $result);
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         $result = $schedules->getAllRouteSchedules();
180 180
 
181 181
         $this->assertIsArray($result);
182
-        if (count($result) > 0) {
182
+        if (count($result)>0) {
183 183
             $this->assertInstanceOf(RouteSchedule::class, $result[0]);
184 184
         }
185 185
     }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
         $this->assertIsArray($result);
193 193
         $this->assertArrayHasKey('route_schedules', $result);
194
-        if (count($result['route_schedules']) > 0) {
194
+        if (count($result['route_schedules'])>0) {
195 195
             $this->assertInstanceOf(RouteSchedule::class, $result['route_schedules'][0]);
196 196
         }
197 197
         $this->assertArrayHasKey('page_info', $result);
Please login to merge, or discard this patch.
src/Route4Me/V5/RecurringRoutes/RouteSchedule.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@
 block discarded – undo
13 13
  */
14 14
 class RouteSchedule extends Common
15 15
 {
16
-    /**
17
-     * The Route ID
18
-     */
19
-    public ?string $route_id = null;
16
+	/**
17
+	 * The Route ID
18
+	 */
19
+	public ?string $route_id = null;
20 20
 
21
-    /**
22
-     * The Schedule ID
23
-     */
24
-    public ?string $schedule_uid = null;
21
+	/**
22
+	 * The Schedule ID
23
+	 */
24
+	public ?string $schedule_uid = null;
25 25
 
26
-    /**
27
-     * The Schedule ID
28
-     */
29
-    public ?int $member_id = null;
26
+	/**
27
+	 * The Schedule ID
28
+	 */
29
+	public ?int $member_id = null;
30 30
 
31
-    /**
32
-     * The Schedule ID
33
-     */
34
-    public ?string $vehicle_id = null;
31
+	/**
32
+	 * The Schedule ID
33
+	 */
34
+	public ?string $vehicle_id = null;
35 35
 
36
-    public function __construct(?array $params = null)
37
-    {
38
-        if ($params !== null) {
39
-            $this->fillFromArray($params);
40
-        }
41
-    }
36
+	public function __construct(?array $params = null)
37
+	{
38
+		if ($params !== null) {
39
+			$this->fillFromArray($params);
40
+		}
41
+	}
42 42
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
     public function __construct(?array $params = null)
37 37
     {
38
-        if ($params !== null) {
38
+        if ($params!==null) {
39 39
             $this->fillFromArray($params);
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
src/Route4Me/V5/RecurringRoutes/PageInfo.php 2 patches
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -13,72 +13,72 @@
 block discarded – undo
13 13
  */
14 14
 class PageInfo extends Common
15 15
 {
16
-    /**
17
-     * URL of first page
18
-     */
19
-    public ?string $url_of_first_page = null;
16
+	/**
17
+	 * URL of first page
18
+	 */
19
+	public ?string $url_of_first_page = null;
20 20
 
21
-    /**
22
-     * URL of last page
23
-     */
24
-    public ?string $url_of_last_page = null;
21
+	/**
22
+	 * URL of last page
23
+	 */
24
+	public ?string $url_of_last_page = null;
25 25
 
26
-    /**
27
-     * URL of previous page
28
-     */
29
-    public ?string $url_of_previous_page = null;
26
+	/**
27
+	 * URL of previous page
28
+	 */
29
+	public ?string $url_of_previous_page = null;
30 30
 
31
-    /**
32
-     * URL of next page
33
-     */
34
-    public ?string $url_of_next_page = null;
31
+	/**
32
+	 * URL of next page
33
+	 */
34
+	public ?string $url_of_next_page = null;
35 35
 
36
-    /**
37
-     * Number of current page
38
-     */
39
-    public ?int $number_of_current_page = null;
36
+	/**
37
+	 * Number of current page
38
+	 */
39
+	public ?int $number_of_current_page = null;
40 40
 
41
-    /**
42
-     * Number of last page
43
-     */
44
-    public ?int $number_of_last_page = null;
41
+	/**
42
+	 * Number of last page
43
+	 */
44
+	public ?int $number_of_last_page = null;
45 45
 
46
-    /**
47
-     * Items per page
48
-     */
49
-    public ?int $items_per_page = null;
46
+	/**
47
+	 * Items per page
48
+	 */
49
+	public ?int $items_per_page = null;
50 50
 
51
-    /**
52
-     * Index of first item on page
53
-     */
54
-    public ?int $index_of_first = null;
51
+	/**
52
+	 * Index of first item on page
53
+	 */
54
+	public ?int $index_of_first = null;
55 55
 
56
-    /**
57
-     * Index of last item on page
58
-     */
59
-    public ?int $index_of_last = null;
56
+	/**
57
+	 * Index of last item on page
58
+	 */
59
+	public ?int $index_of_last = null;
60 60
 
61
-    /**
62
-     * Total items
63
-     */
64
-    public ?int $total_items = null;
61
+	/**
62
+	 * Total items
63
+	 */
64
+	public ?int $total_items = null;
65 65
 
66
-    public function __construct(array $links = null, array $meta = null)
67
-    {
68
-        if ($links !== null && is_array($links)) {
69
-            $this->url_of_first_page = Common::getValue($links, 'first');
70
-            $this->url_of_last_page = Common::getValue($links, 'last');
71
-            $this->url_of_previous_page = Common::getValue($links, 'prev');
72
-            $this->url_of_next_page = Common::getValue($links, 'next');
73
-        }
66
+	public function __construct(array $links = null, array $meta = null)
67
+	{
68
+		if ($links !== null && is_array($links)) {
69
+			$this->url_of_first_page = Common::getValue($links, 'first');
70
+			$this->url_of_last_page = Common::getValue($links, 'last');
71
+			$this->url_of_previous_page = Common::getValue($links, 'prev');
72
+			$this->url_of_next_page = Common::getValue($links, 'next');
73
+		}
74 74
 
75
-        if ($meta !== null && is_array($meta)) {
76
-            $this->number_of_current_page = Common::getValue($meta, 'current_page');
77
-            $this->number_of_last_page = Common::getValue($meta, 'last_page');
78
-            $this->items_per_page = Common::getValue($meta, 'per_page');
79
-            $this->index_of_first = Common::getValue($meta, 'from');
80
-            $this->index_of_last = Common::getValue($meta, 'to');
81
-            $this->total_items = Common::getValue($meta, 'total');
82
-        }
83
-    }
75
+		if ($meta !== null && is_array($meta)) {
76
+			$this->number_of_current_page = Common::getValue($meta, 'current_page');
77
+			$this->number_of_last_page = Common::getValue($meta, 'last_page');
78
+			$this->items_per_page = Common::getValue($meta, 'per_page');
79
+			$this->index_of_first = Common::getValue($meta, 'from');
80
+			$this->index_of_last = Common::getValue($meta, 'to');
81
+			$this->total_items = Common::getValue($meta, 'total');
82
+		}
83
+	}
84 84
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -65,14 +65,14 @@
 block discarded – undo
65 65
 
66 66
     public function __construct(array $links = null, array $meta = null)
67 67
     {
68
-        if ($links !== null && is_array($links)) {
68
+        if ($links!==null && is_array($links)) {
69 69
             $this->url_of_first_page = Common::getValue($links, 'first');
70 70
             $this->url_of_last_page = Common::getValue($links, 'last');
71 71
             $this->url_of_previous_page = Common::getValue($links, 'prev');
72 72
             $this->url_of_next_page = Common::getValue($links, 'next');
73 73
         }
74 74
 
75
-        if ($meta !== null && is_array($meta)) {
75
+        if ($meta!==null && is_array($meta)) {
76 76
             $this->number_of_current_page = Common::getValue($meta, 'current_page');
77 77
             $this->number_of_last_page = Common::getValue($meta, 'last_page');
78 78
             $this->items_per_page = Common::getValue($meta, 'per_page');
Please login to merge, or discard this patch.
src/Route4Me/V5/RecurringRoutes/Schedule.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -13,40 +13,40 @@
 block discarded – undo
13 13
  */
14 14
 class Schedule extends Common
15 15
 {
16
-    /**
17
-     * The Schedule ID
18
-     */
19
-    public ?string $schedule_uid = null;
20
-
21
-    /**
22
-     * The name of Schedule
23
-     */
24
-    public ?string $name = null;
25
-
26
-    /**
27
-     * Array of blacklisted dates as string 'YYYY-MM-DD'.
28
-     */
29
-    public ?array $schedule_blacklist = null;
30
-
31
-    public int $advance_interval = 1;
32
-
33
-    public int $advance_schedule_interval_days = 0;
34
-
35
-    /**
36
-     * Schedule as JSON string
37
-     * e.g. '{"enabled":true,"mode":"daily","daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}'
38
-     */
39
-    public ?string $schedule = null;
40
-
41
-    /**
42
-     * Timezone as 'America/New_York'.
43
-     */
44
-    public ?string $timezone = null;
45
-
46
-    public function __construct(?array $params = null)
47
-    {
48
-        if ($params !== null) {
49
-            $this->fillFromArray($params);
50
-        }
51
-    }
16
+	/**
17
+	 * The Schedule ID
18
+	 */
19
+	public ?string $schedule_uid = null;
20
+
21
+	/**
22
+	 * The name of Schedule
23
+	 */
24
+	public ?string $name = null;
25
+
26
+	/**
27
+	 * Array of blacklisted dates as string 'YYYY-MM-DD'.
28
+	 */
29
+	public ?array $schedule_blacklist = null;
30
+
31
+	public int $advance_interval = 1;
32
+
33
+	public int $advance_schedule_interval_days = 0;
34
+
35
+	/**
36
+	 * Schedule as JSON string
37
+	 * e.g. '{"enabled":true,"mode":"daily","daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}'
38
+	 */
39
+	public ?string $schedule = null;
40
+
41
+	/**
42
+	 * Timezone as 'America/New_York'.
43
+	 */
44
+	public ?string $timezone = null;
45
+
46
+	public function __construct(?array $params = null)
47
+	{
48
+		if ($params !== null) {
49
+			$this->fillFromArray($params);
50
+		}
51
+	}
52 52
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
     public function __construct(?array $params = null)
37 37
     {
38
-        if ($params !== null) {
38
+        if ($params!==null) {
39 39
             $this->fillFromArray($params);
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
src/Route4Me/V5/RecurringRoutes/Schedules.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     public function getSchedule(string $scheduleId) : Schedule
68 68
     {
69 69
         return $this->toSchedule(Route4Me::makeRequst([
70
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId,
70
+            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES.'/'.$scheduleId,
71 71
             'method' => 'GET'
72 72
         ]));
73 73
     }
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
             'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
164 164
 
165 165
         return $this->toSchedule(Route4Me::makeRequst([
166
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId,
166
+            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES.'/'.$scheduleId,
167 167
             'method' => 'PUT',
168 168
             'HTTPHEADER' => 'Content-Type: application/json',
169 169
             'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
     public function deleteSchedule(string $scheduleId, bool $withRoutes = false) : Schedule
186 186
     {
187 187
         return $this->toSchedule(Route4Me::makeRequst([
188
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId,
188
+            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES.'/'.$scheduleId,
189 189
             'method' => 'DELETE',
190 190
             'query' => ['with_routes' => $withRoutes]
191 191
         ]));
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
     public function getRouteSchedule(string $route_id) : RouteSchedule
229 229
     {
230 230
         return $this->toRouteSchedule(Route4Me::makeRequst([
231
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
231
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES.'/'.$route_id,
232 232
             'method' => 'GET'
233 233
         ]));
234 234
     }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
         $allBodyFields = ['schedule_uid', 'member_id', 'vehicle_id'];
318 318
 
319 319
         return $this->toRouteSchedule(Route4Me::makeRequst([
320
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
320
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES.'/'.$route_id,
321 321
             'method' => 'PUT',
322 322
             'HTTPHEADER' => 'Content-Type: application/json',
323 323
             'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
@@ -337,10 +337,10 @@  discard block
 block discarded – undo
337 337
     public function deleteRouteSchedules(string $route_id) : bool
338 338
     {
339 339
         $result = Route4Me::makeRequst([
340
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
340
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES.'/'.$route_id,
341 341
             'method' => 'DELETE'
342 342
         ]);
343
-        return ($result == 1 ? true : false);
343
+        return ($result==1 ? true : false);
344 344
     }
345 345
 
346 346
     /**
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
     public function deleteRouteSchedule(string $route_id) : RouteSchedule
356 356
     {
357 357
         return $this->toRouteSchedule(Route4Me::makeRequst([
358
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id  . '/items',
358
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES.'/'.$route_id.'/items',
359 359
             'method' => 'DELETE'
360 360
         ]));
361 361
     }
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
             'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
387 387
 
388 388
         return $this->toRouteSchedule(Route4Me::makeRequst([
389
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE . '/' . $route_id,
389
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE.'/'.$route_id,
390 390
             'method' => 'PUT',
391 391
             'HTTPHEADER' => 'Content-Type: application/json',
392 392
             'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     public function getRouteSchedulePreview(string $route_id, string $start, string $end) : array
408 408
     {
409 409
         return Route4Me::makeRequst([
410
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/preview',
410
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES.'/'.$route_id.'/preview',
411 411
             'method' => 'GET',
412 412
             'query' => ['start' => $start, 'end' => $end]
413 413
         ]);
@@ -426,7 +426,7 @@  discard block
 block discarded – undo
426 426
     public function isScheduledRouteCopy(string $route_id) : bool
427 427
     {
428 428
         return Route4Me::makeRequst([
429
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY . '/' . $route_id,
429
+            'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY.'/'.$route_id,
430 430
             'method' => 'GET'
431 431
         ]);
432 432
     }
Please login to merge, or discard this patch.
Indentation   +495 added lines, -495 removed lines patch added patch discarded remove patch
@@ -19,499 +19,499 @@
 block discarded – undo
19 19
  */
20 20
 class Schedules extends Common
21 21
 {
22
-    public function __construct()
23
-    {
24
-        Route4Me::setBaseUrl('');
25
-    }
26
-
27
-    /**
28
-     * Create a new Schedule by sending the corresponding data.
29
-     *
30
-     * @since 1.2.3
31
-     *
32
-     * @param  array    $params
33
-     *   string   schedule_uid - Schedule ID,
34
-     *   int      root_member_id,
35
-     *   string   name - Name of Schedule,
36
-     *   string[] schedule_blacklist - An array of blacklisted dates as 'YYYY-MM-DD',
37
-     *   int      advance_interval,
38
-     *   int      advance_schedule_interval_days,
39
-     *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
40
-     *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
41
-     *   string   timezone - Timezone as 'America/New_York'
42
-     * @return Schedule
43
-     * @throws Exception\ApiError
44
-     */
45
-    public function createSchedule(array $params) : Schedule
46
-    {
47
-        $allBodyFields = ['schedule_uid', 'root_member_id', 'name', 'schedule_blacklist',
48
-            'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
49
-
50
-        return $this->toSchedule(Route4Me::makeRequst([
51
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES,
52
-            'method' => 'POST',
53
-            'HTTPHEADER' => 'Content-Type: application/json',
54
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
55
-        ]));
56
-    }
57
-
58
-    /**
59
-     * Get the Schedule by specifying the Schedule ID.
60
-     *
61
-     * @since 1.2.3
62
-     *
63
-     * @param  string $scheduleId Schedule ID.
64
-     * @return Schedule
65
-     * @throws Exception\ApiError
66
-     */
67
-    public function getSchedule(string $scheduleId) : Schedule
68
-    {
69
-        return $this->toSchedule(Route4Me::makeRequst([
70
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId,
71
-            'method' => 'GET'
72
-        ]));
73
-    }
74
-
75
-    /**
76
-     * Get the list of all Schedules.
77
-     *
78
-     * @since 1.2.3
79
-     *
80
-     * @return Schedule[]
81
-      * @throws Exception\ApiError
82
-    */
83
-    public function getAllSchedules() : array
84
-    {
85
-        $result = Route4Me::makeRequst([
86
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES,
87
-            'method' => 'GET'
88
-        ]);
89
-
90
-        if (is_array($result) && isset($result['data'])) {
91
-            $data = $result['data'];
92
-            if (is_array($data) && isset($data[0]) && is_array($data[0])) {
93
-                $arr = [];
94
-                foreach ($data as $key => $value) {
95
-                    array_push($arr, new Schedule($value));
96
-                }
97
-                return $arr;
98
-            }
99
-        }
100
-        return null;
101
-    }
102
-
103
-    /**
104
-     * Get paginated list of Schedules.
105
-     *
106
-     * @since 1.2.3
107
-     *
108
-     * @param  int   $page Requested page.
109
-     * @param  int   $per_page Number of Schedules per page.
110
-     * @return array
111
-     * @throws Exception\ApiError
112
-     */
113
-    public function getSchedules(int $page = 1, int $per_page = 15) : array
114
-    {
115
-        $result = Route4Me::makeRequst([
116
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES_PAGINATION,
117
-            'method' => 'GET',
118
-            'query' => [
119
-                'with_pagination' => true,
120
-                'page' => $page,
121
-                'per_page' => $per_page
122
-            ]
123
-        ]);
124
-
125
-        if (is_array($result) && isset($result['data'])) {
126
-            $data = $result['data'];
127
-            $schedules = [];
128
-            if (is_array($data) && isset($data[0]) && is_array($data[0])) {
129
-                foreach ($data as $key => $value) {
130
-                    array_push($schedules, new Schedule($value));
131
-                }
132
-            }
133
-            return [
134
-                'schedules' => $schedules,
135
-                'page_info' => new PageInfo($result['links'], $result['meta'])
136
-            ];
137
-        }
138
-        return null;
139
-    }
140
-
141
-    /**
142
-     * Update the existing Schedule by sending the corresponding data.
143
-     *
144
-     * @since 1.2.3
145
-     *
146
-     * @param  string   $schedule_uid Schedule ID
147
-     * @param  array    $params
148
-     *   string   schedule_uid - Schedule ID,
149
-     *   int      root_member_id,
150
-     *   string   name - Name of Schedule,
151
-     *   string[] schedule_blacklist - An array of blacklisted dates as 'YYYY-MM-DD',
152
-     *   int      advance_interval,
153
-     *   int      advance_schedule_interval_days,
154
-     *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
155
-     *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
156
-     *   string   timezone - Timezone as 'America/New_York'
157
-     * @return Schedule
158
-     * @throws Exception\ApiError
159
-     */
160
-    public function updateSchedule(string $scheduleId, array $params) : Schedule
161
-    {
162
-        $allBodyFields = ['root_member_id', 'name', 'schedule_blacklist',
163
-            'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
164
-
165
-        return $this->toSchedule(Route4Me::makeRequst([
166
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId,
167
-            'method' => 'PUT',
168
-            'HTTPHEADER' => 'Content-Type: application/json',
169
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
170
-        ]));
171
-    }
172
-
173
-    /**
174
-     * Delete the specified Schedule with the option to delete the associated route.
175
-     *
176
-     * @since 1.2.3
177
-     *
178
-     * @param  string $schedule_uid Schedule ID
179
-     * @param  bool   $withRoutes Delete the Schedule that matches the specified Schedule ID.
180
-     *                            If the deleted Schedule has one or multiple associated Routes,
181
-     *                            these Routes are also deleted.
182
-     * @return Schedule
183
-     * @throws Exception\ApiError
184
-     */
185
-    public function deleteSchedule(string $scheduleId, bool $withRoutes = false) : Schedule
186
-    {
187
-        return $this->toSchedule(Route4Me::makeRequst([
188
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId,
189
-            'method' => 'DELETE',
190
-            'query' => ['with_routes' => $withRoutes]
191
-        ]));
192
-    }
193
-
194
-    /**
195
-     * Create a new Route Schedule by sending the corresponding data.
196
-     *
197
-     * @since 1.2.3
198
-     *
199
-     * @param  array  $params
200
-     *   string route_id - Route ID,
201
-     *   string schedule_uid - Schedule ID,
202
-     *   int    member_id - A unique ID of the root member,
203
-     *   string vehicle_id - Vehicle ID
204
-     * @return RouteSchedule
205
-     * @throws Exception\ApiError
206
-     */
207
-    public function createRouteSchedule(array $params) : RouteSchedule
208
-    {
209
-        $allBodyFields = ['route_id', 'schedule_uid', 'member_id', 'vehicle_id'];
210
-
211
-        return $this->toRouteSchedule(Route4Me::makeRequst([
212
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES,
213
-            'method' => 'POST',
214
-            'HTTPHEADER' => 'Content-Type: application/json',
215
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
216
-        ]));
217
-    }
218
-
219
-    /**
220
-     * Get the Route Schedule by specifying the Route ID.
221
-     *
222
-     * @since 1.2.3
223
-     *
224
-     * @param  string $routeId Route ID.
225
-     * @return RouteSchedule
226
-     * @throws Exception\ApiError
227
-     */
228
-    public function getRouteSchedule(string $route_id) : RouteSchedule
229
-    {
230
-        return $this->toRouteSchedule(Route4Me::makeRequst([
231
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
232
-            'method' => 'GET'
233
-        ]));
234
-    }
235
-
236
-    /**
237
-     * Get the list of all Route Schedules.
238
-     *
239
-     * @since 1.2.3
240
-     *
241
-     * @return RouteSchedule[]
242
-     * @throws Exception\ApiError
243
-     */
244
-    public function getAllRouteSchedules() : array
245
-    {
246
-        $result = Route4Me::makeRequst([
247
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES,
248
-            'method' => 'GET'
249
-        ]);
250
-
251
-        if (is_array($result) && isset($result['data'])) {
252
-            $data = $result['data'];
253
-            if (is_array($data) && isset($data[0]) && is_array($data[0])) {
254
-                $arr = [];
255
-                foreach ($data as $key => $value) {
256
-                    array_push($arr, new RouteSchedule($value));
257
-                }
258
-                return $arr;
259
-            }
260
-        }
261
-        return null;
262
-    }
263
-
264
-    /**
265
-     * Get paginated list of Route Schedules.
266
-     *
267
-     * @since 1.2.3
268
-     *
269
-     * @param  int $page Requested page.
270
-     * @param  int $per_page Number of Route Schedules per page.
271
-     * @return array
272
-     * @throws Exception\ApiError
273
-     */
274
-    public function getRouteSchedules(int $page = 1, int $per_page = 15) : array
275
-    {
276
-        $result = Route4Me::makeRequst([
277
-            'url' =>    Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_PAGINATION,
278
-            'method' => 'GET',
279
-            'query' => [
280
-                'with_pagination' => true,
281
-                'page' => $page,
282
-                'per_page' => $per_page
283
-            ]
284
-        ]);
285
-
286
-        if (is_array($result) && isset($result['data'])) {
287
-            $data = $result['data'];
288
-            $route_schedules = [];
289
-            if (is_array($data) && isset($data[0]) && is_array($data[0])) {
290
-                foreach ($data as $key => $value) {
291
-                    array_push($route_schedules, new RouteSchedule($value));
292
-                }
293
-            }
294
-            return [
295
-                'route_schedules' => $route_schedules,
296
-                'page_info' => new PageInfo($result['links'], $result['meta'])
297
-            ];
298
-        }
299
-        return null;
300
-    }
301
-
302
-    /**
303
-     * Update the existing Route Schedule by sending the corresponding data.
304
-     *
305
-     * @since 1.2.3
306
-     *
307
-     * @param  string $route_id Route ID
308
-     * @param  array  $params
309
-     *   string schedule_uid - Schedule ID,
310
-     *   int    member_id - A unique ID of the root member,
311
-     *   string vehicle_id - Vehicle ID
312
-     * @return RouteSchedule
313
-     * @throws Exception\ApiError
314
-     */
315
-    public function updateRouteSchedule(string $route_id, array $params) : RouteSchedule
316
-    {
317
-        $allBodyFields = ['schedule_uid', 'member_id', 'vehicle_id'];
318
-
319
-        return $this->toRouteSchedule(Route4Me::makeRequst([
320
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
321
-            'method' => 'PUT',
322
-            'HTTPHEADER' => 'Content-Type: application/json',
323
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
324
-        ]));
325
-    }
326
-
327
-    /**
328
-     * Delete the Route Schedules.
329
-     * @todo request return true instead of return json status
330
-     *
331
-     * @since 1.2.3
332
-     *
333
-     * @param  string $route_id Route ID
334
-     * @return bool
335
-     * @throws Exception\ApiError
336
-     */
337
-    public function deleteRouteSchedules(string $route_id) : bool
338
-    {
339
-        $result = Route4Me::makeRequst([
340
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
341
-            'method' => 'DELETE'
342
-        ]);
343
-        return ($result == 1 ? true : false);
344
-    }
345
-
346
-    /**
347
-     * Delete the specified Route Schedule.
348
-     *
349
-     * @since 1.2.3
350
-     *
351
-     * @param  string $route_id Route ID
352
-     * @return RouteSchedule
353
-     * @throws Exception\ApiError
354
-     */
355
-    public function deleteRouteSchedule(string $route_id) : RouteSchedule
356
-    {
357
-        return $this->toRouteSchedule(Route4Me::makeRequst([
358
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id  . '/items',
359
-            'method' => 'DELETE'
360
-        ]));
361
-    }
362
-
363
-    /**
364
-     * Replace the existing Route Schedule by sending the corresponding data.
365
-     *
366
-     * @since 1.2.3
367
-     *
368
-     * @param  string   $route_id Route ID.
369
-     * @param  array    $params
370
-     *   int      member_id - A unique ID of the root member,
371
-     *   string   vehicle_id - Vehicle ID,
372
-     *   string   schedule_uid - Schedule ID,
373
-     *   string   name,
374
-     *   string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD,
375
-     *   int      advance_interval,
376
-     *   int      advance_schedule_interval_days,
377
-     *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
378
-     *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
379
-     *   string   timezone - Timezone as 'America/New_York'
380
-     * @return RouteSchedule
381
-     * @throws Exception\ApiError
382
-     */
383
-    public function replaceRouteSchedule(string $route_id, array $params)
384
-    {
385
-        $allBodyFields = ['member_id', 'vehicle_id', 'schedule_uid', 'name', 'schedule_blacklist',
386
-            'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
387
-
388
-        return $this->toRouteSchedule(Route4Me::makeRequst([
389
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE . '/' . $route_id,
390
-            'method' => 'PUT',
391
-            'HTTPHEADER' => 'Content-Type: application/json',
392
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
393
-        ]));
394
-    }
395
-
396
-    /**
397
-     * Get the Route Schedule preview by specifying the 'route_id'.
398
-     *
399
-     * @since 1.2.3
400
-     *
401
-     * @param  string $routeId Route ID.
402
-     * @param  string $start Start date as 'YYYY-MM-DD'
403
-     * @param  string $end End date as 'YYYY-MM-DD'
404
-     * @return array
405
-     * @throws Exception\ApiError
406
-     */
407
-    public function getRouteSchedulePreview(string $route_id, string $start, string $end) : array
408
-    {
409
-        return Route4Me::makeRequst([
410
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/preview',
411
-            'method' => 'GET',
412
-            'query' => ['start' => $start, 'end' => $end]
413
-        ]);
414
-    }
415
-
416
-    /**
417
-     * Check if the Scheduled Route was copied by specifying the 'route_id'.
418
-     * @todo request return true instead of return json status
419
-     *
420
-     * @since 1.2.3
421
-     *
422
-     * @param  string $routeId Route ID.
423
-     * @return bool
424
-     * @throws Exception\ApiError
425
-     */
426
-    public function isScheduledRouteCopy(string $route_id) : bool
427
-    {
428
-        return Route4Me::makeRequst([
429
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY . '/' . $route_id,
430
-            'method' => 'GET'
431
-        ]);
432
-    }
433
-
434
-    /**
435
-     * Get all routes copied from the specified Scheduled Route by sending
436
-     * the corresponding data.
437
-     *
438
-     * @since 1.2.3
439
-     *
440
-     * @param  string   $route_id Route ID.
441
-     * @param  string   $schedule_uid Schedule ID.
442
-     * @param  string   $route_date Route date as 'YYYY-MM-DD'.
443
-     * @return array
444
-     * @throws Exception\ApiError
445
-     */
446
-    public function getScheduledRoutesCopies(string $route_id, string $schedule_uid, string $route_date) : array
447
-    {
448
-        return Route4Me::makeRequst([
449
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES,
450
-            'method' => 'POST',
451
-            'HTTPHEADER' => 'Content-Type: application/json',
452
-            'body' => [
453
-                'route_id' => $route_id,
454
-                'schedule_uid' => $schedule_uid,
455
-                'route_date' => $route_date
456
-            ]
457
-        ]);
458
-    }
459
-
460
-    /**
461
-     * Create a new Master Route by sending the corresponding data.
462
-     * @todo request return true instead of return json status
463
-     *
464
-     * @since 1.2.3
465
-     *
466
-     * @param  array    $params
467
-     *   string   route_id - Route ID,
468
-     *   string   route_name,
469
-     *   int      member_id - A unique ID of the root member,
470
-     *   string   vehicle_id - Vehicle ID,
471
-     *   string   schedule_uid - Schedule ID,
472
-     *   string   name,
473
-     *   string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD,
474
-     *   int      advance_interval,
475
-     *   int      advance_schedule_interval_days,
476
-     *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
477
-     *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
478
-     *   bool     sync - Type of result, synchronous or not
479
-     *   string   timezone - Timezone as 'America/New_York'
480
-     * @return bool
481
-     * @throws Exception\ApiError
482
-     */
483
-    public function createMasterRoute(array $params) : bool
484
-    {
485
-        $allBodyFields = ['route_id', 'route_name', 'member_id', 'schedule_uid', 'vehicle_id', 'name',
486
-            'schedule_blacklist', 'advance_schedule_interval_days', 'schedule', 'timezone', 'sync'];
487
-
488
-        return Route4Me::makeRequst([
489
-            'url' => Endpoint::RECURRING_ROUTES_MASTER_ROUTES,
490
-            'method' => 'POST',
491
-            'HTTPHEADER' => 'Content-Type: application/json',
492
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
493
-        ]);
494
-    }
495
-
496
-    private function toSchedule($result) : Schedule
497
-    {
498
-        if (is_array($result) && isset($result['data'])) {
499
-            $data = $result['data'];
500
-            if (is_array($data) && isset($data[0]) && is_array($data[0])) {
501
-                return new Schedule($data[0]);
502
-            }
503
-        }
504
-        throw new ApiError('Can not convert result to Schedule object.');
505
-    }
506
-
507
-    private function toRouteSchedule($result) : RouteSchedule
508
-    {
509
-        if (is_array($result) && isset($result['data'])) {
510
-            $data = $result['data'];
511
-            if (is_array($data) && isset($data[0]) && is_array($data[0])) {
512
-                return new RouteSchedule($data[0]);
513
-            }
514
-        }
515
-        throw new ApiError('Can not convert result to RouteSchedule object.');
516
-    }
22
+	public function __construct()
23
+	{
24
+		Route4Me::setBaseUrl('');
25
+	}
26
+
27
+	/**
28
+	 * Create a new Schedule by sending the corresponding data.
29
+	 *
30
+	 * @since 1.2.3
31
+	 *
32
+	 * @param  array    $params
33
+	 *   string   schedule_uid - Schedule ID,
34
+	 *   int      root_member_id,
35
+	 *   string   name - Name of Schedule,
36
+	 *   string[] schedule_blacklist - An array of blacklisted dates as 'YYYY-MM-DD',
37
+	 *   int      advance_interval,
38
+	 *   int      advance_schedule_interval_days,
39
+	 *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
40
+	 *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
41
+	 *   string   timezone - Timezone as 'America/New_York'
42
+	 * @return Schedule
43
+	 * @throws Exception\ApiError
44
+	 */
45
+	public function createSchedule(array $params) : Schedule
46
+	{
47
+		$allBodyFields = ['schedule_uid', 'root_member_id', 'name', 'schedule_blacklist',
48
+			'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
49
+
50
+		return $this->toSchedule(Route4Me::makeRequst([
51
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULES,
52
+			'method' => 'POST',
53
+			'HTTPHEADER' => 'Content-Type: application/json',
54
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
55
+		]));
56
+	}
57
+
58
+	/**
59
+	 * Get the Schedule by specifying the Schedule ID.
60
+	 *
61
+	 * @since 1.2.3
62
+	 *
63
+	 * @param  string $scheduleId Schedule ID.
64
+	 * @return Schedule
65
+	 * @throws Exception\ApiError
66
+	 */
67
+	public function getSchedule(string $scheduleId) : Schedule
68
+	{
69
+		return $this->toSchedule(Route4Me::makeRequst([
70
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId,
71
+			'method' => 'GET'
72
+		]));
73
+	}
74
+
75
+	/**
76
+	 * Get the list of all Schedules.
77
+	 *
78
+	 * @since 1.2.3
79
+	 *
80
+	 * @return Schedule[]
81
+	 * @throws Exception\ApiError
82
+	 */
83
+	public function getAllSchedules() : array
84
+	{
85
+		$result = Route4Me::makeRequst([
86
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULES,
87
+			'method' => 'GET'
88
+		]);
89
+
90
+		if (is_array($result) && isset($result['data'])) {
91
+			$data = $result['data'];
92
+			if (is_array($data) && isset($data[0]) && is_array($data[0])) {
93
+				$arr = [];
94
+				foreach ($data as $key => $value) {
95
+					array_push($arr, new Schedule($value));
96
+				}
97
+				return $arr;
98
+			}
99
+		}
100
+		return null;
101
+	}
102
+
103
+	/**
104
+	 * Get paginated list of Schedules.
105
+	 *
106
+	 * @since 1.2.3
107
+	 *
108
+	 * @param  int   $page Requested page.
109
+	 * @param  int   $per_page Number of Schedules per page.
110
+	 * @return array
111
+	 * @throws Exception\ApiError
112
+	 */
113
+	public function getSchedules(int $page = 1, int $per_page = 15) : array
114
+	{
115
+		$result = Route4Me::makeRequst([
116
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULES_PAGINATION,
117
+			'method' => 'GET',
118
+			'query' => [
119
+				'with_pagination' => true,
120
+				'page' => $page,
121
+				'per_page' => $per_page
122
+			]
123
+		]);
124
+
125
+		if (is_array($result) && isset($result['data'])) {
126
+			$data = $result['data'];
127
+			$schedules = [];
128
+			if (is_array($data) && isset($data[0]) && is_array($data[0])) {
129
+				foreach ($data as $key => $value) {
130
+					array_push($schedules, new Schedule($value));
131
+				}
132
+			}
133
+			return [
134
+				'schedules' => $schedules,
135
+				'page_info' => new PageInfo($result['links'], $result['meta'])
136
+			];
137
+		}
138
+		return null;
139
+	}
140
+
141
+	/**
142
+	 * Update the existing Schedule by sending the corresponding data.
143
+	 *
144
+	 * @since 1.2.3
145
+	 *
146
+	 * @param  string   $schedule_uid Schedule ID
147
+	 * @param  array    $params
148
+	 *   string   schedule_uid - Schedule ID,
149
+	 *   int      root_member_id,
150
+	 *   string   name - Name of Schedule,
151
+	 *   string[] schedule_blacklist - An array of blacklisted dates as 'YYYY-MM-DD',
152
+	 *   int      advance_interval,
153
+	 *   int      advance_schedule_interval_days,
154
+	 *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
155
+	 *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
156
+	 *   string   timezone - Timezone as 'America/New_York'
157
+	 * @return Schedule
158
+	 * @throws Exception\ApiError
159
+	 */
160
+	public function updateSchedule(string $scheduleId, array $params) : Schedule
161
+	{
162
+		$allBodyFields = ['root_member_id', 'name', 'schedule_blacklist',
163
+			'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
164
+
165
+		return $this->toSchedule(Route4Me::makeRequst([
166
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId,
167
+			'method' => 'PUT',
168
+			'HTTPHEADER' => 'Content-Type: application/json',
169
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
170
+		]));
171
+	}
172
+
173
+	/**
174
+	 * Delete the specified Schedule with the option to delete the associated route.
175
+	 *
176
+	 * @since 1.2.3
177
+	 *
178
+	 * @param  string $schedule_uid Schedule ID
179
+	 * @param  bool   $withRoutes Delete the Schedule that matches the specified Schedule ID.
180
+	 *                            If the deleted Schedule has one or multiple associated Routes,
181
+	 *                            these Routes are also deleted.
182
+	 * @return Schedule
183
+	 * @throws Exception\ApiError
184
+	 */
185
+	public function deleteSchedule(string $scheduleId, bool $withRoutes = false) : Schedule
186
+	{
187
+		return $this->toSchedule(Route4Me::makeRequst([
188
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULES . '/' . $scheduleId,
189
+			'method' => 'DELETE',
190
+			'query' => ['with_routes' => $withRoutes]
191
+		]));
192
+	}
193
+
194
+	/**
195
+	 * Create a new Route Schedule by sending the corresponding data.
196
+	 *
197
+	 * @since 1.2.3
198
+	 *
199
+	 * @param  array  $params
200
+	 *   string route_id - Route ID,
201
+	 *   string schedule_uid - Schedule ID,
202
+	 *   int    member_id - A unique ID of the root member,
203
+	 *   string vehicle_id - Vehicle ID
204
+	 * @return RouteSchedule
205
+	 * @throws Exception\ApiError
206
+	 */
207
+	public function createRouteSchedule(array $params) : RouteSchedule
208
+	{
209
+		$allBodyFields = ['route_id', 'schedule_uid', 'member_id', 'vehicle_id'];
210
+
211
+		return $this->toRouteSchedule(Route4Me::makeRequst([
212
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES,
213
+			'method' => 'POST',
214
+			'HTTPHEADER' => 'Content-Type: application/json',
215
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
216
+		]));
217
+	}
218
+
219
+	/**
220
+	 * Get the Route Schedule by specifying the Route ID.
221
+	 *
222
+	 * @since 1.2.3
223
+	 *
224
+	 * @param  string $routeId Route ID.
225
+	 * @return RouteSchedule
226
+	 * @throws Exception\ApiError
227
+	 */
228
+	public function getRouteSchedule(string $route_id) : RouteSchedule
229
+	{
230
+		return $this->toRouteSchedule(Route4Me::makeRequst([
231
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
232
+			'method' => 'GET'
233
+		]));
234
+	}
235
+
236
+	/**
237
+	 * Get the list of all Route Schedules.
238
+	 *
239
+	 * @since 1.2.3
240
+	 *
241
+	 * @return RouteSchedule[]
242
+	 * @throws Exception\ApiError
243
+	 */
244
+	public function getAllRouteSchedules() : array
245
+	{
246
+		$result = Route4Me::makeRequst([
247
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES,
248
+			'method' => 'GET'
249
+		]);
250
+
251
+		if (is_array($result) && isset($result['data'])) {
252
+			$data = $result['data'];
253
+			if (is_array($data) && isset($data[0]) && is_array($data[0])) {
254
+				$arr = [];
255
+				foreach ($data as $key => $value) {
256
+					array_push($arr, new RouteSchedule($value));
257
+				}
258
+				return $arr;
259
+			}
260
+		}
261
+		return null;
262
+	}
263
+
264
+	/**
265
+	 * Get paginated list of Route Schedules.
266
+	 *
267
+	 * @since 1.2.3
268
+	 *
269
+	 * @param  int $page Requested page.
270
+	 * @param  int $per_page Number of Route Schedules per page.
271
+	 * @return array
272
+	 * @throws Exception\ApiError
273
+	 */
274
+	public function getRouteSchedules(int $page = 1, int $per_page = 15) : array
275
+	{
276
+		$result = Route4Me::makeRequst([
277
+			'url' =>    Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_PAGINATION,
278
+			'method' => 'GET',
279
+			'query' => [
280
+				'with_pagination' => true,
281
+				'page' => $page,
282
+				'per_page' => $per_page
283
+			]
284
+		]);
285
+
286
+		if (is_array($result) && isset($result['data'])) {
287
+			$data = $result['data'];
288
+			$route_schedules = [];
289
+			if (is_array($data) && isset($data[0]) && is_array($data[0])) {
290
+				foreach ($data as $key => $value) {
291
+					array_push($route_schedules, new RouteSchedule($value));
292
+				}
293
+			}
294
+			return [
295
+				'route_schedules' => $route_schedules,
296
+				'page_info' => new PageInfo($result['links'], $result['meta'])
297
+			];
298
+		}
299
+		return null;
300
+	}
301
+
302
+	/**
303
+	 * Update the existing Route Schedule by sending the corresponding data.
304
+	 *
305
+	 * @since 1.2.3
306
+	 *
307
+	 * @param  string $route_id Route ID
308
+	 * @param  array  $params
309
+	 *   string schedule_uid - Schedule ID,
310
+	 *   int    member_id - A unique ID of the root member,
311
+	 *   string vehicle_id - Vehicle ID
312
+	 * @return RouteSchedule
313
+	 * @throws Exception\ApiError
314
+	 */
315
+	public function updateRouteSchedule(string $route_id, array $params) : RouteSchedule
316
+	{
317
+		$allBodyFields = ['schedule_uid', 'member_id', 'vehicle_id'];
318
+
319
+		return $this->toRouteSchedule(Route4Me::makeRequst([
320
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
321
+			'method' => 'PUT',
322
+			'HTTPHEADER' => 'Content-Type: application/json',
323
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
324
+		]));
325
+	}
326
+
327
+	/**
328
+	 * Delete the Route Schedules.
329
+	 * @todo request return true instead of return json status
330
+	 *
331
+	 * @since 1.2.3
332
+	 *
333
+	 * @param  string $route_id Route ID
334
+	 * @return bool
335
+	 * @throws Exception\ApiError
336
+	 */
337
+	public function deleteRouteSchedules(string $route_id) : bool
338
+	{
339
+		$result = Route4Me::makeRequst([
340
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
341
+			'method' => 'DELETE'
342
+		]);
343
+		return ($result == 1 ? true : false);
344
+	}
345
+
346
+	/**
347
+	 * Delete the specified Route Schedule.
348
+	 *
349
+	 * @since 1.2.3
350
+	 *
351
+	 * @param  string $route_id Route ID
352
+	 * @return RouteSchedule
353
+	 * @throws Exception\ApiError
354
+	 */
355
+	public function deleteRouteSchedule(string $route_id) : RouteSchedule
356
+	{
357
+		return $this->toRouteSchedule(Route4Me::makeRequst([
358
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id  . '/items',
359
+			'method' => 'DELETE'
360
+		]));
361
+	}
362
+
363
+	/**
364
+	 * Replace the existing Route Schedule by sending the corresponding data.
365
+	 *
366
+	 * @since 1.2.3
367
+	 *
368
+	 * @param  string   $route_id Route ID.
369
+	 * @param  array    $params
370
+	 *   int      member_id - A unique ID of the root member,
371
+	 *   string   vehicle_id - Vehicle ID,
372
+	 *   string   schedule_uid - Schedule ID,
373
+	 *   string   name,
374
+	 *   string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD,
375
+	 *   int      advance_interval,
376
+	 *   int      advance_schedule_interval_days,
377
+	 *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
378
+	 *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
379
+	 *   string   timezone - Timezone as 'America/New_York'
380
+	 * @return RouteSchedule
381
+	 * @throws Exception\ApiError
382
+	 */
383
+	public function replaceRouteSchedule(string $route_id, array $params)
384
+	{
385
+		$allBodyFields = ['member_id', 'vehicle_id', 'schedule_uid', 'name', 'schedule_blacklist',
386
+			'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
387
+
388
+		return $this->toRouteSchedule(Route4Me::makeRequst([
389
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE . '/' . $route_id,
390
+			'method' => 'PUT',
391
+			'HTTPHEADER' => 'Content-Type: application/json',
392
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
393
+		]));
394
+	}
395
+
396
+	/**
397
+	 * Get the Route Schedule preview by specifying the 'route_id'.
398
+	 *
399
+	 * @since 1.2.3
400
+	 *
401
+	 * @param  string $routeId Route ID.
402
+	 * @param  string $start Start date as 'YYYY-MM-DD'
403
+	 * @param  string $end End date as 'YYYY-MM-DD'
404
+	 * @return array
405
+	 * @throws Exception\ApiError
406
+	 */
407
+	public function getRouteSchedulePreview(string $route_id, string $start, string $end) : array
408
+	{
409
+		return Route4Me::makeRequst([
410
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/preview',
411
+			'method' => 'GET',
412
+			'query' => ['start' => $start, 'end' => $end]
413
+		]);
414
+	}
415
+
416
+	/**
417
+	 * Check if the Scheduled Route was copied by specifying the 'route_id'.
418
+	 * @todo request return true instead of return json status
419
+	 *
420
+	 * @since 1.2.3
421
+	 *
422
+	 * @param  string $routeId Route ID.
423
+	 * @return bool
424
+	 * @throws Exception\ApiError
425
+	 */
426
+	public function isScheduledRouteCopy(string $route_id) : bool
427
+	{
428
+		return Route4Me::makeRequst([
429
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY . '/' . $route_id,
430
+			'method' => 'GET'
431
+		]);
432
+	}
433
+
434
+	/**
435
+	 * Get all routes copied from the specified Scheduled Route by sending
436
+	 * the corresponding data.
437
+	 *
438
+	 * @since 1.2.3
439
+	 *
440
+	 * @param  string   $route_id Route ID.
441
+	 * @param  string   $schedule_uid Schedule ID.
442
+	 * @param  string   $route_date Route date as 'YYYY-MM-DD'.
443
+	 * @return array
444
+	 * @throws Exception\ApiError
445
+	 */
446
+	public function getScheduledRoutesCopies(string $route_id, string $schedule_uid, string $route_date) : array
447
+	{
448
+		return Route4Me::makeRequst([
449
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES,
450
+			'method' => 'POST',
451
+			'HTTPHEADER' => 'Content-Type: application/json',
452
+			'body' => [
453
+				'route_id' => $route_id,
454
+				'schedule_uid' => $schedule_uid,
455
+				'route_date' => $route_date
456
+			]
457
+		]);
458
+	}
459
+
460
+	/**
461
+	 * Create a new Master Route by sending the corresponding data.
462
+	 * @todo request return true instead of return json status
463
+	 *
464
+	 * @since 1.2.3
465
+	 *
466
+	 * @param  array    $params
467
+	 *   string   route_id - Route ID,
468
+	 *   string   route_name,
469
+	 *   int      member_id - A unique ID of the root member,
470
+	 *   string   vehicle_id - Vehicle ID,
471
+	 *   string   schedule_uid - Schedule ID,
472
+	 *   string   name,
473
+	 *   string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD,
474
+	 *   int      advance_interval,
475
+	 *   int      advance_schedule_interval_days,
476
+	 *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
477
+	 *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
478
+	 *   bool     sync - Type of result, synchronous or not
479
+	 *   string   timezone - Timezone as 'America/New_York'
480
+	 * @return bool
481
+	 * @throws Exception\ApiError
482
+	 */
483
+	public function createMasterRoute(array $params) : bool
484
+	{
485
+		$allBodyFields = ['route_id', 'route_name', 'member_id', 'schedule_uid', 'vehicle_id', 'name',
486
+			'schedule_blacklist', 'advance_schedule_interval_days', 'schedule', 'timezone', 'sync'];
487
+
488
+		return Route4Me::makeRequst([
489
+			'url' => Endpoint::RECURRING_ROUTES_MASTER_ROUTES,
490
+			'method' => 'POST',
491
+			'HTTPHEADER' => 'Content-Type: application/json',
492
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
493
+		]);
494
+	}
495
+
496
+	private function toSchedule($result) : Schedule
497
+	{
498
+		if (is_array($result) && isset($result['data'])) {
499
+			$data = $result['data'];
500
+			if (is_array($data) && isset($data[0]) && is_array($data[0])) {
501
+				return new Schedule($data[0]);
502
+			}
503
+		}
504
+		throw new ApiError('Can not convert result to Schedule object.');
505
+	}
506
+
507
+	private function toRouteSchedule($result) : RouteSchedule
508
+	{
509
+		if (is_array($result) && isset($result['data'])) {
510
+			$data = $result['data'];
511
+			if (is_array($data) && isset($data[0]) && is_array($data[0])) {
512
+				return new RouteSchedule($data[0]);
513
+			}
514
+		}
515
+		throw new ApiError('Can not convert result to RouteSchedule object.');
516
+	}
517 517
 }
Please login to merge, or discard this patch.
src/Route4Me/Exception/ApiError.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@
 block discarded – undo
4 4
 
5 5
 class ApiError extends \Exception
6 6
 {
7
-    protected string $source = '';
7
+	protected string $source = '';
8 8
 
9
-    public function __construct(string $message = '', int $code = 0, string $source = '', \Throwable $previous = null)
10
-    {
11
-        parent::__construct($message, $code, $previous);
12
-        $this->source = $source;
13
-    }
9
+	public function __construct(string $message = '', int $code = 0, string $source = '', \Throwable $previous = null)
10
+	{
11
+		parent::__construct($message, $code, $previous);
12
+		$this->source = $source;
13
+	}
14 14
 
15
-    final public function getSource() : string
16
-    {
17
-        return $this->source;
18
-    }
15
+	final public function getSource() : string
16
+	{
17
+		return $this->source;
18
+	}
19 19
 }
Please login to merge, or discard this patch.
UnitTestFiles/Test/V5/VehicleTests.php 2 patches
Indentation   +494 added lines, -494 removed lines patch added patch discarded remove patch
@@ -26,539 +26,539 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Route4Me/V5/Vehicles/DataTypes/Vehicle.php 2 patches
Indentation   +375 added lines, -375 removed lines patch added patch discarded remove patch
@@ -19,379 +19,379 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -235,7 +235,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.