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 Setup Failed
Push — master ( 311795...859c79 )
by Igor
06:22 queued 13s
created
UnitTestFiles/Test/V5/RecurringRoutesUnitTests.php 1 patch
Indentation   +321 added lines, -321 removed lines patch added patch discarded remove patch
@@ -14,330 +14,330 @@
 block discarded – undo
14 14
 
15 15
 final class RecurringRoutesUnitTests extends \PHPUnit\Framework\TestCase
16 16
 {
17
-    public static ?Schedule $schedule;
18
-    public static ?RouteSchedule $route_schedule;
19
-    public static ?string $route_id;
20
-    public static ?string $member_id;
21
-    public static ?string $vehicle_id;
22
-
23
-    public static function setUpBeforeClass() : void
24
-    {
25
-        Route4Me::setApiKey(Constants::API_KEY);
26
-        self::$schedule = null;
27
-        self::$route_schedule = null;
28
-        self::$route_id = null;
29
-        self::$member_id = null;
30
-        self::$vehicle_id = null;
31
-    }
32
-
33
-    public function testScheduleCanBeCreateEmpty() : void
34
-    {
35
-        $this->assertInstanceOf(Schedule::class, new Schedule());
36
-    }
37
-
38
-    public function testScheduleCanBeCreateFromArray() : void
39
-    {
40
-        $this->assertInstanceOf(Schedule::class, new Schedule([
41
-            'schedule_uid' => '1',
42
-            'name' => 'The best Schedule'
43
-        ]));
44
-    }
45
-
46
-    public function testRouteScheduleCanBeCreateEmpty() : void
47
-    {
48
-        $this->assertInstanceOf(RouteSchedule::class, new RouteSchedule());
49
-    }
50
-
51
-    public function testRouteScheduleCanBeCreateFromArray() : void
52
-    {
53
-        $this->assertInstanceOf(RouteSchedule::class, new RouteSchedule([
54
-            'route_id' => '1',
55
-            'schedule_uid' => '2'
56
-        ]));
57
-    }
58
-
59
-    public function testPageInfoCanBeCreateEmpty() : void
60
-    {
61
-        $this->assertInstanceOf(PageInfo::class, new PageInfo());
62
-    }
63
-
64
-    public function testPageInfoCanBeCreateFromArray() : void
65
-    {
66
-        $this->assertInstanceOf(PageInfo::class, new PageInfo([
67
-            'first' => 'URL_first',
68
-            'last' => 'URL_last'
69
-        ], [
70
-            'current_page' => 1,
71
-            'last_page' => 15
72
-        ]));
73
-    }
74
-
75
-    public function testSchedulesCanBeCreateEmpty() : void
76
-    {
77
-        $this->assertInstanceOf(Schedules::class, new Schedules());
78
-    }
79
-
80
-    public function testCreateScheduleMustReturnScahedule() : void
81
-    {
82
-        $schedules = new Schedules();
83
-        self::$schedule = $schedules->createSchedule([
84
-            'name' => 'The bestest schedule',
85
-            'schedule_blacklist' => [],
86
-            'schedule' => null,
87
-            'timezone' => 'UTC'
88
-        ]);
89
-
90
-        $this->assertInstanceOf(Schedule::class, self::$schedule);
91
-        $this->assertNotNull(self::$schedule->schedule_uid);
92
-        $this->assertEquals(self::$schedule->name, 'The bestest schedule');
93
-    }
94
-
95
-    public function testGetScheduleMustReturnScahedule() : void
96
-    {
97
-        $schedules = new Schedules();
98
-        $schedule = $schedules->getSchedule(self::$schedule->schedule_uid);
99
-
100
-        $this->assertInstanceOf(Schedule::class, $schedule);
101
-        $this->assertNotNull(self::$schedule->schedule_uid);
102
-        $this->assertEquals(self::$schedule->name, 'The bestest schedule');
103
-    }
104
-
105
-    public function testGetAllSchedulesMustReturnArrayOfScahedules() : void
106
-    {
107
-        $schedules = new Schedules();
108
-        $result = $schedules->getAllSchedules();
109
-
110
-        $this->assertIsArray($result);
111
-        if (count($result) > 0) {
112
-            $this->assertInstanceOf(Schedule::class, $result[0]);
113
-        }
114
-    }
115
-
116
-    public function testGetSchedulesMustReturnOnePage() : void
117
-    {
118
-        $schedules = new Schedules();
119
-        $result = $schedules->getSchedules();
120
-
121
-        $this->assertIsArray($result);
122
-        $this->assertArrayHasKey('schedules', $result);
123
-        if (count($result['schedules']) > 0) {
124
-            $this->assertInstanceOf(Schedule::class, $result['schedules'][0]);
125
-        }
126
-        $this->assertArrayHasKey('page_info', $result);
127
-        $this->assertInstanceOf(PageInfo::class, $result['page_info']);
128
-    }
129
-
130
-    public function testUpdateScheduleMustReturnUpdatedScahedule() : void
131
-    {
132
-        $schedules = new Schedules();
133
-        self::$schedule = $schedules->updateSchedule(self::$schedule->schedule_uid, [
134
-            'name' => 'The bestest schedule 1'
135
-        ]);
136
-
137
-        $this->assertInstanceOf(Schedule::class, self::$schedule);
138
-        $this->assertEquals(self::$schedule->name, 'The bestest schedule 1');
139
-    }
140
-
141
-    public function testCreateRouteScheduleMustReturnRouteScahedule() : void
142
-    {
143
-        $route = new Route;
144
-        $routes = $route->getRoutes([
145
-            'limit' => 1,
146
-            'offset' => 0
147
-        ]);
17
+	public static ?Schedule $schedule;
18
+	public static ?RouteSchedule $route_schedule;
19
+	public static ?string $route_id;
20
+	public static ?string $member_id;
21
+	public static ?string $vehicle_id;
22
+
23
+	public static function setUpBeforeClass() : void
24
+	{
25
+		Route4Me::setApiKey(Constants::API_KEY);
26
+		self::$schedule = null;
27
+		self::$route_schedule = null;
28
+		self::$route_id = null;
29
+		self::$member_id = null;
30
+		self::$vehicle_id = null;
31
+	}
32
+
33
+	public function testScheduleCanBeCreateEmpty() : void
34
+	{
35
+		$this->assertInstanceOf(Schedule::class, new Schedule());
36
+	}
37
+
38
+	public function testScheduleCanBeCreateFromArray() : void
39
+	{
40
+		$this->assertInstanceOf(Schedule::class, new Schedule([
41
+			'schedule_uid' => '1',
42
+			'name' => 'The best Schedule'
43
+		]));
44
+	}
45
+
46
+	public function testRouteScheduleCanBeCreateEmpty() : void
47
+	{
48
+		$this->assertInstanceOf(RouteSchedule::class, new RouteSchedule());
49
+	}
50
+
51
+	public function testRouteScheduleCanBeCreateFromArray() : void
52
+	{
53
+		$this->assertInstanceOf(RouteSchedule::class, new RouteSchedule([
54
+			'route_id' => '1',
55
+			'schedule_uid' => '2'
56
+		]));
57
+	}
58
+
59
+	public function testPageInfoCanBeCreateEmpty() : void
60
+	{
61
+		$this->assertInstanceOf(PageInfo::class, new PageInfo());
62
+	}
63
+
64
+	public function testPageInfoCanBeCreateFromArray() : void
65
+	{
66
+		$this->assertInstanceOf(PageInfo::class, new PageInfo([
67
+			'first' => 'URL_first',
68
+			'last' => 'URL_last'
69
+		], [
70
+			'current_page' => 1,
71
+			'last_page' => 15
72
+		]));
73
+	}
74
+
75
+	public function testSchedulesCanBeCreateEmpty() : void
76
+	{
77
+		$this->assertInstanceOf(Schedules::class, new Schedules());
78
+	}
79
+
80
+	public function testCreateScheduleMustReturnScahedule() : void
81
+	{
82
+		$schedules = new Schedules();
83
+		self::$schedule = $schedules->createSchedule([
84
+			'name' => 'The bestest schedule',
85
+			'schedule_blacklist' => [],
86
+			'schedule' => null,
87
+			'timezone' => 'UTC'
88
+		]);
89
+
90
+		$this->assertInstanceOf(Schedule::class, self::$schedule);
91
+		$this->assertNotNull(self::$schedule->schedule_uid);
92
+		$this->assertEquals(self::$schedule->name, 'The bestest schedule');
93
+	}
94
+
95
+	public function testGetScheduleMustReturnScahedule() : void
96
+	{
97
+		$schedules = new Schedules();
98
+		$schedule = $schedules->getSchedule(self::$schedule->schedule_uid);
99
+
100
+		$this->assertInstanceOf(Schedule::class, $schedule);
101
+		$this->assertNotNull(self::$schedule->schedule_uid);
102
+		$this->assertEquals(self::$schedule->name, 'The bestest schedule');
103
+	}
104
+
105
+	public function testGetAllSchedulesMustReturnArrayOfScahedules() : void
106
+	{
107
+		$schedules = new Schedules();
108
+		$result = $schedules->getAllSchedules();
109
+
110
+		$this->assertIsArray($result);
111
+		if (count($result) > 0) {
112
+			$this->assertInstanceOf(Schedule::class, $result[0]);
113
+		}
114
+	}
115
+
116
+	public function testGetSchedulesMustReturnOnePage() : void
117
+	{
118
+		$schedules = new Schedules();
119
+		$result = $schedules->getSchedules();
120
+
121
+		$this->assertIsArray($result);
122
+		$this->assertArrayHasKey('schedules', $result);
123
+		if (count($result['schedules']) > 0) {
124
+			$this->assertInstanceOf(Schedule::class, $result['schedules'][0]);
125
+		}
126
+		$this->assertArrayHasKey('page_info', $result);
127
+		$this->assertInstanceOf(PageInfo::class, $result['page_info']);
128
+	}
129
+
130
+	public function testUpdateScheduleMustReturnUpdatedScahedule() : void
131
+	{
132
+		$schedules = new Schedules();
133
+		self::$schedule = $schedules->updateSchedule(self::$schedule->schedule_uid, [
134
+			'name' => 'The bestest schedule 1'
135
+		]);
136
+
137
+		$this->assertInstanceOf(Schedule::class, self::$schedule);
138
+		$this->assertEquals(self::$schedule->name, 'The bestest schedule 1');
139
+	}
140
+
141
+	public function testCreateRouteScheduleMustReturnRouteScahedule() : void
142
+	{
143
+		$route = new Route;
144
+		$routes = $route->getRoutes([
145
+			'limit' => 1,
146
+			'offset' => 0
147
+		]);
148 148
     
149
-        if (is_array($routes) && isset($routes[0])) {
150
-            self::$route_id = $routes[0]->route_id;
151
-            self::$member_id = $routes[0]->member_id;
152
-        }
153
-        $route = null;
149
+		if (is_array($routes) && isset($routes[0])) {
150
+			self::$route_id = $routes[0]->route_id;
151
+			self::$member_id = $routes[0]->member_id;
152
+		}
153
+		$route = null;
154 154
 
155
-        $this->assertNotNull(self::$route_id);
155
+		$this->assertNotNull(self::$route_id);
156 156
     
157
-        $schedules = new Schedules();
158
-        self::$route_schedule = $schedules->createRouteSchedule([
159
-            'route_id' => self::$route_id,
160
-            'schedule_uid' => self::$schedule->schedule_uid
161
-        ]);
162
-
163
-        $this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
164
-        $this->assertNotNull(self::$route_schedule->schedule_uid);
165
-        $this->assertEquals(self::$route_schedule->schedule_uid, self::$schedule->schedule_uid);
166
-    }
167
-
168
-    public function testGetRouteScheduleMustReturnRouteScahedule() : void
169
-    {
170
-        $schedules = new Schedules();
171
-        $route_schedule = $schedules->getRouteSchedule(self::$route_id);
172
-
173
-        $this->assertInstanceOf(RouteSchedule::class, $route_schedule);
174
-        $this->assertNotNull($route_schedule->schedule_uid);
175
-    }
176
-
177
-    public function testGetAllRouteSchedulesMustReturnArrayOfRouteScahedules() : void
178
-    {
179
-        $schedules = new Schedules();
180
-        $result = $schedules->getAllRouteSchedules();
181
-
182
-        $this->assertIsArray($result);
183
-        if (count($result) > 0) {
184
-            $this->assertInstanceOf(RouteSchedule::class, $result[0]);
185
-        }
186
-    }
187
-
188
-    public function testGetRouteSchedulesMustReturnOnePage() : void
189
-    {
190
-        $schedules = new Schedules();
191
-        $result = $schedules->getRouteSchedules();
192
-
193
-        $this->assertIsArray($result);
194
-        $this->assertArrayHasKey('route_schedules', $result);
195
-        if (count($result['route_schedules']) > 0) {
196
-            $this->assertInstanceOf(RouteSchedule::class, $result['route_schedules'][0]);
197
-        }
198
-        $this->assertArrayHasKey('page_info', $result);
199
-        $this->assertInstanceOf(PageInfo::class, $result['page_info']);
200
-    }
201
-
202
-    public function testUpdateRouteScheduleMustReturnUpdatedRouteScahedule() : void
203
-    {
204
-        $vehicle = new Vehicle();
205
-        $vehicles = $vehicle->getVehiclesPaginatedList([
206
-            'with_pagination' => true,
207
-            'page' => 1,
208
-            'perPage' => 1
209
-        ]);
157
+		$schedules = new Schedules();
158
+		self::$route_schedule = $schedules->createRouteSchedule([
159
+			'route_id' => self::$route_id,
160
+			'schedule_uid' => self::$schedule->schedule_uid
161
+		]);
162
+
163
+		$this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
164
+		$this->assertNotNull(self::$route_schedule->schedule_uid);
165
+		$this->assertEquals(self::$route_schedule->schedule_uid, self::$schedule->schedule_uid);
166
+	}
167
+
168
+	public function testGetRouteScheduleMustReturnRouteScahedule() : void
169
+	{
170
+		$schedules = new Schedules();
171
+		$route_schedule = $schedules->getRouteSchedule(self::$route_id);
172
+
173
+		$this->assertInstanceOf(RouteSchedule::class, $route_schedule);
174
+		$this->assertNotNull($route_schedule->schedule_uid);
175
+	}
176
+
177
+	public function testGetAllRouteSchedulesMustReturnArrayOfRouteScahedules() : void
178
+	{
179
+		$schedules = new Schedules();
180
+		$result = $schedules->getAllRouteSchedules();
181
+
182
+		$this->assertIsArray($result);
183
+		if (count($result) > 0) {
184
+			$this->assertInstanceOf(RouteSchedule::class, $result[0]);
185
+		}
186
+	}
187
+
188
+	public function testGetRouteSchedulesMustReturnOnePage() : void
189
+	{
190
+		$schedules = new Schedules();
191
+		$result = $schedules->getRouteSchedules();
192
+
193
+		$this->assertIsArray($result);
194
+		$this->assertArrayHasKey('route_schedules', $result);
195
+		if (count($result['route_schedules']) > 0) {
196
+			$this->assertInstanceOf(RouteSchedule::class, $result['route_schedules'][0]);
197
+		}
198
+		$this->assertArrayHasKey('page_info', $result);
199
+		$this->assertInstanceOf(PageInfo::class, $result['page_info']);
200
+	}
201
+
202
+	public function testUpdateRouteScheduleMustReturnUpdatedRouteScahedule() : void
203
+	{
204
+		$vehicle = new Vehicle();
205
+		$vehicles = $vehicle->getVehiclesPaginatedList([
206
+			'with_pagination' => true,
207
+			'page' => 1,
208
+			'perPage' => 1
209
+		]);
210 210
     
211
-        if (is_array($vehicles) && isset($vehicles[0]) && is_array($vehicles[0]) && isset($vehicles[0]['vehicle_id'])) {
212
-            self::$vehicle_id = $vehicles[0]['vehicle_id'];
213
-        }
214
-        $vehicle = null;
211
+		if (is_array($vehicles) && isset($vehicles[0]) && is_array($vehicles[0]) && isset($vehicles[0]['vehicle_id'])) {
212
+			self::$vehicle_id = $vehicles[0]['vehicle_id'];
213
+		}
214
+		$vehicle = null;
215 215
     
216
-        $this->assertNotNull(self::$vehicle_id);
217
-
218
-        $schedules = new Schedules();
219
-        self::$route_schedule = $schedules->updateRouteSchedule(self::$route_id, [
220
-            'schedule_uid' => self::$route_schedule->schedule_uid,
221
-            'member_id' => self::$member_id,
222
-            'vehicle_id' => self::$vehicle_id
223
-        ]);
224
-
225
-        $this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
226
-        $this->assertEquals(self::$route_schedule->member_id, self::$member_id);
227
-    }
228
-
229
-    public function testrReplaceRouteScheduleMustReturnRouteScahedule() : void
230
-    {
231
-        $schedules = new Schedules();
232
-        self::$route_schedule = $schedules->replaceRouteSchedule(self::$route_id, [
233
-            'schedule_uid' => self::$route_schedule->schedule_uid,
234
-            'member_id' => self::$member_id,
235
-            'vehicle_id' => self::$vehicle_id
236
-        ]);
237
-
238
-        $this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
239
-        $this->assertEquals(self::$route_schedule->member_id, self::$member_id);
240
-    }
241
-
242
-    public function testGetRouteSchedulePreviewMustReturnArray() : void
243
-    {
244
-        $schedules = new Schedules();
245
-        $start = '2022-01-01';
246
-        $end = '2023-12-31';
247
-        $result = $schedules->getRouteSchedulePreview(self::$route_id, $start, $end);
248
-
249
-        $this->assertIsArray($result);
250
-    }
251
-
252
-    public function testIsScheduledRouteCopyMustReturnBool() : void
253
-    {
254
-        $schedules = new Schedules();
255
-        $result = $schedules->isScheduledRouteCopy(self::$route_id);
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 testDeleteRouteSchedulesMustReturnTrue() : 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 function testDeleteRouteScheduleMustReturnDeletedRouteScahedule() : void
308
-    {
309
-        $schedules = new Schedules();
310
-        self::$schedule = $schedules->createSchedule([
311
-            'name' => 'The bestest schedule',
312
-            'schedule_blacklist' => [],
313
-            'schedule' => null,
314
-            'timezone' => 'UTC'
315
-        ]);
316
-
317
-        self::$route_schedule = $schedules->createRouteSchedule([
318
-            'route_id' => self::$route_id,
319
-            'schedule_uid' => self::$schedule->schedule_uid
320
-        ]);
321
-
322
-        $res_route_schedule = $schedules->deleteRouteSchedule(self::$route_schedule->route_id);
323
-
324
-        $this->assertInstanceOf(RouteSchedule::class, $res_route_schedule);
325
-
326
-        self::$schedule = null;
327
-        self::$route_schedule = null;
328
-    }
329
-
330
-    public static function tearDownAfterClass() : void
331
-    {
332
-        if (!is_null(self::$schedule)) {
333
-            $schedules = new Schedules();
334
-            $result = $schedules->deleteSchedule(self::$schedule->schedule_uid);
335
-            self::assertInstanceOf(Schedule::class, $result);
336
-        }
337
-        if (!is_null(self::$route_schedule)) {
338
-            $schedules = new Schedules();
339
-            $result = $schedules->deleteRouteSchedule(self::$route_schedule->route_id);
340
-            self::assertInstanceOf(RouteSchedule::class, $result);
341
-        }
342
-    }
216
+		$this->assertNotNull(self::$vehicle_id);
217
+
218
+		$schedules = new Schedules();
219
+		self::$route_schedule = $schedules->updateRouteSchedule(self::$route_id, [
220
+			'schedule_uid' => self::$route_schedule->schedule_uid,
221
+			'member_id' => self::$member_id,
222
+			'vehicle_id' => self::$vehicle_id
223
+		]);
224
+
225
+		$this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
226
+		$this->assertEquals(self::$route_schedule->member_id, self::$member_id);
227
+	}
228
+
229
+	public function testrReplaceRouteScheduleMustReturnRouteScahedule() : void
230
+	{
231
+		$schedules = new Schedules();
232
+		self::$route_schedule = $schedules->replaceRouteSchedule(self::$route_id, [
233
+			'schedule_uid' => self::$route_schedule->schedule_uid,
234
+			'member_id' => self::$member_id,
235
+			'vehicle_id' => self::$vehicle_id
236
+		]);
237
+
238
+		$this->assertInstanceOf(RouteSchedule::class, self::$route_schedule);
239
+		$this->assertEquals(self::$route_schedule->member_id, self::$member_id);
240
+	}
241
+
242
+	public function testGetRouteSchedulePreviewMustReturnArray() : void
243
+	{
244
+		$schedules = new Schedules();
245
+		$start = '2022-01-01';
246
+		$end = '2023-12-31';
247
+		$result = $schedules->getRouteSchedulePreview(self::$route_id, $start, $end);
248
+
249
+		$this->assertIsArray($result);
250
+	}
251
+
252
+	public function testIsScheduledRouteCopyMustReturnBool() : void
253
+	{
254
+		$schedules = new Schedules();
255
+		$result = $schedules->isScheduledRouteCopy(self::$route_id);
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 testDeleteRouteSchedulesMustReturnTrue() : 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 function testDeleteRouteScheduleMustReturnDeletedRouteScahedule() : void
308
+	{
309
+		$schedules = new Schedules();
310
+		self::$schedule = $schedules->createSchedule([
311
+			'name' => 'The bestest schedule',
312
+			'schedule_blacklist' => [],
313
+			'schedule' => null,
314
+			'timezone' => 'UTC'
315
+		]);
316
+
317
+		self::$route_schedule = $schedules->createRouteSchedule([
318
+			'route_id' => self::$route_id,
319
+			'schedule_uid' => self::$schedule->schedule_uid
320
+		]);
321
+
322
+		$res_route_schedule = $schedules->deleteRouteSchedule(self::$route_schedule->route_id);
323
+
324
+		$this->assertInstanceOf(RouteSchedule::class, $res_route_schedule);
325
+
326
+		self::$schedule = null;
327
+		self::$route_schedule = null;
328
+	}
329
+
330
+	public static function tearDownAfterClass() : void
331
+	{
332
+		if (!is_null(self::$schedule)) {
333
+			$schedules = new Schedules();
334
+			$result = $schedules->deleteSchedule(self::$schedule->schedule_uid);
335
+			self::assertInstanceOf(Schedule::class, $result);
336
+		}
337
+		if (!is_null(self::$route_schedule)) {
338
+			$schedules = new Schedules();
339
+			$result = $schedules->deleteRouteSchedule(self::$route_schedule->route_id);
340
+			self::assertInstanceOf(RouteSchedule::class, $result);
341
+		}
342
+	}
343 343
 }
Please login to merge, or discard this patch.
UnitTestFiles/Test/V5/AddressBookUnitTests.php 2 patches
Indentation   +653 added lines, -653 removed lines patch added patch discarded remove patch
@@ -20,658 +20,658 @@
 block discarded – undo
20 20
 
21 21
 final class AddressBookUnitTests extends \PHPUnit\Framework\TestCase
22 22
 {
23
-    public static $createdAdddressIds = [];
24
-
25
-    public static function setUpBeforeClass() : void
26
-    {
27
-        Route4Me::setApiKey(Constants::API_KEY);
28
-    }
29
-
30
-    public function testAddressCanBeCreateFromArray() : void
31
-    {
32
-        $this->assertInstanceOf(Address::class, new Address([
33
-            'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514',
34
-            'cached_lat' => 38.024654,
35
-            'cached_lng' => 77.338814,
36
-            'address_stop_type' => 'DELIVERY'
37
-        ]));
38
-    }
39
-
40
-    public function testAddressCanBeCreateFromParams() : void
41
-    {
42
-        $this->assertInstanceOf(Address::class, new Address(
43
-            '17205 RICHMOND TNPK, MILFORD, VA, 22514',
44
-            38.024654,
45
-            77.338814,
46
-            'DELIVERY'
47
-        ));
48
-    }
49
-
50
-    public function testAssignedToCanBeCreateEmpty() : void
51
-    {
52
-        $this->assertInstanceOf(AssignedTo::class, new AssignedTo());
53
-    }
54
-
55
-    public function testAssignedToCanBeCreateFromArray() : void
56
-    {
57
-        $this->assertInstanceOf(AssignedTo::class, new AssignedTo([
58
-            'member_id' => '1',
59
-            'member_first_name' => 'John Doe'
60
-        ]));
61
-    }
62
-
63
-    public function testClusterCanBeCreateEmpty() : void
64
-    {
65
-        $this->assertInstanceOf(Cluster::class, new Cluster());
66
-    }
67
-
68
-    public function testClusterCanBeCreateFromArray() : void
69
-    {
70
-        $this->assertInstanceOf(Cluster::class, new Cluster([
71
-            'geohash' => '1gmlagrpoarepker',
72
-            'lat' => 34.3456
73
-        ]));
74
-    }
75
-
76
-    public function testResponseAddressCanBeCreateEmpty() : void
77
-    {
78
-        $this->assertInstanceOf(ResponseAddress::class, new ResponseAddress());
79
-    }
80
-
81
-    public function testResponseAddressCanBeCreateFromArray() : void
82
-    {
83
-        $this->assertInstanceOf(ResponseAddress::class, new ResponseAddress([
84
-            'created_timestamp' => 15,
85
-            'address_id' => 1234567,
86
-            'schedule' => [
87
-                'enable' => true,
88
-                'mode' => 'monthly'
89
-            ],
90
-            'assigned_to' => [
91
-                'member_id' => 123453,
92
-                'member_first_name' => 'Jane Doe'
93
-            ]
94
-        ]));
95
-    }
96
-
97
-    public function testResponseAddressCanBeCreateFromArrayAndObjects() : void
98
-    {
99
-        $this->assertInstanceOf(ResponseAddress::class, new ResponseAddress([
100
-            'created_timestamp' => 15,
101
-            'address_id' => 1234567,
102
-            'schedule' => new ScheduleItem(),
103
-            'assigned_to' => new AssignedTo()
104
-        ]));
105
-    }
106
-
107
-    public function testResponseAllCanBeCreateEmpty() : void
108
-    {
109
-        $this->assertInstanceOf(ResponseAll::class, new ResponseAll());
110
-    }
111
-
112
-    public function testResponseAllCanBeCreateFromArray() : void
113
-    {
114
-        $this->assertInstanceOf(ResponseAll::class, new ResponseAll([
115
-            'results' => [[
116
-                'created_timestamp' => 1,
117
-                'address_id' => 11
118
-            ], [
119
-                'created_timestamp' => 2,
120
-                'address_id' => 22
121
-            ]],
122
-            'total' => 0
123
-        ]));
124
-    }
125
-
126
-    public function testResponseAllCanBeCreateFromArrayAndResponseAddresses() : void
127
-    {
128
-        $this->assertInstanceOf(ResponseAll::class, new ResponseAll([
129
-            'results' => [
130
-                new ResponseAddress(),
131
-                new ResponseAddress(),
132
-            ],
133
-            'total' => 0
134
-        ]));
135
-    }
136
-
137
-    public function testResponseClusterCanBeCreateEmpty() : void
138
-    {
139
-        $this->assertInstanceOf(ResponseCluster::class, new ResponseCluster());
140
-    }
141
-
142
-    public function testResponseClusterCanBeCreateFromArrays() : void
143
-    {
144
-        $this->assertInstanceOf(ResponseCluster::class, new ResponseCluster([
145
-            'cluster' => [
146
-                'geohash' => 'tipageohash',
147
-                'lat' => 123.5657
148
-            ],
149
-            'address_count' => 1
150
-        ]));
151
-    }
152
-
153
-    public function testResponseClusterCanBeCreateFromArrayAndCluster() : void
154
-    {
155
-        $this->assertInstanceOf(ResponseCluster::class, new ResponseCluster([
156
-            'cluster' => new Cluster(),
157
-            'address_count' => 1
158
-        ]));
159
-    }
160
-
161
-    public function testResponseClusteringCanBeCreateEmpty() : void
162
-    {
163
-        $this->assertInstanceOf(ResponseClustering::class, new ResponseClustering());
164
-    }
165
-
166
-    public function testResponseClusteringCanBeCreateFromArrays() : void
167
-    {
168
-        $this->assertInstanceOf(ResponseClustering::class, new ResponseClustering([
169
-            'clusters' => [[
170
-                'geohash' => 'tipageohash',
171
-                'lat' => 123.5657
172
-            ], [
173
-                'geohash' => 'tipageohashtoo',
174
-                'lat' => 23.56578
175
-            ]],
176
-            'total' => 2
177
-        ]));
178
-    }
179
-
180
-    public function testResponseClusteringCanBeCreateFromArrayAndClusters() : void
181
-    {
182
-        $this->assertInstanceOf(ResponseClustering::class, new ResponseClustering([
183
-            'clusters' => [
184
-                new Cluster(),
185
-                new Cluster()
186
-            ],
187
-            'total' => 2
188
-        ]));
189
-    }
190
-
191
-    public function testResponsePaginationCanBeCreateEmpty() : void
192
-    {
193
-        $this->assertInstanceOf(ResponsePagination::class, new ResponsePagination());
194
-    }
195
-
196
-    public function testResponsePaginationCanBeCreateFromArray() : void
197
-    {
198
-        $this->assertInstanceOf(ResponsePagination::class, new ResponsePagination([
199
-            'current_page' => 1,
200
-            'last_page' => 2
201
-        ]));
202
-    }
203
-
204
-    public function testScheduleItemCanBeCreateEmpty() : void
205
-    {
206
-        $this->assertInstanceOf(ScheduleItem::class, new ScheduleItem());
207
-    }
208
-
209
-    public function testScheduleItemCanBeCreateFromArray() : void
210
-    {
211
-        $this->assertInstanceOf(ScheduleItem::class, new ScheduleItem([
212
-            'enable' => true,
213
-            'mode' => 'monthly'
214
-        ]));
215
-    }
216
-
217
-    public function testStatusCheckerCanBeCreateEmpty() : void
218
-    {
219
-        $this->assertInstanceOf(StatusChecker::class, new StatusChecker());
220
-    }
221
-
222
-    public function testStatusCheckerCanBeCreateFromArray() : void
223
-    {
224
-        $this->assertInstanceOf(StatusChecker::class, new StatusChecker([
225
-            'code' => 200,
226
-            'data' => []
227
-        ]));
228
-    }
229
-
230
-    public function testUpdateAddressCanBeCreateFromParam() : void
231
-    {
232
-        $this->assertInstanceOf(UpdateAddress::class, new UpdateAddress(15));
233
-    }
234
-
235
-    public function testAddressBookCanBeCreateEmpty() : void
236
-    {
237
-        $this->assertInstanceOf(AddressBook::class, new AddressBook());
238
-    }
239
-
240
-    public function testAddAddressGetArrayMustReturnResponseAddress() : void
241
-    {
242
-        $addr_book = new AddressBook();
243
-        $res_addr = $addr_book->addAddress([
244
-            'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514',
245
-            'cached_lat' => 38.024654,
246
-            'cached_lng' => 77.338814,
247
-            'address_stop_type' => 'DELIVERY',
248
-            'address_city' => 'Tbilisi Vah',
249
-            'first_name' => 'Tusha I',
250
-            'last_name' => 'Grigoriani'
251
-        ]);
252
-
253
-        $this->assertInstanceOf(ResponseAddress::class, $res_addr);
254
-        $this->assertNotNull($res_addr->address_id);
255
-        $this->assertEquals($res_addr->first_name, 'Tusha I');
256
-
257
-        self::$createdAdddressIds[] = $res_addr->address_id;
258
-    }
259
-
260
-    public function testAddAddressGetAddressMustReturnResponseAddress() : void
261
-    {
262
-        $addr_book = new AddressBook();
263
-        $addr = new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY');
264
-        $addr->first_name = 'Tusha I';
265
-        $res_addr = $addr_book->addAddress($addr);
266
-
267
-        $this->assertInstanceOf(Address::class, $addr);
268
-        $this->assertEquals($addr->first_name, 'Tusha I');
269
-        $this->assertInstanceOf(ResponseAddress::class, $res_addr);
270
-        $this->assertNotNull($res_addr->address_id);
271
-        $this->assertEquals($res_addr->first_name, 'Tusha I');
272
-
273
-        self::$createdAdddressIds[] = $res_addr->address_id;
274
-    }
275
-
276
-    public function testAddMultipleAddressGetArrayMustReturnBool() : void
277
-    {
278
-        $addr_book = new AddressBook();
279
-        $res = $addr_book->addMultipleAddresses([[
280
-            'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514',
281
-            'cached_lat' => 38.024654,
282
-            'cached_lng' => 77.338814,
283
-            'address_stop_type' => 'DELIVERY',
284
-            'address_city' => 'Tbilisi Vah',
285
-            'first_name' => 'Tusha I',
286
-            'last_name' => 'Grigoriani'
287
-        ], [
288
-            'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514',
289
-            'cached_lat' => 38.024654,
290
-            'cached_lng' => 77.338814,
291
-            'address_stop_type' => 'DELIVERY',
292
-            'address_city' => 'Tbilisi Vah',
293
-            'first_name' => 'Tusha II',
294
-            'last_name' => 'Grigoriani'
295
-        ]]);
296
-
297
-        $this->assertIsBool($res);
298
-        $this->assertTrue($res);
299
-    }
300
-
301
-    public function testAddMultipleAddressGetAddressesMustReturnBool() : void
302
-    {
303
-        $addr_book = new AddressBook();
304
-        $addresses = [
305
-            new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY'),
306
-            new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY')
307
-        ];
308
-        $addresses[0]->first_name = 'Tusha I';
309
-        $addresses[1]->first_name = 'Tusha II';
310
-        $res = $addr_book->addMultipleAddresses($addresses);
311
-
312
-        $this->assertIsBool($res);
313
-        $this->assertTrue($res);
314
-    }
315
-
316
-    public function testGetAddressesMustReturnResponseAll() : void
317
-    {
318
-        $options = [
319
-            'fields' => "address_id, address_1, first_name, last_name, address_city",
320
-            'query' => 'Tusha',
321
-            'limit' => 5,
322
-            'offset' => 0
323
-        ];
324
-        $addr_book = new AddressBook();
325
-        $result = $addr_book->getAddresses($options);
326
-
327
-        $this->assertInstanceOf(ResponseAll::class, $result);
328
-        $this->assertNotNull($result->fields);
329
-        $this->assertIsArray($result->results);
330
-        $this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
331
-    }
332
-
333
-    public function testGetAddressesByBodyPayloadMustReturnResponseAll() : void
334
-    {
335
-        $options = [
336
-            'filter' => [
337
-                'query' => 'Tusha',
338
-                'selected_areas' => [[
339
-                    'type' => 'circle',
340
-                    'value' => [
341
-                        'center' => [
342
-                            'lat' => 38.024654,
343
-                            'lng' => 77.338814
344
-                            ],
345
-                        'distance' => 10000
346
-                    ]
347
-                ]]
348
-            ],
349
-            'limit' => 5,
350
-            'offset' => 0
351
-        ];
352
-        $addr_book = new AddressBook();
353
-        $result = $addr_book->getAddressesByBodyPayload($options);
354
-
355
-        $this->assertInstanceOf(ResponseAll::class, $result);
356
-        $this->assertIsArray($result->results);
357
-        $this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
358
-    }
359
-
360
-    public function testGetAddressesPaginatedMustReturnResponsePaginated() : void
361
-    {
362
-        $options = [
363
-            'fields' => "address_id, address_1, first_name, last_name, address_city",
364
-            'query' => 'Tusha',
365
-            'per_page' => 5,
366
-            'page' => 0
367
-        ];
368
-        $addr_book = new AddressBook();
369
-        $result = $addr_book->getAddressesPaginated($options);
370
-
371
-        $this->assertInstanceOf(ResponsePagination::class, $result);
372
-        $this->assertNotNull($result->fields);
373
-        $this->assertNotNull($result->current_page);
374
-        $this->assertIsArray($result->results);
375
-        $this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
376
-    }
377
-
378
-    public function testGetAddressesPaginatedByBodyPayloadMustReturnResponsePaginated() : void
379
-    {
380
-        $options = [
381
-            'filter' => [
382
-                'query' => 'Tusha',
383
-                'selected_areas' => [[
384
-                    'type' => 'circle',
385
-                    'value' => [
386
-                        'center' => [
387
-                            'lat' => 52.4025,
388
-                            'lng' => 4.5601
389
-                        ],
390
-                        'distance' => 10000
391
-                    ]
392
-                ]]
393
-            ],
394
-            'page' => 2,
395
-            'per_page' => 10
396
-        ];
397
-        $addr_book = new AddressBook();
398
-        $result = $addr_book->getAddressesPaginatedByBodyPayload($options);
399
-
400
-        $this->assertInstanceOf(ResponsePagination::class, $result);
401
-        $this->assertNotNull($result->current_page);
402
-        $this->assertIsArray($result->results);
403
-        if (count($result->results) > 0) {
404
-            $this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
405
-        }
406
-    }
407
-
408
-    public function testGetAddressClustersMustReturnResponseClustering() : void
409
-    {
410
-        $options = [
411
-            'display' => 'unrouted',
412
-            'query' => 'Tusha'
413
-        ];
414
-        $addr_book = new AddressBook();
415
-        $result = $addr_book->getAddressClusters($options);
416
-
417
-        $this->assertInstanceOf(ResponseClustering::class, $result);
418
-        $this->assertIsArray($result->clusters);
419
-        $this->assertInstanceOf(Cluster::class, $result->clusters[0]);
420
-    }
421
-
422
-    public function testGetAddressClustersByBodyPayloadMustReturnResponseClustering() : void
423
-    {
424
-        $options = [
425
-            'clustering' => [
426
-                'precision' => 2
427
-            ],
428
-            'filter' => [
429
-                'query' => 'Tusha',
430
-                'selected_areas' => [[
431
-                    'type' => 'circle',
432
-                    'value' => [
433
-                        'center' => [
434
-                            'lat' => 52.4025,
435
-                            'lng' => 4.5601
436
-                        ],
437
-                        'distance' => 10000
438
-                    ]
439
-                ]]
440
-            ]
441
-        ];
442
-        $addr_book = new AddressBook();
443
-        $result = $addr_book->getAddressClustersByBodyPayload($options);
444
-
445
-        $this->assertInstanceOf(ResponseClustering::class, $result);
446
-        $this->assertIsArray($result->clusters);
447
-    }
448
-
449
-    public function testGetAddressByIdMustReturnResponseAddress() : void
450
-    {
451
-        $addr_book = new AddressBook();
452
-        $result = $addr_book->getAddressById(self::$createdAdddressIds[0]);
453
-
454
-        $this->assertInstanceOf(ResponseAddress::class, $result);
455
-        $this->assertIsInt($result->address_id);
456
-    }
457
-
458
-    public function testGetAddressesByIdsMustReturnResponseAddress() : void
459
-    {
460
-        $addr_book = new AddressBook();
461
-        $result = $addr_book->getAddressesByIds(self::$createdAdddressIds);
462
-
463
-        $this->assertInstanceOf(ResponseAll::class, $result);
464
-        $this->assertIsArray($result->results);
465
-        $this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
466
-        $this->assertIsInt($result->results[0]->address_id);
467
-    }
468
-
469
-    public function testUpdateAddressByIdMustReturnResponseAddress() : void
470
-    {
471
-        $addr_book = new AddressBook();
472
-        $result = $addr_book->updateAddressById(self::$createdAdddressIds[0], ['last_name' => 'Grigoriani III']);
473
-
474
-        $this->assertInstanceOf(ResponseAddress::class, $result);
475
-        $this->assertEqualsCanonicalizing($result->last_name, 'Grigoriani III');
476
-    }
477
-
478
-    public function testUpdateAddressesByIdsMustReturnArray() : void
479
-    {
480
-        $addr_book = new AddressBook();
481
-        $result = $addr_book->updateAddressesByIds(self::$createdAdddressIds, ['last_name' => 'Grigoriani IV']);
482
-
483
-        $this->assertIsArray($result);
484
-        $this->assertInstanceOf(ResponseAddress::class, $result[0]);
485
-        $this->assertEqualsCanonicalizing($result[0]->last_name, 'Grigoriani IV');
486
-    }
487
-
488
-    // TODO: request has uncheckable result - 403 forbidden
489
-    public function testUpdateAddressesByAreasMustReturnStatusChecker() : void
490
-    {
491
-        $addr_book = new AddressBook();
492
-        $filter = [
493
-            'query' => "Tusha",
494
-            'bounding_box' => null,
495
-            'selected_areas' => [[
496
-                'type' => 'circle',
497
-                'value' => [
498
-                    'center' => [
499
-                        'lat' => 38.024654,
500
-                        'lng' => 77.338814
501
-                    ],
502
-                    'distance' => 10000
503
-                ]
504
-            ]]
505
-        ];
23
+	public static $createdAdddressIds = [];
24
+
25
+	public static function setUpBeforeClass() : void
26
+	{
27
+		Route4Me::setApiKey(Constants::API_KEY);
28
+	}
29
+
30
+	public function testAddressCanBeCreateFromArray() : void
31
+	{
32
+		$this->assertInstanceOf(Address::class, new Address([
33
+			'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514',
34
+			'cached_lat' => 38.024654,
35
+			'cached_lng' => 77.338814,
36
+			'address_stop_type' => 'DELIVERY'
37
+		]));
38
+	}
39
+
40
+	public function testAddressCanBeCreateFromParams() : void
41
+	{
42
+		$this->assertInstanceOf(Address::class, new Address(
43
+			'17205 RICHMOND TNPK, MILFORD, VA, 22514',
44
+			38.024654,
45
+			77.338814,
46
+			'DELIVERY'
47
+		));
48
+	}
49
+
50
+	public function testAssignedToCanBeCreateEmpty() : void
51
+	{
52
+		$this->assertInstanceOf(AssignedTo::class, new AssignedTo());
53
+	}
54
+
55
+	public function testAssignedToCanBeCreateFromArray() : void
56
+	{
57
+		$this->assertInstanceOf(AssignedTo::class, new AssignedTo([
58
+			'member_id' => '1',
59
+			'member_first_name' => 'John Doe'
60
+		]));
61
+	}
62
+
63
+	public function testClusterCanBeCreateEmpty() : void
64
+	{
65
+		$this->assertInstanceOf(Cluster::class, new Cluster());
66
+	}
67
+
68
+	public function testClusterCanBeCreateFromArray() : void
69
+	{
70
+		$this->assertInstanceOf(Cluster::class, new Cluster([
71
+			'geohash' => '1gmlagrpoarepker',
72
+			'lat' => 34.3456
73
+		]));
74
+	}
75
+
76
+	public function testResponseAddressCanBeCreateEmpty() : void
77
+	{
78
+		$this->assertInstanceOf(ResponseAddress::class, new ResponseAddress());
79
+	}
80
+
81
+	public function testResponseAddressCanBeCreateFromArray() : void
82
+	{
83
+		$this->assertInstanceOf(ResponseAddress::class, new ResponseAddress([
84
+			'created_timestamp' => 15,
85
+			'address_id' => 1234567,
86
+			'schedule' => [
87
+				'enable' => true,
88
+				'mode' => 'monthly'
89
+			],
90
+			'assigned_to' => [
91
+				'member_id' => 123453,
92
+				'member_first_name' => 'Jane Doe'
93
+			]
94
+		]));
95
+	}
96
+
97
+	public function testResponseAddressCanBeCreateFromArrayAndObjects() : void
98
+	{
99
+		$this->assertInstanceOf(ResponseAddress::class, new ResponseAddress([
100
+			'created_timestamp' => 15,
101
+			'address_id' => 1234567,
102
+			'schedule' => new ScheduleItem(),
103
+			'assigned_to' => new AssignedTo()
104
+		]));
105
+	}
106
+
107
+	public function testResponseAllCanBeCreateEmpty() : void
108
+	{
109
+		$this->assertInstanceOf(ResponseAll::class, new ResponseAll());
110
+	}
111
+
112
+	public function testResponseAllCanBeCreateFromArray() : void
113
+	{
114
+		$this->assertInstanceOf(ResponseAll::class, new ResponseAll([
115
+			'results' => [[
116
+				'created_timestamp' => 1,
117
+				'address_id' => 11
118
+			], [
119
+				'created_timestamp' => 2,
120
+				'address_id' => 22
121
+			]],
122
+			'total' => 0
123
+		]));
124
+	}
125
+
126
+	public function testResponseAllCanBeCreateFromArrayAndResponseAddresses() : void
127
+	{
128
+		$this->assertInstanceOf(ResponseAll::class, new ResponseAll([
129
+			'results' => [
130
+				new ResponseAddress(),
131
+				new ResponseAddress(),
132
+			],
133
+			'total' => 0
134
+		]));
135
+	}
136
+
137
+	public function testResponseClusterCanBeCreateEmpty() : void
138
+	{
139
+		$this->assertInstanceOf(ResponseCluster::class, new ResponseCluster());
140
+	}
141
+
142
+	public function testResponseClusterCanBeCreateFromArrays() : void
143
+	{
144
+		$this->assertInstanceOf(ResponseCluster::class, new ResponseCluster([
145
+			'cluster' => [
146
+				'geohash' => 'tipageohash',
147
+				'lat' => 123.5657
148
+			],
149
+			'address_count' => 1
150
+		]));
151
+	}
152
+
153
+	public function testResponseClusterCanBeCreateFromArrayAndCluster() : void
154
+	{
155
+		$this->assertInstanceOf(ResponseCluster::class, new ResponseCluster([
156
+			'cluster' => new Cluster(),
157
+			'address_count' => 1
158
+		]));
159
+	}
160
+
161
+	public function testResponseClusteringCanBeCreateEmpty() : void
162
+	{
163
+		$this->assertInstanceOf(ResponseClustering::class, new ResponseClustering());
164
+	}
165
+
166
+	public function testResponseClusteringCanBeCreateFromArrays() : void
167
+	{
168
+		$this->assertInstanceOf(ResponseClustering::class, new ResponseClustering([
169
+			'clusters' => [[
170
+				'geohash' => 'tipageohash',
171
+				'lat' => 123.5657
172
+			], [
173
+				'geohash' => 'tipageohashtoo',
174
+				'lat' => 23.56578
175
+			]],
176
+			'total' => 2
177
+		]));
178
+	}
179
+
180
+	public function testResponseClusteringCanBeCreateFromArrayAndClusters() : void
181
+	{
182
+		$this->assertInstanceOf(ResponseClustering::class, new ResponseClustering([
183
+			'clusters' => [
184
+				new Cluster(),
185
+				new Cluster()
186
+			],
187
+			'total' => 2
188
+		]));
189
+	}
190
+
191
+	public function testResponsePaginationCanBeCreateEmpty() : void
192
+	{
193
+		$this->assertInstanceOf(ResponsePagination::class, new ResponsePagination());
194
+	}
195
+
196
+	public function testResponsePaginationCanBeCreateFromArray() : void
197
+	{
198
+		$this->assertInstanceOf(ResponsePagination::class, new ResponsePagination([
199
+			'current_page' => 1,
200
+			'last_page' => 2
201
+		]));
202
+	}
203
+
204
+	public function testScheduleItemCanBeCreateEmpty() : void
205
+	{
206
+		$this->assertInstanceOf(ScheduleItem::class, new ScheduleItem());
207
+	}
208
+
209
+	public function testScheduleItemCanBeCreateFromArray() : void
210
+	{
211
+		$this->assertInstanceOf(ScheduleItem::class, new ScheduleItem([
212
+			'enable' => true,
213
+			'mode' => 'monthly'
214
+		]));
215
+	}
216
+
217
+	public function testStatusCheckerCanBeCreateEmpty() : void
218
+	{
219
+		$this->assertInstanceOf(StatusChecker::class, new StatusChecker());
220
+	}
221
+
222
+	public function testStatusCheckerCanBeCreateFromArray() : void
223
+	{
224
+		$this->assertInstanceOf(StatusChecker::class, new StatusChecker([
225
+			'code' => 200,
226
+			'data' => []
227
+		]));
228
+	}
229
+
230
+	public function testUpdateAddressCanBeCreateFromParam() : void
231
+	{
232
+		$this->assertInstanceOf(UpdateAddress::class, new UpdateAddress(15));
233
+	}
234
+
235
+	public function testAddressBookCanBeCreateEmpty() : void
236
+	{
237
+		$this->assertInstanceOf(AddressBook::class, new AddressBook());
238
+	}
239
+
240
+	public function testAddAddressGetArrayMustReturnResponseAddress() : void
241
+	{
242
+		$addr_book = new AddressBook();
243
+		$res_addr = $addr_book->addAddress([
244
+			'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514',
245
+			'cached_lat' => 38.024654,
246
+			'cached_lng' => 77.338814,
247
+			'address_stop_type' => 'DELIVERY',
248
+			'address_city' => 'Tbilisi Vah',
249
+			'first_name' => 'Tusha I',
250
+			'last_name' => 'Grigoriani'
251
+		]);
252
+
253
+		$this->assertInstanceOf(ResponseAddress::class, $res_addr);
254
+		$this->assertNotNull($res_addr->address_id);
255
+		$this->assertEquals($res_addr->first_name, 'Tusha I');
256
+
257
+		self::$createdAdddressIds[] = $res_addr->address_id;
258
+	}
259
+
260
+	public function testAddAddressGetAddressMustReturnResponseAddress() : void
261
+	{
262
+		$addr_book = new AddressBook();
263
+		$addr = new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY');
264
+		$addr->first_name = 'Tusha I';
265
+		$res_addr = $addr_book->addAddress($addr);
266
+
267
+		$this->assertInstanceOf(Address::class, $addr);
268
+		$this->assertEquals($addr->first_name, 'Tusha I');
269
+		$this->assertInstanceOf(ResponseAddress::class, $res_addr);
270
+		$this->assertNotNull($res_addr->address_id);
271
+		$this->assertEquals($res_addr->first_name, 'Tusha I');
272
+
273
+		self::$createdAdddressIds[] = $res_addr->address_id;
274
+	}
275
+
276
+	public function testAddMultipleAddressGetArrayMustReturnBool() : void
277
+	{
278
+		$addr_book = new AddressBook();
279
+		$res = $addr_book->addMultipleAddresses([[
280
+			'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514',
281
+			'cached_lat' => 38.024654,
282
+			'cached_lng' => 77.338814,
283
+			'address_stop_type' => 'DELIVERY',
284
+			'address_city' => 'Tbilisi Vah',
285
+			'first_name' => 'Tusha I',
286
+			'last_name' => 'Grigoriani'
287
+		], [
288
+			'address_1' => '17205 RICHMOND TNPK, MILFORD, VA, 22514',
289
+			'cached_lat' => 38.024654,
290
+			'cached_lng' => 77.338814,
291
+			'address_stop_type' => 'DELIVERY',
292
+			'address_city' => 'Tbilisi Vah',
293
+			'first_name' => 'Tusha II',
294
+			'last_name' => 'Grigoriani'
295
+		]]);
296
+
297
+		$this->assertIsBool($res);
298
+		$this->assertTrue($res);
299
+	}
300
+
301
+	public function testAddMultipleAddressGetAddressesMustReturnBool() : void
302
+	{
303
+		$addr_book = new AddressBook();
304
+		$addresses = [
305
+			new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY'),
306
+			new Address('17205 Tbilisi Vah, GEORGIAN, GE, 22514', 38.024654, 77.338814, 'DELIVERY')
307
+		];
308
+		$addresses[0]->first_name = 'Tusha I';
309
+		$addresses[1]->first_name = 'Tusha II';
310
+		$res = $addr_book->addMultipleAddresses($addresses);
311
+
312
+		$this->assertIsBool($res);
313
+		$this->assertTrue($res);
314
+	}
315
+
316
+	public function testGetAddressesMustReturnResponseAll() : void
317
+	{
318
+		$options = [
319
+			'fields' => "address_id, address_1, first_name, last_name, address_city",
320
+			'query' => 'Tusha',
321
+			'limit' => 5,
322
+			'offset' => 0
323
+		];
324
+		$addr_book = new AddressBook();
325
+		$result = $addr_book->getAddresses($options);
326
+
327
+		$this->assertInstanceOf(ResponseAll::class, $result);
328
+		$this->assertNotNull($result->fields);
329
+		$this->assertIsArray($result->results);
330
+		$this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
331
+	}
332
+
333
+	public function testGetAddressesByBodyPayloadMustReturnResponseAll() : void
334
+	{
335
+		$options = [
336
+			'filter' => [
337
+				'query' => 'Tusha',
338
+				'selected_areas' => [[
339
+					'type' => 'circle',
340
+					'value' => [
341
+						'center' => [
342
+							'lat' => 38.024654,
343
+							'lng' => 77.338814
344
+							],
345
+						'distance' => 10000
346
+					]
347
+				]]
348
+			],
349
+			'limit' => 5,
350
+			'offset' => 0
351
+		];
352
+		$addr_book = new AddressBook();
353
+		$result = $addr_book->getAddressesByBodyPayload($options);
354
+
355
+		$this->assertInstanceOf(ResponseAll::class, $result);
356
+		$this->assertIsArray($result->results);
357
+		$this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
358
+	}
359
+
360
+	public function testGetAddressesPaginatedMustReturnResponsePaginated() : void
361
+	{
362
+		$options = [
363
+			'fields' => "address_id, address_1, first_name, last_name, address_city",
364
+			'query' => 'Tusha',
365
+			'per_page' => 5,
366
+			'page' => 0
367
+		];
368
+		$addr_book = new AddressBook();
369
+		$result = $addr_book->getAddressesPaginated($options);
370
+
371
+		$this->assertInstanceOf(ResponsePagination::class, $result);
372
+		$this->assertNotNull($result->fields);
373
+		$this->assertNotNull($result->current_page);
374
+		$this->assertIsArray($result->results);
375
+		$this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
376
+	}
377
+
378
+	public function testGetAddressesPaginatedByBodyPayloadMustReturnResponsePaginated() : void
379
+	{
380
+		$options = [
381
+			'filter' => [
382
+				'query' => 'Tusha',
383
+				'selected_areas' => [[
384
+					'type' => 'circle',
385
+					'value' => [
386
+						'center' => [
387
+							'lat' => 52.4025,
388
+							'lng' => 4.5601
389
+						],
390
+						'distance' => 10000
391
+					]
392
+				]]
393
+			],
394
+			'page' => 2,
395
+			'per_page' => 10
396
+		];
397
+		$addr_book = new AddressBook();
398
+		$result = $addr_book->getAddressesPaginatedByBodyPayload($options);
399
+
400
+		$this->assertInstanceOf(ResponsePagination::class, $result);
401
+		$this->assertNotNull($result->current_page);
402
+		$this->assertIsArray($result->results);
403
+		if (count($result->results) > 0) {
404
+			$this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
405
+		}
406
+	}
407
+
408
+	public function testGetAddressClustersMustReturnResponseClustering() : void
409
+	{
410
+		$options = [
411
+			'display' => 'unrouted',
412
+			'query' => 'Tusha'
413
+		];
414
+		$addr_book = new AddressBook();
415
+		$result = $addr_book->getAddressClusters($options);
416
+
417
+		$this->assertInstanceOf(ResponseClustering::class, $result);
418
+		$this->assertIsArray($result->clusters);
419
+		$this->assertInstanceOf(Cluster::class, $result->clusters[0]);
420
+	}
421
+
422
+	public function testGetAddressClustersByBodyPayloadMustReturnResponseClustering() : void
423
+	{
424
+		$options = [
425
+			'clustering' => [
426
+				'precision' => 2
427
+			],
428
+			'filter' => [
429
+				'query' => 'Tusha',
430
+				'selected_areas' => [[
431
+					'type' => 'circle',
432
+					'value' => [
433
+						'center' => [
434
+							'lat' => 52.4025,
435
+							'lng' => 4.5601
436
+						],
437
+						'distance' => 10000
438
+					]
439
+				]]
440
+			]
441
+		];
442
+		$addr_book = new AddressBook();
443
+		$result = $addr_book->getAddressClustersByBodyPayload($options);
444
+
445
+		$this->assertInstanceOf(ResponseClustering::class, $result);
446
+		$this->assertIsArray($result->clusters);
447
+	}
448
+
449
+	public function testGetAddressByIdMustReturnResponseAddress() : void
450
+	{
451
+		$addr_book = new AddressBook();
452
+		$result = $addr_book->getAddressById(self::$createdAdddressIds[0]);
453
+
454
+		$this->assertInstanceOf(ResponseAddress::class, $result);
455
+		$this->assertIsInt($result->address_id);
456
+	}
457
+
458
+	public function testGetAddressesByIdsMustReturnResponseAddress() : void
459
+	{
460
+		$addr_book = new AddressBook();
461
+		$result = $addr_book->getAddressesByIds(self::$createdAdddressIds);
462
+
463
+		$this->assertInstanceOf(ResponseAll::class, $result);
464
+		$this->assertIsArray($result->results);
465
+		$this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
466
+		$this->assertIsInt($result->results[0]->address_id);
467
+	}
468
+
469
+	public function testUpdateAddressByIdMustReturnResponseAddress() : void
470
+	{
471
+		$addr_book = new AddressBook();
472
+		$result = $addr_book->updateAddressById(self::$createdAdddressIds[0], ['last_name' => 'Grigoriani III']);
473
+
474
+		$this->assertInstanceOf(ResponseAddress::class, $result);
475
+		$this->assertEqualsCanonicalizing($result->last_name, 'Grigoriani III');
476
+	}
477
+
478
+	public function testUpdateAddressesByIdsMustReturnArray() : void
479
+	{
480
+		$addr_book = new AddressBook();
481
+		$result = $addr_book->updateAddressesByIds(self::$createdAdddressIds, ['last_name' => 'Grigoriani IV']);
482
+
483
+		$this->assertIsArray($result);
484
+		$this->assertInstanceOf(ResponseAddress::class, $result[0]);
485
+		$this->assertEqualsCanonicalizing($result[0]->last_name, 'Grigoriani IV');
486
+	}
487
+
488
+	// TODO: request has uncheckable result - 403 forbidden
489
+	public function testUpdateAddressesByAreasMustReturnStatusChecker() : void
490
+	{
491
+		$addr_book = new AddressBook();
492
+		$filter = [
493
+			'query' => "Tusha",
494
+			'bounding_box' => null,
495
+			'selected_areas' => [[
496
+				'type' => 'circle',
497
+				'value' => [
498
+					'center' => [
499
+						'lat' => 38.024654,
500
+						'lng' => 77.338814
501
+					],
502
+					'distance' => 10000
503
+				]
504
+			]]
505
+		];
506 506
     
507
-        $params = [
508
-            'last_name' => 'Grigoriani V'
509
-        ];
510
-        try {
511
-            $result = $addr_book->updateAddressesByAreas($filter, $params);
512
-
513
-            $this->assertInstanceOf(StatusChecker::class, $result);
514
-        } catch (ApiError $err) {
515
-            $this->assertEquals($err->getCode(), 403);
516
-        }
517
-    }
518
-
519
-    public function testDeleteAddressesByIdsMustReturnStatusChecker() : void
520
-    {
521
-        $addr_book = new AddressBook();
522
-        $result = $addr_book->deleteAddressesByIds(self::$createdAdddressIds);
523
-
524
-        $this->assertInstanceOf(StatusChecker::class, $result);
525
-        $this->assertIsInt($result->code);
526
-    }
527
-
528
-    // TODO: request has uncheckable result - 403 forbidden
529
-    public function testDeleteAddressesByAreasMustReturnStatusChecker() : void
530
-    {
531
-        $addr_book = new AddressBook();
532
-        $filter = [
533
-            'query' => 'Tusha',
534
-            'selected_areas' => [[
535
-                'type' => 'circle',
536
-                'value' => [
537
-                    'center' => [
538
-                        'lat' => 38.024654,
539
-                        'lng' => 77.338814
540
-                    ],
541
-                    'distance' => 10000
542
-                ]
543
-            ]]
544
-        ];
545
-        try {
546
-            $result = $addr_book->deleteAddressesByAreas($filter);
547
-
548
-            $this->assertInstanceOf(StatusChecker::class, $result);
549
-            $this->assertIsInt($result->code);
550
-        } catch (ApiError $err) {
551
-            $this->assertEquals($err->getCode(), 403);
552
-        }
553
-    }
554
-
555
-    public function testGetAddressCustomFieldsMustReturnArray() : void
556
-    {
557
-        $addr_book = new AddressBook();
558
-        $result = $addr_book->getAddressCustomFields();
559
-
560
-        $this->assertIsArray($result);
561
-    }
562
-
563
-    public function testGetAddressDepotsFieldsMustReturnArray() : void
564
-    {
565
-        $addr_book = new AddressBook();
566
-        $result = $addr_book->getAddressesDepots();
567
-
568
-        $this->assertIsArray($result);
569
-    }
570
-
571
-    public function testExportAddressesByIdsMustReturnStatusChecker() : void
572
-    {
573
-        $addr_book = new AddressBook();
574
-        $filename = 'test_export.csv';
575
-        $result = $addr_book->exportAddressesByIds(self::$createdAdddressIds, $filename);
576
-
577
-        $this->assertInstanceOf(StatusChecker::class, $result);
578
-        $this->assertIsInt($result->code);
579
-    }
580
-
581
-    // TODO: request has uncheckable result - 403 forbidden
582
-    public function testExportAddressesByAreasMustReturnStatusChecker() : void
583
-    {
584
-        $addr_book = new AddressBook();
585
-        $filter = [
586
-            'query' => "Tusha",
587
-            'bounding_box' => null,
588
-            'selected_areas' => [[
589
-                'type' => 'circle',
590
-                'value' => [
591
-                    'center' => [
592
-                        'lat' => 38.024654,
593
-                        'lng' => 77.338814
594
-                    ],
595
-                    'distance' => 10000
596
-                ]
597
-            ]],
598
-            'filename' => 'test_export.csv'
599
-        ];
600
-        try {
601
-            $result = $addr_book->exportAddressesByAreas($filter);
602
-
603
-            $this->assertInstanceOf(StatusChecker::class, $result);
604
-            $this->assertIsInt($result->code);
605
-        } catch (ApiError $err) {
606
-            $this->assertEquals($err->getCode(), 403);
607
-        }
608
-    }
609
-
610
-    // TODO: request has uncheckable result - 403 forbidden
611
-    public function testExportAddressesByAreaIdsMustReturnStatusChecker() : void
612
-    {
613
-        $addr_book = new AddressBook();
614
-        $territoryIds = [96100573, 96100961];
615
-        $filename = 'test_export.csv';
616
-        try {
617
-            $result = $addr_book->exportAddressesByAreaIds($territoryIds, $filename);
618
-
619
-            $this->assertInstanceOf(StatusChecker::class, $result);
620
-            $this->assertIsInt($result->code);
621
-        } catch (ApiError $err) {
622
-            $this->assertEquals($err->getCode(), 403);
623
-        }
624
-    }
625
-
626
-    // request has result - 404 not found, bc there is absent a jobId = 96100961
627
-    public function testGetAddressesAsynchronousJobStatusMustReturnStatusChecker() : void
628
-    {
629
-        $addr_book = new AddressBook();
630
-        $jobId = 96100961;
631
-        try {
632
-            $result = $addr_book->getAddressesAsynchronousJobStatus($jobId);
633
-
634
-            $this->assertInstanceOf(StatusChecker::class, $result);
635
-            $this->assertIsInt($result->code);
636
-        } catch (ApiError $err) {
637
-            $this->assertEquals($err->getCode(), 404);
638
-        }
639
-    }
640
-
641
-    // request has result - 404 not found, bc there is absent a jobId = 96100961
642
-    public function testGetAddressesAsynchronousJobResultMustReturnBool() : void
643
-    {
644
-        $addr_book = new AddressBook();
645
-        $jobId = 96100961;
646
-        try {
647
-            $result = $addr_book->getAddressesAsynchronousJobResult($jobId);
648
-
649
-            $this->assertIsBool($result);
650
-        } catch (ApiError $err) {
651
-            $this->assertEquals($err->getCode(), 404);
652
-        }
653
-    }
654
-
655
-    public static function tearDownAfterClass() : void
656
-    {
657
-        sleep(5);
658
-
659
-        $addr_book = new AddressBook();
660
-
661
-        if (count(self::$createdAdddressIds)) {
662
-            $addr_book->deleteAddressesByIds(self::$createdAdddressIds);
663
-        }
664
-
665
-        $res = $addr_book->getAddresses(['query' => 'Tusha']);
666
-        if ($res) {
667
-            $ids = [];
668
-            foreach ($res->results as $key => $value) {
669
-                $ids[] = $value->address_id;
670
-            }
671
-
672
-            if (count($ids)) {
673
-                $addr_book->deleteAddressesByIds($ids);
674
-            }
675
-        }
676
-    }
507
+		$params = [
508
+			'last_name' => 'Grigoriani V'
509
+		];
510
+		try {
511
+			$result = $addr_book->updateAddressesByAreas($filter, $params);
512
+
513
+			$this->assertInstanceOf(StatusChecker::class, $result);
514
+		} catch (ApiError $err) {
515
+			$this->assertEquals($err->getCode(), 403);
516
+		}
517
+	}
518
+
519
+	public function testDeleteAddressesByIdsMustReturnStatusChecker() : void
520
+	{
521
+		$addr_book = new AddressBook();
522
+		$result = $addr_book->deleteAddressesByIds(self::$createdAdddressIds);
523
+
524
+		$this->assertInstanceOf(StatusChecker::class, $result);
525
+		$this->assertIsInt($result->code);
526
+	}
527
+
528
+	// TODO: request has uncheckable result - 403 forbidden
529
+	public function testDeleteAddressesByAreasMustReturnStatusChecker() : void
530
+	{
531
+		$addr_book = new AddressBook();
532
+		$filter = [
533
+			'query' => 'Tusha',
534
+			'selected_areas' => [[
535
+				'type' => 'circle',
536
+				'value' => [
537
+					'center' => [
538
+						'lat' => 38.024654,
539
+						'lng' => 77.338814
540
+					],
541
+					'distance' => 10000
542
+				]
543
+			]]
544
+		];
545
+		try {
546
+			$result = $addr_book->deleteAddressesByAreas($filter);
547
+
548
+			$this->assertInstanceOf(StatusChecker::class, $result);
549
+			$this->assertIsInt($result->code);
550
+		} catch (ApiError $err) {
551
+			$this->assertEquals($err->getCode(), 403);
552
+		}
553
+	}
554
+
555
+	public function testGetAddressCustomFieldsMustReturnArray() : void
556
+	{
557
+		$addr_book = new AddressBook();
558
+		$result = $addr_book->getAddressCustomFields();
559
+
560
+		$this->assertIsArray($result);
561
+	}
562
+
563
+	public function testGetAddressDepotsFieldsMustReturnArray() : void
564
+	{
565
+		$addr_book = new AddressBook();
566
+		$result = $addr_book->getAddressesDepots();
567
+
568
+		$this->assertIsArray($result);
569
+	}
570
+
571
+	public function testExportAddressesByIdsMustReturnStatusChecker() : void
572
+	{
573
+		$addr_book = new AddressBook();
574
+		$filename = 'test_export.csv';
575
+		$result = $addr_book->exportAddressesByIds(self::$createdAdddressIds, $filename);
576
+
577
+		$this->assertInstanceOf(StatusChecker::class, $result);
578
+		$this->assertIsInt($result->code);
579
+	}
580
+
581
+	// TODO: request has uncheckable result - 403 forbidden
582
+	public function testExportAddressesByAreasMustReturnStatusChecker() : void
583
+	{
584
+		$addr_book = new AddressBook();
585
+		$filter = [
586
+			'query' => "Tusha",
587
+			'bounding_box' => null,
588
+			'selected_areas' => [[
589
+				'type' => 'circle',
590
+				'value' => [
591
+					'center' => [
592
+						'lat' => 38.024654,
593
+						'lng' => 77.338814
594
+					],
595
+					'distance' => 10000
596
+				]
597
+			]],
598
+			'filename' => 'test_export.csv'
599
+		];
600
+		try {
601
+			$result = $addr_book->exportAddressesByAreas($filter);
602
+
603
+			$this->assertInstanceOf(StatusChecker::class, $result);
604
+			$this->assertIsInt($result->code);
605
+		} catch (ApiError $err) {
606
+			$this->assertEquals($err->getCode(), 403);
607
+		}
608
+	}
609
+
610
+	// TODO: request has uncheckable result - 403 forbidden
611
+	public function testExportAddressesByAreaIdsMustReturnStatusChecker() : void
612
+	{
613
+		$addr_book = new AddressBook();
614
+		$territoryIds = [96100573, 96100961];
615
+		$filename = 'test_export.csv';
616
+		try {
617
+			$result = $addr_book->exportAddressesByAreaIds($territoryIds, $filename);
618
+
619
+			$this->assertInstanceOf(StatusChecker::class, $result);
620
+			$this->assertIsInt($result->code);
621
+		} catch (ApiError $err) {
622
+			$this->assertEquals($err->getCode(), 403);
623
+		}
624
+	}
625
+
626
+	// request has result - 404 not found, bc there is absent a jobId = 96100961
627
+	public function testGetAddressesAsynchronousJobStatusMustReturnStatusChecker() : void
628
+	{
629
+		$addr_book = new AddressBook();
630
+		$jobId = 96100961;
631
+		try {
632
+			$result = $addr_book->getAddressesAsynchronousJobStatus($jobId);
633
+
634
+			$this->assertInstanceOf(StatusChecker::class, $result);
635
+			$this->assertIsInt($result->code);
636
+		} catch (ApiError $err) {
637
+			$this->assertEquals($err->getCode(), 404);
638
+		}
639
+	}
640
+
641
+	// request has result - 404 not found, bc there is absent a jobId = 96100961
642
+	public function testGetAddressesAsynchronousJobResultMustReturnBool() : void
643
+	{
644
+		$addr_book = new AddressBook();
645
+		$jobId = 96100961;
646
+		try {
647
+			$result = $addr_book->getAddressesAsynchronousJobResult($jobId);
648
+
649
+			$this->assertIsBool($result);
650
+		} catch (ApiError $err) {
651
+			$this->assertEquals($err->getCode(), 404);
652
+		}
653
+	}
654
+
655
+	public static function tearDownAfterClass() : void
656
+	{
657
+		sleep(5);
658
+
659
+		$addr_book = new AddressBook();
660
+
661
+		if (count(self::$createdAdddressIds)) {
662
+			$addr_book->deleteAddressesByIds(self::$createdAdddressIds);
663
+		}
664
+
665
+		$res = $addr_book->getAddresses(['query' => 'Tusha']);
666
+		if ($res) {
667
+			$ids = [];
668
+			foreach ($res->results as $key => $value) {
669
+				$ids[] = $value->address_id;
670
+			}
671
+
672
+			if (count($ids)) {
673
+				$addr_book->deleteAddressesByIds($ids);
674
+			}
675
+		}
676
+	}
677 677
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -400,7 +400,7 @@
 block discarded – undo
400 400
         $this->assertInstanceOf(ResponsePagination::class, $result);
401 401
         $this->assertNotNull($result->current_page);
402 402
         $this->assertIsArray($result->results);
403
-        if (count($result->results) > 0) {
403
+        if (count($result->results)>0) {
404 404
             $this->assertInstanceOf(ResponseAddress::class, $result->results[0]);
405 405
         }
406 406
     }
Please login to merge, or discard this patch.
UnitTestFiles/Test/V5/VehicleTests.php 2 patches
Indentation   +627 added lines, -627 removed lines patch added patch discarded remove patch
@@ -27,637 +27,637 @@
 block discarded – undo
27 27
 
28 28
 class VehicleTests extends TestCase
29 29
 {
30
-    public static $createdVehicles = [];
31
-    public static $createdVehicleProfiles = [];
32
-
33
-    public static function setUpBeforeClass()
34
-    {
35
-        Route4Me::setApiKey(Constants::API_KEY);
36
-
37
-        $vehicle = new Vehicle();
38
-
39
-        //region Create Test Vehicles
40
-
41
-        $class6TruckParams = Vehicle::fromArray([
42
-            'vehicle_alias'             => 'GMC TopKick C5500 TST 6',
43
-            'vehicle_vin'               => 'SAJXA01A06FN08012',
44
-            'vehicle_license_plate'     => 'CVH4561',
45
-            'vehicle_model'             => 'TopKick C5500',
46
-            'vehicle_model_year'        => 1995,
47
-            'vehicle_year_acquired'     => 2008,
48
-            'vehicle_reg_country_id'    => 223,
49
-            'vehicle_reg_state_id'      => 12,
50
-            'vehicle_make'              => 'GMC',
51
-            'vehicle_type_id'           => 'pickup_truck',
52
-            'vehicle_cost_new'          => 60000,
53
-            'purchased_new'             => true,
54
-            'mpg_city'                  => 8,
55
-            'mpg_highway'               => 14,
56
-            'fuel_type'                 => 'diesel',
57
-            'license_start_date'        => '2021-01-01',
58
-            'license_end_date'          => '2031-01-01',
59
-        ]);
60
-
61
-        $result = $vehicle->createVehicle($class6TruckParams);
62
-
63
-        self::assertNotNull($result);
64
-        self::assertInstanceOf(
65
-            Vehicle::class,
66
-            Vehicle::fromArray($result)
67
-        );
68
-
69
-        self::$createdVehicles[] = $result;
70
-
71
-
72
-        $class7TruckParams = Vehicle::fromArray([
73
-            'vehicle_alias'             => 'FORD F750 TST 7',
74
-            'vehicle_vin'               => '1NPAX6EX2YD550743',
75
-            'vehicle_license_plate'     => 'FFV9547',
76
-            'vehicle_model'             => 'F-750',
77
-            'vehicle_model_year'        => 2010,
78
-            'vehicle_year_acquired'     => 2018,
79
-            'vehicle_reg_country_id'    => 223,
80
-            'vehicle_make'              => 'Ford',
81
-            'vehicle_type_id'           => 'livestock_carrier',
82
-            'vehicle_cost_new'          => 60000,
83
-            'purchased_new'             => true,
84
-            'mpg_city'                  => 7,
85
-            'mpg_highway'               => 14,
86
-            'fuel_consumption_city'     => 7,
87
-            'fuel_consumption_highway'  => 14,
88
-            'fuel_type'                 => 'diesel',
89
-            'license_start_date'        => '2021-01-01',
90
-            'license_end_date'          => '2031-01-01',
91
-        ]);
92
-
93
-        $result = $vehicle->createVehicle($class7TruckParams);
94
-
95
-        self::assertNotNull($result);
96
-        self::assertInstanceOf(
97
-            Vehicle::class,
98
-            Vehicle::fromArray($result)
99
-        );
100
-
101
-        self::$createdVehicles[] = $result;
102
-
103
-        //endregion
104
-
105
-        #region Create Test Vehicle Profiles
106
-
107
-        // TODO: comment as since 20230605 VehicleProfile is not creatable
108
-        // $profile1 = new VehicleProfile();
109
-
110
-        // $profile1->name = "Heavy Duty - 28 Double Trailer ".date('Y-m-d H:i');
111
-        // $profile1->height_units = VehicleSizeUnits::METER;
112
-        // $profile1->width_units = VehicleSizeUnits::METER;
113
-        // $profile1->length_units = VehicleSizeUnits::METER;
114
-        // $profile1->height = 4;
115
-        // $profile1->width = 2.44;
116
-        // $profile1->length = 12.2;
117
-        // $profile1->is_predefined = false;
118
-        // $profile1->is_default = false;
119
-        // $profile1->weight_units = VehicleWeightUnits::KILOGRAM;
120
-        // $profile1->weight = 20400;
121
-        // $profile1->max_weight_per_axle = 15400;
122
-        // $profile1->fuel_type = FuelTypes::UNLEADED_91;
123
-        // $profile1->fuel_consumption_city = 6;
124
-        // $profile1->fuel_consumption_highway = 12;
125
-        // $profile1->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
126
-        // $profile1->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
127
-
128
-        // $result1 = $profile1->createVehicleProfile($profile1->toArray());
129
-
130
-        // self::assertNotNull($result1);
131
-        // self::assertInstanceOf(
132
-        //     VehicleProfile::class,
133
-        //     VehicleProfile::fromArray($result1)
134
-        // );
135
-
136
-        // self::$createdVehicleProfiles[] = $result1;
137
-
138
-        // $profile2 = new VehicleProfile();
139
-
140
-        // $profile2->name = "Heavy Duty - 40 Straight Truck ".date('Y-m-d H:i');
141
-        // $profile2->height_units = VehicleSizeUnits::METER;
142
-        // $profile2->width_units = VehicleSizeUnits::METER;
143
-        // $profile2->length_units = VehicleSizeUnits::METER;
144
-        // $profile2->height = 4;
145
-        // $profile2->width = 2.44;
146
-        // $profile2->length = 14.6;
147
-        // $profile2->is_predefined = false;
148
-        // $profile2->is_default = false;
149
-        // $profile2->weight_units = VehicleWeightUnits::KILOGRAM;
150
-        // $profile2->weight = 36300;
151
-        // $profile2->max_weight_per_axle = 15400;
152
-        // $profile2->fuel_type = FuelTypes::UNLEADED_87;
153
-        // $profile2->fuel_consumption_city = 5;
154
-        // $profile2->fuel_consumption_highway = 10;
155
-        // $profile2->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
156
-        // $profile2->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
157
-
158
-        // $result2 = $profile2->createVehicleProfile($profile2->toArray());
159
-
160
-        // self::assertNotNull($result2);
161
-        // self::assertInstanceOf(
162
-        //     VehicleProfile::class,
163
-        //     VehicleProfile::fromArray($result2)
164
-        // );
165
-
166
-        // self::$createdVehicleProfiles[] = $result2;
167
-
168
-        #endregion
169
-    }
170
-
171
-    public function testFromArray()
172
-    {
173
-        $class6TruckParams = Vehicle::fromArray([
174
-            'vehicle_alias'             => 'GMC TopKick C5500 TST 6',
175
-            'vehicle_vin'               => 'SAJXA01A06FN08012',
176
-            'vehicle_license_plate'     => 'CVH4561',
177
-            'vehicle_model'             => 'TopKick C5500',
178
-            'vehicle_model_year'        => 1995,
179
-            'vehicle_year_acquired'     => 2008,
180
-            'vehicle_reg_country_id'    => 223,
181
-            'vehicle_reg_state_id'      => 12,
182
-            'vehicle_make'              => 'GMC',
183
-            'vehicle_type_id'           => 'pickup_truck',
184
-            'vehicle_cost_new'          => 60000,
185
-            'purchased_new'             => true,
186
-            'mpg_city'                  => 8,
187
-            'mpg_highway'               => 14,
188
-            'fuel_type'                 => 'diesel',
189
-            'license_start_date'        => '2021-01-01',
190
-            'license_end_date'          => '2031-01-01',
191
-        ]);
192
-
193
-        $this->assertEquals($class6TruckParams->vehicle_alias, 'GMC TopKick C5500 TST 6');
194
-        $this->assertEquals($class6TruckParams->vehicle_vin, 'SAJXA01A06FN08012');
195
-        $this->assertEquals($class6TruckParams->vehicle_license_plate, 'CVH4561');
196
-        $this->assertEquals($class6TruckParams->vehicle_model, 'TopKick C5500');
197
-        $this->assertEquals($class6TruckParams->vehicle_model_year, 1995);
198
-        $this->assertEquals($class6TruckParams->vehicle_year_acquired, 2008);
199
-        $this->assertEquals($class6TruckParams->vehicle_reg_country_id, 223);
200
-        $this->assertEquals($class6TruckParams->vehicle_reg_state_id, 12);
201
-        $this->assertEquals($class6TruckParams->vehicle_make, 'GMC');
202
-        $this->assertEquals($class6TruckParams->vehicle_type_id, 'pickup_truck');
203
-        $this->assertEquals($class6TruckParams->vehicle_cost_new, 60000);
204
-        $this->assertEquals($class6TruckParams->purchased_new, true);
205
-        $this->assertEquals($class6TruckParams->mpg_city, 8);
206
-        $this->assertEquals($class6TruckParams->mpg_highway, 14);
207
-        $this->assertEquals($class6TruckParams->fuel_type, 'diesel');
208
-        $this->assertEquals($class6TruckParams->license_start_date, '2021-01-01');
209
-        $this->assertEquals($class6TruckParams->license_end_date, '2031-01-01');
210
-    }
211
-
212
-    public function testVehicleLocationResponseFromArray()
213
-    {
214
-        $vlr = new VehicleLocationResponse();
215
-        $vlr = $vlr->fromArray([
216
-            'data' => [],
217
-            'null_data' => null
218
-        ]);
219
-
220
-        self::assertInstanceOf(VehicleLocationResponse::class, $vlr);
221
-        self::assertTrue(isset($vlr->data));
222
-        self::assertTrue(is_array($vlr->data));
223
-    }
224
-
225
-    public function testVehicleOrderResponseFromArray()
226
-    {
227
-        $vor = new VehicleOrderResponse();
228
-        $vor = $vor->fromArray([
229
-            'vehicle_id' => '12345',
230
-            'order_id' => 15,
231
-            'null_data' => null
232
-        ]);
233
-
234
-        self::assertInstanceOf(VehicleOrderResponse::class, $vor);
235
-        self::assertEquals($vor->vehicle_id, '12345');
236
-        self::assertEquals($vor->order_id, 15);
237
-    }
238
-
239
-    public function testVehicleTemporaryFromArray()
240
-    {
241
-        $vt = new VehicleTemporary();
242
-        $vt = $vt->fromArray([
243
-            'vehicle_id' => '12345',
244
-            'null_data' => null
245
-        ]);
246
-
247
-        self::assertInstanceOf(VehicleTemporary::class, $vt);
248
-        self::assertEquals($vt->vehicle_id, '12345');
249
-    }
250
-
251
-    public function testVehicleTrackResponseFromArray()
252
-    {
253
-        $vtr = new VehicleTrackResponse();
254
-        $vtr = $vtr->fromArray([
255
-            'data' => [],
256
-            'null_data' => null
257
-        ]);
258
-
259
-        self::assertInstanceOf(VehicleTrackResponse::class, $vtr);
260
-        self::assertTrue(isset($vtr->data));
261
-        self::assertTrue(is_array($vtr->data));
262
-    }
263
-
264
-    public function testVehicleResponseFromArray()
265
-    {
266
-        $vr = new VehicleResponse();
267
-        $vr = $vr->fromArray([
268
-            'data' => [],
269
-            'null_data' => null
270
-        ]);
271
-
272
-        self::assertInstanceOf(VehicleResponse::class, $vr);
273
-        self::assertTrue(isset($vr->data));
274
-        self::assertTrue(is_array($vr->data));
275
-    }
276
-
277
-    public function testGetVehiclesPaginatedList()
278
-    {
279
-        $vehParams = new VehicleParameters();
280
-
281
-        $vehParams->with_pagination = true;
282
-        $vehParams->page = 1;
283
-        $vehParams->perPage = 10;
284
-
285
-        $vehicle = new Vehicle();
286
-
287
-        $result = $vehicle->getVehiclesPaginatedList($vehParams->toArray());
288
-
289
-        $this->assertNotNull($result);
290
-        $this->assertTrue(is_array($result));
291
-        $this->assertTrue(sizeof($result)>0);
292
-        $this->assertInstanceOf(Vehicle::class, Vehicle::fromArray($result));
293
-    }
294
-
295
-    public function testCreateVehicle()
296
-    {
297
-        $vehicle = new Vehicle();
298
-
299
-        $class7TruckParams = Vehicle::fromArray([
300
-            'vehicle_alias'             => 'FORD F750 TST 7',
301
-            'vehicle_vin'               => '1NPAX6EX2YD550743',
302
-            'vehicle_license_plate'     => 'FFV9547',
303
-            'vehicle_model'             => 'F-750',
304
-            'vehicle_model_year'        => 2010,
305
-            'vehicle_year_acquired'     => 2018,
306
-            'vehicle_reg_country_id'    => 223,
307
-            'vehicle_reg_state_id'      => 12,
308
-            'vehicle_make'              => 'Ford',
309
-            'vehicle_type_id'           => 'livestock_carrier',
310
-            'vehicle_cost_new'          => 70000,
311
-            'purchased_new'             => false,
312
-            'mpg_city'                  => 6,
313
-            'mpg_highway'               => 12,
314
-            'fuel_consumption_city'     => 6,
315
-            'fuel_consumption_highway'  => 12,
316
-            'fuel_type'                 => 'diesel',
317
-            'license_start_date'        => '2020-03-01',
318
-            'license_end_date'          => '2028-12-01',
319
-        ]);
320
-
321
-        $result = $vehicle->createVehicle($class7TruckParams);
322
-
323
-        self::assertNotNull($result);
324
-        self::assertInstanceOf(
325
-            Vehicle::class,
326
-            Vehicle::fromArray($result)
327
-        );
328
-
329
-        self::$createdVehicles[] = $result;
330
-    }
331
-
332
-    // TODO: request has uncheckable result - 406 Not Acceptable
333
-    public function testCreateTemporaryVehicle()
334
-    {
335
-        $vehicle = new Vehicle();
336
-
337
-        $tempVehParams = new VehicleTemporary();
338
-
339
-        $tempVehParams->assigned_member_id = 1;
340
-        $tempVehParams->expires_at = time() + 100;
341
-        $tempVehParams->force_assignment = true;
342
-        $tempVehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
343
-        $tempVehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate'];
344
-
345
-        try {
346
-            $result = $vehicle->createTemporaryVehicle($tempVehParams->toArray());
347
-
348
-            self::assertNotNull($result);
349
-            self::assertInstanceOf(
350
-                VehicleTemporary::class,
351
-                VehicleTemporary::fromArray($result)
352
-            );
353
-        } catch (ApiError $err) {
354
-            $this->assertEquals($err->getCode(), 403);
355
-        }
356
-    }
357
-
358
-    // TODO: request has uncheckable result - 500 Internal Server Error
359
-    public function testExecuteVehicleOrder()
360
-    {
361
-        $vehicle = new Vehicle();
362
-
363
-        $orderParams = new VehicleOrderParameters();
364
-        $orderParams->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
365
-        $orderParams->lat = 38.247605;
366
-        $orderParams->lng = -85.746697;
367
-
368
-        try {
369
-            $result = $vehicle->executeVehicleOrder($orderParams->toArray());
370
-
371
-            self::assertNotNull($result);
372
-            self::assertInstanceOf(
373
-                VehicleOrderResponse::class,
374
-                VehicleOrderResponse::fromArray($result)
375
-            );
376
-        } catch (ApiError $err) {
377
-            $this->assertEquals($err->getCode(), 500);
378
-        }
379
-    }
380
-
381
-    // TODO: request has uncheckable result - 500 Internal Server Error
382
-    public function testGetLatestVehicleLocations()
383
-    {
384
-        $vehicle = new Vehicle();
385
-
386
-        $vehicleIDs = array_column(self::$createdVehicles, 'vehicle_id');
387
-
388
-        $vehParams = new VehicleParameters();
389
-        $vehParams->ids = $vehicleIDs;
390
-
391
-        try {
392
-            $result = $vehicle->getVehicleLocations($vehParams);
393
-
394
-            self::assertNotNull($result);
395
-            self::assertInstanceOf(
396
-                VehicleLocationResponse::class,
397
-                VehicleLocationResponse::fromArray($result)
398
-            );
399
-            self::assertTrue(isset($result['data']));
400
-            self::assertTrue(is_array($result['data']));
401
-        } catch (ApiError $err) {
402
-            $this->assertEquals($err->getCode(), 500);
403
-        }
404
-    }
405
-
406
-    public function testGetVehicleById()
407
-    {
408
-        $vehicle = new Vehicle();
409
-
410
-        $vehParams = new VehicleParameters();
411
-        $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
412
-
413
-        $result = $vehicle->getVehicleById($vehParams->toArray());
414
-
415
-        self::assertNotNull($result);
416
-        self::assertInstanceOf(
417
-            Vehicle::class,
418
-            Vehicle::fromArray($result)
419
-        );
420
-        self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']);
421
-    }
422
-
423
-    // TODO: request has uncheckable result - 500 Internal Server Error
424
-    public function testGetVehicleTrack()
425
-    {
426
-        $vehicle = new Vehicle();
427
-
428
-        $vehParams = new VehicleParameters();
429
-        $vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
430
-
431
-        try {
432
-            $result = $vehicle->getVehicleTrack($vehParams->toArray());
433
-
434
-            self::assertNotNull($result);
435
-            self::assertInstanceOf(
436
-                VehicleTrackResponse::class,
437
-                VehicleTrackResponse::fromArray($result)
438
-            );
439
-        } catch (ApiError $err) {
440
-            $this->assertEquals($err->getCode(), 500);
441
-        }
442
-    }
443
-
444
-    public function testDeleteVehicle()
445
-    {
446
-        $vehicle = new Vehicle();
447
-
448
-        $vehParams = new VehicleParameters();
449
-        $vehParams->vehicle_id = self::$createdVehicles[sizeof(self::$createdVehicles) - 1]['vehicle_id'];
450
-
451
-        $result = $vehicle->removeVehicle($vehParams->toArray());
452
-
453
-        self::assertNotNull($result);
454
-        self::assertInstanceOf(
455
-            Vehicle::class,
456
-            Vehicle::fromArray($result)
457
-        );
458
-        self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']);
459
-
460
-        array_pop(self::$createdVehicles);
461
-    }
462
-
463
-    // TODO: skip as since 20230605 VehicleProfile is not creatable
464
-    public function testGetVehicleProfiles()
465
-    {
466
-        $this->markTestSkipped('must be revisited.');
467
-
468
-        $vehicleProfile = new VehicleProfile();
469
-
470
-        $vehProfileParams = new VehicleProfileParameters();
471
-
472
-        $vehProfileParams->with_pagination = true;
473
-        $vehProfileParams->page = 1;
474
-        $vehProfileParams->perPage = 10;
475
-
476
-        $result = $vehicleProfile->getVehicleProfiles($vehProfileParams->toArray());
477
-
478
-        self::assertNotNull($result);
479
-        self::assertInstanceOf(
480
-            VehicleProfilesResponse::class,
481
-            VehicleProfilesResponse::fromArray($result)
482
-        );
483
-    }
484
-
485
-    // TODO: skip as since 20230605 VehicleProfile is not creatable
486
-    public function testCreateVehicleProfile()
487
-    {
488
-        $this->markTestSkipped('must be revisited.');
489
-
490
-        $vehicleProfile = new VehicleProfile();
491
-
492
-        $profile = new VehicleProfile();
493
-
494
-        $profile->name = "Heavy Duty - 48 Semitrailer ".date('Y-m-d H:i');
495
-        $profile->height_units = VehicleSizeUnits::METER;
496
-        $profile->width_units = VehicleSizeUnits::METER;
497
-        $profile->length_units = VehicleSizeUnits::METER;
498
-        $profile->height = 3.5;
499
-        $profile->width = 2.5;
500
-        $profile->length = 16;
501
-        $profile->is_predefined = false;
502
-        $profile->is_default = false;
503
-        $profile->weight_units = VehicleWeightUnits::KILOGRAM;
504
-        $profile->weight = 35000;
505
-        $profile->max_weight_per_axle = 17500;
506
-        $profile->fuel_type = FuelTypes::UNLEADED_87;
507
-        $profile->fuel_consumption_city = 6;
508
-        $profile->fuel_consumption_highway = 11;
509
-        $profile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
510
-        $profile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
511
-
512
-        $result = $vehicleProfile->createVehicleProfile($profile->toArray());
513
-
514
-        self::assertNotNull($result);
515
-        self::assertInstanceOf(
516
-            VehicleProfile::class,
517
-            VehicleProfile::fromArray($result)
518
-        );
519
-
520
-        self::$createdVehicleProfiles[] = $result;
521
-    }
522
-
523
-    // TODO: skip as since 20230605 VehicleProfile is not creatable
524
-    public function testDeleteVehicleProfile()
525
-    {
526
-        $this->markTestSkipped('must be revisited.');
527
-
528
-        $vehicleProfile = new VehicleProfile();
529
-
530
-        $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id'];
531
-
532
-        $result = $vehicleProfile->removeVehicleProfile($vehProfileId);
533
-
534
-        self::assertNotNull($result);
535
-        self::assertInstanceOf(
536
-            VehicleProfile::class,
537
-            VehicleProfile::fromArray($result)
538
-        );
539
-
540
-        array_pop(self::$createdVehicleProfiles);
541
-    }
542
-
543
-    // TODO: skip as since 20230605 VehicleProfile is not creatable
544
-    public function testGetVehicleProfileById()
545
-    {
546
-        $this->markTestSkipped('must be revisited.');
30
+	public static $createdVehicles = [];
31
+	public static $createdVehicleProfiles = [];
32
+
33
+	public static function setUpBeforeClass()
34
+	{
35
+		Route4Me::setApiKey(Constants::API_KEY);
36
+
37
+		$vehicle = new Vehicle();
38
+
39
+		//region Create Test Vehicles
40
+
41
+		$class6TruckParams = Vehicle::fromArray([
42
+			'vehicle_alias'             => 'GMC TopKick C5500 TST 6',
43
+			'vehicle_vin'               => 'SAJXA01A06FN08012',
44
+			'vehicle_license_plate'     => 'CVH4561',
45
+			'vehicle_model'             => 'TopKick C5500',
46
+			'vehicle_model_year'        => 1995,
47
+			'vehicle_year_acquired'     => 2008,
48
+			'vehicle_reg_country_id'    => 223,
49
+			'vehicle_reg_state_id'      => 12,
50
+			'vehicle_make'              => 'GMC',
51
+			'vehicle_type_id'           => 'pickup_truck',
52
+			'vehicle_cost_new'          => 60000,
53
+			'purchased_new'             => true,
54
+			'mpg_city'                  => 8,
55
+			'mpg_highway'               => 14,
56
+			'fuel_type'                 => 'diesel',
57
+			'license_start_date'        => '2021-01-01',
58
+			'license_end_date'          => '2031-01-01',
59
+		]);
60
+
61
+		$result = $vehicle->createVehicle($class6TruckParams);
62
+
63
+		self::assertNotNull($result);
64
+		self::assertInstanceOf(
65
+			Vehicle::class,
66
+			Vehicle::fromArray($result)
67
+		);
68
+
69
+		self::$createdVehicles[] = $result;
70
+
71
+
72
+		$class7TruckParams = Vehicle::fromArray([
73
+			'vehicle_alias'             => 'FORD F750 TST 7',
74
+			'vehicle_vin'               => '1NPAX6EX2YD550743',
75
+			'vehicle_license_plate'     => 'FFV9547',
76
+			'vehicle_model'             => 'F-750',
77
+			'vehicle_model_year'        => 2010,
78
+			'vehicle_year_acquired'     => 2018,
79
+			'vehicle_reg_country_id'    => 223,
80
+			'vehicle_make'              => 'Ford',
81
+			'vehicle_type_id'           => 'livestock_carrier',
82
+			'vehicle_cost_new'          => 60000,
83
+			'purchased_new'             => true,
84
+			'mpg_city'                  => 7,
85
+			'mpg_highway'               => 14,
86
+			'fuel_consumption_city'     => 7,
87
+			'fuel_consumption_highway'  => 14,
88
+			'fuel_type'                 => 'diesel',
89
+			'license_start_date'        => '2021-01-01',
90
+			'license_end_date'          => '2031-01-01',
91
+		]);
92
+
93
+		$result = $vehicle->createVehicle($class7TruckParams);
94
+
95
+		self::assertNotNull($result);
96
+		self::assertInstanceOf(
97
+			Vehicle::class,
98
+			Vehicle::fromArray($result)
99
+		);
100
+
101
+		self::$createdVehicles[] = $result;
102
+
103
+		//endregion
104
+
105
+		#region Create Test Vehicle Profiles
106
+
107
+		// TODO: comment as since 20230605 VehicleProfile is not creatable
108
+		// $profile1 = new VehicleProfile();
109
+
110
+		// $profile1->name = "Heavy Duty - 28 Double Trailer ".date('Y-m-d H:i');
111
+		// $profile1->height_units = VehicleSizeUnits::METER;
112
+		// $profile1->width_units = VehicleSizeUnits::METER;
113
+		// $profile1->length_units = VehicleSizeUnits::METER;
114
+		// $profile1->height = 4;
115
+		// $profile1->width = 2.44;
116
+		// $profile1->length = 12.2;
117
+		// $profile1->is_predefined = false;
118
+		// $profile1->is_default = false;
119
+		// $profile1->weight_units = VehicleWeightUnits::KILOGRAM;
120
+		// $profile1->weight = 20400;
121
+		// $profile1->max_weight_per_axle = 15400;
122
+		// $profile1->fuel_type = FuelTypes::UNLEADED_91;
123
+		// $profile1->fuel_consumption_city = 6;
124
+		// $profile1->fuel_consumption_highway = 12;
125
+		// $profile1->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
126
+		// $profile1->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
127
+
128
+		// $result1 = $profile1->createVehicleProfile($profile1->toArray());
129
+
130
+		// self::assertNotNull($result1);
131
+		// self::assertInstanceOf(
132
+		//     VehicleProfile::class,
133
+		//     VehicleProfile::fromArray($result1)
134
+		// );
135
+
136
+		// self::$createdVehicleProfiles[] = $result1;
137
+
138
+		// $profile2 = new VehicleProfile();
139
+
140
+		// $profile2->name = "Heavy Duty - 40 Straight Truck ".date('Y-m-d H:i');
141
+		// $profile2->height_units = VehicleSizeUnits::METER;
142
+		// $profile2->width_units = VehicleSizeUnits::METER;
143
+		// $profile2->length_units = VehicleSizeUnits::METER;
144
+		// $profile2->height = 4;
145
+		// $profile2->width = 2.44;
146
+		// $profile2->length = 14.6;
147
+		// $profile2->is_predefined = false;
148
+		// $profile2->is_default = false;
149
+		// $profile2->weight_units = VehicleWeightUnits::KILOGRAM;
150
+		// $profile2->weight = 36300;
151
+		// $profile2->max_weight_per_axle = 15400;
152
+		// $profile2->fuel_type = FuelTypes::UNLEADED_87;
153
+		// $profile2->fuel_consumption_city = 5;
154
+		// $profile2->fuel_consumption_highway = 10;
155
+		// $profile2->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
156
+		// $profile2->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
157
+
158
+		// $result2 = $profile2->createVehicleProfile($profile2->toArray());
159
+
160
+		// self::assertNotNull($result2);
161
+		// self::assertInstanceOf(
162
+		//     VehicleProfile::class,
163
+		//     VehicleProfile::fromArray($result2)
164
+		// );
165
+
166
+		// self::$createdVehicleProfiles[] = $result2;
167
+
168
+		#endregion
169
+	}
170
+
171
+	public function testFromArray()
172
+	{
173
+		$class6TruckParams = Vehicle::fromArray([
174
+			'vehicle_alias'             => 'GMC TopKick C5500 TST 6',
175
+			'vehicle_vin'               => 'SAJXA01A06FN08012',
176
+			'vehicle_license_plate'     => 'CVH4561',
177
+			'vehicle_model'             => 'TopKick C5500',
178
+			'vehicle_model_year'        => 1995,
179
+			'vehicle_year_acquired'     => 2008,
180
+			'vehicle_reg_country_id'    => 223,
181
+			'vehicle_reg_state_id'      => 12,
182
+			'vehicle_make'              => 'GMC',
183
+			'vehicle_type_id'           => 'pickup_truck',
184
+			'vehicle_cost_new'          => 60000,
185
+			'purchased_new'             => true,
186
+			'mpg_city'                  => 8,
187
+			'mpg_highway'               => 14,
188
+			'fuel_type'                 => 'diesel',
189
+			'license_start_date'        => '2021-01-01',
190
+			'license_end_date'          => '2031-01-01',
191
+		]);
192
+
193
+		$this->assertEquals($class6TruckParams->vehicle_alias, 'GMC TopKick C5500 TST 6');
194
+		$this->assertEquals($class6TruckParams->vehicle_vin, 'SAJXA01A06FN08012');
195
+		$this->assertEquals($class6TruckParams->vehicle_license_plate, 'CVH4561');
196
+		$this->assertEquals($class6TruckParams->vehicle_model, 'TopKick C5500');
197
+		$this->assertEquals($class6TruckParams->vehicle_model_year, 1995);
198
+		$this->assertEquals($class6TruckParams->vehicle_year_acquired, 2008);
199
+		$this->assertEquals($class6TruckParams->vehicle_reg_country_id, 223);
200
+		$this->assertEquals($class6TruckParams->vehicle_reg_state_id, 12);
201
+		$this->assertEquals($class6TruckParams->vehicle_make, 'GMC');
202
+		$this->assertEquals($class6TruckParams->vehicle_type_id, 'pickup_truck');
203
+		$this->assertEquals($class6TruckParams->vehicle_cost_new, 60000);
204
+		$this->assertEquals($class6TruckParams->purchased_new, true);
205
+		$this->assertEquals($class6TruckParams->mpg_city, 8);
206
+		$this->assertEquals($class6TruckParams->mpg_highway, 14);
207
+		$this->assertEquals($class6TruckParams->fuel_type, 'diesel');
208
+		$this->assertEquals($class6TruckParams->license_start_date, '2021-01-01');
209
+		$this->assertEquals($class6TruckParams->license_end_date, '2031-01-01');
210
+	}
211
+
212
+	public function testVehicleLocationResponseFromArray()
213
+	{
214
+		$vlr = new VehicleLocationResponse();
215
+		$vlr = $vlr->fromArray([
216
+			'data' => [],
217
+			'null_data' => null
218
+		]);
219
+
220
+		self::assertInstanceOf(VehicleLocationResponse::class, $vlr);
221
+		self::assertTrue(isset($vlr->data));
222
+		self::assertTrue(is_array($vlr->data));
223
+	}
224
+
225
+	public function testVehicleOrderResponseFromArray()
226
+	{
227
+		$vor = new VehicleOrderResponse();
228
+		$vor = $vor->fromArray([
229
+			'vehicle_id' => '12345',
230
+			'order_id' => 15,
231
+			'null_data' => null
232
+		]);
233
+
234
+		self::assertInstanceOf(VehicleOrderResponse::class, $vor);
235
+		self::assertEquals($vor->vehicle_id, '12345');
236
+		self::assertEquals($vor->order_id, 15);
237
+	}
238
+
239
+	public function testVehicleTemporaryFromArray()
240
+	{
241
+		$vt = new VehicleTemporary();
242
+		$vt = $vt->fromArray([
243
+			'vehicle_id' => '12345',
244
+			'null_data' => null
245
+		]);
246
+
247
+		self::assertInstanceOf(VehicleTemporary::class, $vt);
248
+		self::assertEquals($vt->vehicle_id, '12345');
249
+	}
250
+
251
+	public function testVehicleTrackResponseFromArray()
252
+	{
253
+		$vtr = new VehicleTrackResponse();
254
+		$vtr = $vtr->fromArray([
255
+			'data' => [],
256
+			'null_data' => null
257
+		]);
258
+
259
+		self::assertInstanceOf(VehicleTrackResponse::class, $vtr);
260
+		self::assertTrue(isset($vtr->data));
261
+		self::assertTrue(is_array($vtr->data));
262
+	}
263
+
264
+	public function testVehicleResponseFromArray()
265
+	{
266
+		$vr = new VehicleResponse();
267
+		$vr = $vr->fromArray([
268
+			'data' => [],
269
+			'null_data' => null
270
+		]);
271
+
272
+		self::assertInstanceOf(VehicleResponse::class, $vr);
273
+		self::assertTrue(isset($vr->data));
274
+		self::assertTrue(is_array($vr->data));
275
+	}
276
+
277
+	public function testGetVehiclesPaginatedList()
278
+	{
279
+		$vehParams = new VehicleParameters();
280
+
281
+		$vehParams->with_pagination = true;
282
+		$vehParams->page = 1;
283
+		$vehParams->perPage = 10;
284
+
285
+		$vehicle = new Vehicle();
286
+
287
+		$result = $vehicle->getVehiclesPaginatedList($vehParams->toArray());
288
+
289
+		$this->assertNotNull($result);
290
+		$this->assertTrue(is_array($result));
291
+		$this->assertTrue(sizeof($result)>0);
292
+		$this->assertInstanceOf(Vehicle::class, Vehicle::fromArray($result));
293
+	}
294
+
295
+	public function testCreateVehicle()
296
+	{
297
+		$vehicle = new Vehicle();
298
+
299
+		$class7TruckParams = Vehicle::fromArray([
300
+			'vehicle_alias'             => 'FORD F750 TST 7',
301
+			'vehicle_vin'               => '1NPAX6EX2YD550743',
302
+			'vehicle_license_plate'     => 'FFV9547',
303
+			'vehicle_model'             => 'F-750',
304
+			'vehicle_model_year'        => 2010,
305
+			'vehicle_year_acquired'     => 2018,
306
+			'vehicle_reg_country_id'    => 223,
307
+			'vehicle_reg_state_id'      => 12,
308
+			'vehicle_make'              => 'Ford',
309
+			'vehicle_type_id'           => 'livestock_carrier',
310
+			'vehicle_cost_new'          => 70000,
311
+			'purchased_new'             => false,
312
+			'mpg_city'                  => 6,
313
+			'mpg_highway'               => 12,
314
+			'fuel_consumption_city'     => 6,
315
+			'fuel_consumption_highway'  => 12,
316
+			'fuel_type'                 => 'diesel',
317
+			'license_start_date'        => '2020-03-01',
318
+			'license_end_date'          => '2028-12-01',
319
+		]);
320
+
321
+		$result = $vehicle->createVehicle($class7TruckParams);
322
+
323
+		self::assertNotNull($result);
324
+		self::assertInstanceOf(
325
+			Vehicle::class,
326
+			Vehicle::fromArray($result)
327
+		);
328
+
329
+		self::$createdVehicles[] = $result;
330
+	}
331
+
332
+	// TODO: request has uncheckable result - 406 Not Acceptable
333
+	public function testCreateTemporaryVehicle()
334
+	{
335
+		$vehicle = new Vehicle();
336
+
337
+		$tempVehParams = new VehicleTemporary();
338
+
339
+		$tempVehParams->assigned_member_id = 1;
340
+		$tempVehParams->expires_at = time() + 100;
341
+		$tempVehParams->force_assignment = true;
342
+		$tempVehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
343
+		$tempVehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate'];
344
+
345
+		try {
346
+			$result = $vehicle->createTemporaryVehicle($tempVehParams->toArray());
347
+
348
+			self::assertNotNull($result);
349
+			self::assertInstanceOf(
350
+				VehicleTemporary::class,
351
+				VehicleTemporary::fromArray($result)
352
+			);
353
+		} catch (ApiError $err) {
354
+			$this->assertEquals($err->getCode(), 403);
355
+		}
356
+	}
357
+
358
+	// TODO: request has uncheckable result - 500 Internal Server Error
359
+	public function testExecuteVehicleOrder()
360
+	{
361
+		$vehicle = new Vehicle();
362
+
363
+		$orderParams = new VehicleOrderParameters();
364
+		$orderParams->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
365
+		$orderParams->lat = 38.247605;
366
+		$orderParams->lng = -85.746697;
367
+
368
+		try {
369
+			$result = $vehicle->executeVehicleOrder($orderParams->toArray());
370
+
371
+			self::assertNotNull($result);
372
+			self::assertInstanceOf(
373
+				VehicleOrderResponse::class,
374
+				VehicleOrderResponse::fromArray($result)
375
+			);
376
+		} catch (ApiError $err) {
377
+			$this->assertEquals($err->getCode(), 500);
378
+		}
379
+	}
380
+
381
+	// TODO: request has uncheckable result - 500 Internal Server Error
382
+	public function testGetLatestVehicleLocations()
383
+	{
384
+		$vehicle = new Vehicle();
385
+
386
+		$vehicleIDs = array_column(self::$createdVehicles, 'vehicle_id');
387
+
388
+		$vehParams = new VehicleParameters();
389
+		$vehParams->ids = $vehicleIDs;
390
+
391
+		try {
392
+			$result = $vehicle->getVehicleLocations($vehParams);
393
+
394
+			self::assertNotNull($result);
395
+			self::assertInstanceOf(
396
+				VehicleLocationResponse::class,
397
+				VehicleLocationResponse::fromArray($result)
398
+			);
399
+			self::assertTrue(isset($result['data']));
400
+			self::assertTrue(is_array($result['data']));
401
+		} catch (ApiError $err) {
402
+			$this->assertEquals($err->getCode(), 500);
403
+		}
404
+	}
405
+
406
+	public function testGetVehicleById()
407
+	{
408
+		$vehicle = new Vehicle();
409
+
410
+		$vehParams = new VehicleParameters();
411
+		$vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
412
+
413
+		$result = $vehicle->getVehicleById($vehParams->toArray());
414
+
415
+		self::assertNotNull($result);
416
+		self::assertInstanceOf(
417
+			Vehicle::class,
418
+			Vehicle::fromArray($result)
419
+		);
420
+		self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']);
421
+	}
422
+
423
+	// TODO: request has uncheckable result - 500 Internal Server Error
424
+	public function testGetVehicleTrack()
425
+	{
426
+		$vehicle = new Vehicle();
427
+
428
+		$vehParams = new VehicleParameters();
429
+		$vehParams->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
430
+
431
+		try {
432
+			$result = $vehicle->getVehicleTrack($vehParams->toArray());
433
+
434
+			self::assertNotNull($result);
435
+			self::assertInstanceOf(
436
+				VehicleTrackResponse::class,
437
+				VehicleTrackResponse::fromArray($result)
438
+			);
439
+		} catch (ApiError $err) {
440
+			$this->assertEquals($err->getCode(), 500);
441
+		}
442
+	}
443
+
444
+	public function testDeleteVehicle()
445
+	{
446
+		$vehicle = new Vehicle();
447
+
448
+		$vehParams = new VehicleParameters();
449
+		$vehParams->vehicle_id = self::$createdVehicles[sizeof(self::$createdVehicles) - 1]['vehicle_id'];
450
+
451
+		$result = $vehicle->removeVehicle($vehParams->toArray());
452
+
453
+		self::assertNotNull($result);
454
+		self::assertInstanceOf(
455
+			Vehicle::class,
456
+			Vehicle::fromArray($result)
457
+		);
458
+		self::assertEquals($vehParams->vehicle_id, $result['vehicle_id']);
459
+
460
+		array_pop(self::$createdVehicles);
461
+	}
462
+
463
+	// TODO: skip as since 20230605 VehicleProfile is not creatable
464
+	public function testGetVehicleProfiles()
465
+	{
466
+		$this->markTestSkipped('must be revisited.');
467
+
468
+		$vehicleProfile = new VehicleProfile();
469
+
470
+		$vehProfileParams = new VehicleProfileParameters();
471
+
472
+		$vehProfileParams->with_pagination = true;
473
+		$vehProfileParams->page = 1;
474
+		$vehProfileParams->perPage = 10;
475
+
476
+		$result = $vehicleProfile->getVehicleProfiles($vehProfileParams->toArray());
477
+
478
+		self::assertNotNull($result);
479
+		self::assertInstanceOf(
480
+			VehicleProfilesResponse::class,
481
+			VehicleProfilesResponse::fromArray($result)
482
+		);
483
+	}
484
+
485
+	// TODO: skip as since 20230605 VehicleProfile is not creatable
486
+	public function testCreateVehicleProfile()
487
+	{
488
+		$this->markTestSkipped('must be revisited.');
489
+
490
+		$vehicleProfile = new VehicleProfile();
491
+
492
+		$profile = new VehicleProfile();
493
+
494
+		$profile->name = "Heavy Duty - 48 Semitrailer ".date('Y-m-d H:i');
495
+		$profile->height_units = VehicleSizeUnits::METER;
496
+		$profile->width_units = VehicleSizeUnits::METER;
497
+		$profile->length_units = VehicleSizeUnits::METER;
498
+		$profile->height = 3.5;
499
+		$profile->width = 2.5;
500
+		$profile->length = 16;
501
+		$profile->is_predefined = false;
502
+		$profile->is_default = false;
503
+		$profile->weight_units = VehicleWeightUnits::KILOGRAM;
504
+		$profile->weight = 35000;
505
+		$profile->max_weight_per_axle = 17500;
506
+		$profile->fuel_type = FuelTypes::UNLEADED_87;
507
+		$profile->fuel_consumption_city = 6;
508
+		$profile->fuel_consumption_highway = 11;
509
+		$profile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
510
+		$profile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
511
+
512
+		$result = $vehicleProfile->createVehicleProfile($profile->toArray());
513
+
514
+		self::assertNotNull($result);
515
+		self::assertInstanceOf(
516
+			VehicleProfile::class,
517
+			VehicleProfile::fromArray($result)
518
+		);
519
+
520
+		self::$createdVehicleProfiles[] = $result;
521
+	}
522
+
523
+	// TODO: skip as since 20230605 VehicleProfile is not creatable
524
+	public function testDeleteVehicleProfile()
525
+	{
526
+		$this->markTestSkipped('must be revisited.');
527
+
528
+		$vehicleProfile = new VehicleProfile();
529
+
530
+		$vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id'];
531
+
532
+		$result = $vehicleProfile->removeVehicleProfile($vehProfileId);
533
+
534
+		self::assertNotNull($result);
535
+		self::assertInstanceOf(
536
+			VehicleProfile::class,
537
+			VehicleProfile::fromArray($result)
538
+		);
539
+
540
+		array_pop(self::$createdVehicleProfiles);
541
+	}
542
+
543
+	// TODO: skip as since 20230605 VehicleProfile is not creatable
544
+	public function testGetVehicleProfileById()
545
+	{
546
+		$this->markTestSkipped('must be revisited.');
547 547
 
548
-        $vehicleProfile = new VehicleProfile();
549
-
550
-        $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id'];
551
-
552
-        $result = $vehicleProfile->getVehicleProfileById($vehProfileId);
553
-
554
-        self::assertNotNull($result);
555
-        self::assertInstanceOf(
556
-            VehicleProfile::class,
557
-            VehicleProfile::fromArray($result)
558
-        );
559
-        self::assertEquals($vehProfileId, $result['vehicle_profile_id']);
560
-    }
561
-
562
-    public function testGetVehicleByLicensePlate()
563
-    {
564
-        $vehicle = new Vehicle();
565
-
566
-        $vehParams = new VehicleParameters();
567
-        $vehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate'];
568
-
569
-        $result = $vehicle->getVehicleByLicensePlate($vehParams);
570
-
571
-        self::assertNotNull($result);
572
-        self::assertInstanceOf(
573
-            VehicleResponse::class,
574
-            VehicleResponse::fromArray($result)
575
-        );
576
-    }
577
-
578
-    // TODO: request has uncheckable result - 500 Internal Server Error
579
-    public function testSearchVehicles()
580
-    {
581
-        $vehicle = new Vehicle();
582
-
583
-        $searchParams = new VehicleSearchParameters();
584
-
585
-        $searchParams->vehicle_ids = array_column(self::$createdVehicles, 'vehicle_id');
586
-        $searchParams->lat = 29.748868;
587
-        $searchParams->lng = -95.358473;
588
-
589
-        try {
590
-            $result = $vehicle->searchVehicles($searchParams);
591
-
592
-            self::assertNotNull($result);
593
-            self::assertInstanceOf(
594
-                Vehicle::class,
595
-                VehicleResponse::fromArray($result[0])
596
-            );
597
-        } catch (ApiError $err) {
598
-            $this->assertEquals($err->getCode(), 500);
599
-        }
600
-    }
601
-
602
-    public function testUpdateVehicle()
603
-    {
604
-        $vehicle = new Vehicle();
605
-
606
-        $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'] .' Updated';
607
-        $vehicle->vehicle_vin = '11111111111111111';
608
-        $vehicle->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
548
+		$vehicleProfile = new VehicleProfile();
549
+
550
+		$vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id'];
551
+
552
+		$result = $vehicleProfile->getVehicleProfileById($vehProfileId);
553
+
554
+		self::assertNotNull($result);
555
+		self::assertInstanceOf(
556
+			VehicleProfile::class,
557
+			VehicleProfile::fromArray($result)
558
+		);
559
+		self::assertEquals($vehProfileId, $result['vehicle_profile_id']);
560
+	}
561
+
562
+	public function testGetVehicleByLicensePlate()
563
+	{
564
+		$vehicle = new Vehicle();
565
+
566
+		$vehParams = new VehicleParameters();
567
+		$vehParams->vehicle_license_plate = self::$createdVehicles[0]['vehicle_license_plate'];
568
+
569
+		$result = $vehicle->getVehicleByLicensePlate($vehParams);
570
+
571
+		self::assertNotNull($result);
572
+		self::assertInstanceOf(
573
+			VehicleResponse::class,
574
+			VehicleResponse::fromArray($result)
575
+		);
576
+	}
577
+
578
+	// TODO: request has uncheckable result - 500 Internal Server Error
579
+	public function testSearchVehicles()
580
+	{
581
+		$vehicle = new Vehicle();
582
+
583
+		$searchParams = new VehicleSearchParameters();
584
+
585
+		$searchParams->vehicle_ids = array_column(self::$createdVehicles, 'vehicle_id');
586
+		$searchParams->lat = 29.748868;
587
+		$searchParams->lng = -95.358473;
588
+
589
+		try {
590
+			$result = $vehicle->searchVehicles($searchParams);
591
+
592
+			self::assertNotNull($result);
593
+			self::assertInstanceOf(
594
+				Vehicle::class,
595
+				VehicleResponse::fromArray($result[0])
596
+			);
597
+		} catch (ApiError $err) {
598
+			$this->assertEquals($err->getCode(), 500);
599
+		}
600
+	}
601
+
602
+	public function testUpdateVehicle()
603
+	{
604
+		$vehicle = new Vehicle();
605
+
606
+		$vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'] .' Updated';
607
+		$vehicle->vehicle_vin = '11111111111111111';
608
+		$vehicle->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
609 609
 
610
-        $result = $vehicle->updateVehicle($vehicle->toArray());
610
+		$result = $vehicle->updateVehicle($vehicle->toArray());
611 611
 
612
-        self::assertNotNull($result);
613
-        self::assertInstanceOf(
614
-            Vehicle::class,
615
-            Vehicle::fromArray($result)
616
-        );
617
-    }
612
+		self::assertNotNull($result);
613
+		self::assertInstanceOf(
614
+			Vehicle::class,
615
+			Vehicle::fromArray($result)
616
+		);
617
+	}
618 618
 
619
-    // TODO: skip as since 20230605 VehicleProfile is not creatable
620
-    public function testUpdateVehicleProfile()
621
-    {
622
-        $this->markTestSkipped('must be revisited.');
623
-
624
-        $vehicleProfile = new VehicleProfile();
619
+	// TODO: skip as since 20230605 VehicleProfile is not creatable
620
+	public function testUpdateVehicleProfile()
621
+	{
622
+		$this->markTestSkipped('must be revisited.');
623
+
624
+		$vehicleProfile = new VehicleProfile();
625 625
 
626
-        $vehProfileId = self::$createdVehicleProfiles[0]['vehicle_profile_id'];
626
+		$vehProfileId = self::$createdVehicleProfiles[0]['vehicle_profile_id'];
627 627
 
628
-        $vehicleProfile->name = self::$createdVehicleProfiles[0]['name'].'Updated';
629
-        $vehicleProfile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
630
-        $vehicleProfile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
631
-        $vehicleProfile->vehicle_profile_id = self::$createdVehicleProfiles[0]['vehicle_profile_id'];
632
-
633
-        $result = $vehicleProfile->updateVehicleProfile($vehicleProfile->toArray());
634
-
635
-        self::assertNotNull($result);
636
-        self::assertInstanceOf(
637
-            VehicleProfile::class,
638
-            VehicleProfile::fromArray($result)
639
-        );
640
-    }
641
-
642
-    public static function tearDownAfterClass()
643
-    {
644
-        $vehicle = new Vehicle();
645
-
646
-        $vehParams = new VehicleParameters();
647
-
648
-        foreach (self::$createdVehicles as $veh1) {
649
-            if (isset($veh1['vehicle_id'])) {
650
-                $vehParams->vehicle_id = $veh1['vehicle_id'];
651
-                $result1 = $vehicle->removeVehicle($vehParams->toArray());
652
-            }
653
-        }
654
-
655
-        $vehProfile = new VehicleProfile();
656
-
657
-        foreach (self::$createdVehicleProfiles as $prof1) {
658
-            if (isset($prof1['vehicle_profile_id'])) {
659
-                $result2 = $vehProfile->removeVehicleProfile($prof1['vehicle_profile_id']);
660
-            }
661
-        }
662
-    }
628
+		$vehicleProfile->name = self::$createdVehicleProfiles[0]['name'].'Updated';
629
+		$vehicleProfile->fuel_consumption_city_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
630
+		$vehicleProfile->fuel_consumption_highway_unit = FuelConsumptionUnits::MILES_PER_GALLON_US;
631
+		$vehicleProfile->vehicle_profile_id = self::$createdVehicleProfiles[0]['vehicle_profile_id'];
632
+
633
+		$result = $vehicleProfile->updateVehicleProfile($vehicleProfile->toArray());
634
+
635
+		self::assertNotNull($result);
636
+		self::assertInstanceOf(
637
+			VehicleProfile::class,
638
+			VehicleProfile::fromArray($result)
639
+		);
640
+	}
641
+
642
+	public static function tearDownAfterClass()
643
+	{
644
+		$vehicle = new Vehicle();
645
+
646
+		$vehParams = new VehicleParameters();
647
+
648
+		foreach (self::$createdVehicles as $veh1) {
649
+			if (isset($veh1['vehicle_id'])) {
650
+				$vehParams->vehicle_id = $veh1['vehicle_id'];
651
+				$result1 = $vehicle->removeVehicle($vehParams->toArray());
652
+			}
653
+		}
654
+
655
+		$vehProfile = new VehicleProfile();
656
+
657
+		foreach (self::$createdVehicleProfiles as $prof1) {
658
+			if (isset($prof1['vehicle_profile_id'])) {
659
+				$result2 = $vehProfile->removeVehicleProfile($prof1['vehicle_profile_id']);
660
+			}
661
+		}
662
+	}
663 663
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 
528 528
         $vehicleProfile = new VehicleProfile();
529 529
 
530
-        $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id'];
530
+        $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles) - 1]['vehicle_profile_id'];
531 531
 
532 532
         $result = $vehicleProfile->removeVehicleProfile($vehProfileId);
533 533
 
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 
548 548
         $vehicleProfile = new VehicleProfile();
549 549
 
550
-        $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles)-1]['vehicle_profile_id'];
550
+        $vehProfileId = self::$createdVehicleProfiles[sizeof(self::$createdVehicleProfiles) - 1]['vehicle_profile_id'];
551 551
 
