GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( d9a634...e591c7 )
by Juan Jose
07:17 queued 16s
created
UnitTestFiles/Test/V5/OrderUnitTests.php 2 patches
Indentation   +351 added lines, -351 removed lines patch added patch discarded remove patch
@@ -15,357 +15,357 @@
 block discarded – undo
15 15
 
16 16
 final class OrderUnitTests extends \PHPUnit\Framework\TestCase
17 17
 {
18
-    public static ?string $created_uuid = null;
19
-    public static ?string $created_field_uuid = null;
20
-
21
-    public static function setUpBeforeClass() : void
22
-    {
23
-        Route4Me::setApiKey(Constants::API_KEY);
24
-    }
25
-
26
-    public function testCustomDataCanBeCreateEmpty() : void
27
-    {
28
-        $this->assertInstanceOf(CustomData::class, new CustomData());
29
-    }
30
-
31
-    public function testCustomDataCanBeCreateFromArray() : void
32
-    {
33
-        $this->assertInstanceOf(CustomData::class, new CustomData([
34
-            'barcode' => '1',
35
-            'airbillno' => '2',
36
-            'sorted_on_date' => '3',
37
-            'sorted_on_utc' => 1
38
-        ]));
39
-    }
40
-
41
-    public function testCustomFieldCanBeCreateEmpty() : void
42
-    {
43
-        $this->assertInstanceOf(CustomField::class, new CustomField());
44
-    }
45
-
46
-    public function testCustomFieldCanBeCreateFromArray() : void
47
-    {
48
-        $this->assertInstanceOf(CustomField::class, new CustomField([
49
-            'order_custom_field_uuid' => 'uuid',
50
-            'order_custom_field_value' => 'value'
51
-        ]));
52
-    }
53
-
54
-    public function testGPSCoordsCanBeCreateEmpty() : void
55
-    {
56
-        $this->assertInstanceOf(GPSCoords::class, new GPSCoords());
57
-    }
58
-
59
-    public function testGPSCoordsCanBeCreateByConstructor() : void
60
-    {
61
-        $coords = new GPSCoords(40.5, 90.0);
62
-        $this->assertInstanceOf(GPSCoords::class, $coords);
63
-        $this->assertEquals($coords->lat, 40.5);
64
-        $this->assertEquals($coords->lng, 90.0);
65
-    }
66
-
67
-    public function testGPSCoordsCanBeCreateFromArray() : void
68
-    {
69
-        $coords = new GPSCoords([
70
-            'lat' => 40.5,
71
-            'lng' => 90.0
72
-        ]);
73
-        $this->assertInstanceOf(GPSCoords::class, $coords);
74
-        $this->assertEquals($coords->lat, 40.5);
75
-        $this->assertEquals($coords->lng, 90.0);
76
-    }
77
-
78
-    public function testLocalTimeWindowCanBeCreateEmpty() : void
79
-    {
80
-        $this->assertInstanceOf(LocalTimeWindow::class, new LocalTimeWindow());
81
-    }
82
-
83
-    public function testLocalTimeWindowCanBeCreateByConstructor() : void
84
-    {
85
-        $coords = new LocalTimeWindow(1, 2);
86
-        $this->assertInstanceOf(LocalTimeWindow::class, $coords);
87
-        $this->assertEquals($coords->start, 1);
88
-        $this->assertEquals($coords->end, 2);
89
-    }
90
-
91
-    public function testLocalTimeWindowCanBeCreateFromArray() : void
92
-    {
93
-        $coords = new LocalTimeWindow([
94
-            'start' => 1,
95
-            'end' => 2
96
-        ]);
97
-        $this->assertInstanceOf(LocalTimeWindow::class, $coords);
98
-        $this->assertEquals($coords->start, 1);
99
-        $this->assertEquals($coords->end, 2);
100
-    }
101
-
102
-    public function testOrderCanBeCreateEmpty() : void
103
-    {
104
-        $this->assertInstanceOf(Order::class, new Order());
105
-    }
106
-
107
-    public function testOrderCanBeCreateFromArray() : void
108
-    {
109
-        $order = new Order([
110
-            'first_name' => 'John',
111
-            'last_name' => 'Doe',
112
-            'email' => '[email protected]'
113
-        ]);
114
-        $this->assertInstanceOf(Order::class, $order);
115
-        $this->assertEquals($order->first_name, 'John');
116
-        $this->assertEquals($order->last_name, 'Doe');
117
-    }
118
-
119
-    public function testResponseOrderCanBeCreateEmpty() : void
120
-    {
121
-        $this->assertInstanceOf(Order::class, new Order());
122
-    }
123
-
124
-    public function testResponseOrderCanBeCreateFromArray() : void
125
-    {
126
-        $order = new ResponseOrder([
127
-            'first_name' => 'John',
128
-            'last_name' => 'Doe',
129
-            'email' => '[email protected]'
130
-        ]);
131
-        $this->assertInstanceOf(ResponseOrder::class, $order);
132
-        $this->assertEquals($order->first_name, 'John');
133
-        $this->assertEquals($order->last_name, 'Doe');
134
-    }
135
-
136
-    public function testCreateMustReturnResponseOrder() : void
137
-    {
138
-        $orders = new Orders();
139
-        $order = $orders->create([
140
-            'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
141
-            'address_alias' => 'Auto test address',
142
-            'address_city' => 'Philadelphia',
143
-            'address_geo' => [
144
-                'lat' => 48.335991,
145
-                'lng' => 31.18287
146
-            ],
147
-            'first_name' => 'John',
148
-            'last_name' => 'Doe',
149
-            'email' => '[email protected]'
150
-        ]);
151
-
152
-        $this->assertInstanceOf(ResponseOrder::class, $order);
153
-        $this->assertNotNull($order->first_name);
154
-        $this->assertEquals($order->first_name, 'John');
18
+	public static ?string $created_uuid = null;
19
+	public static ?string $created_field_uuid = null;
20
+
21
+	public static function setUpBeforeClass() : void
22
+	{
23
+		Route4Me::setApiKey(Constants::API_KEY);
24
+	}
25
+
26
+	public function testCustomDataCanBeCreateEmpty() : void
27
+	{
28
+		$this->assertInstanceOf(CustomData::class, new CustomData());
29
+	}
30
+
31
+	public function testCustomDataCanBeCreateFromArray() : void
32
+	{
33
+		$this->assertInstanceOf(CustomData::class, new CustomData([
34
+			'barcode' => '1',
35
+			'airbillno' => '2',
36
+			'sorted_on_date' => '3',
37
+			'sorted_on_utc' => 1
38
+		]));
39
+	}
40
+
41
+	public function testCustomFieldCanBeCreateEmpty() : void
42
+	{
43
+		$this->assertInstanceOf(CustomField::class, new CustomField());
44
+	}
45
+
46
+	public function testCustomFieldCanBeCreateFromArray() : void
47
+	{
48
+		$this->assertInstanceOf(CustomField::class, new CustomField([
49
+			'order_custom_field_uuid' => 'uuid',
50
+			'order_custom_field_value' => 'value'
51
+		]));
52
+	}
53
+
54
+	public function testGPSCoordsCanBeCreateEmpty() : void
55
+	{
56
+		$this->assertInstanceOf(GPSCoords::class, new GPSCoords());
57
+	}
58
+
59
+	public function testGPSCoordsCanBeCreateByConstructor() : void
60
+	{
61
+		$coords = new GPSCoords(40.5, 90.0);
62
+		$this->assertInstanceOf(GPSCoords::class, $coords);
63
+		$this->assertEquals($coords->lat, 40.5);
64
+		$this->assertEquals($coords->lng, 90.0);
65
+	}
66
+
67
+	public function testGPSCoordsCanBeCreateFromArray() : void
68
+	{
69
+		$coords = new GPSCoords([
70
+			'lat' => 40.5,
71
+			'lng' => 90.0
72
+		]);
73
+		$this->assertInstanceOf(GPSCoords::class, $coords);
74
+		$this->assertEquals($coords->lat, 40.5);
75
+		$this->assertEquals($coords->lng, 90.0);
76
+	}
77
+
78
+	public function testLocalTimeWindowCanBeCreateEmpty() : void
79
+	{
80
+		$this->assertInstanceOf(LocalTimeWindow::class, new LocalTimeWindow());
81
+	}
82
+
83
+	public function testLocalTimeWindowCanBeCreateByConstructor() : void
84
+	{
85
+		$coords = new LocalTimeWindow(1, 2);
86
+		$this->assertInstanceOf(LocalTimeWindow::class, $coords);
87
+		$this->assertEquals($coords->start, 1);
88
+		$this->assertEquals($coords->end, 2);
89
+	}
90
+
91
+	public function testLocalTimeWindowCanBeCreateFromArray() : void
92
+	{
93
+		$coords = new LocalTimeWindow([
94
+			'start' => 1,
95
+			'end' => 2
96
+		]);
97
+		$this->assertInstanceOf(LocalTimeWindow::class, $coords);
98
+		$this->assertEquals($coords->start, 1);
99
+		$this->assertEquals($coords->end, 2);
100
+	}
101
+
102
+	public function testOrderCanBeCreateEmpty() : void
103
+	{
104
+		$this->assertInstanceOf(Order::class, new Order());
105
+	}
106
+
107
+	public function testOrderCanBeCreateFromArray() : void
108
+	{
109
+		$order = new Order([
110
+			'first_name' => 'John',
111
+			'last_name' => 'Doe',
112
+			'email' => '[email protected]'
113
+		]);
114
+		$this->assertInstanceOf(Order::class, $order);
115
+		$this->assertEquals($order->first_name, 'John');
116
+		$this->assertEquals($order->last_name, 'Doe');
117
+	}
118
+
119
+	public function testResponseOrderCanBeCreateEmpty() : void
120
+	{
121
+		$this->assertInstanceOf(Order::class, new Order());
122
+	}
123
+
124
+	public function testResponseOrderCanBeCreateFromArray() : void
125
+	{
126
+		$order = new ResponseOrder([
127
+			'first_name' => 'John',
128
+			'last_name' => 'Doe',
129
+			'email' => '[email protected]'
130
+		]);
131
+		$this->assertInstanceOf(ResponseOrder::class, $order);
132
+		$this->assertEquals($order->first_name, 'John');
133
+		$this->assertEquals($order->last_name, 'Doe');
134
+	}
135
+
136
+	public function testCreateMustReturnResponseOrder() : void
137
+	{
138
+		$orders = new Orders();
139
+		$order = $orders->create([
140
+			'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
141
+			'address_alias' => 'Auto test address',
142
+			'address_city' => 'Philadelphia',
143
+			'address_geo' => [
144
+				'lat' => 48.335991,
145
+				'lng' => 31.18287
146
+			],
147
+			'first_name' => 'John',
148
+			'last_name' => 'Doe',
149
+			'email' => '[email protected]'
150
+		]);
151
+
152
+		$this->assertInstanceOf(ResponseOrder::class, $order);
153
+		$this->assertNotNull($order->first_name);
154
+		$this->assertEquals($order->first_name, 'John');
155 155
         
156
-        self::$created_uuid = $order->order_uuid;
157
-    }
158
-
159
-    public function testGetMustReturnResponseOrder() : void
160
-    {
161
-        if (self::$created_uuid !== null) {
162
-            $orders = new Orders();
163
-            $order = $orders->get(self::$created_uuid);
164
-
165
-            $this->assertInstanceOf(ResponseOrder::class, $order);
166
-            $this->assertNotNull($order->first_name);
167
-            $this->assertEquals($order->first_name, 'John');
168
-        }
169
-    }
170
-
171
-    public function testUpdateMustReturnResponseOrder() : void
172
-    {
173
-        if (self::$created_uuid !== null) {
174
-            $orders = new Orders();
175
-            $order = $orders->update(self::$created_uuid, ['first_name' => 'Jane']);
176
-
177
-            $this->assertInstanceOf(ResponseOrder::class, $order);
178
-            $this->assertNotNull($order->first_name);
179
-            $this->assertEquals($order->first_name, 'Jane');
180
-        }
181
-    }
182
-
183
-    public function testSearchMustReturnResponseSearchWithoutParams() : void
184
-    {
185
-        $orders = new Orders();
186
-        $res = $orders->search();
187
-
188
-        $this->assertInstanceOf(ResponseSearch::class, $res);
189
-        $this->assertNotNull($res->total);
190
-    }
191
-
192
-    public function testSearchMustReturnResponseSearchWithParams() : void
193
-    {
194
-        if (self::$created_uuid !== null) {
195
-            $orders = new Orders();
196
-            $params = [
197
-                "filters" => [
198
-                    "order_ids" => [self::$created_uuid]
199
-                ]
200
-            ];
201
-            $res = $orders->search($params);
202
-
203
-            $this->assertInstanceOf(ResponseSearch::class, $res);
204
-            $this->assertNotNull($res->total);
205
-            $this->assertNotNull($res->results);
206
-        }
207
-    }
208
-
209
-    public function testBatchCreateMustReturnTrue() : void
210
-    {
211
-        $this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
212
-
213
-        $orders = new Orders();
214
-        $params = [
215
-            [
216
-                'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
217
-                'address_alias' => 'Address for batch workflow 0',
218
-                'address_city' => 'Philadelphia',
219
-                'address_geo' => [
220
-                    'lat' => 48.335991,
221
-                    'lng' => 31.18287
222
-                ],
223
-                'first_name' => 'John',
224
-                'last_name' => 'Doe',
225
-                'email' => '[email protected]'
226
-            ], [
227
-                'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
228
-                'address_alias' => 'Address for batch workflow 1',
229
-                'address_city' => 'Philadelphia',
230
-                'address_geo' => [
231
-                    'lat' => 48.335991,
232
-                    'lng' => 31.18287
233
-                ],
234
-                'first_name' => 'John',
235
-                'last_name' => 'Doe',
236
-                'email' => '[email protected]'
237
-            ]
238
-        ];
239
-        $res = $orders->batchCreate($params);
240
-
241
-        $this->assertIsBool($res);
242
-        $this->assertTrue($res);
243
-    }
244
-
245
-    public function testBatchUpdateMustReturnArray() : void
246
-    {
247
-        $this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
248
-
249
-        $orders = new Orders();
250
-        $orderIds = ['', ''];
251
-        $data = [
252
-            'first_name' => 'Jane'
253
-        ];
254
-        $res = $orders->batchUpdate($orderIds, $data);
255
-
256
-        $this->assertIsArray($res);
257
-    }
258
-
259
-    public function testBatchUpdateByFiltersMustReturnTrue() : void
260
-    {
261
-        $this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
262
-
263
-        $orders = new Orders();
264
-        $params = [
265
-            'data' => [
266
-                'first_name' => 'John'
267
-            ],
268
-            'filters' => [
269
-                'orderIds' => ['', '']
270
-            ]
271
-        ];
272
-        $res = $orders->batchUpdateByFilters($params);
273
-
274
-        $this->assertIsBool($res);
275
-        $this->assertTrue($res);
276
-    }
277
-
278
-    public function testBatchDeleteMustReturnTrue() : void
279
-    {
280
-        $this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
281
-
282
-        $orders = new Orders();
283
-        $orderIds = ['', ''];
284
-        $res = $orders->batchDelete($orderIds);
285
-
286
-        $this->assertIsBool($res);
287
-        $this->assertTrue($res);
288
-    }
289
-
290
-    public function testGetOrderCustomFieldsReturnArray() : void
291
-    {
292
-        $orders = new Orders();
293
-        $res = $orders->getOrderCustomFields();
294
-
295
-        $this->assertIsArray($res);
296
-    }
297
-
298
-    public function testCreateOrderCustomFieldMustReturnCustomField() : void
299
-    {
300
-        $orders = new Orders();
301
-        $field = $orders->createOrderCustomField([
302
-            'order_custom_field_name' => 'CustomField1',
303
-            'order_custom_field_label' => 'Custom Field 1',
304
-            'order_custom_field_type' => 'checkbox',
305
-            'order_custom_field_type_info' => [
306
-                'short_label' => 'cFl1'
307
-            ]
308
-        ]);
309
-
310
-        $this->assertInstanceOf(CustomField::class, $field);
311
-        $this->assertNotNull($field->order_custom_field_label);
312
-        $this->assertEquals($field->order_custom_field_label, 'Custom Field 1');
156
+		self::$created_uuid = $order->order_uuid;
157
+	}
158
+
159
+	public function testGetMustReturnResponseOrder() : void
160
+	{
161
+		if (self::$created_uuid !== null) {
162
+			$orders = new Orders();
163
+			$order = $orders->get(self::$created_uuid);
164
+
165
+			$this->assertInstanceOf(ResponseOrder::class, $order);
166
+			$this->assertNotNull($order->first_name);
167
+			$this->assertEquals($order->first_name, 'John');
168
+		}
169
+	}
170
+
171
+	public function testUpdateMustReturnResponseOrder() : void
172
+	{
173
+		if (self::$created_uuid !== null) {
174
+			$orders = new Orders();
175
+			$order = $orders->update(self::$created_uuid, ['first_name' => 'Jane']);
176
+
177
+			$this->assertInstanceOf(ResponseOrder::class, $order);
178
+			$this->assertNotNull($order->first_name);
179
+			$this->assertEquals($order->first_name, 'Jane');
180
+		}
181
+	}
182
+
183
+	public function testSearchMustReturnResponseSearchWithoutParams() : void
184
+	{
185
+		$orders = new Orders();
186
+		$res = $orders->search();
187
+
188
+		$this->assertInstanceOf(ResponseSearch::class, $res);
189
+		$this->assertNotNull($res->total);
190
+	}
191
+
192
+	public function testSearchMustReturnResponseSearchWithParams() : void
193
+	{
194
+		if (self::$created_uuid !== null) {
195
+			$orders = new Orders();
196
+			$params = [
197
+				"filters" => [
198
+					"order_ids" => [self::$created_uuid]
199
+				]
200
+			];
201
+			$res = $orders->search($params);
202
+
203
+			$this->assertInstanceOf(ResponseSearch::class, $res);
204
+			$this->assertNotNull($res->total);
205
+			$this->assertNotNull($res->results);
206
+		}
207
+	}
208
+
209
+	public function testBatchCreateMustReturnTrue() : void
210
+	{
211
+		$this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
212
+
213
+		$orders = new Orders();
214
+		$params = [
215
+			[
216
+				'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
217
+				'address_alias' => 'Address for batch workflow 0',
218
+				'address_city' => 'Philadelphia',
219
+				'address_geo' => [
220
+					'lat' => 48.335991,
221
+					'lng' => 31.18287
222
+				],
223
+				'first_name' => 'John',
224
+				'last_name' => 'Doe',
225
+				'email' => '[email protected]'
226
+			], [
227
+				'address_1' => '1358 E Luzerne St, Philadelphia, PA 19124, US',
228
+				'address_alias' => 'Address for batch workflow 1',
229
+				'address_city' => 'Philadelphia',
230
+				'address_geo' => [
231
+					'lat' => 48.335991,
232
+					'lng' => 31.18287
233
+				],
234
+				'first_name' => 'John',
235
+				'last_name' => 'Doe',
236
+				'email' => '[email protected]'
237
+			]
238
+		];
239
+		$res = $orders->batchCreate($params);
240
+
241
+		$this->assertIsBool($res);
242
+		$this->assertTrue($res);
243
+	}
244
+
245
+	public function testBatchUpdateMustReturnArray() : void
246
+	{
247
+		$this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
248
+
249
+		$orders = new Orders();
250
+		$orderIds = ['', ''];
251
+		$data = [
252
+			'first_name' => 'Jane'
253
+		];
254
+		$res = $orders->batchUpdate($orderIds, $data);
255
+
256
+		$this->assertIsArray($res);
257
+	}
258
+
259
+	public function testBatchUpdateByFiltersMustReturnTrue() : void
260
+	{
261
+		$this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
262
+
263
+		$orders = new Orders();
264
+		$params = [
265
+			'data' => [
266
+				'first_name' => 'John'
267
+			],
268
+			'filters' => [
269
+				'orderIds' => ['', '']
270
+			]
271
+		];
272
+		$res = $orders->batchUpdateByFilters($params);
273
+
274
+		$this->assertIsBool($res);
275
+		$this->assertTrue($res);
276
+	}
277
+
278
+	public function testBatchDeleteMustReturnTrue() : void
279
+	{
280
+		$this->markTestSkipped('must be revisited, cannot get back IDs or created Orders.');
281
+
282
+		$orders = new Orders();
283
+		$orderIds = ['', ''];
284
+		$res = $orders->batchDelete($orderIds);
285
+
286
+		$this->assertIsBool($res);
287
+		$this->assertTrue($res);
288
+	}
289
+
290
+	public function testGetOrderCustomFieldsReturnArray() : void
291
+	{
292
+		$orders = new Orders();
293
+		$res = $orders->getOrderCustomFields();
294
+
295
+		$this->assertIsArray($res);
296
+	}
297
+
298
+	public function testCreateOrderCustomFieldMustReturnCustomField() : void
299
+	{
300
+		$orders = new Orders();
301
+		$field = $orders->createOrderCustomField([
302
+			'order_custom_field_name' => 'CustomField1',
303
+			'order_custom_field_label' => 'Custom Field 1',
304
+			'order_custom_field_type' => 'checkbox',
305
+			'order_custom_field_type_info' => [
306
+				'short_label' => 'cFl1'
307
+			]
308
+		]);
309
+
310
+		$this->assertInstanceOf(CustomField::class, $field);
311
+		$this->assertNotNull($field->order_custom_field_label);
312
+		$this->assertEquals($field->order_custom_field_label, 'Custom Field 1');
313 313
         
314
-        self::$created_field_uuid = $field->order_custom_field_uuid;
315
-    }
316
-
317
-    public function testUpdateOrderCustomFieldMustReturnCustomField() : void
318
-    {
319
-        if (self::$created_field_uuid !== null) {
320
-            $orders = new Orders();
321
-            $field = $orders->updateOrderCustomField(self::$created_field_uuid, [
322
-                'order_custom_field_label' => 'Custom Field New',
323
-                'order_custom_field_type' => 'checkbox',
324
-                'order_custom_field_type_info' => [
325
-                    'short_label' => 'cFl1'
326
-                ]
327
-            ]);
328
-
329
-            $this->assertInstanceOf(CustomField::class, $field);
330
-            $this->assertNotNull($field->order_custom_field_label);
331
-            $this->assertEquals($field->order_custom_field_label, 'Custom Field New');
332
-        }
333
-    }
334
-
335
-    public function testDeleteOrderCustomFieldMustReturnCustomField() : void
336
-    {
337
-        if (self::$created_field_uuid !== null) {
338
-            $orders = new Orders();
339
-            $field = $orders->deleteOrderCustomField(self::$created_field_uuid);
340
-
341
-            $this->assertInstanceOf(CustomField::class, $field);
342
-            self::$created_field_uuid = null;
343
-        }
344
-    }
345
-
346
-    public function testDeleteMustReturnTrue() : void
347
-    {
348
-        if (self::$created_uuid !== null) {
349
-            $orders = new Orders();
350
-            $result = $orders->delete(self::$created_uuid);
351
-
352
-            $this->assertTrue($result);
353
-            self::$created_uuid = null;
354
-        }
355
-    }
356
-
357
-    public static function tearDownAfterClass() : void
358
-    {
359
-        sleep(1);
360
-
361
-        if (self::$created_uuid !== null || self::$created_field_uuid !== null) {
362
-            $orders = new Orders();
363
-            if (self::$created_uuid !== null) {
364
-                $orders->delete(self::$created_uuid);
365
-            }
366
-            if (self::$created_field_uuid !== null) {
367
-                $orders->deleteOrderCustomField(self::$created_field_uuid);
368
-            }
369
-        }
370
-    }
314
+		self::$created_field_uuid = $field->order_custom_field_uuid;
315
+	}
316
+
317
+	public function testUpdateOrderCustomFieldMustReturnCustomField() : void
318
+	{
319
+		if (self::$created_field_uuid !== null) {
320
+			$orders = new Orders();
321
+			$field = $orders->updateOrderCustomField(self::$created_field_uuid, [
322
+				'order_custom_field_label' => 'Custom Field New',
323
+				'order_custom_field_type' => 'checkbox',
324
+				'order_custom_field_type_info' => [
325
+					'short_label' => 'cFl1'
326
+				]
327
+			]);
328
+
329
+			$this->assertInstanceOf(CustomField::class, $field);
330
+			$this->assertNotNull($field->order_custom_field_label);
331
+			$this->assertEquals($field->order_custom_field_label, 'Custom Field New');
332
+		}
333
+	}
334
+
335
+	public function testDeleteOrderCustomFieldMustReturnCustomField() : void
336
+	{
337
+		if (self::$created_field_uuid !== null) {
338
+			$orders = new Orders();
339
+			$field = $orders->deleteOrderCustomField(self::$created_field_uuid);
340
+
341
+			$this->assertInstanceOf(CustomField::class, $field);
342
+			self::$created_field_uuid = null;
343
+		}
344
+	}
345
+
346
+	public function testDeleteMustReturnTrue() : void
347
+	{
348
+		if (self::$created_uuid !== null) {
349
+			$orders = new Orders();
350
+			$result = $orders->delete(self::$created_uuid);
351
+
352
+			$this->assertTrue($result);
353
+			self::$created_uuid = null;
354
+		}
355
+	}
356
+
357
+	public static function tearDownAfterClass() : void
358
+	{
359
+		sleep(1);
360
+
361
+		if (self::$created_uuid !== null || self::$created_field_uuid !== null) {
362
+			$orders = new Orders();
363
+			if (self::$created_uuid !== null) {
364
+				$orders->delete(self::$created_uuid);
365
+			}
366
+			if (self::$created_field_uuid !== null) {
367
+				$orders->deleteOrderCustomField(self::$created_field_uuid);
368
+			}
369
+		}
370
+	}
371 371
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
     public function testGetMustReturnResponseOrder() : void
160 160
     {
161
-        if (self::$created_uuid !== null) {
161
+        if (self::$created_uuid!==null) {
162 162
             $orders = new Orders();
163 163
             $order = $orders->get(self::$created_uuid);
164 164
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
     public function testUpdateMustReturnResponseOrder() : void
172 172
     {
173
-        if (self::$created_uuid !== null) {
173
+        if (self::$created_uuid!==null) {
174 174
             $orders = new Orders();
175 175
             $order = $orders->update(self::$created_uuid, ['first_name' => 'Jane']);
176 176
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 
192 192
     public function testSearchMustReturnResponseSearchWithParams() : void
193 193
     {
194
-        if (self::$created_uuid !== null) {
194
+        if (self::$created_uuid!==null) {
195 195
             $orders = new Orders();
196 196
             $params = [
197 197
                 "filters" => [
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
     public function testUpdateOrderCustomFieldMustReturnCustomField() : void
318 318
     {
319
-        if (self::$created_field_uuid !== null) {
319
+        if (self::$created_field_uuid!==null) {
320 320
             $orders = new Orders();
321 321
             $field = $orders->updateOrderCustomField(self::$created_field_uuid, [
322 322
                 'order_custom_field_label' => 'Custom Field New',
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 
335 335
     public function testDeleteOrderCustomFieldMustReturnCustomField() : void
336 336
     {
337
-        if (self::$created_field_uuid !== null) {
337
+        if (self::$created_field_uuid!==null) {
338 338
             $orders = new Orders();
339 339
             $field = $orders->deleteOrderCustomField(self::$created_field_uuid);
340 340
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 
346 346
     public function testDeleteMustReturnTrue() : void
347 347
     {
348
-        if (self::$created_uuid !== null) {
348
+        if (self::$created_uuid!==null) {
349 349
             $orders = new Orders();
350 350
             $result = $orders->delete(self::$created_uuid);
351 351
 
@@ -358,12 +358,12 @@  discard block
 block discarded – undo
358 358
     {
359 359
         sleep(1);
360 360
 
361
-        if (self::$created_uuid !== null || self::$created_field_uuid !== null) {
361
+        if (self::$created_uuid!==null || self::$created_field_uuid!==null) {
362 362
             $orders = new Orders();
363
-            if (self::$created_uuid !== null) {
363
+            if (self::$created_uuid!==null) {
364 364
                 $orders->delete(self::$created_uuid);
365 365
             }
366
-            if (self::$created_field_uuid !== null) {
366
+            if (self::$created_field_uuid!==null) {
367 367
                 $orders->deleteOrderCustomField(self::$created_field_uuid);
368 368
             }
369 369
         }
Please login to merge, or discard this patch.
UnitTestFiles/Test/OrderTests.php 2 patches
Indentation   +574 added lines, -574 removed lines patch added patch discarded remove patch
@@ -20,578 +20,578 @@
 block discarded – undo
20 20
 
21 21
 class OrderTests extends \PHPUnit\Framework\TestCase
22 22
 {
23
-    public static $createdOrders = [];
24
-    public static $createdProblems = [];
25
-
26
-    public static function setUpBeforeClass()
27
-    {
28
-        Route4Me::setApiKey(Constants::API_KEY);
29
-
30
-        //region -- Create Test Optimization --
31
-
32
-        // Huge list of addresses
33
-        $json = json_decode(file_get_contents(dirname(__FILE__).'/data/addresses.json'), true);
34
-        $json = array_slice($json, 0, 10);
35
-
36
-        $addresses = [];
37
-        foreach ($json as $address) {
38
-            $addresses[] = Address::fromArray($address);
39
-        }
40
-
41
-        $parameters = RouteParameters::fromArray([
42
-            'algorithm_type'    => Algorithmtype::TSP,
43
-            'route_name'        => 'Single Driver Multiple TW 10 Stops '.date('Y-m-d H:i'),
44
-            'route_date'        => time() + 24 * 60 * 60,
45
-            'route_time'        => 5 * 3600 + 30 * 60,
46
-            'distance_unit'     => DistanceUnit::MILES,
47
-            'device_type'       => DeviceType::WEB,
48
-            'optimize'          => OptimizationType::DISTANCE,
49
-            'metric'            => Metric::GEODESIC,
50
-        ]);
51
-
52
-        $optimizationParams = new OptimizationProblemParams();
53
-        $optimizationParams->setAddresses($addresses);
54
-        $optimizationParams->setParameters($parameters);
55
-
56
-        $problem = OptimizationProblem::optimize($optimizationParams);
57
-
58
-        self::$createdProblems[] = $problem;
59
-
60
-        //endregion
61
-
62
-        //region -- Create Test Order --
63
-
64
-        $orderParameters = Order::fromArray([
65
-            'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
66
-            'cached_lat'                => 48.335991,
67
-            'cached_lng'                => 31.18287,
68
-            'address_alias'             => 'Auto test address',
69
-            'address_city'              => 'Philadelphia',
70
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
71
-            'EXT_FIELD_first_name'      => 'Igor',
72
-            'EXT_FIELD_last_name'       => 'Progman',
73
-            'EXT_FIELD_email'           => '[email protected]',
74
-            'EXT_FIELD_phone'           => '380380380380',
75
-            'EXT_FIELD_custom_data'     => [
76
-                0 => [
77
-                    'order_id'  => '10',
78
-                    'name'      => 'Bill Soul',
79
-                ],
80
-            ],
81
-        ]);
82
-
83
-        $order = new Order();
84
-
85
-        $response = $order->addOrder($orderParameters);
86
-
87
-        self::assertNotNull($response);
88
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
89
-
90
-        self::$createdOrders[] = $response;
91
-
92
-        //endregion
93
-    }
94
-
95
-    public function testFromArray()
96
-    {
97
-        $orderParameters = Order::fromArray([
98
-            'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
99
-            'cached_lat'                => 48.335991,
100
-            'cached_lng'                => 31.18287,
101
-            'address_alias'             => 'Auto test address',
102
-            'address_city'              => 'Philadelphia',
103
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
104
-            'EXT_FIELD_first_name'      => 'Igor',
105
-            'EXT_FIELD_last_name'       => 'Progman',
106
-            'EXT_FIELD_email'           => '[email protected]',
107
-            'EXT_FIELD_phone'           => '380380380380',
108
-            'EXT_FIELD_custom_data'     => [
109
-                0 => [
110
-                    'order_id'  => '10',
111
-                    'name'      => 'Bill Soul',
112
-                ],
113
-            ],
114
-        ]);
115
-
116
-        $this->assertEquals('1358 E Luzerne St, Philadelphia, PA 19124, US', $orderParameters->address_1);
117
-        $this->assertEquals(48.335991, $orderParameters->cached_lat);
118
-        $this->assertEquals(31.18287, $orderParameters->cached_lng);
119
-        $this->assertEquals('Auto test address', $orderParameters->address_alias);
120
-        $this->assertEquals('Philadelphia', $orderParameters->address_city);
121
-        $this->assertEquals(date('Y-m-d'), $orderParameters->day_scheduled_for_YYMMDD);
122
-        $this->assertEquals('Igor', $orderParameters->EXT_FIELD_first_name);
123
-        $this->assertEquals('Progman', $orderParameters->EXT_FIELD_last_name);
124
-        $this->assertEquals('[email protected]', $orderParameters->EXT_FIELD_email);
125
-        $this->assertEquals('380380380380', $orderParameters->EXT_FIELD_phone);
126
-        $this->assertEquals([
127
-            0 => [
128
-                'order_id'  => '10',
129
-                'name'      => 'Bill Soul',
130
-            ],
131
-        ], $orderParameters->EXT_FIELD_custom_data);
132
-    }
133
-
134
-    public function testToArray()
135
-    {
136
-        $orderParameters = Order::fromArray([
137
-            'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
138
-            'cached_lat'                => 48.335991,
139
-            'cached_lng'                => 31.18287,
140
-            'address_alias'             => 'Auto test address',
141
-            'address_city'              => 'Philadelphia',
142
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
143
-            'EXT_FIELD_first_name'      => 'Igor',
144
-            'EXT_FIELD_last_name'       => 'Progman',
145
-            'EXT_FIELD_email'           => '[email protected]',
146
-            'EXT_FIELD_phone'           => '380380380380',
147
-            'EXT_FIELD_custom_data'     => [
148
-                0 => [
149
-                    'order_id'  => '10',
150
-                    'name'      => 'Bill Soul',
151
-                ],
152
-            ],
153
-        ]);
154
-
155
-        $this->assertEquals($orderParameters->toArray(), [
156
-            'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
157
-            'cached_lat'                => 48.335991,
158
-            'cached_lng'                => 31.18287,
159
-            'address_alias'             => 'Auto test address',
160
-            'address_city'              => 'Philadelphia',
161
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
162
-            'EXT_FIELD_first_name'      => 'Igor',
163
-            'EXT_FIELD_last_name'       => 'Progman',
164
-            'EXT_FIELD_email'           => '[email protected]',
165
-            'EXT_FIELD_phone'           => '380380380380',
166
-            'EXT_FIELD_custom_data'     => [
167
-                0 => [
168
-                    'order_id'  => '10',
169
-                    'name'      => 'Bill Soul',
170
-                ],
171
-            ],
172
-        ]);
173
-    }
174
-
175
-    public function testGetOrders()
176
-    {
177
-        $order = new Order();
178
-
179
-        $orderParameters = Order::fromArray([
180
-            'offset'    => 0,
181
-            'limit'     => 5,
182
-        ]);
183
-
184
-        $response = $order->getOrders($orderParameters);
185
-
186
-        $this->assertNotNull($response);
187
-        $this->assertTrue(is_array($response));
188
-        $this->assertTrue(isset($response['total']));
189
-        $this->assertTrue(isset($response['results']));
190
-        $this->assertInstanceOf(
191
-            Order::class,
192
-            Order::fromArray($response['results'][0])
193
-        );
194
-    }
195
-
196
-    public function testCreateNewOrder()
197
-    {
198
-        $orderParameters = Order::fromArray([
199
-            'address_1'                 => '106 Liberty St, New York, NY 10006, USA',
200
-            'address_alias'             => 'BK Restaurant #: 2446',
201
-            'cached_lat'                => 40.709637,
202
-            'cached_lng'                => -74.011912,
203
-            'curbside_lat'              => 40.709637,
204
-            'curbside_lng'              => -74.011912,
205
-            'address_city'              => 'New York',
206
-            'EXT_FIELD_first_name'      => 'Lui',
207
-            'EXT_FIELD_last_name'       => 'Carol',
208
-            'EXT_FIELD_email'           => '[email protected]',
209
-            'EXT_FIELD_phone'           => '897946541',
210
-            'local_time_window_end'     => 39000,
211
-            'local_time_window_end_2'   => 46200,
212
-            'local_time_window_start'   => 37800,
213
-            'local_time_window_start_2' => 45000,
214
-            'local_timezone_string'     => 'America/New_York',
215
-            'order_icon'                => 'emoji/emoji-bank',
216
-        ]);
217
-
218
-        $order = new Order();
219
-
220
-        $response = $order->addOrder($orderParameters);
221
-
222
-        self::assertNotNull($response);
223
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
224
-
225
-        self::$createdOrders[] = $response;
226
-    }
227
-
228
-    public function testAddOrdersToOptimization()
229
-    {
230
-        $body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_optimization_data.json'), true);
231
-
232
-        $optimizationProblemId = self::$createdProblems[0]->optimization_problem_id;
233
-
234
-        $orderParameters = [
235
-            'optimization_problem_id'   => $optimizationProblemId,
236
-            'redirect'                  => 0,
237
-            'device_type'               => 'web',
238
-            'addresses'                 => $body['addresses'],
239
-        ];
240
-
241
-        $order = new Order();
242
-
243
-        $response = $order->addOrder2Optimization($orderParameters);
244
-
245
-        self::assertNotNull($response);
246
-        self::assertInstanceOf(OptimizationProblem::class, OptimizationProblem::fromArray($response));
247
-    }
248
-
249
-    public function testAddOrdersToRoute()
250
-    {
251
-        $this->markTestSkipped('Read old data.');
252
-
253
-        $body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_route_data.json'), true);
254
-
255
-        $routeId = self::$createdProblems[0]->routes[0]->route_id;
256
-
257
-        $orderParameters = Order::fromArray([
258
-            'route_id'  => $routeId,
259
-            'redirect'  => 0,
260
-            'addresses' => $body['addresses'],
261
-        ]);
262
-
263
-        $order = new Order();
264
-
265
-        $response = $order->addOrder2Route($orderParameters);
266
-
267
-        self::assertNotNull($response);
268
-        self::assertInstanceOf(Route::class, Route::fromArray($response));
269
-    }
270
-
271
-    public function testAddScheduledOrder()
272
-    {
273
-        $orderParameters = Order::fromArray([
274
-            'address_1'                 => '318 S 39th St, Louisville, KY 40212, USA',
275
-            'cached_lat'                => 38.259326,
276
-            'cached_lng'                => -85.814979,
277
-            'curbside_lat'              => 38.259326,
278
-            'curbside_lng'              => -85.814979,
279
-            'address_alias'             => '318 S 39th St 40212',
280
-            'address_city'              => 'Louisville',
281
-            'EXT_FIELD_first_name'      => 'Lui',
282
-            'EXT_FIELD_last_name'       => 'Carol',
283
-            'EXT_FIELD_email'           => '[email protected]',
284
-            'EXT_FIELD_phone'           => '897946541',
285
-            'EXT_FIELD_custom_data'     => ['order_type' => 'scheduled order'],
286
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
287
-            'local_time_window_end'     => 39000,
288
-            'local_time_window_end_2'   => 46200,
289
-            'local_time_window_start'   => 37800,
290
-            'local_time_window_start_2' => 45000,
291
-            'local_timezone_string'     => 'America/New_York',
292
-            'order_icon'                => 'emoji/emoji-bank',
293
-        ]);
294
-
295
-        $order = new Order();
296
-
297
-        $response = $order->addOrder($orderParameters);
298
-
299
-        self::assertNotNull($response);
300
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
301
-
302
-        self::$createdOrders[] = $response;
303
-    }
304
-
305
-    public function testCreateOrderWithCustomField()
306
-    {
307
-        $orderParameters = Order::fromArray([
308
-            'address_1'                => '1358 E Luzerne St, Philadelphia, PA 19124, US',
309
-            'cached_lat'               => 48.335991,
310
-            'cached_lng'               => 31.18287,
311
-            'day_scheduled_for_YYMMDD' => '2019-10-11',
312
-            'address_alias'            => 'Auto test address',
313
-            'custom_user_fields' => [
314
-                OrderCustomField::fromArray([
315
-                    'order_custom_field_id'    => 93,
316
-                    'order_custom_field_value' => 'false'
317
-                ])
318
-            ]
319
-        ]);
320
-
321
-        $order = new Order();
322
-
323
-        $response = $order->addOrder($orderParameters);
324
-
325
-        self::assertNotNull($response);
326
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
327
-        $this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
328
-        $this->assertEquals(false, $response['custom_user_fields'][0]['order_custom_field_value']);
329
-
330
-        self::$createdOrders[] = $response;
331
-    }
332
-
333
-    public function testGetOrderByID()
334
-    {
335
-        $order = new Order();
336
-
337
-        $orderID = self::$createdOrders[0]['order_id'];
338
-
339
-        // Get an order
340
-        $orderParameters = Order::fromArray([
341
-            'order_id' => $orderID,
342
-        ]);
343
-
344
-        $response = $order->getOrder($orderParameters);
345
-
346
-        self::assertNotNull($response);
347
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
348
-    }
349
-
350
-    public function testGetOrderByUUID()
351
-    {
352
-        $order = new Order();
353
-
354
-        $orderUUID = self::$createdOrders[0]['order_uuid'];
355
-
356
-        // Get an order
357
-        $orderParameters = Order::fromArray([
358
-            'order_id' => $orderUUID,
359
-        ]);
360
-
361
-        $response = $order->getOrder($orderParameters);
362
-
363
-        self::assertNotNull($response);
364
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
365
-    }
366
-
367
-    public function testGetOrderByInsertedDate()
368
-    {
369
-        $orderParameters = Order::fromArray([
370
-            'day_added_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
371
-            'offset'            => 0,
372
-            'limit'             => 5,
373
-        ]);
374
-
375
-        $order = new Order();
376
-
377
-        $response = $order->getOrder($orderParameters);
378
-
379
-        $this->assertNotNull($response);
380
-        $this->assertTrue(is_array($response));
381
-        $this->assertTrue(isset($response['total']));
382
-        $this->assertTrue(isset($response['results']));
383
-        $this->assertInstanceOf(
384
-            Order::class,
385
-            Order::fromArray($response['results'][0])
386
-        );
387
-    }
388
-
389
-    public function testGetOrderByScheduledDate()
390
-    {
391
-        $orderParameters = Order::fromArray([
392
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
393
-            'offset'                    => 0,
394
-            'limit'                     => 5,
395
-        ]);
396
-
397
-        $order = new Order();
398
-
399
-        $response = $order->getOrder($orderParameters);
400
-
401
-        $this->assertNotNull($response);
402
-        $this->assertTrue(is_array($response));
403
-        $this->assertTrue(isset($response['total']));
404
-        $this->assertTrue(isset($response['results']));
405
-        $this->assertInstanceOf(
406
-            Order::class,
407
-            Order::fromArray($response['results'][0])
408
-        );
409
-    }
410
-
411
-    public function testGetOrdersByCustomFields()
412
-    {
413
-        $orderParameters = Order::fromArray([
414
-            'fields'    => 'order_id,member_id',
415
-            'offset'    => 0,
416
-            'limit'     => 5,
417
-        ]);
418
-
419
-        $order = new Order();
420
-
421
-        $response = $order->getOrder($orderParameters);
422
-
423
-        $response = $order->getOrder($orderParameters);
424
-
425
-        $this->assertNotNull($response);
426
-        $this->assertTrue(is_array($response));
427
-        $this->assertTrue(isset($response['total']));
428
-        $this->assertTrue(isset($response['results']));
429
-        $this->assertTrue(isset($response['fields']));
430
-        $this->assertInstanceOf(
431
-            Order::class,
432
-            Order::fromArray($response['results'][0])
433
-        );
434
-    }
435
-
436
-    public function testGetOrdersByScheduleFilter()
437
-    {
438
-        $orderParameters = Order::fromArray([
439
-            'limit'  => 5,
440
-            'filter' => [
441
-                'display'               => 'all',
442
-                'scheduled_for_YYMMDD'  => [
443
-                    date('Y-m-d', strtotime('-1 days')),
444
-                    date('Y-m-d', strtotime('1 days'))
445
-                ]
446
-            ]
447
-        ]);
448
-
449
-        $order = new Order();
450
-
451
-        $response = $order->getOrder($orderParameters);
452
-
453
-        $this->assertNotNull($response);
454
-        $this->assertTrue(is_array($response));
455
-        $this->assertTrue(isset($response['total']));
456
-        $this->assertTrue(isset($response['results']));
457
-        $this->assertInstanceOf(
458
-            Order::class,
459
-            Order::fromArray($response['results'][0])
460
-        );
461
-    }
462
-
463
-    public function testGetOrdersBySpecifiedText()
464
-    {
465
-        $orderParameters = Order::fromArray([
466
-            'query'     => 'Auto test',
467
-            'offset'    => 0,
468
-            'limit'     => 5,
469
-        ]);
470
-
471
-        $order = new Order();
472
-
473
-        $response = $order->getOrder($orderParameters);
474
-
475
-        $this->assertNotNull($response);
476
-        $this->assertTrue(is_array($response));
477
-        $this->assertTrue(isset($response['total']));
478
-        $this->assertTrue(isset($response['results']));
479
-        $this->assertInstanceOf(
480
-            Order::class,
481
-            Order::fromArray($response['results'][0])
482
-        );
483
-    }
484
-
485
-    public function testUpdateOrder()
486
-    {
487
-        $order = new Order();
488
-
489
-        // Update the order
490
-        self::$createdOrders[0]['address_2'] = 'Lviv';
491
-        self::$createdOrders[0]['EXT_FIELD_phone'] = '032268593';
492
-        self::$createdOrders[0]['EXT_FIELD_custom_data'] = [
493
-            0 => [
494
-                'customer_no' => '11',
495
-            ],
496
-        ];
497
-
498
-        $response = $order->updateOrder(self::$createdOrders[0]);
499
-
500
-        $this->assertNotNull($response);
501
-        $this->assertInstanceOf(Order::class, Order::fromArray($response));
502
-        $this->assertEquals('Lviv', $response['address_2']);
503
-        $this->assertEquals('032268593', $response['EXT_FIELD_phone']);
504
-        $this->assertEquals(
505
-            [0 => '{"order_id":"10","name":"Bill Soul"}'],
506
-            $response['EXT_FIELD_custom_data']
507
-        );
508
-    }
509
-
510
-    public function testUpdateOrderWithCustomFiel()
511
-    {
512
-        $orderParameters = Order::fromArray([
513
-            'order_id'              => self::$createdOrders[0]['order_id'],
514
-            'custom_user_fields'    => [
515
-                OrderCustomField::fromArray([
516
-                    'order_custom_field_id'    => 93,
517
-                    'order_custom_field_value' => 'true'
518
-                ])
519
-            ]
520
-        ]);
521
-
522
-        $order = new Order();
523
-
524
-        $response = $order->updateOrder($orderParameters);
525
-
526
-        $this->assertNotNull($response);
527
-        $this->assertInstanceOf(Order::class, Order::fromArray($response));
528
-        $this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
529
-        $this->assertEquals(true, $response['custom_user_fields'][0]['order_custom_field_value']);
530
-    }
531
-
532
-    public function testDeleteOrderByUuid()
533
-    {
534
-        $lastOrder = array_pop(self::$createdOrders);
535
-        if ($lastOrder != null) {
536
-            $order = new Order();
537
-            $ids = [
538
-                "order_ids" => [$lastOrder['order_uuid']]
539
-            ];
540
-
541
-            $response = $order->removeOrder($ids);
542
-
543
-            if (!is_null($response) && isset($response['status']) && $response['status']) {
544
-                echo "The test order removed by UUID <br>";
545
-            }
546
-        }
547
-    }
548
-
549
-    public static function tearDownAfterClass()
550
-    {
551
-        if (sizeof(self::$createdOrders)) {
552
-            $orderIDs = [];
553
-
554
-            foreach (self::$createdOrders as $ord) {
555
-                $orderIDs[] = $ord['order_id'];
556
-            }
557
-
558
-            $orderParameters = Order::fromArray([
559
-                'order_ids' => $orderIDs
560
-            ]);
561
-
562
-            $order = new Order();
563
-
564
-            $response = $order->removeOrder($orderParameters);
565
-
566
-            if (!is_null($response) &&
567
-                isset($response['status']) &&
568
-                $response['status']) {
569
-                echo "The test orders removed <br>";
570
-            }
571
-        }
572
-
573
-        if (sizeof(self::$createdProblems)>0) {
574
-            $optimizationProblemIDs = [];
575
-
576
-            foreach (self::$createdProblems as $problem) {
577
-                $optimizationProblemId = $problem->optimization_problem_id;
578
-
579
-                $optimizationProblemIDs[] = $optimizationProblemId;
580
-            }
581
-
582
-            $params = [
583
-                'optimization_problem_ids' => $optimizationProblemIDs,
584
-                'redirect'                 => 0,
585
-            ];
586
-
587
-            $problem = new OptimizationProblem();
588
-            $result = $problem->removeOptimization($params);
589
-
590
-            if ($result!=null && $result['status']==true) {
591
-                echo "The test optimizations were removed <br>";
592
-            } else {
593
-                echo "Cannot remove the test optimizations <br>";
594
-            }
595
-        }
596
-    }
23
+	public static $createdOrders = [];
24
+	public static $createdProblems = [];
25
+
26
+	public static function setUpBeforeClass()
27
+	{
28
+		Route4Me::setApiKey(Constants::API_KEY);
29
+
30
+		//region -- Create Test Optimization --
31
+
32
+		// Huge list of addresses
33
+		$json = json_decode(file_get_contents(dirname(__FILE__).'/data/addresses.json'), true);
34
+		$json = array_slice($json, 0, 10);
35
+
36
+		$addresses = [];
37
+		foreach ($json as $address) {
38
+			$addresses[] = Address::fromArray($address);
39
+		}
40
+
41
+		$parameters = RouteParameters::fromArray([
42
+			'algorithm_type'    => Algorithmtype::TSP,
43
+			'route_name'        => 'Single Driver Multiple TW 10 Stops '.date('Y-m-d H:i'),
44
+			'route_date'        => time() + 24 * 60 * 60,
45
+			'route_time'        => 5 * 3600 + 30 * 60,
46
+			'distance_unit'     => DistanceUnit::MILES,
47
+			'device_type'       => DeviceType::WEB,
48
+			'optimize'          => OptimizationType::DISTANCE,
49
+			'metric'            => Metric::GEODESIC,
50
+		]);
51
+
52
+		$optimizationParams = new OptimizationProblemParams();
53
+		$optimizationParams->setAddresses($addresses);
54
+		$optimizationParams->setParameters($parameters);
55
+
56
+		$problem = OptimizationProblem::optimize($optimizationParams);
57
+
58
+		self::$createdProblems[] = $problem;
59
+
60
+		//endregion
61
+
62
+		//region -- Create Test Order --
63
+
64
+		$orderParameters = Order::fromArray([
65
+			'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
66
+			'cached_lat'                => 48.335991,
67
+			'cached_lng'                => 31.18287,
68
+			'address_alias'             => 'Auto test address',
69
+			'address_city'              => 'Philadelphia',
70
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
71
+			'EXT_FIELD_first_name'      => 'Igor',
72
+			'EXT_FIELD_last_name'       => 'Progman',
73
+			'EXT_FIELD_email'           => '[email protected]',
74
+			'EXT_FIELD_phone'           => '380380380380',
75
+			'EXT_FIELD_custom_data'     => [
76
+				0 => [
77
+					'order_id'  => '10',
78
+					'name'      => 'Bill Soul',
79
+				],
80
+			],
81
+		]);
82
+
83
+		$order = new Order();
84
+
85
+		$response = $order->addOrder($orderParameters);
86
+
87
+		self::assertNotNull($response);
88
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
89
+
90
+		self::$createdOrders[] = $response;
91
+
92
+		//endregion
93
+	}
94
+
95
+	public function testFromArray()
96
+	{
97
+		$orderParameters = Order::fromArray([
98
+			'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
99
+			'cached_lat'                => 48.335991,
100
+			'cached_lng'                => 31.18287,
101
+			'address_alias'             => 'Auto test address',
102
+			'address_city'              => 'Philadelphia',
103
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
104
+			'EXT_FIELD_first_name'      => 'Igor',
105
+			'EXT_FIELD_last_name'       => 'Progman',
106
+			'EXT_FIELD_email'           => '[email protected]',
107
+			'EXT_FIELD_phone'           => '380380380380',
108
+			'EXT_FIELD_custom_data'     => [
109
+				0 => [
110
+					'order_id'  => '10',
111
+					'name'      => 'Bill Soul',
112
+				],
113
+			],
114
+		]);
115
+
116
+		$this->assertEquals('1358 E Luzerne St, Philadelphia, PA 19124, US', $orderParameters->address_1);
117
+		$this->assertEquals(48.335991, $orderParameters->cached_lat);
118
+		$this->assertEquals(31.18287, $orderParameters->cached_lng);
119
+		$this->assertEquals('Auto test address', $orderParameters->address_alias);
120
+		$this->assertEquals('Philadelphia', $orderParameters->address_city);
121
+		$this->assertEquals(date('Y-m-d'), $orderParameters->day_scheduled_for_YYMMDD);
122
+		$this->assertEquals('Igor', $orderParameters->EXT_FIELD_first_name);
123
+		$this->assertEquals('Progman', $orderParameters->EXT_FIELD_last_name);
124
+		$this->assertEquals('[email protected]', $orderParameters->EXT_FIELD_email);
125
+		$this->assertEquals('380380380380', $orderParameters->EXT_FIELD_phone);
126
+		$this->assertEquals([
127
+			0 => [
128
+				'order_id'  => '10',
129
+				'name'      => 'Bill Soul',
130
+			],
131
+		], $orderParameters->EXT_FIELD_custom_data);
132
+	}
133
+
134
+	public function testToArray()
135
+	{
136
+		$orderParameters = Order::fromArray([
137
+			'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
138
+			'cached_lat'                => 48.335991,
139
+			'cached_lng'                => 31.18287,
140
+			'address_alias'             => 'Auto test address',
141
+			'address_city'              => 'Philadelphia',
142
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
143
+			'EXT_FIELD_first_name'      => 'Igor',
144
+			'EXT_FIELD_last_name'       => 'Progman',
145
+			'EXT_FIELD_email'           => '[email protected]',
146
+			'EXT_FIELD_phone'           => '380380380380',
147
+			'EXT_FIELD_custom_data'     => [
148
+				0 => [
149
+					'order_id'  => '10',
150
+					'name'      => 'Bill Soul',
151
+				],
152
+			],
153
+		]);
154
+
155
+		$this->assertEquals($orderParameters->toArray(), [
156
+			'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
157
+			'cached_lat'                => 48.335991,
158
+			'cached_lng'                => 31.18287,
159
+			'address_alias'             => 'Auto test address',
160
+			'address_city'              => 'Philadelphia',
161
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
162
+			'EXT_FIELD_first_name'      => 'Igor',
163
+			'EXT_FIELD_last_name'       => 'Progman',
164
+			'EXT_FIELD_email'           => '[email protected]',
165
+			'EXT_FIELD_phone'           => '380380380380',
166
+			'EXT_FIELD_custom_data'     => [
167
+				0 => [
168
+					'order_id'  => '10',
169
+					'name'      => 'Bill Soul',
170
+				],
171
+			],
172
+		]);
173
+	}
174
+
175
+	public function testGetOrders()
176
+	{
177
+		$order = new Order();
178
+
179
+		$orderParameters = Order::fromArray([
180
+			'offset'    => 0,
181
+			'limit'     => 5,
182
+		]);
183
+
184
+		$response = $order->getOrders($orderParameters);
185
+
186
+		$this->assertNotNull($response);
187
+		$this->assertTrue(is_array($response));
188
+		$this->assertTrue(isset($response['total']));
189
+		$this->assertTrue(isset($response['results']));
190
+		$this->assertInstanceOf(
191
+			Order::class,
192
+			Order::fromArray($response['results'][0])
193
+		);
194
+	}
195
+
196
+	public function testCreateNewOrder()
197
+	{
198
+		$orderParameters = Order::fromArray([
199
+			'address_1'                 => '106 Liberty St, New York, NY 10006, USA',
200
+			'address_alias'             => 'BK Restaurant #: 2446',
201
+			'cached_lat'                => 40.709637,
202
+			'cached_lng'                => -74.011912,
203
+			'curbside_lat'              => 40.709637,
204
+			'curbside_lng'              => -74.011912,
205
+			'address_city'              => 'New York',
206
+			'EXT_FIELD_first_name'      => 'Lui',
207
+			'EXT_FIELD_last_name'       => 'Carol',
208
+			'EXT_FIELD_email'           => '[email protected]',
209
+			'EXT_FIELD_phone'           => '897946541',
210
+			'local_time_window_end'     => 39000,
211
+			'local_time_window_end_2'   => 46200,
212
+			'local_time_window_start'   => 37800,
213
+			'local_time_window_start_2' => 45000,
214
+			'local_timezone_string'     => 'America/New_York',
215
+			'order_icon'                => 'emoji/emoji-bank',
216
+		]);
217
+
218
+		$order = new Order();
219
+
220
+		$response = $order->addOrder($orderParameters);
221
+
222
+		self::assertNotNull($response);
223
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
224
+
225
+		self::$createdOrders[] = $response;
226
+	}
227
+
228
+	public function testAddOrdersToOptimization()
229
+	{
230
+		$body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_optimization_data.json'), true);
231
+
232
+		$optimizationProblemId = self::$createdProblems[0]->optimization_problem_id;
233
+
234
+		$orderParameters = [
235
+			'optimization_problem_id'   => $optimizationProblemId,
236
+			'redirect'                  => 0,
237
+			'device_type'               => 'web',
238
+			'addresses'                 => $body['addresses'],
239
+		];
240
+
241
+		$order = new Order();
242
+
243
+		$response = $order->addOrder2Optimization($orderParameters);
244
+
245
+		self::assertNotNull($response);
246
+		self::assertInstanceOf(OptimizationProblem::class, OptimizationProblem::fromArray($response));
247
+	}
248
+
249
+	public function testAddOrdersToRoute()
250
+	{
251
+		$this->markTestSkipped('Read old data.');
252
+
253
+		$body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_route_data.json'), true);
254
+
255
+		$routeId = self::$createdProblems[0]->routes[0]->route_id;
256
+
257
+		$orderParameters = Order::fromArray([
258
+			'route_id'  => $routeId,
259
+			'redirect'  => 0,
260
+			'addresses' => $body['addresses'],
261
+		]);
262
+
263
+		$order = new Order();
264
+
265
+		$response = $order->addOrder2Route($orderParameters);
266
+
267
+		self::assertNotNull($response);
268
+		self::assertInstanceOf(Route::class, Route::fromArray($response));
269
+	}
270
+
271
+	public function testAddScheduledOrder()
272
+	{
273
+		$orderParameters = Order::fromArray([
274
+			'address_1'                 => '318 S 39th St, Louisville, KY 40212, USA',
275
+			'cached_lat'                => 38.259326,
276
+			'cached_lng'                => -85.814979,
277
+			'curbside_lat'              => 38.259326,
278
+			'curbside_lng'              => -85.814979,
279
+			'address_alias'             => '318 S 39th St 40212',
280
+			'address_city'              => 'Louisville',
281
+			'EXT_FIELD_first_name'      => 'Lui',
282
+			'EXT_FIELD_last_name'       => 'Carol',
283
+			'EXT_FIELD_email'           => '[email protected]',
284
+			'EXT_FIELD_phone'           => '897946541',
285
+			'EXT_FIELD_custom_data'     => ['order_type' => 'scheduled order'],
286
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
287
+			'local_time_window_end'     => 39000,
288
+			'local_time_window_end_2'   => 46200,
289
+			'local_time_window_start'   => 37800,
290
+			'local_time_window_start_2' => 45000,
291
+			'local_timezone_string'     => 'America/New_York',
292
+			'order_icon'                => 'emoji/emoji-bank',
293
+		]);
294
+
295
+		$order = new Order();
296
+
297
+		$response = $order->addOrder($orderParameters);
298
+
299
+		self::assertNotNull($response);
300
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
301
+
302
+		self::$createdOrders[] = $response;
303
+	}
304
+
305
+	public function testCreateOrderWithCustomField()
306
+	{
307
+		$orderParameters = Order::fromArray([
308
+			'address_1'                => '1358 E Luzerne St, Philadelphia, PA 19124, US',
309
+			'cached_lat'               => 48.335991,
310
+			'cached_lng'               => 31.18287,
311
+			'day_scheduled_for_YYMMDD' => '2019-10-11',
312
+			'address_alias'            => 'Auto test address',
313
+			'custom_user_fields' => [
314
+				OrderCustomField::fromArray([
315
+					'order_custom_field_id'    => 93,
316
+					'order_custom_field_value' => 'false'
317
+				])
318
+			]
319
+		]);
320
+
321
+		$order = new Order();
322
+
323
+		$response = $order->addOrder($orderParameters);
324
+
325
+		self::assertNotNull($response);
326
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
327
+		$this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
328
+		$this->assertEquals(false, $response['custom_user_fields'][0]['order_custom_field_value']);
329
+
330
+		self::$createdOrders[] = $response;
331
+	}
332
+
333
+	public function testGetOrderByID()
334
+	{
335
+		$order = new Order();
336
+
337
+		$orderID = self::$createdOrders[0]['order_id'];
338
+
339
+		// Get an order
340
+		$orderParameters = Order::fromArray([
341
+			'order_id' => $orderID,
342
+		]);
343
+
344
+		$response = $order->getOrder($orderParameters);
345
+
346
+		self::assertNotNull($response);
347
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
348
+	}
349
+
350
+	public function testGetOrderByUUID()
351
+	{
352
+		$order = new Order();
353
+
354
+		$orderUUID = self::$createdOrders[0]['order_uuid'];
355
+
356
+		// Get an order
357
+		$orderParameters = Order::fromArray([
358
+			'order_id' => $orderUUID,
359
+		]);
360
+
361
+		$response = $order->getOrder($orderParameters);
362
+
363
+		self::assertNotNull($response);
364
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
365
+	}
366
+
367
+	public function testGetOrderByInsertedDate()
368
+	{
369
+		$orderParameters = Order::fromArray([
370
+			'day_added_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
371
+			'offset'            => 0,
372
+			'limit'             => 5,
373
+		]);
374
+
375
+		$order = new Order();
376
+
377
+		$response = $order->getOrder($orderParameters);
378
+
379
+		$this->assertNotNull($response);
380
+		$this->assertTrue(is_array($response));
381
+		$this->assertTrue(isset($response['total']));
382
+		$this->assertTrue(isset($response['results']));
383
+		$this->assertInstanceOf(
384
+			Order::class,
385
+			Order::fromArray($response['results'][0])
386
+		);
387
+	}
388
+
389
+	public function testGetOrderByScheduledDate()
390
+	{
391
+		$orderParameters = Order::fromArray([
392
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
393
+			'offset'                    => 0,
394
+			'limit'                     => 5,
395
+		]);
396
+
397
+		$order = new Order();
398
+
399
+		$response = $order->getOrder($orderParameters);
400
+
401
+		$this->assertNotNull($response);
402
+		$this->assertTrue(is_array($response));
403
+		$this->assertTrue(isset($response['total']));
404
+		$this->assertTrue(isset($response['results']));
405
+		$this->assertInstanceOf(
406
+			Order::class,
407
+			Order::fromArray($response['results'][0])
408
+		);
409
+	}
410
+
411
+	public function testGetOrdersByCustomFields()
412
+	{
413
+		$orderParameters = Order::fromArray([
414
+			'fields'    => 'order_id,member_id',
415
+			'offset'    => 0,
416
+			'limit'     => 5,
417
+		]);
418
+
419
+		$order = new Order();
420
+
421
+		$response = $order->getOrder($orderParameters);
422
+
423
+		$response = $order->getOrder($orderParameters);
424
+
425
+		$this->assertNotNull($response);
426
+		$this->assertTrue(is_array($response));
427
+		$this->assertTrue(isset($response['total']));
428
+		$this->assertTrue(isset($response['results']));
429
+		$this->assertTrue(isset($response['fields']));
430
+		$this->assertInstanceOf(
431
+			Order::class,
432
+			Order::fromArray($response['results'][0])
433
+		);
434
+	}
435
+
436
+	public function testGetOrdersByScheduleFilter()
437
+	{
438
+		$orderParameters = Order::fromArray([
439
+			'limit'  => 5,
440
+			'filter' => [
441
+				'display'               => 'all',
442
+				'scheduled_for_YYMMDD'  => [
443
+					date('Y-m-d', strtotime('-1 days')),
444
+					date('Y-m-d', strtotime('1 days'))
445
+				]
446
+			]
447
+		]);
448
+
449
+		$order = new Order();
450
+
451
+		$response = $order->getOrder($orderParameters);
452
+
453
+		$this->assertNotNull($response);
454
+		$this->assertTrue(is_array($response));
455
+		$this->assertTrue(isset($response['total']));
456
+		$this->assertTrue(isset($response['results']));
457
+		$this->assertInstanceOf(
458
+			Order::class,
459
+			Order::fromArray($response['results'][0])
460
+		);
461
+	}
462
+
463
+	public function testGetOrdersBySpecifiedText()
464
+	{
465
+		$orderParameters = Order::fromArray([
466
+			'query'     => 'Auto test',
467
+			'offset'    => 0,
468
+			'limit'     => 5,
469
+		]);
470
+
471
+		$order = new Order();
472
+
473
+		$response = $order->getOrder($orderParameters);
474
+
475
+		$this->assertNotNull($response);
476
+		$this->assertTrue(is_array($response));
477
+		$this->assertTrue(isset($response['total']));
478
+		$this->assertTrue(isset($response['results']));
479
+		$this->assertInstanceOf(
480
+			Order::class,
481
+			Order::fromArray($response['results'][0])
482
+		);
483
+	}
484
+
485
+	public function testUpdateOrder()
486
+	{
487
+		$order = new Order();
488
+
489
+		// Update the order
490
+		self::$createdOrders[0]['address_2'] = 'Lviv';
491
+		self::$createdOrders[0]['EXT_FIELD_phone'] = '032268593';
492
+		self::$createdOrders[0]['EXT_FIELD_custom_data'] = [
493
+			0 => [
494
+				'customer_no' => '11',
495
+			],
496
+		];
497
+
498
+		$response = $order->updateOrder(self::$createdOrders[0]);
499
+
500
+		$this->assertNotNull($response);
501
+		$this->assertInstanceOf(Order::class, Order::fromArray($response));
502
+		$this->assertEquals('Lviv', $response['address_2']);
503
+		$this->assertEquals('032268593', $response['EXT_FIELD_phone']);
504
+		$this->assertEquals(
505
+			[0 => '{"order_id":"10","name":"Bill Soul"}'],
506
+			$response['EXT_FIELD_custom_data']
507
+		);
508
+	}
509
+
510
+	public function testUpdateOrderWithCustomFiel()
511
+	{
512
+		$orderParameters = Order::fromArray([
513
+			'order_id'              => self::$createdOrders[0]['order_id'],
514
+			'custom_user_fields'    => [
515
+				OrderCustomField::fromArray([
516
+					'order_custom_field_id'    => 93,
517
+					'order_custom_field_value' => 'true'
518
+				])
519
+			]
520
+		]);
521
+
522
+		$order = new Order();
523
+
524
+		$response = $order->updateOrder($orderParameters);
525
+
526
+		$this->assertNotNull($response);
527
+		$this->assertInstanceOf(Order::class, Order::fromArray($response));
528
+		$this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
529
+		$this->assertEquals(true, $response['custom_user_fields'][0]['order_custom_field_value']);
530
+	}
531
+
532
+	public function testDeleteOrderByUuid()
533
+	{
534
+		$lastOrder = array_pop(self::$createdOrders);
535
+		if ($lastOrder != null) {
536
+			$order = new Order();
537
+			$ids = [
538
+				"order_ids" => [$lastOrder['order_uuid']]
539
+			];
540
+
541
+			$response = $order->removeOrder($ids);
542
+
543
+			if (!is_null($response) && isset($response['status']) && $response['status']) {
544
+				echo "The test order removed by UUID <br>";
545
+			}
546
+		}
547
+	}
548
+
549
+	public static function tearDownAfterClass()
550
+	{
551
+		if (sizeof(self::$createdOrders)) {
552
+			$orderIDs = [];
553
+
554
+			foreach (self::$createdOrders as $ord) {
555
+				$orderIDs[] = $ord['order_id'];
556
+			}
557
+
558
+			$orderParameters = Order::fromArray([
559
+				'order_ids' => $orderIDs
560
+			]);
561
+
562
+			$order = new Order();
563
+
564
+			$response = $order->removeOrder($orderParameters);
565
+
566
+			if (!is_null($response) &&
567
+				isset($response['status']) &&
568
+				$response['status']) {
569
+				echo "The test orders removed <br>";
570
+			}
571
+		}
572
+
573
+		if (sizeof(self::$createdProblems)>0) {
574
+			$optimizationProblemIDs = [];
575
+
576
+			foreach (self::$createdProblems as $problem) {
577
+				$optimizationProblemId = $problem->optimization_problem_id;
578
+
579
+				$optimizationProblemIDs[] = $optimizationProblemId;
580
+			}
581
+
582
+			$params = [
583
+				'optimization_problem_ids' => $optimizationProblemIDs,
584
+				'redirect'                 => 0,
585
+			];
586
+
587
+			$problem = new OptimizationProblem();
588
+			$result = $problem->removeOptimization($params);
589
+
590
+			if ($result!=null && $result['status']==true) {
591
+				echo "The test optimizations were removed <br>";
592
+			} else {
593
+				echo "Cannot remove the test optimizations <br>";
594
+			}
595
+		}
596
+	}
597 597
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -532,7 +532,7 @@
 block discarded – undo
532 532
     public function testDeleteOrderByUuid()
533 533
     {
534 534
         $lastOrder = array_pop(self::$createdOrders);
535
-        if ($lastOrder != null) {
535
+        if ($lastOrder!=null) {
536 536
             $order = new Order();
537 537
             $ids = [
538 538
                 "order_ids" => [$lastOrder['order_uuid']]
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/ResponseSearch.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -14,41 +14,41 @@
 block discarded – undo
14 14
  */
15 15
 class ResponseSearch extends Common
16 16
 {
17
-    /**
18
-     * Total number of orders found.
19
-     */
20
-    public ?int $total = null;
17
+	/**
18
+	 * Total number of orders found.
19
+	 */
20
+	public ?int $total = null;
21 21
 
22
-    /**
23
-     * An array of field names asked in the request.
24
-     * If null then field names were not asked.
25
-     */
26
-    public ?array $fields = null;
22
+	/**
23
+	 * An array of field names asked in the request.
24
+	 * If null then field names were not asked.
25
+	 */
26
+	public ?array $fields = null;
27 27
 
28
-    /**
29
-     * An array of orders received from the server.
30
-     */
31
-    public ?array $results = null;
28
+	/**
29
+	 * An array of orders received from the server.
30
+	 */
31
+	public ?array $results = null;
32 32
 
33
-    public function __construct(array $params = null)
34
-    {
35
-        if ($params !== null) {
36
-            foreach ($this as $key => $value) {
37
-                if (isset($params[$key])) {
38
-                    if ($key === 'results') {
39
-                        $this->{$key} = array();
40
-                        foreach ($params[$key] as $r_key => $r_value) {
41
-                            if (is_array($r_value)) {
42
-                                array_push($this->{$key}, new ResponseOrder($r_value));
43
-                            } elseif (is_object($r_value) && $r_value instanceof ResponseOrder) {
44
-                                array_push($this->{$key}, $r_value);
45
-                            }
46
-                        }
47
-                    } else {
48
-                        $this->{$key} = $params[$key];
49
-                    }
50
-                }
51
-            }
52
-        }
53
-    }
33
+	public function __construct(array $params = null)
34
+	{
35
+		if ($params !== null) {
36
+			foreach ($this as $key => $value) {
37
+				if (isset($params[$key])) {
38
+					if ($key === 'results') {
39
+						$this->{$key} = array();
40
+						foreach ($params[$key] as $r_key => $r_value) {
41
+							if (is_array($r_value)) {
42
+								array_push($this->{$key}, new ResponseOrder($r_value));
43
+							} elseif (is_object($r_value) && $r_value instanceof ResponseOrder) {
44
+								array_push($this->{$key}, $r_value);
45
+							}
46
+						}
47
+					} else {
48
+						$this->{$key} = $params[$key];
49
+					}
50
+				}
51
+			}
52
+		}
53
+	}
54 54
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@
 block discarded – undo
32 32
 
33 33
     public function __construct(array $params = null)
34 34
     {
35
-        if ($params !== null) {
35
+        if ($params!==null) {
36 36
             foreach ($this as $key => $value) {
37 37
                 if (isset($params[$key])) {
38
-                    if ($key === 'results') {
38
+                    if ($key==='results') {
39 39
                         $this->{$key} = array();
40 40
                         foreach ($params[$key] as $r_key => $r_value) {
41 41
                             if (is_array($r_value)) {
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/CustomData.php 2 patches
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@
 block discarded – undo
13 13
  */
14 14
 class CustomData extends Common
15 15
 {
16
-    /**
17
-     * Tracking number for order.
18
-     */
19
-    public ?string $barcode = null;
16
+	/**
17
+	 * Tracking number for order.
18
+	 */
19
+	public ?string $barcode = null;
20 20
 
21
-    /**
22
-     * Additional tracking number for order.
23
-     */
24
-    public ?string $airbillno = null;
21
+	/**
22
+	 * Additional tracking number for order.
23
+	 */
24
+	public ?string $airbillno = null;
25 25
 
26
-    /**
27
-     * Datetime String with "T" delimiter, ISO 8601.
28
-     */
29
-    public ?string $sorted_on_date = null;
26
+	/**
27
+	 * Datetime String with "T" delimiter, ISO 8601.
28
+	 */
29
+	public ?string $sorted_on_date = null;
30 30
 
31
-    /**
32
-     * Timestamp only; replaced data in`sorted_on_date` property.
33
-     */
34
-    public ?int $sorted_on_utc = null;
31
+	/**
32
+	 * Timestamp only; replaced data in`sorted_on_date` property.
33
+	 */
34
+	public ?int $sorted_on_utc = null;
35 35
 
36
-    public function __construct(array $params = null)
37
-    {
38
-        if ($params != null) {
39
-            $this->fillFromArray($params);
40
-        }
41
-    }
36
+	public function __construct(array $params = null)
37
+	{
38
+		if ($params != null) {
39
+			$this->fillFromArray($params);
40
+		}
41
+	}
42 42
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
 
36 36
     public function __construct(array $params = null)
37 37
     {
38
-        if ($params != null) {
38
+        if ($params!=null) {
39 39
             $this->fillFromArray($params);
40 40
         }
41 41
     }
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/GPSCoords.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@
 block discarded – undo
13 13
  */
14 14
 class GPSCoords extends Common
15 15
 {
16
-    /**
17
-     * Latitude.
18
-     */
19
-    public ?float $lat = null;
16
+	/**
17
+	 * Latitude.
18
+	 */
19
+	public ?float $lat = null;
20 20
 
21
-    /**
22
-     * Longitude.
23
-     */
24
-    public ?float $lng = null;
21
+	/**
22
+	 * Longitude.
23
+	 */
24
+	public ?float $lng = null;
25 25
 
26
-    public function __construct($params_or_lat = null, float $lng = null)
27
-    {
28
-        if (is_array($params_or_lat)) {
29
-            $this->fillFromArray($params_or_lat);
30
-        } elseif (is_float($params_or_lat)) {
31
-            $this->lat = $params_or_lat;
32
-            $this->lng = $lng;
33
-        }
34
-    }
26
+	public function __construct($params_or_lat = null, float $lng = null)
27
+	{
28
+		if (is_array($params_or_lat)) {
29
+			$this->fillFromArray($params_or_lat);
30
+		} elseif (is_float($params_or_lat)) {
31
+			$this->lat = $params_or_lat;
32
+			$this->lng = $lng;
33
+		}
34
+	}
35 35
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/LocalTimeWindow.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -13,23 +13,23 @@
 block discarded – undo
13 13
  */
14 14
 class LocalTimeWindow extends Common
15 15
 {
16
-    /**
17
-     * Start time, unix timestamp.
18
-     */
19
-    public ?int $start = null;
16
+	/**
17
+	 * Start time, unix timestamp.
18
+	 */
19
+	public ?int $start = null;
20 20
 
21
-    /**
22
-     * End time, unix timestamp.
23
-     */
24
-    public ?int $end = null;
21
+	/**
22
+	 * End time, unix timestamp.
23
+	 */
24
+	public ?int $end = null;
25 25
 
26
-    public function __construct($params_or_start = null, int $end = null)
27
-    {
28
-        if (is_array($params_or_start)) {
29
-            $this->fillFromArray($params_or_start);
30
-        } elseif (is_int($params_or_start)) {
31
-            $this->start = $params_or_start;
32
-            $this->end = $end;
33
-        }
34
-    }
26
+	public function __construct($params_or_start = null, int $end = null)
27
+	{
28
+		if (is_array($params_or_start)) {
29
+			$this->fillFromArray($params_or_start);
30
+		} elseif (is_int($params_or_start)) {
31
+			$this->start = $params_or_start;
32
+			$this->end = $end;
33
+		}
34
+	}
35 35
 }
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/Order.php 2 patches
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -17,239 +17,239 @@
 block discarded – undo
17 17
  */
18 18
 class Order extends Common
19 19
 {
20
-    /**
21
-     * Order owner ID.
22
-     */
23
-    public ?int $member_id = null;
24
-
25
-    /**
26
-     * The order Address line 1.
27
-     */
28
-    public ?string $address_1 = null;
29
-
30
-    /**
31
-     * The order Address line 2.
32
-     */
33
-    public ?string $address_2 = null;
34
-
35
-    /**
36
-     * Address alias.
37
-     */
38
-    public ?string $address_alias = null;
39
-
40
-    /**
41
-     * The city the address is located in.
42
-     */
43
-    public ?string $address_city = null;
44
-
45
-    /**
46
-     * The state the address is located in.
47
-     */
48
-    public ?string $address_state = null;
49
-
50
-    /**
51
-     * The zip code the address is located in.
52
-     */
53
-    public ?string $address_zip = null;
54
-
55
-    /**
56
-     * The country the address is located in.
57
-     */
58
-    public ?string $address_country = null;
59
-
60
-    /**
61
-     * GPS coords of address.
62
-     */
63
-    public ?GPSCoords $address_geo = null;
64
-
65
-    /**
66
-     * Curbside GPS coords of address.
67
-     */
68
-    public ?GPSCoords $curbside_geo = null;
69
-
70
-    /**
71
-     * Date scheduled.
72
-     * e.g. YY-MM-DD, YYMMDD, ISO 8601
73
-     */
74
-    public ?string $date_scheduled_for = null;
75
-
76
-    /**
77
-     * Order status ID.
78
-     */
79
-    public ?int $order_status_id = null;
80
-
81
-    /**
82
-     * If true, the order is pending.
83
-     */
84
-    public ?bool $is_pending = null;
85
-
86
-    /**
87
-     * If true, the order is accepted.
88
-     */
89
-    public ?bool $is_accepted = null;
90
-
91
-    /**
92
-     * If true, the order is started.
93
-     */
94
-    public ?bool $is_started = null;
95
-
96
-    /**
97
-     * If true, the order is completed.
98
-     */
99
-    public ?bool $is_completed = null;
100
-
101
-    /**
102
-     * If true, the order is validated.
103
-     */
104
-    public ?bool $is_validated = null;
105
-
106
-    /**
107
-     * The phone number.
108
-     */
109
-    public ?string $phone = null;
110
-
111
-    /**
112
-     * The first name.
113
-     */
114
-    public ?string $first_name = null;
115
-
116
-    /**
117
-     * The last name.
118
-     */
119
-    public ?string $last_name = null;
120
-
121
-    /**
122
-     * E-mail.
123
-     */
124
-    public ?string $email = null;
125
-
126
-    /**
127
-     * Order custom data.
128
-     */
129
-    public ?CustomData $custom_data = null;
130
-
131
-    /**
132
-     * Array of Time Window objects.
133
-     */
134
-    public ?array $local_time_windows = null;
135
-
136
-    /**
137
-     * Local timezone String.
138
-     */
139
-    public ?string $local_timezone_string = null;
140
-
141
-    /**
142
-     * Consumed service time.
143
-     */
144
-    public ?int $service_time = null;
145
-
146
-    /**
147
-     * Color of an address, e.g., 'FF0000'.
148
-     */
149
-    public ?string $color = null;
150
-
151
-    /**
152
-     * Tracking number
153
-     */
154
-    public ?string $tracking_number = null;
155
-
156
-    /**
157
-     * The address type of stop, this is one of 'DELIVERY', 'PICKUP',
158
-     * 'BREAK', 'MEETUP', 'SERVICE', 'VISIT' or 'DRIVEBY'.
159
-     */
160
-    public ?string $address_stop_type = null;
161
-
162
-    /**
163
-     * Last known status
164
-     */
165
-    public ?int $last_status = null;
166
-
167
-    /**
168
-     * Weight of the cargo.
169
-     */
170
-    public ?float $weight = null;
171
-
172
-    /**
173
-     * Cost of the cargo.
174
-     */
175
-    public ?float $cost = null;
176
-
177
-    /**
178
-     * The total revenue for the order.
179
-     */
180
-    public ?float $revenue = null;
181
-
182
-    /**
183
-     * The cubic volume of the cargo.
184
-     */
185
-    public ?float $cube = null;
186
-
187
-    /**
188
-     *The item quantity of the cargo.
189
-     */
190
-    public ?float $pieces = null;
191
-
192
-    /**
193
-     * The group.
194
-     */
195
-    public ?string $group = null;
196
-
197
-    /**
198
-     * Priority of address
199
-     * 0 is the highest priority, n has higher priority than n + 1
200
-     */
201
-    public ?int $address_priority = null;
202
-
203
-    /**
204
-     * The customer purchase order for the address, length <= 50.
205
-     */
206
-    public ?string $address_customer_po = null;
207
-
208
-    /**
209
-     * Array of Custom Fields objects.
210
-     */
211
-    public ?array $custom_fields = null;
212
-
213
-    public function __construct(array $params = null)
214
-    {
215
-        if ($params !== null) {
216
-            foreach ($this as $key => $value) {
217
-                if (isset($params[$key])) {
218
-                    if ($key === 'local_time_windows') {
219
-                        $this->{$key} = array();
220
-                        foreach ($params[$key] as $ltw_key => $ltw_value) {
221
-                            if (is_array($ltw_value)) {
222
-                                array_push($this->{$key}, new LocalTimeWindow($ltw_value));
223
-                            } elseif (is_object($ltw_value) && $ltw_value instanceof LocalTimeWindow) {
224
-                                array_push($this->{$key}, $ltw_value);
225
-                            }
226
-                        }
227
-                    } elseif ($key === 'custom_fields') {
228
-                        $this->{$key} = array();
229
-                        foreach ($params[$key] as $cf_key => $cf_value) {
230
-                            if (is_array($cf_value)) {
231
-                                array_push($this->{$key}, new CustomField($cf_value));
232
-                            } elseif (is_object($cf_value) && $cf_value instanceof CustomField) {
233
-                                array_push($this->{$key}, $cf_value);
234
-                            }
235
-                        }
236
-                    } elseif ($key === 'address_geo' || $key === 'curbside_geo') {
237
-                        if (is_array($params[$key])) {
238
-                            $this->{$key} = new GPSCoords($params[$key]);
239
-                        } elseif (is_object($params[$key]) && $params[$key] instanceof GPSCoords) {
240
-                            $this->{$key} = $params[$key];
241
-                        }
242
-                    } elseif ($key === 'custom_data') {
243
-                        if (is_array($params[$key])) {
244
-                            $this->{$key} = new CustomData($params[$key]);
245
-                        } elseif (is_object($params[$key]) && $params[$key] instanceof CustomData) {
246
-                            $this->{$key} = $params[$key];
247
-                        }
248
-                    } else {
249
-                        $this->{$key} = $params[$key];
250
-                    }
251
-                }
252
-            }
253
-        }
254
-    }
20
+	/**
21
+	 * Order owner ID.
22
+	 */
23
+	public ?int $member_id = null;
24
+
25
+	/**
26
+	 * The order Address line 1.
27
+	 */
28
+	public ?string $address_1 = null;
29
+
30
+	/**
31
+	 * The order Address line 2.
32
+	 */
33
+	public ?string $address_2 = null;
34
+
35
+	/**
36
+	 * Address alias.
37
+	 */
38
+	public ?string $address_alias = null;
39
+
40
+	/**
41
+	 * The city the address is located in.
42
+	 */
43
+	public ?string $address_city = null;
44
+
45
+	/**
46
+	 * The state the address is located in.
47
+	 */
48
+	public ?string $address_state = null;
49
+
50
+	/**
51
+	 * The zip code the address is located in.
52
+	 */
53
+	public ?string $address_zip = null;
54
+
55
+	/**
56
+	 * The country the address is located in.
57
+	 */
58
+	public ?string $address_country = null;
59
+
60
+	/**
61
+	 * GPS coords of address.
62
+	 */
63
+	public ?GPSCoords $address_geo = null;
64
+
65
+	/**
66
+	 * Curbside GPS coords of address.
67
+	 */
68
+	public ?GPSCoords $curbside_geo = null;
69
+
70
+	/**
71
+	 * Date scheduled.
72
+	 * e.g. YY-MM-DD, YYMMDD, ISO 8601
73
+	 */
74
+	public ?string $date_scheduled_for = null;
75
+
76
+	/**
77
+	 * Order status ID.
78
+	 */
79
+	public ?int $order_status_id = null;
80
+
81
+	/**
82
+	 * If true, the order is pending.
83
+	 */
84
+	public ?bool $is_pending = null;
85
+
86
+	/**
87
+	 * If true, the order is accepted.
88
+	 */
89
+	public ?bool $is_accepted = null;
90
+
91
+	/**
92
+	 * If true, the order is started.
93
+	 */
94
+	public ?bool $is_started = null;
95
+
96
+	/**
97
+	 * If true, the order is completed.
98
+	 */
99
+	public ?bool $is_completed = null;
100
+
101
+	/**
102
+	 * If true, the order is validated.
103
+	 */
104
+	public ?bool $is_validated = null;
105
+
106
+	/**
107
+	 * The phone number.
108
+	 */
109
+	public ?string $phone = null;
110
+
111
+	/**
112
+	 * The first name.
113
+	 */
114
+	public ?string $first_name = null;
115
+
116
+	/**
117
+	 * The last name.
118
+	 */
119
+	public ?string $last_name = null;
120
+
121
+	/**
122
+	 * E-mail.
123
+	 */
124
+	public ?string $email = null;
125
+
126
+	/**
127
+	 * Order custom data.
128
+	 */
129
+	public ?CustomData $custom_data = null;
130
+
131
+	/**
132
+	 * Array of Time Window objects.
133
+	 */
134
+	public ?array $local_time_windows = null;
135
+
136
+	/**
137
+	 * Local timezone String.
138
+	 */
139
+	public ?string $local_timezone_string = null;
140
+
141
+	/**
142
+	 * Consumed service time.
143
+	 */
144
+	public ?int $service_time = null;
145
+
146
+	/**
147
+	 * Color of an address, e.g., 'FF0000'.
148
+	 */
149
+	public ?string $color = null;
150
+
151
+	/**
152
+	 * Tracking number
153
+	 */
154
+	public ?string $tracking_number = null;
155
+
156
+	/**
157
+	 * The address type of stop, this is one of 'DELIVERY', 'PICKUP',
158
+	 * 'BREAK', 'MEETUP', 'SERVICE', 'VISIT' or 'DRIVEBY'.
159
+	 */
160
+	public ?string $address_stop_type = null;
161
+
162
+	/**
163
+	 * Last known status
164
+	 */
165
+	public ?int $last_status = null;
166
+
167
+	/**
168
+	 * Weight of the cargo.
169
+	 */
170
+	public ?float $weight = null;
171
+
172
+	/**
173
+	 * Cost of the cargo.
174
+	 */
175
+	public ?float $cost = null;
176
+
177
+	/**
178
+	 * The total revenue for the order.
179
+	 */
180
+	public ?float $revenue = null;
181
+
182
+	/**
183
+	 * The cubic volume of the cargo.
184
+	 */
185
+	public ?float $cube = null;
186
+
187
+	/**
188
+	 *The item quantity of the cargo.
189
+	 */
190
+	public ?float $pieces = null;
191
+
192
+	/**
193
+	 * The group.
194
+	 */
195
+	public ?string $group = null;
196
+
197
+	/**
198
+	 * Priority of address
199
+	 * 0 is the highest priority, n has higher priority than n + 1
200
+	 */
201
+	public ?int $address_priority = null;
202
+
203
+	/**
204
+	 * The customer purchase order for the address, length <= 50.
205
+	 */
206
+	public ?string $address_customer_po = null;
207
+
208
+	/**
209
+	 * Array of Custom Fields objects.
210
+	 */
211
+	public ?array $custom_fields = null;
212
+
213
+	public function __construct(array $params = null)
214
+	{
215
+		if ($params !== null) {
216
+			foreach ($this as $key => $value) {
217
+				if (isset($params[$key])) {
218
+					if ($key === 'local_time_windows') {
219
+						$this->{$key} = array();
220
+						foreach ($params[$key] as $ltw_key => $ltw_value) {
221
+							if (is_array($ltw_value)) {
222
+								array_push($this->{$key}, new LocalTimeWindow($ltw_value));
223
+							} elseif (is_object($ltw_value) && $ltw_value instanceof LocalTimeWindow) {
224
+								array_push($this->{$key}, $ltw_value);
225
+							}
226
+						}
227
+					} elseif ($key === 'custom_fields') {
228
+						$this->{$key} = array();
229
+						foreach ($params[$key] as $cf_key => $cf_value) {
230
+							if (is_array($cf_value)) {
231
+								array_push($this->{$key}, new CustomField($cf_value));
232
+							} elseif (is_object($cf_value) && $cf_value instanceof CustomField) {
233
+								array_push($this->{$key}, $cf_value);
234
+							}
235
+						}
236
+					} elseif ($key === 'address_geo' || $key === 'curbside_geo') {
237
+						if (is_array($params[$key])) {
238
+							$this->{$key} = new GPSCoords($params[$key]);
239
+						} elseif (is_object($params[$key]) && $params[$key] instanceof GPSCoords) {
240
+							$this->{$key} = $params[$key];
241
+						}
242
+					} elseif ($key === 'custom_data') {
243
+						if (is_array($params[$key])) {
244
+							$this->{$key} = new CustomData($params[$key]);
245
+						} elseif (is_object($params[$key]) && $params[$key] instanceof CustomData) {
246
+							$this->{$key} = $params[$key];
247
+						}
248
+					} else {
249
+						$this->{$key} = $params[$key];
250
+					}
251
+				}
252
+			}
253
+		}
254
+	}
255 255
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 
213 213
     public function __construct(array $params = null)
214 214
     {
215
-        if ($params !== null) {
215
+        if ($params!==null) {
216 216
             foreach ($this as $key => $value) {
217 217
                 if (isset($params[$key])) {
218
-                    if ($key === 'local_time_windows') {
218
+                    if ($key==='local_time_windows') {
219 219
                         $this->{$key} = array();
220 220
                         foreach ($params[$key] as $ltw_key => $ltw_value) {
221 221
                             if (is_array($ltw_value)) {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
                                 array_push($this->{$key}, $ltw_value);
225 225
                             }
226 226
                         }
227
-                    } elseif ($key === 'custom_fields') {
227
+                    } elseif ($key==='custom_fields') {
228 228
                         $this->{$key} = array();
229 229
                         foreach ($params[$key] as $cf_key => $cf_value) {
230 230
                             if (is_array($cf_value)) {
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
                                 array_push($this->{$key}, $cf_value);
234 234
                             }
235 235
                         }
236
-                    } elseif ($key === 'address_geo' || $key === 'curbside_geo') {
236
+                    } elseif ($key==='address_geo' || $key==='curbside_geo') {
237 237
                         if (is_array($params[$key])) {
238 238
                             $this->{$key} = new GPSCoords($params[$key]);
239 239
                         } elseif (is_object($params[$key]) && $params[$key] instanceof GPSCoords) {
240 240
                             $this->{$key} = $params[$key];
241 241
                         }
242
-                    } elseif ($key === 'custom_data') {
242
+                    } elseif ($key==='custom_data') {
243 243
                         if (is_array($params[$key])) {
244 244
                             $this->{$key} = new CustomData($params[$key]);
245 245
                         } elseif (is_object($params[$key]) && $params[$key] instanceof CustomData) {
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/Orders.php 2 patches
Indentation   +484 added lines, -484 removed lines patch added patch discarded remove patch
@@ -19,514 +19,514 @@
 block discarded – undo
19 19
  */
20 20
 class Orders extends Common
21 21
 {
22
-    public function __construct()
23
-    {
24
-        Route4Me::setBaseUrl('');
25
-    }
22
+	public function __construct()
23
+	{
24
+		Route4Me::setBaseUrl('');
25
+	}
26 26
 
27
-    /**
28
-     * Create single order
29
-     *
30
-     * @since 1.3.0
31
-     *
32
-     * @param  $params_or_order             - Array of order's parameters or Order object
33
-     *   number member_id                   - Order owner ID.
34
-     *   string address_1                   - The order Address line 1.
35
-     *   string address_2                   - The order Address line 2.
36
-     *   string address_alias               - Address alias.
37
-     *   string address_city                - The city the address is located in.
38
-     *   string address_state               - The state the address is located in.
39
-     *   string address_zip                 - The zip code the address is located in.
40
-     *   string address_country             - The country the address is located in.
41
-     *   object address_geo                 - GPS coords of address.
42
-     *     number lat                       - Latitude.
43
-     *     number lng                       - Longitude.
44
-     *   object curbside_geo                - Curbside GPS coords of address.
45
-     *     number lat                       - Curbside latitude.
46
-     *     number lng                       - Curbside longitude.
47
-     *   string date_scheduled_for          - Date scheduled.
48
-     *                                        Possible formats: YY-MM-DD, YYMMDD, ISO 8601
49
-     *   number order_status_id             - Order status ID.
50
-     *   bool   is_pending                  - If true, the order is pending.
51
-     *   bool   is_accepted                 - If true, the order is accepted.
52
-     *   bool   is_started                  - If true, the order is started.
53
-     *   bool   is_completed                - If true, the order is completed.
54
-     *   bool   is_validated                - If true, the order is validated.
55
-     *   string phone                       - The phone number.
56
-     *   string first_name                  - The first name.
57
-     *   string last_name                   - The last name.
58
-     *   string email                       - E-mail.
59
-     *   array  custom_data                 - Order custom data.
60
-     *     string barcode                   - Tracking number for order.
61
-     *     string airbillno                 - Additional tracking number for order.
62
-     *     string sorted_on_date            - Datetime string with "T" delimiter, ISO 8601.
63
-     *     number sorted_on_utc             - Timestamp only; replaced data in
64
-     *                                        sorted_on_date` property.
65
-     *   array  local_time_windows          - Array of Time Window objects.
66
-     *     number start                     - Start of Time Window, unix timestamp.
67
-     *     number end                       - End of Time Window, unix timestamp.
68
-     *   string local_timezone_string       - Local timezone string
69
-     *   number service_time                - Consumed service time.
70
-     *   string color                       - Color of an address, e.g., 'FF0000'.
71
-     *   string tracking_number             - Tracking number
72
-     *   string address_stop_type           - The type of stop that this is
73
-     *                                        one of 'DELIVERY', 'PICKUP', 'BREAK', 'MEETUP',
74
-     *                                        'SERVICE', 'VISIT' or 'DRIVEBY'.
75
-     *   number last_status
76
-     *   number weight                      - Weight of the cargo.
77
-     *   number cost                        - Cost of the cargo.
78
-     *   number revenue                     - The total revenue for the order.
79
-     *   number cube                        - The cubic volume of the cargo.
80
-     *   number pieces                      - The item quantity of the cargo.
81
-     *   string group                       - The group.
82
-     *   number address_priority            - Priority of address 0 is the highest priority,
83
-     *                                        n has higher priority than n + 1
84
-     *   string address_customer_po         - The customer purchase order for
85
-     *                                        the address, length <= 50.
86
-     *   array  custom_fields               - Array of Custom Fields objects.
87
-     *     string order_custom_field_uuid   - HEX-string.
88
-     *     string order_custom_field_value  - Value of Custom Fields.
89
-     * @return ResponseOrder
90
-     * @throws Exception\ApiError
91
-     */
92
-    public function create($params_or_order) : ResponseOrder
93
-    {
94
-        $allBodyFields = ['member_id', 'address_1', 'address_2', 'address_alias',
95
-            'address_city', 'address_state', 'address_zip', 'address_country', 'address_geo', 'curbside_geo',
96
-            'date_scheduled_for', 'order_status_id', 'is_pending', 'is_accepted',
97
-            'is_started', 'is_completed', 'is_validated', 'phone', 'first_name',
98
-            'last_name', 'email', 'custom_data', 'local_time_windows', 'local_timezone_string',
99
-            'service_time', 'color', 'tracking_number', 'address_stop_type', 'last_status', 'weight',
100
-            'cost', 'revenue', 'cube', 'pieces', 'group', 'address_priority',
101
-            'address_customer_po', 'custom_fields'
102
-        ];
27
+	/**
28
+	 * Create single order
29
+	 *
30
+	 * @since 1.3.0
31
+	 *
32
+	 * @param  $params_or_order             - Array of order's parameters or Order object
33
+	 *   number member_id                   - Order owner ID.
34
+	 *   string address_1                   - The order Address line 1.
35
+	 *   string address_2                   - The order Address line 2.
36
+	 *   string address_alias               - Address alias.
37
+	 *   string address_city                - The city the address is located in.
38
+	 *   string address_state               - The state the address is located in.
39
+	 *   string address_zip                 - The zip code the address is located in.
40
+	 *   string address_country             - The country the address is located in.
41
+	 *   object address_geo                 - GPS coords of address.
42
+	 *     number lat                       - Latitude.
43
+	 *     number lng                       - Longitude.
44
+	 *   object curbside_geo                - Curbside GPS coords of address.
45
+	 *     number lat                       - Curbside latitude.
46
+	 *     number lng                       - Curbside longitude.
47
+	 *   string date_scheduled_for          - Date scheduled.
48
+	 *                                        Possible formats: YY-MM-DD, YYMMDD, ISO 8601
49
+	 *   number order_status_id             - Order status ID.
50
+	 *   bool   is_pending                  - If true, the order is pending.
51
+	 *   bool   is_accepted                 - If true, the order is accepted.
52
+	 *   bool   is_started                  - If true, the order is started.
53
+	 *   bool   is_completed                - If true, the order is completed.
54
+	 *   bool   is_validated                - If true, the order is validated.
55
+	 *   string phone                       - The phone number.
56
+	 *   string first_name                  - The first name.
57
+	 *   string last_name                   - The last name.
58
+	 *   string email                       - E-mail.
59
+	 *   array  custom_data                 - Order custom data.
60
+	 *     string barcode                   - Tracking number for order.
61
+	 *     string airbillno                 - Additional tracking number for order.
62
+	 *     string sorted_on_date            - Datetime string with "T" delimiter, ISO 8601.
63
+	 *     number sorted_on_utc             - Timestamp only; replaced data in
64
+	 *                                        sorted_on_date` property.
65
+	 *   array  local_time_windows          - Array of Time Window objects.
66
+	 *     number start                     - Start of Time Window, unix timestamp.
67
+	 *     number end                       - End of Time Window, unix timestamp.
68
+	 *   string local_timezone_string       - Local timezone string
69
+	 *   number service_time                - Consumed service time.
70
+	 *   string color                       - Color of an address, e.g., 'FF0000'.
71
+	 *   string tracking_number             - Tracking number
72
+	 *   string address_stop_type           - The type of stop that this is
73
+	 *                                        one of 'DELIVERY', 'PICKUP', 'BREAK', 'MEETUP',
74
+	 *                                        'SERVICE', 'VISIT' or 'DRIVEBY'.
75
+	 *   number last_status
76
+	 *   number weight                      - Weight of the cargo.
77
+	 *   number cost                        - Cost of the cargo.
78
+	 *   number revenue                     - The total revenue for the order.
79
+	 *   number cube                        - The cubic volume of the cargo.
80
+	 *   number pieces                      - The item quantity of the cargo.
81
+	 *   string group                       - The group.
82
+	 *   number address_priority            - Priority of address 0 is the highest priority,
83
+	 *                                        n has higher priority than n + 1
84
+	 *   string address_customer_po         - The customer purchase order for
85
+	 *                                        the address, length <= 50.
86
+	 *   array  custom_fields               - Array of Custom Fields objects.
87
+	 *     string order_custom_field_uuid   - HEX-string.
88
+	 *     string order_custom_field_value  - Value of Custom Fields.
89
+	 * @return ResponseOrder
90
+	 * @throws Exception\ApiError
91
+	 */
92
+	public function create($params_or_order) : ResponseOrder
93
+	{
94
+		$allBodyFields = ['member_id', 'address_1', 'address_2', 'address_alias',
95
+			'address_city', 'address_state', 'address_zip', 'address_country', 'address_geo', 'curbside_geo',
96
+			'date_scheduled_for', 'order_status_id', 'is_pending', 'is_accepted',
97
+			'is_started', 'is_completed', 'is_validated', 'phone', 'first_name',
98
+			'last_name', 'email', 'custom_data', 'local_time_windows', 'local_timezone_string',
99
+			'service_time', 'color', 'tracking_number', 'address_stop_type', 'last_status', 'weight',
100
+			'cost', 'revenue', 'cube', 'pieces', 'group', 'address_priority',
101
+			'address_customer_po', 'custom_fields'
102
+		];
103 103
 
104
-        return $this->toResponseOrder(Route4Me::makeRequst([
105
-            'url' => Endpoint::ORDER_CREATE,
106
-            'method' => 'POST',
107
-            'HTTPHEADER' => 'Content-Type: application/json',
108
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params_or_order)
109
-        ]));
110
-    }
104
+		return $this->toResponseOrder(Route4Me::makeRequst([
105
+			'url' => Endpoint::ORDER_CREATE,
106
+			'method' => 'POST',
107
+			'HTTPHEADER' => 'Content-Type: application/json',
108
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params_or_order)
109
+		]));
110
+	}
111 111
 
112
-    /**
113
-     * Show single order by its id
114
-     *
115
-     * @since 1.3.0
116
-     *
117
-     * @param  string $order_id - Order ID.
118
-     * @return ResponseOrder
119
-     * @throws Exception\ApiError
120
-     */
121
-    public function get(string $order_id) : ResponseOrder
122
-    {
123
-        return $this->toResponseOrder(Route4Me::makeRequst([
124
-            'url' => Endpoint::ORDER . '/' . $order_id,
125
-            'method' => 'GET'
126
-        ]));
127
-    }
112
+	/**
113
+	 * Show single order by its id
114
+	 *
115
+	 * @since 1.3.0
116
+	 *
117
+	 * @param  string $order_id - Order ID.
118
+	 * @return ResponseOrder
119
+	 * @throws Exception\ApiError
120
+	 */
121
+	public function get(string $order_id) : ResponseOrder
122
+	{
123
+		return $this->toResponseOrder(Route4Me::makeRequst([
124
+			'url' => Endpoint::ORDER . '/' . $order_id,
125
+			'method' => 'GET'
126
+		]));
127
+	}
128 128
 
129
-    /**
130
-     * Update single order by its id
131
-     *
132
-     * @since 1.3.0
133
-     *
134
-     * @param  string $order_id - Order ID.
135
-     * @param  object $params   - Parameters of order to update, look for more
136
-     *                            information in create()
137
-     * @return ResponseOrder
138
-     * @throws Exception\ApiError
139
-     */
140
-    public function update(string $order_id, $params) : ResponseOrder
141
-    {
142
-        $allBodyFields = ['member_id', 'address_1', 'address_2', 'address_alias',
143
-            'address_city', 'address_state', 'address_zip', 'address_country', 'address_geo', 'curbside_geo',
144
-            'date_scheduled_for', 'order_status_id', 'is_pending', 'is_accepted',
145
-            'is_started', 'is_completed', 'is_validated', 'phone', 'first_name',
146
-            'last_name', 'email', 'custom_data', 'local_time_windows', 'local_timezone_string',
147
-            'service_time', 'color', 'tracking_number', 'address_stop_type', 'last_status', 'weight',
148
-            'cost', 'revenue', 'cube', 'pieces', 'group', 'address_priority',
149
-            'address_customer_po', 'custom_fields'
150
-        ];
129
+	/**
130
+	 * Update single order by its id
131
+	 *
132
+	 * @since 1.3.0
133
+	 *
134
+	 * @param  string $order_id - Order ID.
135
+	 * @param  object $params   - Parameters of order to update, look for more
136
+	 *                            information in create()
137
+	 * @return ResponseOrder
138
+	 * @throws Exception\ApiError
139
+	 */
140
+	public function update(string $order_id, $params) : ResponseOrder
141
+	{
142
+		$allBodyFields = ['member_id', 'address_1', 'address_2', 'address_alias',
143
+			'address_city', 'address_state', 'address_zip', 'address_country', 'address_geo', 'curbside_geo',
144
+			'date_scheduled_for', 'order_status_id', 'is_pending', 'is_accepted',
145
+			'is_started', 'is_completed', 'is_validated', 'phone', 'first_name',
146
+			'last_name', 'email', 'custom_data', 'local_time_windows', 'local_timezone_string',
147
+			'service_time', 'color', 'tracking_number', 'address_stop_type', 'last_status', 'weight',
148
+			'cost', 'revenue', 'cube', 'pieces', 'group', 'address_priority',
149
+			'address_customer_po', 'custom_fields'
150
+		];
151 151
 
152
-        return $this->toResponseOrder(Route4Me::makeRequst([
153
-            'url' => Endpoint::ORDER . '/' . $order_id,
154
-            'method' => 'PUT',
155
-            'HTTPHEADER' => 'Content-Type: application/json',
156
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
157
-        ]));
158
-    }
152
+		return $this->toResponseOrder(Route4Me::makeRequst([
153
+			'url' => Endpoint::ORDER . '/' . $order_id,
154
+			'method' => 'PUT',
155
+			'HTTPHEADER' => 'Content-Type: application/json',
156
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
157
+		]));
158
+	}
159 159
 
160
-    /**
161
-     * Delete (soft) single order by its id
162
-     *
163
-     * @since 1.3.0
164
-     *
165
-     * @param  string $order_id - Order ID.
166
-     * @return bool
167
-     * @throws Exception\ApiError
168
-     */
169
-    public function delete(string $order_id) : bool
170
-    {
171
-        $res = Route4Me::makeRequst([
172
-            'url' => Endpoint::ORDER . '/' . $order_id,
173
-            'method' => 'DELETE'
174
-        ]);
175
-        return (isset($res['status']) ? $res['status'] : false);
176
-    }
160
+	/**
161
+	 * Delete (soft) single order by its id
162
+	 *
163
+	 * @since 1.3.0
164
+	 *
165
+	 * @param  string $order_id - Order ID.
166
+	 * @return bool
167
+	 * @throws Exception\ApiError
168
+	 */
169
+	public function delete(string $order_id) : bool
170
+	{
171
+		$res = Route4Me::makeRequst([
172
+			'url' => Endpoint::ORDER . '/' . $order_id,
173
+			'method' => 'DELETE'
174
+		]);
175
+		return (isset($res['status']) ? $res['status'] : false);
176
+	}
177 177
 
178
-    /**
179
-     * Search orders in ElasticSearch storage or in Spanner database
180
-     *
181
-     * @since 1.3.0
182
-     *
183
-     * @param  $params                    - Search and filter parameters.
184
-     *   string[] [order_ids]             - Array of order ids, HEX-Strings.
185
-     *   bool     return_provided_fields_as_map
186
-     *   array    [orderBy]               - Sort and direction parameters.
187
-     *     string   0                     - The name of the sort field, this is one of
188
-     *                                      'address_alias', 'first_name', 'last_name', 'phone',
189
-     *                                      'is_pending', 'is_validated', 'is_accepted',
190
-     *                                      'is_completed', 'scheduled_for', 'day_added'
191
-     *     string   [1 = 'asc']           - Sorting direction, this is one of 'asc', 'ASC', 'desc', 'DESC'
192
-     *   int      [limit = 30]            - The number of orders per page.
193
-     *   int      [offset = 0]            - The requested page.
194
-     *   string[] [fields]                - An array of returned fields, this is one of
195
-     *                                      'order_uuid', 'member_id', 'address_1', 'address_2',
196
-     *                                      'address_alias', 'address_city', 'address_state', 'address_zip',
197
-     *                                      'address_country', 'coordinates', 'curbside_coordinates',
198
-     *                                      'updated_timestamp', 'created_timestamp', 'day_added',
199
-     *                                      'scheduled_for', 'order_status_id', 'is_pending', 'is_started',
200
-     *                                      'is_completed', 'is_validated', 'phone', 'first_name', 'last_name',
201
-     *                                      'email', 'custom_data', 'local_time_windows', 'local_timezone',
202
-     *                                      'service_time', 'color', 'icon', 'last_visited_timestamp',
203
-     *                                      'visited_count', 'in_route_count', 'last_routed_timestamp',
204
-     *                                      'tracking_number', 'organization_id', 'root_member_id',
205
-     *                                      'address_stop_type', 'last_status', 'sorted_day_id', 'weight',
206
-     *                                      'cost', 'revenue', 'cube', 'pieces', 'done_day_id',
207
-     *                                      'possession_day_id', 'group', 'workflow_uuid', 'address_priority'
208
-     *   string[] [addition]              - An array of additional returned fields, this is one of
209
-     *                                      'territory_ids', 'aggregation_ids'
210
-     *   array    [search]                - Search parameters.
211
-     *     string   [query]               - The string to query to ElasticSearch. If set the `matches` and
212
-     *                                      `terms` sections will be ignored.
213
-     *     array    [matches]             - The object to query to ElasticSearch.
214
-     *       array    [custom_data]       - Order custom data.
215
-     *         string   [barcode]         - Tracking number for order.
216
-     *         string   [airbillno]       - Additional tracking number for order.
217
-     *         string   [sorted_on_date]  - Datetime String with "T" delimiter, ISO 8601.
218
-     *         int      [sorted_on_utc]   - Timestamp only; replaced data in `sorted_on_date` property.
219
-     *       string   [first_name]        - The first name.
220
-     *       string   [last_name]         - The last name.
221
-     *       string   [email]             - E-mail.
222
-     *       string   [phone]             - The phone number.
223
-     *       string   [address_1]         - The order Address line 1.
224
-     *       string   [address_alias]     - Address alias.
225
-     *       string   [address_zip]       - The zip code of the address.
226
-     *     array    [terms]               - The object to query to ElasticSearch.
227
-     *       array    [custom_data]       - Order custom data.
228
-     *         string   [barcode]         - Tracking number for order.
229
-     *         string   [airbillno]       - Additional tracking number for order.
230
-     *         string   [sorted_on_date]  - Datetime String with "T" delimiter, ISO 8601.
231
-     *         int      [sorted_on_utc]   - Timestamp only; replaced data in `sorted_on_date` property.
232
-     *       string   [first_name]        - The first name.
233
-     *       string   [last_name]         - The last name.
234
-     *       string   [email]             - E-mail.
235
-     *       string   [phone]             - The phone number.
236
-     *       string   [address_1]         - The order Address line 1.
237
-     *       string   [address_alias]     - Address alias.
238
-     *       string   [address_zip]       - The zip code the address is located in.
239
-     *   array    [filters]               - Filter parameters.
240
-     *     string[] [order_ids]           - Array of included order ids, HEX-Strings.
241
-     *     string[] [excluded_ids]        - Array of excluded order ids, HEX-Strings.
242
-     *     string[] [tracking_numbers]    - Array of tracking number of orders.
243
-     *     bool  [only_geocoded]
244
-     *     int|string|array [updated_timestamp]  - Can be unix timestamp or ISO 8601 or array [
245
-     *                                                 "start" => "timestamp or ISO 8601",
246
-     *                                                 "end" => "timestamp or ISO 8601"
247
-     *                                             ]
248
-     *     int|string|array [created_timestamp]  - Can be unix timestamp or ISO 8601 or array [
249
-     *                                                 "start" => "timestamp or ISO 8601",
250
-     *                                                 "end" => "timestamp or ISO 8601"
251
-     *                                             ]
252
-     *     int|string|array [scheduled_for]        - Can be unix timestamp or ISO 8601 or array [
253
-     *                                                 "start" => "timestamp or ISO 8601",
254
-     *                                                 "end" => "timestamp or ISO 8601"
255
-     *                                             ]
256
-     *     bool  [only_unscheduled]
257
-     *     int|string|array [day_added]            - Can be unix timestamp or ISO 8601 or array [
258
-     *                                                 "start" => "timestamp or ISO 8601",
259
-     *                                                 "end" => "timestamp or ISO 8601"
260
-     *                                             ]
261
-     *     int|string|array [sorted_on]            - Can be unix timestamp or ISO 8601 or array [
262
-     *                                                 "start" => "timestamp or ISO 8601",
263
-     *                                                 "end" => "timestamp or ISO 8601"
264
-     *                                             ]
265
-     *     string[] [address_stop_types]           - Array of stop type names, possible values
266
-     *                                               'DELIVERY', 'PICKUP', 'BREAK', 'MEETUP',
267
-     *                                               'SERVICE', 'VISIT' or 'DRIVEBY'.
268
-     *     int[]    [last_statuses]                - Array of statuses.
269
-     *     int[]    [territory_ids]                - Array of territory ids.
270
-     *     string   [done_day]
271
-     *     string   [possession_day]
272
-     *     string[] [groups]
273
-     *     string   [display= 'all']               - Filtering by the in_route_count field, is one of
274
-     *                                               'routed', 'unrouted', 'all'
275
-     * @return ResponseSearch
276
-     * @throws Exception\ApiError
277
-     */
278
-    public function search(?array $params = null) : ResponseSearch
279
-    {
280
-        $allBodyFields = ['order_ids', 'return_provided_fields_as_map', 'orderBy', 'limit',
281
-            'offset', 'fields', 'addition', 'search', 'filters'
282
-        ];
178
+	/**
179
+	 * Search orders in ElasticSearch storage or in Spanner database
180
+	 *
181
+	 * @since 1.3.0
182
+	 *
183
+	 * @param  $params                    - Search and filter parameters.
184
+	 *   string[] [order_ids]             - Array of order ids, HEX-Strings.
185
+	 *   bool     return_provided_fields_as_map
186
+	 *   array    [orderBy]               - Sort and direction parameters.
187
+	 *     string   0                     - The name of the sort field, this is one of
188
+	 *                                      'address_alias', 'first_name', 'last_name', 'phone',
189
+	 *                                      'is_pending', 'is_validated', 'is_accepted',
190
+	 *                                      'is_completed', 'scheduled_for', 'day_added'
191
+	 *     string   [1 = 'asc']           - Sorting direction, this is one of 'asc', 'ASC', 'desc', 'DESC'
192
+	 *   int      [limit = 30]            - The number of orders per page.
193
+	 *   int      [offset = 0]            - The requested page.
194
+	 *   string[] [fields]                - An array of returned fields, this is one of
195
+	 *                                      'order_uuid', 'member_id', 'address_1', 'address_2',
196
+	 *                                      'address_alias', 'address_city', 'address_state', 'address_zip',
197
+	 *                                      'address_country', 'coordinates', 'curbside_coordinates',
198
+	 *                                      'updated_timestamp', 'created_timestamp', 'day_added',
199
+	 *                                      'scheduled_for', 'order_status_id', 'is_pending', 'is_started',
200
+	 *                                      'is_completed', 'is_validated', 'phone', 'first_name', 'last_name',
201
+	 *                                      'email', 'custom_data', 'local_time_windows', 'local_timezone',
202
+	 *                                      'service_time', 'color', 'icon', 'last_visited_timestamp',
203
+	 *                                      'visited_count', 'in_route_count', 'last_routed_timestamp',
204
+	 *                                      'tracking_number', 'organization_id', 'root_member_id',
205
+	 *                                      'address_stop_type', 'last_status', 'sorted_day_id', 'weight',
206
+	 *                                      'cost', 'revenue', 'cube', 'pieces', 'done_day_id',
207
+	 *                                      'possession_day_id', 'group', 'workflow_uuid', 'address_priority'
208
+	 *   string[] [addition]              - An array of additional returned fields, this is one of
209
+	 *                                      'territory_ids', 'aggregation_ids'
210
+	 *   array    [search]                - Search parameters.
211
+	 *     string   [query]               - The string to query to ElasticSearch. If set the `matches` and
212
+	 *                                      `terms` sections will be ignored.
213
+	 *     array    [matches]             - The object to query to ElasticSearch.
214
+	 *       array    [custom_data]       - Order custom data.
215
+	 *         string   [barcode]         - Tracking number for order.
216
+	 *         string   [airbillno]       - Additional tracking number for order.
217
+	 *         string   [sorted_on_date]  - Datetime String with "T" delimiter, ISO 8601.
218
+	 *         int      [sorted_on_utc]   - Timestamp only; replaced data in `sorted_on_date` property.
219
+	 *       string   [first_name]        - The first name.
220
+	 *       string   [last_name]         - The last name.
221
+	 *       string   [email]             - E-mail.
222
+	 *       string   [phone]             - The phone number.
223
+	 *       string   [address_1]         - The order Address line 1.
224
+	 *       string   [address_alias]     - Address alias.
225
+	 *       string   [address_zip]       - The zip code of the address.
226
+	 *     array    [terms]               - The object to query to ElasticSearch.
227
+	 *       array    [custom_data]       - Order custom data.
228
+	 *         string   [barcode]         - Tracking number for order.
229
+	 *         string   [airbillno]       - Additional tracking number for order.
230
+	 *         string   [sorted_on_date]  - Datetime String with "T" delimiter, ISO 8601.
231
+	 *         int      [sorted_on_utc]   - Timestamp only; replaced data in `sorted_on_date` property.
232
+	 *       string   [first_name]        - The first name.
233
+	 *       string   [last_name]         - The last name.
234
+	 *       string   [email]             - E-mail.
235
+	 *       string   [phone]             - The phone number.
236
+	 *       string   [address_1]         - The order Address line 1.
237
+	 *       string   [address_alias]     - Address alias.
238
+	 *       string   [address_zip]       - The zip code the address is located in.
239
+	 *   array    [filters]               - Filter parameters.
240
+	 *     string[] [order_ids]           - Array of included order ids, HEX-Strings.
241
+	 *     string[] [excluded_ids]        - Array of excluded order ids, HEX-Strings.
242
+	 *     string[] [tracking_numbers]    - Array of tracking number of orders.
243
+	 *     bool  [only_geocoded]
244
+	 *     int|string|array [updated_timestamp]  - Can be unix timestamp or ISO 8601 or array [
245
+	 *                                                 "start" => "timestamp or ISO 8601",
246
+	 *                                                 "end" => "timestamp or ISO 8601"
247
+	 *                                             ]
248
+	 *     int|string|array [created_timestamp]  - Can be unix timestamp or ISO 8601 or array [
249
+	 *                                                 "start" => "timestamp or ISO 8601",
250
+	 *                                                 "end" => "timestamp or ISO 8601"
251
+	 *                                             ]
252
+	 *     int|string|array [scheduled_for]        - Can be unix timestamp or ISO 8601 or array [
253
+	 *                                                 "start" => "timestamp or ISO 8601",
254
+	 *                                                 "end" => "timestamp or ISO 8601"
255
+	 *                                             ]
256
+	 *     bool  [only_unscheduled]
257
+	 *     int|string|array [day_added]            - Can be unix timestamp or ISO 8601 or array [
258
+	 *                                                 "start" => "timestamp or ISO 8601",
259
+	 *                                                 "end" => "timestamp or ISO 8601"
260
+	 *                                             ]
261
+	 *     int|string|array [sorted_on]            - Can be unix timestamp or ISO 8601 or array [
262
+	 *                                                 "start" => "timestamp or ISO 8601",
263
+	 *                                                 "end" => "timestamp or ISO 8601"
264
+	 *                                             ]
265
+	 *     string[] [address_stop_types]           - Array of stop type names, possible values
266
+	 *                                               'DELIVERY', 'PICKUP', 'BREAK', 'MEETUP',
267
+	 *                                               'SERVICE', 'VISIT' or 'DRIVEBY'.
268
+	 *     int[]    [last_statuses]                - Array of statuses.
269
+	 *     int[]    [territory_ids]                - Array of territory ids.
270
+	 *     string   [done_day]
271
+	 *     string   [possession_day]
272
+	 *     string[] [groups]
273
+	 *     string   [display= 'all']               - Filtering by the in_route_count field, is one of
274
+	 *                                               'routed', 'unrouted', 'all'
275
+	 * @return ResponseSearch
276
+	 * @throws Exception\ApiError
277
+	 */
278
+	public function search(?array $params = null) : ResponseSearch
279
+	{
280
+		$allBodyFields = ['order_ids', 'return_provided_fields_as_map', 'orderBy', 'limit',
281
+			'offset', 'fields', 'addition', 'search', 'filters'
282
+		];
283 283
 
284
-        $result = Route4Me::makeRequst([
285
-            'url' => Endpoint::ORDER,
286
-            'method' => 'POST',
287
-            'HTTPHEADER' => 'Content-Type: application/json',
288
-            'body' => ($params ? Route4Me::generateRequestParameters($allBodyFields, $params) : [])
289
-        ]);
284
+		$result = Route4Me::makeRequst([
285
+			'url' => Endpoint::ORDER,
286
+			'method' => 'POST',
287
+			'HTTPHEADER' => 'Content-Type: application/json',
288
+			'body' => ($params ? Route4Me::generateRequestParameters($allBodyFields, $params) : [])
289
+		]);
290 290
 
291
-        if (isset($result)) {
292
-            return new ResponseSearch($result);
293
-        }
294
-        return [];
295
-    }
291
+		if (isset($result)) {
292
+			return new ResponseSearch($result);
293
+		}
294
+		return [];
295
+	}
296 296
 
297
-    /**
298
-     * Update the batch of orders (asynchronous, by filters)
299
-     *
300
-     * @since 1.3.0
301
-     *
302
-     * @param  array    $params             - Batch update parameters.
303
-     *   array    data                      - Order values for batch update, look for more
304
-     *                                        information in create()
305
-     *   array    search                    - Search parameters for batch update,
306
-     *                                        look for more information in search()
307
-     *   array    filters                   - Filter parameters for batch update,
308
-     *                                        look for more information in search()
309
-     * @return bool
310
-     * @throws Exception\ApiError
311
-     */
312
-    public function batchUpdateByFilters(array $params) : bool
313
-    {
314
-        $allBodyFields = ['data', 'search', 'filters'];
297
+	/**
298
+	 * Update the batch of orders (asynchronous, by filters)
299
+	 *
300
+	 * @since 1.3.0
301
+	 *
302
+	 * @param  array    $params             - Batch update parameters.
303
+	 *   array    data                      - Order values for batch update, look for more
304
+	 *                                        information in create()
305
+	 *   array    search                    - Search parameters for batch update,
306
+	 *                                        look for more information in search()
307
+	 *   array    filters                   - Filter parameters for batch update,
308
+	 *                                        look for more information in search()
309
+	 * @return bool
310
+	 * @throws Exception\ApiError
311
+	 */
312
+	public function batchUpdateByFilters(array $params) : bool
313
+	{
314
+		$allBodyFields = ['data', 'search', 'filters'];
315 315
 
316
-        $res = Route4Me::makeRequst([
317
-            'url' => Endpoint::ORDER_BATCH_UPDATE_FILTER,
318
-            'method' => 'PUT',
319
-            'HTTPHEADER' => 'Content-Type: application/json',
320
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
321
-        ]);
322
-        return (isset($res['success']) && $res['success'] == 1 ? true : false);
323
-    }
316
+		$res = Route4Me::makeRequst([
317
+			'url' => Endpoint::ORDER_BATCH_UPDATE_FILTER,
318
+			'method' => 'PUT',
319
+			'HTTPHEADER' => 'Content-Type: application/json',
320
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
321
+		]);
322
+		return (isset($res['success']) && $res['success'] == 1 ? true : false);
323
+	}
324 324
 
325
-    /**
326
-     * Delete the batch of orders
327
-     *
328
-     * @since 1.3.0
329
-     *
330
-     * @param  string[] $orderIds           - Array of Order IDs, HEX-Strings.
331
-     * @return bool
332
-     * @throws Exception\ApiError
333
-     */
334
-    public function batchDelete(array $orderIds) : bool
335
-    {
336
-        $res = Route4Me::makeRequst([
337
-            'url' => Endpoint::ORDER_BATCH_DELETE,
338
-            'method' => 'POST',
339
-            'HTTPHEADER' => 'Content-Type: application/json',
340
-            'body' => ['order_ids' => $orderIds]
341
-        ]);
342
-        return (isset($res['status']) ? $res['status'] : false);
343
-    }
325
+	/**
326
+	 * Delete the batch of orders
327
+	 *
328
+	 * @since 1.3.0
329
+	 *
330
+	 * @param  string[] $orderIds           - Array of Order IDs, HEX-Strings.
331
+	 * @return bool
332
+	 * @throws Exception\ApiError
333
+	 */
334
+	public function batchDelete(array $orderIds) : bool
335
+	{
336
+		$res = Route4Me::makeRequst([
337
+			'url' => Endpoint::ORDER_BATCH_DELETE,
338
+			'method' => 'POST',
339
+			'HTTPHEADER' => 'Content-Type: application/json',
340
+			'body' => ['order_ids' => $orderIds]
341
+		]);
342
+		return (isset($res['status']) ? $res['status'] : false);
343
+	}
344 344
 
345
-    /**
346
-     * Update the batch of orders by ids
347
-     *
348
-     * @since 1.3.0
349
-     *
350
-     * @param  string[] $orderIds           - Array of Order IDs, HEX-Strings.
351
-     * @param  array    $data               - Order values for batch update,
352
-     *                                        look for more information in create()
353
-     * @return ResponseOrder[]
354
-     * @throws Exception\ApiError
355
-     */
356
-    public function batchUpdate(array $orderIds, $data) : array
357
-    {
358
-        $allBodyFields = ['member_id', 'address_1', 'address_2', 'address_alias',
359
-            'address_city', 'address_state', 'address_zip', 'address_country', 'address_geo', 'curbside_geo',
360
-            'date_scheduled_for', 'order_status_id', 'is_pending', 'is_accepted',
361
-            'is_started', 'is_completed', 'is_validated', 'phone', 'first_name',
362
-            'last_name', 'email', 'custom_data', 'local_time_windows', 'local_timezone_string',
363
-            'service_time', 'color', 'tracking_number', 'address_stop_type', 'last_status', 'weight',
364
-            'cost', 'revenue', 'cube', 'pieces', 'group', 'address_priority',
365
-            'address_customer_po', 'custom_fields'
366
-        ];
345
+	/**
346
+	 * Update the batch of orders by ids
347
+	 *
348
+	 * @since 1.3.0
349
+	 *
350
+	 * @param  string[] $orderIds           - Array of Order IDs, HEX-Strings.
351
+	 * @param  array    $data               - Order values for batch update,
352
+	 *                                        look for more information in create()
353
+	 * @return ResponseOrder[]
354
+	 * @throws Exception\ApiError
355
+	 */
356
+	public function batchUpdate(array $orderIds, $data) : array
357
+	{
358
+		$allBodyFields = ['member_id', 'address_1', 'address_2', 'address_alias',
359
+			'address_city', 'address_state', 'address_zip', 'address_country', 'address_geo', 'curbside_geo',
360
+			'date_scheduled_for', 'order_status_id', 'is_pending', 'is_accepted',
361
+			'is_started', 'is_completed', 'is_validated', 'phone', 'first_name',
362
+			'last_name', 'email', 'custom_data', 'local_time_windows', 'local_timezone_string',
363
+			'service_time', 'color', 'tracking_number', 'address_stop_type', 'last_status', 'weight',
364
+			'cost', 'revenue', 'cube', 'pieces', 'group', 'address_priority',
365
+			'address_customer_po', 'custom_fields'
366
+		];
367 367
 
368
-        $res = Route4Me::makeRequst([
369
-            'url' => Endpoint::ORDER_BATCH_UPDATE,
370
-            'method' => 'POST',
371
-            'HTTPHEADER' => 'Content-Type: application/json',
372
-            'body' => [
373
-                'order_ids' => $orderIds,
374
-                'data' => Route4Me::generateRequestParameters($allBodyFields, $data)
375
-            ]
376
-        ]);
368
+		$res = Route4Me::makeRequst([
369
+			'url' => Endpoint::ORDER_BATCH_UPDATE,
370
+			'method' => 'POST',
371
+			'HTTPHEADER' => 'Content-Type: application/json',
372
+			'body' => [
373
+				'order_ids' => $orderIds,
374
+				'data' => Route4Me::generateRequestParameters($allBodyFields, $data)
375
+			]
376
+		]);
377 377
 
378
-        $orders = [];
379
-        if (is_array($res)) {
380
-            foreach ($res as $key => $value) {
381
-                $orders[] = new ResponseOrder($value);
382
-            }
383
-        }
384
-        return $orders;
385
-    }
378
+		$orders = [];
379
+		if (is_array($res)) {
380
+			foreach ($res as $key => $value) {
381
+				$orders[] = new ResponseOrder($value);
382
+			}
383
+		}
384
+		return $orders;
385
+	}
386 386
 
387
-    /**
388
-     * Create the batch of orders
389
-     *
390
-     * @since 1.3.0
391
-     *
392
-     * @param  array    $orders             - Array of Orders or of array.
393
-     *                                        look for more information in create()
394
-     * @return bool
395
-     * @throws Exception\ApiError
396
-     */
397
-    public function batchCreate(array $orders) : bool
398
-    {
399
-        $allBodyFields = ['member_id', 'address_1', 'address_2', 'address_alias',
400
-            'address_city', 'address_state', 'address_zip', 'address_country', 'address_geo', 'curbside_geo',
401
-            'date_scheduled_for', 'order_status_id', 'is_pending', 'is_accepted',
402
-            'is_started', 'is_completed', 'is_validated', 'phone', 'first_name',
403
-            'last_name', 'email', 'custom_data', 'local_time_windows', 'local_timezone_string',
404
-            'service_time', 'color', 'tracking_number', 'address_stop_type', 'last_status', 'weight',
405
-            'cost', 'revenue', 'cube', 'pieces', 'group', 'address_priority',
406
-            'address_customer_po', 'custom_fields'
407
-        ];
387
+	/**
388
+	 * Create the batch of orders
389
+	 *
390
+	 * @since 1.3.0
391
+	 *
392
+	 * @param  array    $orders             - Array of Orders or of array.
393
+	 *                                        look for more information in create()
394
+	 * @return bool
395
+	 * @throws Exception\ApiError
396
+	 */
397
+	public function batchCreate(array $orders) : bool
398
+	{
399
+		$allBodyFields = ['member_id', 'address_1', 'address_2', 'address_alias',
400
+			'address_city', 'address_state', 'address_zip', 'address_country', 'address_geo', 'curbside_geo',
401
+			'date_scheduled_for', 'order_status_id', 'is_pending', 'is_accepted',
402
+			'is_started', 'is_completed', 'is_validated', 'phone', 'first_name',
403
+			'last_name', 'email', 'custom_data', 'local_time_windows', 'local_timezone_string',
404
+			'service_time', 'color', 'tracking_number', 'address_stop_type', 'last_status', 'weight',
405
+			'cost', 'revenue', 'cube', 'pieces', 'group', 'address_priority',
406
+			'address_customer_po', 'custom_fields'
407
+		];
408 408
 
409
-        $body = [];
410
-        foreach ($orders as $key => $order) {
411
-            $body[] = Route4Me::generateRequestParameters($allBodyFields, $order);
412
-        }
409
+		$body = [];
410
+		foreach ($orders as $key => $order) {
411
+			$body[] = Route4Me::generateRequestParameters($allBodyFields, $order);
412
+		}
413 413
 
414
-        $res = Route4Me::makeRequst([
415
-            'url' => Endpoint::ORDER_BATCH_CREATE,
416
-            'method' => 'POST',
417
-            'HTTPHEADER' => 'Content-Type: application/json',
418
-            'body' => ['data' => $body]
419
-        ]);
420
-        return (isset($res['status']) ? $res['status'] : false);
421
-    }
414
+		$res = Route4Me::makeRequst([
415
+			'url' => Endpoint::ORDER_BATCH_CREATE,
416
+			'method' => 'POST',
417
+			'HTTPHEADER' => 'Content-Type: application/json',
418
+			'body' => ['data' => $body]
419
+		]);
420
+		return (isset($res['status']) ? $res['status'] : false);
421
+	}
422 422
 
423
-    /**
424
-     * Get a list of Order Custom Fields
425
-     *
426
-     * @since 1.3.0
427
-     *
428
-     * @return CustomField[]
429
-     * @throws Exception\ApiError
430
-     */
431
-    public function getOrderCustomFields() : array
432
-    {
433
-        $res = Route4Me::makeRequst([
434
-            'url' => Endpoint::ORDER_CUSTOM_FIELDS,
435
-            'method' => 'GET'
436
-        ]);
437
-        if (isset($result) && isset($result['data']) && is_array($result['data']) && is_array($result['data'][0])) {
438
-            return new ResponseOrder($result['data'][0]);
439
-        }
440
-        $ocf = [];
441
-        if (isset($res) && isset($res['data']) && is_array($res['data'])) {
442
-            foreach ($res['data'] as $key => $value) {
443
-                $ocf[] = new CustomField($value);
444
-            }
445
-        }
446
-        return $ocf;
447
-    }
423
+	/**
424
+	 * Get a list of Order Custom Fields
425
+	 *
426
+	 * @since 1.3.0
427
+	 *
428
+	 * @return CustomField[]
429
+	 * @throws Exception\ApiError
430
+	 */
431
+	public function getOrderCustomFields() : array
432
+	{
433
+		$res = Route4Me::makeRequst([
434
+			'url' => Endpoint::ORDER_CUSTOM_FIELDS,
435
+			'method' => 'GET'
436
+		]);
437
+		if (isset($result) && isset($result['data']) && is_array($result['data']) && is_array($result['data'][0])) {
438
+			return new ResponseOrder($result['data'][0]);
439
+		}
440
+		$ocf = [];
441
+		if (isset($res) && isset($res['data']) && is_array($res['data'])) {
442
+			foreach ($res['data'] as $key => $value) {
443
+				$ocf[] = new CustomField($value);
444
+			}
445
+		}
446
+		return $ocf;
447
+	}
448 448
 
449
-    /**
450
-     * Create one Order Custom Field
451
-     *
452
-     * @since 1.3.0
453
-     *
454
-     * @param  array    $params_or_custom_field      - Params of CustomField custom field
455
-     *   string   data.order_custom_field_name       - Name, max 128 characters.
456
-     *   string   data.order_custom_field_type       - Type, max 128 characters.
457
-     *   string   data.order_custom_field_label      - Label, max 128 characters.
458
-     *   array    data.order_custom_field_type_info  - Info, as JSON Object max 4096 characters.
459
-     * @return CustomField
460
-     * @throws Exception\ApiError
461
-     */
462
-    public function createOrderCustomField($params_or_custom_field) : CustomField
463
-    {
464
-        $allBodyFields = ['order_custom_field_name', 'order_custom_field_type',
465
-            'order_custom_field_label', 'order_custom_field_type_info'];
449
+	/**
450
+	 * Create one Order Custom Field
451
+	 *
452
+	 * @since 1.3.0
453
+	 *
454
+	 * @param  array    $params_or_custom_field      - Params of CustomField custom field
455
+	 *   string   data.order_custom_field_name       - Name, max 128 characters.
456
+	 *   string   data.order_custom_field_type       - Type, max 128 characters.
457
+	 *   string   data.order_custom_field_label      - Label, max 128 characters.
458
+	 *   array    data.order_custom_field_type_info  - Info, as JSON Object max 4096 characters.
459
+	 * @return CustomField
460
+	 * @throws Exception\ApiError
461
+	 */
462
+	public function createOrderCustomField($params_or_custom_field) : CustomField
463
+	{
464
+		$allBodyFields = ['order_custom_field_name', 'order_custom_field_type',
465
+			'order_custom_field_label', 'order_custom_field_type_info'];
466 466
 
467
-        return $this->toCustomField(Route4Me::makeRequst([
468
-            'url' => Endpoint::ORDER_CUSTOM_FIELDS,
469
-            'method' => 'POST',
470
-            'HTTPHEADER' => 'Content-Type: application/json',
471
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params_or_custom_field)
472
-        ]));
473
-    }
467
+		return $this->toCustomField(Route4Me::makeRequst([
468
+			'url' => Endpoint::ORDER_CUSTOM_FIELDS,
469
+			'method' => 'POST',
470
+			'HTTPHEADER' => 'Content-Type: application/json',
471
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params_or_custom_field)
472
+		]));
473
+	}
474 474
 
475
-    /**
476
-     * Update one Order Custom Fields
477
-     *
478
-     * @since 1.3.0
479
-     *
480
-     * @param  array    $uuid                        - OrderCustomField ID, HEX-string.
481
-     * @param  array    $params_or_custom_field      - Params of Order custom field
482
-     *   string   data.order_custom_field_type       - Type, max 128 characters.
483
-     *   string   data.order_custom_field_label      - Label, max 128 characters.
484
-     *   array    data.order_custom_field_type_info  - Info, as JSON Object max 4096 characters.
485
-     * @return CustomField
486
-     * @throws Exception\ApiError
487
-     */
488
-    public function updateOrderCustomField(string $uuid, $params_or_custom_field) : CustomField
489
-    {
490
-        $allBodyFields = ['order_custom_field_type', 'order_custom_field_label', 'order_custom_field_type_info'];
475
+	/**
476
+	 * Update one Order Custom Fields
477
+	 *
478
+	 * @since 1.3.0
479
+	 *
480
+	 * @param  array    $uuid                        - OrderCustomField ID, HEX-string.
481
+	 * @param  array    $params_or_custom_field      - Params of Order custom field
482
+	 *   string   data.order_custom_field_type       - Type, max 128 characters.
483
+	 *   string   data.order_custom_field_label      - Label, max 128 characters.
484
+	 *   array    data.order_custom_field_type_info  - Info, as JSON Object max 4096 characters.
485
+	 * @return CustomField
486
+	 * @throws Exception\ApiError
487
+	 */
488
+	public function updateOrderCustomField(string $uuid, $params_or_custom_field) : CustomField
489
+	{
490
+		$allBodyFields = ['order_custom_field_type', 'order_custom_field_label', 'order_custom_field_type_info'];
491 491
 
492
-        return $this->toCustomField(Route4Me::makeRequst([
493
-            'url' => Endpoint::ORDER_CUSTOM_FIELDS . '/' . $uuid,
494
-            'method' => 'PUT',
495
-            'HTTPHEADER' => 'Content-Type: application/json',
496
-            'body' => Route4Me::generateRequestParameters($allBodyFields, $params_or_custom_field)
497
-        ]));
498
-    }
492
+		return $this->toCustomField(Route4Me::makeRequst([
493
+			'url' => Endpoint::ORDER_CUSTOM_FIELDS . '/' . $uuid,
494
+			'method' => 'PUT',
495
+			'HTTPHEADER' => 'Content-Type: application/json',
496
+			'body' => Route4Me::generateRequestParameters($allBodyFields, $params_or_custom_field)
497
+		]));
498
+	}
499 499
 
500
-    /**
501
-     * Delete an Order Custom Fields
502
-     *
503
-     * @since 1.3.0
504
-     *
505
-     * @param  array    $uuid                        - OrderCustomField ID, HEX-string.
506
-     * @return CustomField
507
-     * @throws Exception\ApiError
508
-     */
509
-    public function deleteOrderCustomField(string $uuid) : CustomField
510
-    {
511
-        return $this->toCustomField(Route4Me::makeRequst([
512
-            'url' => Endpoint::ORDER_CUSTOM_FIELDS . '/' . $uuid,
513
-            'method' => 'DELETE'
514
-        ]));
515
-    }
500
+	/**
501
+	 * Delete an Order Custom Fields
502
+	 *
503
+	 * @since 1.3.0
504
+	 *
505
+	 * @param  array    $uuid                        - OrderCustomField ID, HEX-string.
506
+	 * @return CustomField
507
+	 * @throws Exception\ApiError
508
+	 */
509
+	public function deleteOrderCustomField(string $uuid) : CustomField
510
+	{
511
+		return $this->toCustomField(Route4Me::makeRequst([
512
+			'url' => Endpoint::ORDER_CUSTOM_FIELDS . '/' . $uuid,
513
+			'method' => 'DELETE'
514
+		]));
515
+	}
516 516
 
517
-    private function toResponseOrder($result) : ResponseOrder
518
-    {
519
-        if (is_array($result)) {
520
-            return new ResponseOrder($result);
521
-        }
522
-        throw new ApiError('Can not convert result to ResponseOrder object.');
523
-    }
517
+	private function toResponseOrder($result) : ResponseOrder
518
+	{
519
+		if (is_array($result)) {
520
+			return new ResponseOrder($result);
521
+		}
522
+		throw new ApiError('Can not convert result to ResponseOrder object.');
523
+	}
524 524
 
525
-    private function toCustomField($result) : CustomField
526
-    {
527
-        if (isset($result) && isset($result['data']) && is_array($result['data'])) {
528
-            return new CustomField($result['data']);
529
-        }
530
-        throw new ApiError('Can not convert result to CustomField object.');
531
-    }
525
+	private function toCustomField($result) : CustomField
526
+	{
527
+		if (isset($result) && isset($result['data']) && is_array($result['data'])) {
528
+			return new CustomField($result['data']);
529
+		}
530
+		throw new ApiError('Can not convert result to CustomField object.');
531
+	}
532 532
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     public function get(string $order_id) : ResponseOrder
122 122
     {
123 123
         return $this->toResponseOrder(Route4Me::makeRequst([
124
-            'url' => Endpoint::ORDER . '/' . $order_id,
124
+            'url' => Endpoint::ORDER.'/'.$order_id,
125 125
             'method' => 'GET'
126 126
         ]));
127 127
     }
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
         ];
151 151
 
152 152
         return $this->toResponseOrder(Route4Me::makeRequst([
153
-            'url' => Endpoint::ORDER . '/' . $order_id,
153
+            'url' => Endpoint::ORDER.'/'.$order_id,
154 154
             'method' => 'PUT',
155 155
             'HTTPHEADER' => 'Content-Type: application/json',
156 156
             'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     public function delete(string $order_id) : bool
170 170
     {
171 171
         $res = Route4Me::makeRequst([
172
-            'url' => Endpoint::ORDER . '/' . $order_id,
172
+            'url' => Endpoint::ORDER.'/'.$order_id,
173 173
             'method' => 'DELETE'
174 174
         ]);
175 175
         return (isset($res['status']) ? $res['status'] : false);
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             'HTTPHEADER' => 'Content-Type: application/json',
320 320
             'body' => Route4Me::generateRequestParameters($allBodyFields, $params)
321 321
         ]);
322
-        return (isset($res['success']) && $res['success'] == 1 ? true : false);
322
+        return (isset($res['success']) && $res['success']==1 ? true : false);
323 323
     }
324 324
 
325 325
     /**
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
         $allBodyFields = ['order_custom_field_type', 'order_custom_field_label', 'order_custom_field_type_info'];
491 491
 
492 492
         return $this->toCustomField(Route4Me::makeRequst([
493
-            'url' => Endpoint::ORDER_CUSTOM_FIELDS . '/' . $uuid,
493
+            'url' => Endpoint::ORDER_CUSTOM_FIELDS.'/'.$uuid,
494 494
             'method' => 'PUT',
495 495
             'HTTPHEADER' => 'Content-Type: application/json',
496 496
             'body' => Route4Me::generateRequestParameters($allBodyFields, $params_or_custom_field)
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
     public function deleteOrderCustomField(string $uuid) : CustomField
510 510
     {
511 511
         return $this->toCustomField(Route4Me::makeRequst([
512
-            'url' => Endpoint::ORDER_CUSTOM_FIELDS . '/' . $uuid,
512
+            'url' => Endpoint::ORDER_CUSTOM_FIELDS.'/'.$uuid,
513 513
             'method' => 'DELETE'
514 514
         ]));
515 515
     }
Please login to merge, or discard this patch.
src/Route4Me/V5/Orders/ResponseOrder.php 2 patches
Indentation   +289 added lines, -289 removed lines patch added patch discarded remove patch
@@ -17,293 +17,293 @@
 block discarded – undo
17 17
  */
18 18
 class ResponseOrder extends Common
19 19
 {
20
-    /**
21
-     * Order ID, HEX-string.
22
-     */
23
-    public ?string $order_id = null;
24
-
25
-    /**
26
-     * Order UUID, HEX-string.
27
-     */
28
-    public ?string $order_uuid = null;
29
-
30
-    /**
31
-     * A unique ID of the owner member.
32
-     */
33
-    public ?int $member_id = null;
34
-
35
-    /**
36
-     * A unique ID of the root member.
37
-     */
38
-    public ?int $root_member_id = null;
39
-
40
-    /**
41
-     * A unique ID of the organization.
42
-     */
43
-    public ?int $organization_id = null;
44
-
45
-    /**
46
-     * Order status ID.
47
-     */
48
-    public ?int $order_status_id = null;
49
-
50
-    public ?int $done_day_id = null;
51
-    public ?int $possession_day_id = null;
52
-
53
-    /**
54
-     * When the order created, unix timestamp.
55
-     */
56
-    public ?int $created_timestamp = null;
57
-
58
-    /**
59
-     * When the order updated, unix timestamp.
60
-     */
61
-    public ?int $updated_timestamp = null;
62
-
63
-    /**
64
-     * When the order created, formatted string: 'YYYY-MM-DD'.
65
-     */
66
-    public ?string $day_added_YYMMDD = null;
67
-
68
-    /**
69
-     * Scheduled order day, formatted string: "YYYY-MM-DD".
70
-     */
71
-    public ?string $day_scheduled_for_YYMMDD = null;
72
-
73
-    /**
74
-     * Address alias.
75
-     */
76
-    public ?string $address_alias = null;
77
-
78
-    /**
79
-     * The order Address line 1.
80
-     */
81
-    public ?string $address_1 = null;
82
-
83
-    /**
84
-     * The order Address line 2.
85
-     */
86
-    public ?string $address_2 = null;
87
-
88
-    /**
89
-     * The city the address is located in.
90
-     */
91
-    public ?string $address_city = null;
92
-
93
-    /**
94
-     * The state the address is located in.
95
-     */
96
-    public ?string $address_state = null;
97
-
98
-    /**
99
-     * The country the address is located in.
100
-     */
101
-    public ?string $address_country = null;
102
-
103
-    /**
104
-     * The zip code the address is located in.
105
-     */
106
-    public ?string $address_zip = null;
107
-
108
-    /**
109
-     * Priority of address
110
-     * 0 is the highest priority, n has higher priority than n + 1
111
-     */
112
-    public ?int $address_priority = null;
113
-
114
-    /**
115
-     * Order custom data.
116
-     */
117
-    public ?CustomData $custom_data = null;
118
-
119
-    /**
120
-     * The customer purchase order for the address, length <= 50.
121
-     */
122
-    public ?string $customer_po = null;
123
-
124
-    /**
125
-     * The first name.
126
-     */
127
-    public ?string $first_name = null;
128
-
129
-    /**
130
-     * The last name.
131
-     */
132
-    public ?string $last_name = null;
133
-
134
-    /**
135
-     * E-mail.
136
-     */
137
-    public ?string $email = null;
138
-
139
-    /**
140
-     * The phone number.
141
-     */
142
-    public ?string $phone = null;
143
-
144
-    /**
145
-     * Weight of the cargo.
146
-     */
147
-    public ?float $weight = null;
148
-
149
-    /**
150
-     * Cost of the cargo.
151
-     */
152
-    public ?float $cost = null;
153
-
154
-    /**
155
-     * The total revenue for the order.
156
-     */
157
-    public ?float $revenue = null;
158
-
159
-    /**
160
-     * The cubic volume of the cargo.
161
-     */
162
-    public ?float $cube = null;
163
-
164
-    /**
165
-     *The item quantity of the cargo.
166
-     */
167
-    public ?float $pieces = null;
168
-
169
-    public ?int $visited_count = null;
170
-    public ?int $in_route_count = null;
171
-    public ?int $last_visited_timestamp = null;
172
-    public ?int $last_routed_timestamp = null;
173
-
174
-    /**
175
-     * Array of Time Window objects.
176
-     */
177
-    public ?array $local_time_windows = null;
178
-
179
-    /**
180
-     * Consumed service time.
181
-     */
182
-    public ?int $service_time = null;
183
-
184
-    /**
185
-     * Local timezone String.
186
-     */
187
-    public ?string $local_timezone_string = null;
188
-
189
-    /**
190
-     * Color of an address, e.g., 'FF0000'.
191
-     */
192
-    public ?string $color = null;
193
-
194
-    /**
195
-     * Icon of an address.
196
-     */
197
-    public ?string $icon = null;
198
-
199
-    /**
200
-     * If true, the order is validated.
201
-     */
202
-    public ?bool $is_validated = null;
203
-
204
-    /**
205
-     * If true, the order is pending.
206
-     */
207
-    public ?bool $is_pending = null;
208
-
209
-    /**
210
-     * If true, the order is accepted.
211
-     */
212
-    public ?bool $is_accepted = null;
213
-
214
-    /**
215
-     * If true, the order is started.
216
-     */
217
-    public ?bool $is_started = null;
218
-
219
-    /**
220
-     * If true, the order is completed.
221
-     */
222
-    public ?bool $is_completed = null;
223
-
224
-    /**
225
-     * Tracking number
226
-     */
227
-    public ?string $tracking_number = null;
228
-
229
-    /**
230
-     * The address type of stop, this is one of 'DELIVERY', 'PICKUP',
231
-     * 'BREAK', 'MEETUP', 'SERVICE', 'VISIT' or 'DRIVEBY'.
232
-     */
233
-    public ?string $address_stop_type = null;
234
-
235
-    /**
236
-     * Last known status
237
-     */
238
-    public ?int $last_status = null;
239
-
240
-    /**
241
-     * Datetime string with "T" delimiter, ISO 8601.
242
-     */
243
-    public ?int $sorted_on_date = null;
244
-
245
-    /**
246
-     * The group.
247
-     */
248
-    public ?string $group = null;
249
-
250
-    public ?string $workflow_uuid = null;
251
-
252
-    /**
253
-     * Array of Custom Fields objects.
254
-     */
255
-    public ?array $custom_user_fields = null;
256
-
257
-    /**
258
-     * GPS coords of address.
259
-     */
260
-    public ?GPSCoords $address_geo = null;
261
-
262
-    /**
263
-     * Curbside GPS coords of address.
264
-     */
265
-    public ?GPSCoords $curbside_geo = null;
266
-
267
-    public function __construct(array $params = null)
268
-    {
269
-        if ($params !== null) {
270
-            foreach ($this as $key => $value) {
271
-                if (isset($params[$key])) {
272
-                    if ($key === 'local_time_windows') {
273
-                        $this->{$key} = array();
274
-                        foreach ($params[$key] as $ltw_key => $ltw_value) {
275
-                            if (is_array($ltw_value)) {
276
-                                array_push($this->{$key}, new LocalTimeWindow($ltw_value));
277
-                            } elseif (is_object($ltw_value) && $ltw_value instanceof LocalTimeWindow) {
278
-                                array_push($this->{$key}, $ltw_value);
279
-                            }
280
-                        }
281
-                    } elseif ($key === 'custom_user_fields') {
282
-                        $this->{$key} = array();
283
-                        foreach ($params[$key] as $cf_key => $cf_value) {
284
-                            if (is_array($cf_value)) {
285
-                                array_push($this->{$key}, new CustomField($cf_value));
286
-                            } elseif (is_object($cf_value) && $cf_value instanceof CustomField) {
287
-                                array_push($this->{$key}, $cf_value);
288
-                            }
289
-                        }
290
-                    } elseif ($key === 'address_geo' || $key === 'curbside_geo') {
291
-                        if (is_array($params[$key])) {
292
-                            $this->{$key} = new GPSCoords($params[$key]);
293
-                        } elseif (is_object($params[$key]) && $params[$key] instanceof GPSCoords) {
294
-                            $this->{$key} = $params[$key];
295
-                        }
296
-                    } elseif ($key === 'custom_data') {
297
-                        if (is_array($params[$key])) {
298
-                            $this->{$key} = new CustomData($params[$key]);
299
-                        } elseif (is_object($params[$key]) && $params[$key] instanceof CustomData) {
300
-                            $this->{$key} = $params[$key];
301
-                        }
302
-                    } else {
303
-                        $this->{$key} = $params[$key];
304
-                    }
305
-                }
306
-            }
307
-        }
308
-    }
20
+	/**
21
+	 * Order ID, HEX-string.
22
+	 */
23
+	public ?string $order_id = null;
24
+
25
+	/**
26
+	 * Order UUID, HEX-string.
27
+	 */
28
+	public ?string $order_uuid = null;
29
+
30
+	/**
31
+	 * A unique ID of the owner member.
32
+	 */
33
+	public ?int $member_id = null;
34
+
35
+	/**
36
+	 * A unique ID of the root member.
37
+	 */
38
+	public ?int $root_member_id = null;
39
+
40
+	/**
41
+	 * A unique ID of the organization.
42
+	 */
43
+	public ?int $organization_id = null;
44
+
45
+	/**
46
+	 * Order status ID.
47
+	 */
48
+	public ?int $order_status_id = null;
49
+
50
+	public ?int $done_day_id = null;
51
+	public ?int $possession_day_id = null;
52
+
53
+	/**
54
+	 * When the order created, unix timestamp.
55
+	 */
56
+	public ?int $created_timestamp = null;
57
+
58
+	/**
59
+	 * When the order updated, unix timestamp.
60
+	 */
61
+	public ?int $updated_timestamp = null;
62
+
63
+	/**
64
+	 * When the order created, formatted string: 'YYYY-MM-DD'.
65
+	 */
66
+	public ?string $day_added_YYMMDD = null;
67
+
68
+	/**
69
+	 * Scheduled order day, formatted string: "YYYY-MM-DD".
70
+	 */
71
+	public ?string $day_scheduled_for_YYMMDD = null;
72
+
73
+	/**
74
+	 * Address alias.
75
+	 */
76
+	public ?string $address_alias = null;
77
+
78
+	/**
79
+	 * The order Address line 1.
80
+	 */
81
+	public ?string $address_1 = null;
82
+
83
+	/**
84
+	 * The order Address line 2.
85
+	 */
86
+	public ?string $address_2 = null;
87
+
88
+	/**
89
+	 * The city the address is located in.
90
+	 */
91
+	public ?string $address_city = null;
92
+
93
+	/**
94
+	 * The state the address is located in.
95
+	 */
96
+	public ?string $address_state = null;
97
+
98
+	/**
99
+	 * The country the address is located in.
100
+	 */
101
+	public ?string $address_country = null;
102
+
103
+	/**
104
+	 * The zip code the address is located in.
105
+	 */
106
+	public ?string $address_zip = null;
107
+
108
+	/**
109
+	 * Priority of address
110
+	 * 0 is the highest priority, n has higher priority than n + 1
111
+	 */
112
+	public ?int $address_priority = null;
113
+
114
+	/**
115
+	 * Order custom data.
116
+	 */
117
+	public ?CustomData $custom_data = null;
118
+
119
+	/**
120
+	 * The customer purchase order for the address, length <= 50.
121
+	 */
122
+	public ?string $customer_po = null;
123
+
124
+	/**
125
+	 * The first name.
126
+	 */
127
+	public ?string $first_name = null;
128
+
129
+	/**
130
+	 * The last name.
131
+	 */
132
+	public ?string $last_name = null;
133
+
134
+	/**
135
+	 * E-mail.
136
+	 */
137
+	public ?string $email = null;
138
+
139
+	/**
140
+	 * The phone number.
141
+	 */
142
+	public ?string $phone = null;
143
+
144
+	/**
145
+	 * Weight of the cargo.
146
+	 */
147
+	public ?float $weight = null;
148
+
149
+	/**
150
+	 * Cost of the cargo.
151
+	 */
152
+	public ?float $cost = null;
153
+
154
+	/**
155
+	 * The total revenue for the order.
156
+	 */
157
+	public ?float $revenue = null;
158
+
159
+	/**
160
+	 * The cubic volume of the cargo.
161
+	 */
162
+	public ?float $cube = null;
163
+
164
+	/**
165
+	 *The item quantity of the cargo.
166
+	 */
167
+	public ?float $pieces = null;
168
+
169
+	public ?int $visited_count = null;
170
+	public ?int $in_route_count = null;
171
+	public ?int $last_visited_timestamp = null;
172
+	public ?int $last_routed_timestamp = null;
173
+
174
+	/**
175
+	 * Array of Time Window objects.
176
+	 */
177
+	public ?array $local_time_windows = null;
178
+
179
+	/**
180
+	 * Consumed service time.
181
+	 */
182
+	public ?int $service_time = null;
183
+
184
+	/**
185
+	 * Local timezone String.
186
+	 */
187
+	public ?string $local_timezone_string = null;
188
+
189
+	/**
190
+	 * Color of an address, e.g., 'FF0000'.
191
+	 */
192
+	public ?string $color = null;
193
+
194
+	/**
195
+	 * Icon of an address.
196
+	 */
197
+	public ?string $icon = null;
198
+
199
+	/**
200
+	 * If true, the order is validated.
201
+	 */
202
+	public ?bool $is_validated = null;
203
+
204
+	/**
205
+	 * If true, the order is pending.
206
+	 */
207
+	public ?bool $is_pending = null;
208
+
209
+	/**
210
+	 * If true, the order is accepted.
211
+	 */
212
+	public ?bool $is_accepted = null;
213
+
214
+	/**
215
+	 * If true, the order is started.
216
+	 */
217
+	public ?bool $is_started = null;
218
+
219
+	/**
220
+	 * If true, the order is completed.
221
+	 */
222
+	public ?bool $is_completed = null;
223
+
224
+	/**
225
+	 * Tracking number
226
+	 */
227
+	public ?string $tracking_number = null;
228
+
229
+	/**
230
+	 * The address type of stop, this is one of 'DELIVERY', 'PICKUP',
231
+	 * 'BREAK', 'MEETUP', 'SERVICE', 'VISIT' or 'DRIVEBY'.
232
+	 */
233
+	public ?string $address_stop_type = null;
234
+
235
+	/**
236
+	 * Last known status
237
+	 */
238
+	public ?int $last_status = null;
239
+
240
+	/**
241
+	 * Datetime string with "T" delimiter, ISO 8601.
242
+	 */
243
+	public ?int $sorted_on_date = null;
244
+
245
+	/**
246
+	 * The group.
247
+	 */
248
+	public ?string $group = null;
249
+
250
+	public ?string $workflow_uuid = null;
251
+
252
+	/**
253
+	 * Array of Custom Fields objects.
254
+	 */
255
+	public ?array $custom_user_fields = null;
256
+
257
+	/**
258
+	 * GPS coords of address.
259
+	 */
260
+	public ?GPSCoords $address_geo = null;
261
+
262
+	/**
263
+	 * Curbside GPS coords of address.
264
+	 */
265
+	public ?GPSCoords $curbside_geo = null;
266
+
267
+	public function __construct(array $params = null)
268
+	{
269
+		if ($params !== null) {
270
+			foreach ($this as $key => $value) {
271
+				if (isset($params[$key])) {
272
+					if ($key === 'local_time_windows') {
273
+						$this->{$key} = array();
274
+						foreach ($params[$key] as $ltw_key => $ltw_value) {
275
+							if (is_array($ltw_value)) {
276
+								array_push($this->{$key}, new LocalTimeWindow($ltw_value));
277
+							} elseif (is_object($ltw_value) && $ltw_value instanceof LocalTimeWindow) {
278
+								array_push($this->{$key}, $ltw_value);
279
+							}
280
+						}
281
+					} elseif ($key === 'custom_user_fields') {
282
+						$this->{$key} = array();
283
+						foreach ($params[$key] as $cf_key => $cf_value) {
284
+							if (is_array($cf_value)) {
285
+								array_push($this->{$key}, new CustomField($cf_value));
286
+							} elseif (is_object($cf_value) && $cf_value instanceof CustomField) {
287
+								array_push($this->{$key}, $cf_value);
288
+							}
289
+						}
290
+					} elseif ($key === 'address_geo' || $key === 'curbside_geo') {
291
+						if (is_array($params[$key])) {
292
+							$this->{$key} = new GPSCoords($params[$key]);
293
+						} elseif (is_object($params[$key]) && $params[$key] instanceof GPSCoords) {
294
+							$this->{$key} = $params[$key];
295
+						}
296
+					} elseif ($key === 'custom_data') {
297
+						if (is_array($params[$key])) {
298
+							$this->{$key} = new CustomData($params[$key]);
299
+						} elseif (is_object($params[$key]) && $params[$key] instanceof CustomData) {
300
+							$this->{$key} = $params[$key];
301
+						}
302
+					} else {
303
+						$this->{$key} = $params[$key];
304
+					}
305
+				}
306
+			}
307
+		}
308
+	}
309 309
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -266,10 +266,10 @@  discard block
 block discarded – undo
266 266
 
267 267
     public function __construct(array $params = null)
268 268
     {
269
-        if ($params !== null) {
269
+        if ($params!==null) {
270 270
             foreach ($this as $key => $value) {
271 271
                 if (isset($params[$key])) {
272
-                    if ($key === 'local_time_windows') {
272
+                    if ($key==='local_time_windows') {
273 273
                         $this->{$key} = array();
274 274
                         foreach ($params[$key] as $ltw_key => $ltw_value) {
275 275
                             if (is_array($ltw_value)) {
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
                                 array_push($this->{$key}, $ltw_value);
279 279
                             }
280 280
                         }
281
-                    } elseif ($key === 'custom_user_fields') {
281
+                    } elseif ($key==='custom_user_fields') {
282 282
                         $this->{$key} = array();
283 283
                         foreach ($params[$key] as $cf_key => $cf_value) {
284 284
                             if (is_array($cf_value)) {
@@ -287,13 +287,13 @@  discard block
 block discarded – undo
287 287
                                 array_push($this->{$key}, $cf_value);
288 288
                             }
289 289
                         }
290
-                    } elseif ($key === 'address_geo' || $key === 'curbside_geo') {
290
+                    } elseif ($key==='address_geo' || $key==='curbside_geo') {
291 291
                         if (is_array($params[$key])) {
292 292
                             $this->{$key} = new GPSCoords($params[$key]);
293 293
                         } elseif (is_object($params[$key]) && $params[$key] instanceof GPSCoords) {
294 294
                             $this->{$key} = $params[$key];
295 295
                         }
296
-                    } elseif ($key === 'custom_data') {
296
+                    } elseif ($key==='custom_data') {
297 297
                         if (is_array($params[$key])) {
298 298
                             $this->{$key} = new CustomData($params[$key]);
299 299
                         } elseif (is_object($params[$key]) && $params[$key] instanceof CustomData) {
Please login to merge, or discard this patch.