552 552
         $result = $vehicleProfile->getVehicleProfileById($vehProfileId);
553 553
 
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
     {
604 604
         $vehicle = new Vehicle();
605 605
 
606
-        $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'] .' Updated';
606
+        $vehicle->vehicle_alias = self::$createdVehicles[0]['vehicle_alias'].' Updated';
607 607
         $vehicle->vehicle_vin = '11111111111111111';
608 608
         $vehicle->vehicle_id = self::$createdVehicles[0]['vehicle_id'];
609 609
 
Please login to merge, or discard this patch.
src/Route4Me/V5/RecurringRoutes/Schedules.php 2 patches
Indentation   +494 added lines, -494 removed lines patch added patch discarded remove patch
@@ -19,498 +19,498 @@
 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
-     *
330
-     * @since 1.2.3
331
-     *
332
-     * @param  string $route_id Route ID
333
-     * @return bool
334
-     * @throws Exception\ApiError
335
-     */
336
-    public function deleteRouteSchedules(string $route_id) : bool
337
-    {
338
-        $result = Route4Me::makeRequst([
339
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
340
-            'method' => 'DELETE'
341
-        ]);
342
-        return (isset($result['status']) ? $result['status'] : false);
343
-    }
344
-
345
-    /**
346
-     * Delete the specified Route Schedule.
347
-     *
348
-     * @since 1.2.3
349
-     *
350
-     * @param  string $route_id Route ID
351
-     * @return RouteSchedule
352
-     * @throws Exception\ApiError
353
-     */
354
-    public function deleteRouteSchedule(string $route_id) : RouteSchedule
355
-    {
356
-        return $this->toRouteSchedule(Route4Me::makeRequst([
357
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id  . '/items',
358
-            'method' => 'DELETE'
359
-        ]));
360
-    }
361
-
362
-    /**
363
-     * Replace the existing Route Schedule by sending the corresponding data.
364
-     *
365
-     * @since 1.2.3
366
-     *
367
-     * @param  string   $route_id Route ID.
368
-     * @param  array    $params
369
-     *   int      member_id - A unique ID of the root member,
370
-     *   string   vehicle_id - Vehicle ID,
371
-     *   string   schedule_uid - Schedule ID,
372
-     *   string   name,
373
-     *   string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD,
374
-     *   int      advance_interval,
375
-     *   int      advance_schedule_interval_days,
376
-     *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
377
-     *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
378
-     *   string   timezone - Timezone as 'America/New_York'
379
-     * @return RouteSchedule
380
-     * @throws Exception\ApiError
381
-     */
382
-    public function replaceRouteSchedule(string $route_id, array $params)
383
-    {
384
-        $allBodyFields = ['member_id', 'vehicle_id', 'schedule_uid', 'name', 'schedule_blacklist',
385
-            'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
386
-
387
-        return $this->toRouteSchedule(Route4Me::makeRequst([
388
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE . '/' . $route_id,
389
-            'method' => 'PUT',
390
-            'HTTPHEADER' => 'Content-Type: application/json',
391
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
392
-        ]));
393
-    }
394
-
395
-    /**
396
-     * Get the Route Schedule preview by specifying the 'route_id'.
397
-     *
398
-     * @since 1.2.3
399
-     *
400
-     * @param  string $routeId Route ID.
401
-     * @param  string $start Start date as 'YYYY-MM-DD'
402
-     * @param  string $end End date as 'YYYY-MM-DD'
403
-     * @return array
404
-     * @throws Exception\ApiError
405
-     */
406
-    public function getRouteSchedulePreview(string $route_id, string $start, string $end) : array
407
-    {
408
-        return Route4Me::makeRequst([
409
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/preview',
410
-            'method' => 'GET',
411
-            'query' => ['start' => $start, 'end' => $end]
412
-        ]);
413
-    }
414
-
415
-    /**
416
-     * Check if the Scheduled Route was copied by specifying the 'route_id'.
417
-     *
418
-     * @since 1.2.3
419
-     *
420
-     * @param  string $routeId Route ID.
421
-     * @return bool
422
-     * @throws Exception\ApiError
423
-     */
424
-    public function isScheduledRouteCopy(string $route_id) : bool
425
-    {
426
-        $result = Route4Me::makeRequst([
427
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY . '/' . $route_id,
428
-            'method' => 'GET'
429
-        ]);
430
-        return (isset($result['status']) ? $result['status'] : false);
431
-    }
432
-
433
-    /**
434
-     * Get all routes copied from the specified Scheduled Route by sending
435
-     * the corresponding data.
436
-     *
437
-     * @since 1.2.3
438
-     *
439
-     * @param  string   $route_id Route ID.
440
-     * @param  string   $schedule_uid Schedule ID.
441
-     * @param  string   $route_date Route date as 'YYYY-MM-DD'.
442
-     * @return array
443
-     * @throws Exception\ApiError
444
-     */
445
-    public function getScheduledRoutesCopies(string $route_id, string $schedule_uid, string $route_date) : array
446
-    {
447
-        return Route4Me::makeRequst([
448
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES,
449
-            'method' => 'POST',
450
-            'HTTPHEADER' => 'Content-Type: application/json',
451
-            'body' => [
452
-                'route_id' => $route_id,
453
-                'schedule_uid' => $schedule_uid,
454
-                'route_date' => $route_date
455
-            ]
456
-        ]);
457
-    }
458
-
459
-    /**
460
-     * Create a new Master Route by sending the corresponding data.
461
-     *
462
-     * @since 1.2.3
463
-     *
464
-     * @param  array    $params
465
-     *   string   route_id - Route ID,
466
-     *   string   route_name,
467
-     *   int      member_id - A unique ID of the root member,
468
-     *   string   vehicle_id - Vehicle ID,
469
-     *   string   schedule_uid - Schedule ID,
470
-     *   string   name,
471
-     *   string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD,
472
-     *   int      advance_interval,
473
-     *   int      advance_schedule_interval_days,
474
-     *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
475
-     *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
476
-     *   bool     sync - Type of result, synchronous or not
477
-     *   string   timezone - Timezone as 'America/New_York'
478
-     * @return bool
479
-     * @throws Exception\ApiError
480
-     */
481
-    public function createMasterRoute(array $params) : bool
482
-    {
483
-        $allBodyFields = ['route_id', 'route_name', 'member_id', 'schedule_uid', 'vehicle_id', 'name',
484
-            'schedule_blacklist', 'advance_schedule_interval_days', 'schedule', 'timezone', 'sync'];
485
-
486
-        $result = Route4Me::makeRequst([
487
-            'url' => Endpoint::RECURRING_ROUTES_MASTER_ROUTES,
488
-            'method' => 'POST',
489
-            'HTTPHEADER' => 'Content-Type: application/json',
490
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
491
-        ]);
492
-        return (isset($result['status']) ? $result['status'] : false);
493
-    }
494
-
495
-    private function toSchedule($result) : Schedule
496
-    {
497
-        if (is_array($result) && isset($result['data'])) {
498
-            $data = $result['data'];
499
-            if (is_array($data) && isset($data[0]) && is_array($data[0])) {
500
-                return new Schedule($data[0]);
501
-            }
502
-        }
503
-        throw new ApiError('Can not convert result to Schedule object.');
504
-    }
505
-
506
-    private function toRouteSchedule($result) : RouteSchedule
507
-    {
508
-        if (is_array($result) && isset($result['data'])) {
509
-            $data = $result['data'];
510
-            if (is_array($data) && isset($data[0]) && is_array($data[0])) {
511
-                return new RouteSchedule($data[0]);
512
-            }
513
-        }
514
-        throw new ApiError('Can not convert result to RouteSchedule object.');
515
-    }
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
+	 *
330
+	 * @since 1.2.3
331
+	 *
332
+	 * @param  string $route_id Route ID
333
+	 * @return bool
334
+	 * @throws Exception\ApiError
335
+	 */
336
+	public function deleteRouteSchedules(string $route_id) : bool
337
+	{
338
+		$result = Route4Me::makeRequst([
339
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
340
+			'method' => 'DELETE'
341
+		]);
342
+		return (isset($result['status']) ? $result['status'] : false);
343
+	}
344
+
345
+	/**
346
+	 * Delete the specified Route Schedule.
347
+	 *
348
+	 * @since 1.2.3
349
+	 *
350
+	 * @param  string $route_id Route ID
351
+	 * @return RouteSchedule
352
+	 * @throws Exception\ApiError
353
+	 */
354
+	public function deleteRouteSchedule(string $route_id) : RouteSchedule
355
+	{
356
+		return $this->toRouteSchedule(Route4Me::makeRequst([
357
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id  . '/items',
358
+			'method' => 'DELETE'
359
+		]));
360
+	}
361
+
362
+	/**
363
+	 * Replace the existing Route Schedule by sending the corresponding data.
364
+	 *
365
+	 * @since 1.2.3
366
+	 *
367
+	 * @param  string   $route_id Route ID.
368
+	 * @param  array    $params
369
+	 *   int      member_id - A unique ID of the root member,
370
+	 *   string   vehicle_id - Vehicle ID,
371
+	 *   string   schedule_uid - Schedule ID,
372
+	 *   string   name,
373
+	 *   string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD,
374
+	 *   int      advance_interval,
375
+	 *   int      advance_schedule_interval_days,
376
+	 *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
377
+	 *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
378
+	 *   string   timezone - Timezone as 'America/New_York'
379
+	 * @return RouteSchedule
380
+	 * @throws Exception\ApiError
381
+	 */
382
+	public function replaceRouteSchedule(string $route_id, array $params)
383
+	{
384
+		$allBodyFields = ['member_id', 'vehicle_id', 'schedule_uid', 'name', 'schedule_blacklist',
385
+			'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
386
+
387
+		return $this->toRouteSchedule(Route4Me::makeRequst([
388
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE . '/' . $route_id,
389
+			'method' => 'PUT',
390
+			'HTTPHEADER' => 'Content-Type: application/json',
391
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
392
+		]));
393
+	}
394
+
395
+	/**
396
+	 * Get the Route Schedule preview by specifying the 'route_id'.
397
+	 *
398
+	 * @since 1.2.3
399
+	 *
400
+	 * @param  string $routeId Route ID.
401
+	 * @param  string $start Start date as 'YYYY-MM-DD'
402
+	 * @param  string $end End date as 'YYYY-MM-DD'
403
+	 * @return array
404
+	 * @throws Exception\ApiError
405
+	 */
406
+	public function getRouteSchedulePreview(string $route_id, string $start, string $end) : array
407
+	{
408
+		return Route4Me::makeRequst([
409
+			'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/preview',
410
+			'method' => 'GET',
411
+			'query' => ['start' => $start, 'end' => $end]
412
+		]);
413
+	}
414
+
415
+	/**
416
+	 * Check if the Scheduled Route was copied by specifying the 'route_id'.
417
+	 *
418
+	 * @since 1.2.3
419
+	 *
420
+	 * @param  string $routeId Route ID.
421
+	 * @return bool
422
+	 * @throws Exception\ApiError
423
+	 */
424
+	public function isScheduledRouteCopy(string $route_id) : bool
425
+	{
426
+		$result = Route4Me::makeRequst([
427
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY . '/' . $route_id,
428
+			'method' => 'GET'
429
+		]);
430
+		return (isset($result['status']) ? $result['status'] : false);
431
+	}
432
+
433
+	/**
434
+	 * Get all routes copied from the specified Scheduled Route by sending
435
+	 * the corresponding data.
436
+	 *
437
+	 * @since 1.2.3
438
+	 *
439
+	 * @param  string   $route_id Route ID.
440
+	 * @param  string   $schedule_uid Schedule ID.
441
+	 * @param  string   $route_date Route date as 'YYYY-MM-DD'.
442
+	 * @return array
443
+	 * @throws Exception\ApiError
444
+	 */
445
+	public function getScheduledRoutesCopies(string $route_id, string $schedule_uid, string $route_date) : array
446
+	{
447
+		return Route4Me::makeRequst([
448
+			'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_GET_COPIES,
449
+			'method' => 'POST',
450
+			'HTTPHEADER' => 'Content-Type: application/json',
451
+			'body' => [
452
+				'route_id' => $route_id,
453
+				'schedule_uid' => $schedule_uid,
454
+				'route_date' => $route_date
455
+			]
456
+		]);
457
+	}
458
+
459
+	/**
460
+	 * Create a new Master Route by sending the corresponding data.
461
+	 *
462
+	 * @since 1.2.3
463
+	 *
464
+	 * @param  array    $params
465
+	 *   string   route_id - Route ID,
466
+	 *   string   route_name,
467
+	 *   int      member_id - A unique ID of the root member,
468
+	 *   string   vehicle_id - Vehicle ID,
469
+	 *   string   schedule_uid - Schedule ID,
470
+	 *   string   name,
471
+	 *   string[] schedule_blacklist - Blacklisted dates as YYYY-MM-DD,
472
+	 *   int      advance_interval,
473
+	 *   int      advance_schedule_interval_days,
474
+	 *   string   schedule - Schedule as JSON string e.g. '{"enabled":true,"mode":"daily",
475
+	 *                           "daily":{"every":2}, "from":"2019-06-05","timestamp":1558538737}',
476
+	 *   bool     sync - Type of result, synchronous or not
477
+	 *   string   timezone - Timezone as 'America/New_York'
478
+	 * @return bool
479
+	 * @throws Exception\ApiError
480
+	 */
481
+	public function createMasterRoute(array $params) : bool
482
+	{
483
+		$allBodyFields = ['route_id', 'route_name', 'member_id', 'schedule_uid', 'vehicle_id', 'name',
484
+			'schedule_blacklist', 'advance_schedule_interval_days', 'schedule', 'timezone', 'sync'];
485
+
486
+		$result = Route4Me::makeRequst([
487
+			'url' => Endpoint::RECURRING_ROUTES_MASTER_ROUTES,
488
+			'method' => 'POST',
489
+			'HTTPHEADER' => 'Content-Type: application/json',
490
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
491
+		]);
492
+		return (isset($result['status']) ? $result['status'] : false);
493
+	}
494
+
495
+	private function toSchedule($result) : Schedule
496
+	{
497
+		if (is_array($result) && isset($result['data'])) {
498
+			$data = $result['data'];
499
+			if (is_array($data) && isset($data[0]) && is_array($data[0])) {
500
+				return new Schedule($data[0]);
501
+			}
502
+		}
503
+		throw new ApiError('Can not convert result to Schedule object.');
504
+	}
505
+
506
+	private function toRouteSchedule($result) : RouteSchedule
507
+	{
508
+		if (is_array($result) && isset($result['data'])) {
509
+			$data = $result['data'];
510
+			if (is_array($data) && isset($data[0]) && is_array($data[0])) {
511
+				return new RouteSchedule($data[0]);
512
+			}
513
+		}
514
+		throw new ApiError('Can not convert result to RouteSchedule object.');
515
+	}
516 516
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 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)
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
     public function deleteRouteSchedules(string $route_id) : bool
337 337
     {
338 338
         $result = Route4Me::makeRequst([
339
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id,
339
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES.'/'.$route_id,
340 340
             'method' => 'DELETE'
341 341
         ]);
342 342
         return (isset($result['status']) ? $result['status'] : false);
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
     public function deleteRouteSchedule(string $route_id) : RouteSchedule
355 355
     {
356 356
         return $this->toRouteSchedule(Route4Me::makeRequst([
357
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id  . '/items',
357
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES.'/'.$route_id.'/items',
358 358
             'method' => 'DELETE'
359 359
         ]));
360 360
     }
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
             'advance_interval', 'advance_schedule_interval_days', 'schedule', 'timezone'];
386 386
 
387 387
         return $this->toRouteSchedule(Route4Me::makeRequst([
388
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE . '/' . $route_id,
388
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES_REPLACE.'/'.$route_id,
389 389
             'method' => 'PUT',
390 390
             'HTTPHEADER' => 'Content-Type: application/json',
391 391
             'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
     public function getRouteSchedulePreview(string $route_id, string $start, string $end) : array
407 407
     {
408 408
         return Route4Me::makeRequst([
409
-            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES . '/' . $route_id . '/preview',
409
+            'url' => Endpoint::RECURRING_ROUTES_ROUTE_SCHEDULES.'/'.$route_id.'/preview',
410 410
             'method' => 'GET',
411 411
             'query' => ['start' => $start, 'end' => $end]
412 412
         ]);
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     public function isScheduledRouteCopy(string $route_id) : bool
425 425
     {
426 426
         $result = Route4Me::makeRequst([
427
-            'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY . '/' . $route_id,
427
+            'url' => Endpoint::RECURRING_ROUTES_SCHEDULED_ROUTES_IS_COPY.'/'.$route_id,
428 428
             'method' => 'GET'
429 429
         ]);
430 430
         return (isset($result['status']) ? $result['status'] : false);
Please login to merge, or discard this patch.
src/Route4Me/V5/Vehicles/QueryTypes/VehicleSearchParameters.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@
 block discarded – undo
11 11
  */
12 12
 class VehicleSearchParameters extends \Route4Me\Common
13 13
 {
14
-    /** An array of the vehicle IDs.
15
-     * @var string[] $vehicle_ids
16
-     */
17
-    public $vehicle_ids = [];
14
+	/** An array of the vehicle IDs.
15
+	 * @var string[] $vehicle_ids
16
+	 */
17
+	public $vehicle_ids = [];
18 18
 
19
-    /** Latitude of a vehicle position.
20
-     * @var float $lat
21
-     */
22
-    public $lat;
19
+	/** Latitude of a vehicle position.
20
+	 * @var float $lat
21
+	 */
22
+	public $lat;
23 23
 
24
-    /** Longitude of a vehicle position.
25
-     * @var float $lng
26
-     */
27
-    public $lng;
24
+	/** Longitude of a vehicle position.
25
+	 * @var float $lng
26
+	 */
27
+	public $lng;
28 28
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/Vehicles/QueryTypes/VehicleProfileParameters.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
  */
12 12
 class VehicleProfileParameters extends Common
13 13
 {
14
-    /** If true, returned vehicle profile is paginated.
15
-     * @var boolean $with_pagination
16
-     */
17
-    public $with_pagination;
14
+	/** If true, returned vehicle profile is paginated.
15
+	 * @var boolean $with_pagination
16
+	 */
17
+	public $with_pagination;
18 18
 
19
-    /** Current page number in the vehicles collection
20
-     * @var integer $page
21
-     */
22
-    public $page;
19
+	/** Current page number in the vehicles collection
20
+	 * @var integer $page
21
+	 */
22
+	public $page;
23 23
 
24
-    /** Returned vehicles number per page
25
-     * @var integer $perPage
26
-     */
27
-    public $perPage;
24
+	/** Returned vehicles number per page
25
+	 * @var integer $perPage
26
+	 */
27
+	public $perPage;
28 28
 
29
-    /** Vehicle profile ID
30
-     * @var integer $id
31
-     */
32
-    public $id;
29
+	/** Vehicle profile ID
30
+	 * @var integer $id
31
+	 */
32
+	public $id;
33 33
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/Vehicles/QueryTypes/VehicleOrderParameters.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -11,33 +11,33 @@
 block discarded – undo
11 11
  */
12 12
 class VehicleOrderParameters extends Common
13 13
 {
14
-    /** The vehicle ID
15
-     * @var string $vehicle_id
16
-     */
17
-    public $vehicle_id;
14
+	/** The vehicle ID
15
+	 * @var string $vehicle_id
16
+	 */
17
+	public $vehicle_id;
18 18
 
19
-    /** Latitude of a vehicle position.
20
-     * @var float $lat
21
-     */
22
-    public $lat;
19
+	/** Latitude of a vehicle position.
20
+	 * @var float $lat
21
+	 */
22
+	public $lat;
23 23
 
24
-    /** Longitude of a vehicle position.
25
-     * @var float $lng
26
-     */
27
-    public $lng;
24
+	/** Longitude of a vehicle position.
25
+	 * @var float $lng
26
+	 */
27
+	public $lng;
28 28
 
29
-    public static function fromArray(array $params)
30
-    {
31
-        $orderParams = new self();
29
+	public static function fromArray(array $params)
30
+	{
31
+		$orderParams = new self();
32 32
 
33
-        foreach ($params as $key => $value) {
34
-            if (is_null(Common::getValue($params, $key))) {
35
-                continue;
36
-            }
37
-            if (property_exists($orderParams, $key)) {
38
-                $orderParams->$key = $value;
39
-            }
40
-        }
41
-        return $orderParams;
42
-    }
33
+		foreach ($params as $key => $value) {
34
+			if (is_null(Common::getValue($params, $key))) {
35
+				continue;
36
+			}
37
+			if (property_exists($orderParams, $key)) {
38
+				$orderParams->$key = $value;
39
+			}
40
+		}
41
+		return $orderParams;
42
+	}
43 43
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/Vehicles/QueryTypes/VehicleParameters.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -6,48 +6,48 @@
 block discarded – undo
6 6
 
7 7
 class VehicleParameters extends Common
8 8
 {
9
-    /** If true, returned vehicles array will be paginated
10
-     * @var boolean $with_pagination
11
-     */
12
-    public $with_pagination;
13
-
14
-    /** Current page number in the vehicles collection
15
-     * @var integer $page
16
-     */
17
-    public $page;
18
-
19
-    /** Returned vehicles number per page
20
-     * @var integer $perPage
21
-     */
22
-    public $perPage;
23
-
24
-    /** An array of the Vehicle IDs.
25
-     * @var string[] $ids = []
26
-     */
27
-    public $ids;
28
-
29
-    /** Vehicle ID
30
-     * @var string $vehicle_id
31
-     */
32
-    public $vehicle_id;
33
-
34
-    /** Vehicle license plate
35
-     * @var string $vehicle_license_plate
36
-     */
37
-    public $vehicle_license_plate;
38
-
39
-    public static function fromArray(array $params)
40
-    {
41
-        $vehParams = new self();
42
-
43
-        foreach ($params as $key => $value) {
44
-            if (is_null(Common::getValue($params, $key))) {
45
-                continue;
46
-            }
47
-            if (property_exists($vehParams, $key)) {
48
-                $vehParams->$key = $value;
49
-            }
50
-        }
51
-        return $vehParams;
52
-    }
9
+	/** If true, returned vehicles array will be paginated
10
+	 * @var boolean $with_pagination
11
+	 */
12
+	public $with_pagination;
13
+
14
+	/** Current page number in the vehicles collection
15
+	 * @var integer $page
16
+	 */
17
+	public $page;
18
+
19
+	/** Returned vehicles number per page
20
+	 * @var integer $perPage
21
+	 */
22
+	public $perPage;
23
+
24
+	/** An array of the Vehicle IDs.
25
+	 * @var string[] $ids = []
26
+	 */
27
+	public $ids;
28
+
29
+	/** Vehicle ID
30
+	 * @var string $vehicle_id
31
+	 */
32
+	public $vehicle_id;
33
+
34
+	/** Vehicle license plate
35
+	 * @var string $vehicle_license_plate
36
+	 */
37
+	public $vehicle_license_plate;
38
+
39
+	public static function fromArray(array $params)
40
+	{
41
+		$vehParams = new self();
42
+
43
+		foreach ($params as $key => $value) {
44
+			if (is_null(Common::getValue($params, $key))) {
45
+				continue;
46
+			}
47
+			if (property_exists($vehParams, $key)) {
48
+				$vehParams->$key = $value;
49
+			}
50
+		}
51
+		return $vehParams;
52
+	}
53 53
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/Vehicles/DataTypes/VehicleTrackResponse.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
  */
12 12
 class VehicleTrackResponse extends Common
13 13
 {
14
-    /** An array of the vehicle locations
15
-     * @var VehicleTrackItem[]  $data
16
-     */
17
-    public $data = [];
14
+	/** An array of the vehicle locations
15
+	 * @var VehicleTrackItem[]  $data
16
+	 */
17
+	public $data = [];
18 18
 
19
-    public static function fromArray(array $params)
20
-    {
21
-        $vehicleTrack = new self();
19
+	public static function fromArray(array $params)
20
+	{
21
+		$vehicleTrack = new self();
22 22
 
23
-        foreach ($params as $key => $value) {
24
-            if (is_null(Common::getValue($params, $key))) {
25
-                continue;
26
-            }
27
-            if (property_exists($vehicleTrack, $key)) {
28
-                $vehicleTrack->$key = $value;
29
-            }
30
-        }
31
-        return $vehicleTrack;
32
-    }
23
+		foreach ($params as $key => $value) {
24
+			if (is_null(Common::getValue($params, $key))) {
25
+				continue;
26
+			}
27
+			if (property_exists($vehicleTrack, $key)) {
28
+				$vehicleTrack->$key = $value;
29
+			}
30
+		}
31
+		return $vehicleTrack;
32
+	}
33 33
 }
Please login to merge, or discard this patch.