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 ( 6c805f...bce16d )
by Igor
09:12 queued 14s
created
src/Route4Me/RapidAddressSearchResponse.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,20 +6,20 @@
 block discarded – undo
6 6
 
7 7
 class RapidAddressSearchResponse
8 8
 {
9
-    public $zipcode;
10
-    public $street_name;
11
-    public $county_no;
9
+	public $zipcode;
10
+	public $street_name;
11
+	public $county_no;
12 12
 
13
-    public static function fromArray(array $params)
14
-    {
15
-        $rapidSearch = new self();
13
+	public static function fromArray(array $params)
14
+	{
15
+		$rapidSearch = new self();
16 16
 
17
-        foreach ($params as $key => $value) {
18
-            if (property_exists($rapidSearch, $key)) {
19
-                $rapidSearch->{$key} = $value;
20
-            }
21
-        }
17
+		foreach ($params as $key => $value) {
18
+			if (property_exists($rapidSearch, $key)) {
19
+				$rapidSearch->{$key} = $value;
20
+			}
21
+		}
22 22
 
23
-        return $rapidSearch;
24
-    }
23
+		return $rapidSearch;
24
+	}
25 25
 }
Please login to merge, or discard this patch.
src/Route4Me/Route4Me.php 3 patches
Indentation   +287 added lines, -287 removed lines patch added patch discarded remove patch
@@ -7,291 +7,291 @@
 block discarded – undo
7 7
 
8 8
 class Route4Me
9 9
 {
10
-    public static $apiKey;
11
-    public static $baseUrl = Endpoint::BASE_URL;
12
-
13
-    public static function setApiKey($apiKey)
14
-    {
15
-        self::$apiKey = $apiKey;
16
-    }
17
-
18
-    public static function getApiKey()
19
-    {
20
-        return self::$apiKey;
21
-    }
22
-
23
-    public static function setBaseUrl($baseUrl)
24
-    {
25
-        self::$baseUrl = $baseUrl;
26
-    }
27
-
28
-    public static function getBaseUrl()
29
-    {
30
-        return self::$baseUrl;
31
-    }
32
-
33
-    public static function makeRequst($options)
34
-    {
35
-        $method = isset($options['method']) ? $options['method'] : 'GET';
36
-        $query = isset($options['query']) ? array_filter($options['query'], function ($x) { return !is_null($x); }) : [];
37
-
38
-        $body = isset($options['body']) ? $options['body'] : null;
39
-        $file = isset($options['FILE']) ? $options['FILE'] : null;
40
-        $headers = [
41
-            'User-Agent: Route4Me php-sdk',
42
-        ];
43
-
44
-        if (isset($options['HTTPHEADER'])) {
45
-            $headers[] = $options['HTTPHEADER'];
46
-        }
47
-
48
-        if (isset($options['HTTPHEADERS'])) {
49
-            foreach ($options['HTTPHEADERS'] as $header) {
50
-                $headers[] = $header;
51
-            }
52
-        }
53
-
54
-        $ch = curl_init();
55
-
56
-        $url = isset($options['url']) ? $options['url'].'?'.http_build_query(array_merge(
57
-            $query, ['api_key' => self::getApiKey()]
58
-        )) : '';
59
-
60
-        $baseUrl = self::getBaseUrl();
61
-
62
-        $curlOpts = [
63
-            CURLOPT_URL             => $baseUrl.$url,
64
-            CURLOPT_RETURNTRANSFER  => true,
65
-            CURLOPT_TIMEOUT         => 120,
66
-            CURLOPT_FOLLOWLOCATION  => true,
67
-            CURLOPT_SSL_VERIFYHOST  => false,
68
-            CURLOPT_SSL_VERIFYPEER  => false,
69
-            CURLOPT_HTTPHEADER      => $headers,
70
-        ];
71
-
72
-        curl_setopt_array($ch, $curlOpts);
73
-
74
-        if (null != $file) {
75
-            $cfile = new \CURLFile($file,'','');
76
-            $body['strFilename']=$cfile;
77
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
78
-            curl_setopt($ch, CURLOPT_POST,true);
79
-            curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
80
-        } else {
81
-            switch ($method) {
82
-                case 'DELETE':
83
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
84
-                    break;
85
-                case 'DELETEARRAY':
86
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
87
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
88
-                    break;
89
-                case 'PUT':
90
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
91
-                    break;
92
-                case 'POST':
93
-                    if (isset($body)) {
94
-                        $bodyData = json_encode($body);
95
-                        if (isset($options['HTTPHEADER'])) {
96
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
97
-                                $bodyData = $body;
98
-                            }
99
-                        }
100
-
101
-                        curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
102
-                    }
103
-                    break;
104
-                case 'ADD':
105
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
106
-            }
107
-
108
-            if (is_numeric(array_search($method, ['DELETE', 'PUT']))) {
109
-                if (isset($body)) {
110
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
111
-                }
112
-            }
113
-        }
114
-
115
-        $result = curl_exec($ch);
116
-
117
-        $isxml = false;
118
-        $jxml = '';
119
-        if (strpos($result, '<?xml') > -1) {
120
-            $xml = simplexml_load_string($result);
121
-            //$jxml = json_encode($xml);
122
-            $jxml = self::object2array($xml);
123
-            $isxml = true;
124
-        }
125
-
126
-        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
127
-        curl_close($ch);
128
-
129
-        if (200 == $code) {
130
-            if ($isxml) {
131
-                $json = $jxml;
132
-            } else {
133
-                $json = json_decode($result, true);
134
-            }
135
-
136
-            if (isset($json['errors'])) {
137
-                throw new ApiError(implode(', ', $json['errors']));
138
-            } else {
139
-                return $json;
140
-            }
141
-        } elseif (409 == $code) {
142
-            throw new ApiError('Wrong API key');
143
-        } else {
144
-            throw new ApiError('Something wrong');
145
-        }
146
-    }
147
-
148
-    /**
149
-     * @param $object: JSON object
150
-     */
151
-    public static function object2array($object)
152
-    {
153
-        return @json_decode(@json_encode($object), 1);
154
-    }
155
-
156
-    /**
157
-     * Prints on the screen main keys and values of the array.
158
-     *
159
-     * @param $results: object to be printed on the screen
160
-     * @param $deepPrinting: if true, object will be printed recursively
161
-     */
162
-    public static function simplePrint($results, $deepPrinting = null)
163
-    {
164
-        if (isset($results)) {
165
-            if (is_array($results)) {
166
-                foreach ($results as $key => $result) {
167
-                    if (is_array($result)) {
168
-                        foreach ($result as $key1 => $result1) {
169
-                            if (is_array($result1)) {
170
-                                if ($deepPrinting) {
171
-                                    echo "<br>$key1 ------><br>";
172
-                                    self::simplePrint($result1, true);
173
-                                    echo '------<br>';
174
-                                } else {
175
-                                    echo $key1.' --> '.'Array() <br>';
176
-                                }
177
-                            } else {
178
-                                if (is_object($result1)) {
179
-                                    if ($deepPrinting) {
180
-                                        echo "<br>$key1 ------><br>";
181
-                                        $oarray = (array) $result1;
182
-                                        self::simplePrint($oarray, true);
183
-                                        echo '------<br>';
184
-                                    } else {
185
-                                        echo $key1.' --> '.'Object <br>';
186
-                                    }
187
-                                } else {
188
-                                    if (!is_null($result1)) {
189
-                                        echo $key1.' --> '.$result1.'<br>';
190
-                                    }
191
-                                }
192
-                            }
193
-                        }
194
-                    } else {
195
-                        if (is_object($result)) {
196
-                            if ($deepPrinting) {
197
-                                echo "<br>$key ------><br>";
198
-                                $oarray = (array) $result;
199
-                                self::simplePrint($oarray, true);
200
-                                echo '------<br>';
201
-                            } else {
202
-                                echo $key.' --> '.'Object <br>';
203
-                            }
204
-                        } else {
205
-                            if (!is_null($result)) {
206
-                                echo $key.' --> '.$result.'<br>';
207
-                            }
208
-                        }
209
-                    }
210
-                    //echo "<br>";
211
-                }
212
-            }
213
-        }
214
-    }
215
-
216
-    /**
217
-     * Generates query or body parameters.
218
-     *
219
-     * @param $allFields: all known fields could be used for parameters generation
220
-     * @param $params: input parameters (array or object)
221
-     */
222
-    public static function generateRequestParameters($allFields, $params)
223
-    {
224
-        $generatedParams = [];
225
-
226
-        if (is_array($params)) {
227
-            foreach ($allFields as $field) {
228
-                if (isset($params[$field])) {
229
-                    $generatedParams[$field] = $params[$field];
230
-                }
231
-            }
232
-        } elseif (is_object($params)) {
233
-            foreach ($allFields as $field) {
234
-                if (isset($params->{$field})) {
235
-                    $generatedParams[$field] = $params->{$field};
236
-                }
237
-            }
238
-        }
239
-
240
-        return $generatedParams;
241
-    }
242
-
243
-    /**
244
-     * Returns an array of the object properties.
245
-     *
246
-     * @param $object: An object
247
-     * @param $exclude: array of the object parameters to be excluded from the returned array
248
-     */
249
-    public static function getObjectProperties($object, $exclude)
250
-    {
251
-        $objectParameters = [];
252
-
253
-        foreach (get_object_vars($object) as $key => $value) {
254
-            if (property_exists($object, $key)) {
255
-                if (!is_numeric(array_search($key, $exclude))) {
256
-                    array_push($objectParameters, $key);
257
-                }
258
-            }
259
-        }
260
-
261
-        return $objectParameters;
262
-    }
263
-
264
-    /**
265
-     * Returns url path generated from the array of the fields and parameters.
266
-     *
267
-     * @param $allFields; array of the paossible fields (parameter names)
268
-     * @param $params: input parameters (array or object)
269
-     */
270
-    public static function generateUrlPath($allFields, $params)
271
-    {
272
-        $generatedPath = '';
273
-
274
-        if (is_array($params)) {
275
-            foreach ($allFields as $field) {
276
-                if (isset($params[$field])) {
277
-                    $generatedPath .= $params[$field].'/';
278
-                }
279
-            }
280
-        } elseif (is_object($params)) {
281
-            foreach ($allFields as $field) {
282
-                if (isset($params->{$field})) {
283
-                    $generatedPath .= $params->{$field}.'/';
284
-                }
285
-            }
286
-        }
287
-
288
-        return $generatedPath;
289
-    }
290
-
291
-    public static function getFileRealPath($fileName)
292
-    {
293
-        $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName);
294
-
295
-        return $rpath;
296
-    }
10
+	public static $apiKey;
11
+	public static $baseUrl = Endpoint::BASE_URL;
12
+
13
+	public static function setApiKey($apiKey)
14
+	{
15
+		self::$apiKey = $apiKey;
16
+	}
17
+
18
+	public static function getApiKey()
19
+	{
20
+		return self::$apiKey;
21
+	}
22
+
23
+	public static function setBaseUrl($baseUrl)
24
+	{
25
+		self::$baseUrl = $baseUrl;
26
+	}
27
+
28
+	public static function getBaseUrl()
29
+	{
30
+		return self::$baseUrl;
31
+	}
32
+
33
+	public static function makeRequst($options)
34
+	{
35
+		$method = isset($options['method']) ? $options['method'] : 'GET';
36
+		$query = isset($options['query']) ? array_filter($options['query'], function ($x) { return !is_null($x); }) : [];
37
+
38
+		$body = isset($options['body']) ? $options['body'] : null;
39
+		$file = isset($options['FILE']) ? $options['FILE'] : null;
40
+		$headers = [
41
+			'User-Agent: Route4Me php-sdk',
42
+		];
43
+
44
+		if (isset($options['HTTPHEADER'])) {
45
+			$headers[] = $options['HTTPHEADER'];
46
+		}
47
+
48
+		if (isset($options['HTTPHEADERS'])) {
49
+			foreach ($options['HTTPHEADERS'] as $header) {
50
+				$headers[] = $header;
51
+			}
52
+		}
53
+
54
+		$ch = curl_init();
55
+
56
+		$url = isset($options['url']) ? $options['url'].'?'.http_build_query(array_merge(
57
+			$query, ['api_key' => self::getApiKey()]
58
+		)) : '';
59
+
60
+		$baseUrl = self::getBaseUrl();
61
+
62
+		$curlOpts = [
63
+			CURLOPT_URL             => $baseUrl.$url,
64
+			CURLOPT_RETURNTRANSFER  => true,
65
+			CURLOPT_TIMEOUT         => 120,
66
+			CURLOPT_FOLLOWLOCATION  => true,
67
+			CURLOPT_SSL_VERIFYHOST  => false,
68
+			CURLOPT_SSL_VERIFYPEER  => false,
69
+			CURLOPT_HTTPHEADER      => $headers,
70
+		];
71
+
72
+		curl_setopt_array($ch, $curlOpts);
73
+
74
+		if (null != $file) {
75
+			$cfile = new \CURLFile($file,'','');
76
+			$body['strFilename']=$cfile;
77
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
78
+			curl_setopt($ch, CURLOPT_POST,true);
79
+			curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
80
+		} else {
81
+			switch ($method) {
82
+				case 'DELETE':
83
+					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
84
+					break;
85
+				case 'DELETEARRAY':
86
+					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
87
+					curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
88
+					break;
89
+				case 'PUT':
90
+					curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
91
+					break;
92
+				case 'POST':
93
+					if (isset($body)) {
94
+						$bodyData = json_encode($body);
95
+						if (isset($options['HTTPHEADER'])) {
96
+							if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
97
+								$bodyData = $body;
98
+							}
99
+						}
100
+
101
+						curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
102
+					}
103
+					break;
104
+				case 'ADD':
105
+					curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
106
+			}
107
+
108
+			if (is_numeric(array_search($method, ['DELETE', 'PUT']))) {
109
+				if (isset($body)) {
110
+					curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
111
+				}
112
+			}
113
+		}
114
+
115
+		$result = curl_exec($ch);
116
+
117
+		$isxml = false;
118
+		$jxml = '';
119
+		if (strpos($result, '<?xml') > -1) {
120
+			$xml = simplexml_load_string($result);
121
+			//$jxml = json_encode($xml);
122
+			$jxml = self::object2array($xml);
123
+			$isxml = true;
124
+		}
125
+
126
+		$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
127
+		curl_close($ch);
128
+
129
+		if (200 == $code) {
130
+			if ($isxml) {
131
+				$json = $jxml;
132
+			} else {
133
+				$json = json_decode($result, true);
134
+			}
135
+
136
+			if (isset($json['errors'])) {
137
+				throw new ApiError(implode(', ', $json['errors']));
138
+			} else {
139
+				return $json;
140
+			}
141
+		} elseif (409 == $code) {
142
+			throw new ApiError('Wrong API key');
143
+		} else {
144
+			throw new ApiError('Something wrong');
145
+		}
146
+	}
147
+
148
+	/**
149
+	 * @param $object: JSON object
150
+	 */
151
+	public static function object2array($object)
152
+	{
153
+		return @json_decode(@json_encode($object), 1);
154
+	}
155
+
156
+	/**
157
+	 * Prints on the screen main keys and values of the array.
158
+	 *
159
+	 * @param $results: object to be printed on the screen
160
+	 * @param $deepPrinting: if true, object will be printed recursively
161
+	 */
162
+	public static function simplePrint($results, $deepPrinting = null)
163
+	{
164
+		if (isset($results)) {
165
+			if (is_array($results)) {
166
+				foreach ($results as $key => $result) {
167
+					if (is_array($result)) {
168
+						foreach ($result as $key1 => $result1) {
169
+							if (is_array($result1)) {
170
+								if ($deepPrinting) {
171
+									echo "<br>$key1 ------><br>";
172
+									self::simplePrint($result1, true);
173
+									echo '------<br>';
174
+								} else {
175
+									echo $key1.' --> '.'Array() <br>';
176
+								}
177
+							} else {
178
+								if (is_object($result1)) {
179
+									if ($deepPrinting) {
180
+										echo "<br>$key1 ------><br>";
181
+										$oarray = (array) $result1;
182
+										self::simplePrint($oarray, true);
183
+										echo '------<br>';
184
+									} else {
185
+										echo $key1.' --> '.'Object <br>';
186
+									}
187
+								} else {
188
+									if (!is_null($result1)) {
189
+										echo $key1.' --> '.$result1.'<br>';
190
+									}
191
+								}
192
+							}
193
+						}
194
+					} else {
195
+						if (is_object($result)) {
196
+							if ($deepPrinting) {
197
+								echo "<br>$key ------><br>";
198
+								$oarray = (array) $result;
199
+								self::simplePrint($oarray, true);
200
+								echo '------<br>';
201
+							} else {
202
+								echo $key.' --> '.'Object <br>';
203
+							}
204
+						} else {
205
+							if (!is_null($result)) {
206
+								echo $key.' --> '.$result.'<br>';
207
+							}
208
+						}
209
+					}
210
+					//echo "<br>";
211
+				}
212
+			}
213
+		}
214
+	}
215
+
216
+	/**
217
+	 * Generates query or body parameters.
218
+	 *
219
+	 * @param $allFields: all known fields could be used for parameters generation
220
+	 * @param $params: input parameters (array or object)
221
+	 */
222
+	public static function generateRequestParameters($allFields, $params)
223
+	{
224
+		$generatedParams = [];
225
+
226
+		if (is_array($params)) {
227
+			foreach ($allFields as $field) {
228
+				if (isset($params[$field])) {
229
+					$generatedParams[$field] = $params[$field];
230
+				}
231
+			}
232
+		} elseif (is_object($params)) {
233
+			foreach ($allFields as $field) {
234
+				if (isset($params->{$field})) {
235
+					$generatedParams[$field] = $params->{$field};
236
+				}
237
+			}
238
+		}
239
+
240
+		return $generatedParams;
241
+	}
242
+
243
+	/**
244
+	 * Returns an array of the object properties.
245
+	 *
246
+	 * @param $object: An object
247
+	 * @param $exclude: array of the object parameters to be excluded from the returned array
248
+	 */
249
+	public static function getObjectProperties($object, $exclude)
250
+	{
251
+		$objectParameters = [];
252
+
253
+		foreach (get_object_vars($object) as $key => $value) {
254
+			if (property_exists($object, $key)) {
255
+				if (!is_numeric(array_search($key, $exclude))) {
256
+					array_push($objectParameters, $key);
257
+				}
258
+			}
259
+		}
260
+
261
+		return $objectParameters;
262
+	}
263
+
264
+	/**
265
+	 * Returns url path generated from the array of the fields and parameters.
266
+	 *
267
+	 * @param $allFields; array of the paossible fields (parameter names)
268
+	 * @param $params: input parameters (array or object)
269
+	 */
270
+	public static function generateUrlPath($allFields, $params)
271
+	{
272
+		$generatedPath = '';
273
+
274
+		if (is_array($params)) {
275
+			foreach ($allFields as $field) {
276
+				if (isset($params[$field])) {
277
+					$generatedPath .= $params[$field].'/';
278
+				}
279
+			}
280
+		} elseif (is_object($params)) {
281
+			foreach ($allFields as $field) {
282
+				if (isset($params->{$field})) {
283
+					$generatedPath .= $params->{$field}.'/';
284
+				}
285
+			}
286
+		}
287
+
288
+		return $generatedPath;
289
+	}
290
+
291
+	public static function getFileRealPath($fileName)
292
+	{
293
+		$rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fileName)) : '@'.realpath($fileName);
294
+
295
+		return $rpath;
296
+	}
297 297
 }
Please login to merge, or discard this patch.
Switch Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -79,30 +79,30 @@
 block discarded – undo
79 79
             curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
80 80
         } else {
81 81
             switch ($method) {
82
-                case 'DELETE':
83
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
84
-                    break;
85
-                case 'DELETEARRAY':
86
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
87
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
88
-                    break;
89
-                case 'PUT':
90
-                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
91
-                    break;
92
-                case 'POST':
93
-                    if (isset($body)) {
94
-                        $bodyData = json_encode($body);
95
-                        if (isset($options['HTTPHEADER'])) {
96
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
97
-                                $bodyData = $body;
98
-                            }
82
+            case 'DELETE':
83
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
84
+                break;
85
+            case 'DELETEARRAY':
86
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
87
+                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
88
+                break;
89
+            case 'PUT':
90
+                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
91
+                break;
92
+            case 'POST':
93
+                if (isset($body)) {
94
+                    $bodyData = json_encode($body);
95
+                    if (isset($options['HTTPHEADER'])) {
96
+                        if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
97
+                            $bodyData = $body;
99 98
                         }
100
-
101
-                        curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
102 99
                     }
103
-                    break;
104
-                case 'ADD':
105
-                    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
100
+
101
+                    curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData);
102
+                }
103
+                break;
104
+            case 'ADD':
105
+                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
106 106
             }
107 107
 
108 108
             if (is_numeric(array_search($method, ['DELETE', 'PUT']))) {
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     public static function makeRequst($options)
34 34
     {
35 35
         $method = isset($options['method']) ? $options['method'] : 'GET';
36
-        $query = isset($options['query']) ? array_filter($options['query'], function ($x) { return !is_null($x); }) : [];
36
+        $query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); }) : [];
37 37
 
38 38
         $body = isset($options['body']) ? $options['body'] : null;
39 39
         $file = isset($options['FILE']) ? $options['FILE'] : null;
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 
72 72
         curl_setopt_array($ch, $curlOpts);
73 73
 
74
-        if (null != $file) {
75
-            $cfile = new \CURLFile($file,'','');
76
-            $body['strFilename']=$cfile;
74
+        if (null!=$file) {
75
+            $cfile = new \CURLFile($file, '', '');
76
+            $body['strFilename'] = $cfile;
77 77
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
78
-            curl_setopt($ch, CURLOPT_POST,true);
78
+            curl_setopt($ch, CURLOPT_POST, true);
79 79
             curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
80 80
         } else {
81 81
             switch ($method) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
                     if (isset($body)) {
94 94
                         $bodyData = json_encode($body);
95 95
                         if (isset($options['HTTPHEADER'])) {
96
-                            if (strpos($options['HTTPHEADER'], 'multipart/form-data') > 0) {
96
+                            if (strpos($options['HTTPHEADER'], 'multipart/form-data')>0) {
97 97
                                 $bodyData = $body;
98 98
                             }
99 99
                         }
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 
117 117
         $isxml = false;
118 118
         $jxml = '';
119
-        if (strpos($result, '<?xml') > -1) {
119
+        if (strpos($result, '<?xml')>-1) {
120 120
             $xml = simplexml_load_string($result);
121 121
             //$jxml = json_encode($xml);
122 122
             $jxml = self::object2array($xml);
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
127 127
         curl_close($ch);
128 128
 
129
-        if (200 == $code) {
129
+        if (200==$code) {
130 130
             if ($isxml) {
131 131
                 $json = $jxml;
132 132
             } else {
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
             } else {
139 139
                 return $json;
140 140
             }
141
-        } elseif (409 == $code) {
141
+        } elseif (409==$code) {
142 142
             throw new ApiError('Wrong API key');
143 143
         } else {
144 144
             throw new ApiError('Something wrong');
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
                                 if (is_object($result1)) {
179 179
                                     if ($deepPrinting) {
180 180
                                         echo "<br>$key1 ------><br>";
181
-                                        $oarray = (array) $result1;
181
+                                        $oarray = (array)$result1;
182 182
                                         self::simplePrint($oarray, true);
183 183
                                         echo '------<br>';
184 184
                                     } else {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
                         if (is_object($result)) {
196 196
                             if ($deepPrinting) {
197 197
                                 echo "<br>$key ------><br>";
198
-                                $oarray = (array) $result;
198
+                                $oarray = (array)$result;
199 199
                                 self::simplePrint($oarray, true);
200 200
                                 echo '------<br>';
201 201
                             } else {
Please login to merge, or discard this patch.
src/Route4Me/AddressBookLocationSearchResponse.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@
 block discarded – undo
6 6
 
7 7
 class AddressBookLocationSearchResponse
8 8
 {
9
-    public $results=[];
10
-    public $total;
11
-    public $fields=[];
9
+	public $results=[];
10
+	public $total;
11
+	public $fields=[];
12 12
 
13
-    public static function fromArray(array $params)
14
-    {
15
-        $ablSearchResponse = new self();
13
+	public static function fromArray(array $params)
14
+	{
15
+		$ablSearchResponse = new self();
16 16
 
17
-        foreach ($params as $key => $value) {
18
-            if (property_exists($ablSearchResponse, $key)) {
19
-                $ablSearchResponse->{$key} = $value;
20
-            } else {
21
-                throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key");
22
-            }
23
-        }
17
+		foreach ($params as $key => $value) {
18
+			if (property_exists($ablSearchResponse, $key)) {
19
+				$ablSearchResponse->{$key} = $value;
20
+			} else {
21
+				throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key");
22
+			}
23
+		}
24 24
 
25
-        return $ablSearchResponse;
26
-    }
25
+		return $ablSearchResponse;
26
+	}
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,9 +6,9 @@
 block discarded – undo
6 6
 
7 7
 class AddressBookLocationSearchResponse
8 8
 {
9
-    public $results=[];
9
+    public $results = [];
10 10
     public $total;
11
-    public $fields=[];
11
+    public $fields = [];
12 12
 
13 13
     public static function fromArray(array $params)
14 14
     {
Please login to merge, or discard this patch.
src/Route4Me/GeoPoint.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,28 +11,28 @@
 block discarded – undo
11 11
  */
12 12
 class GeoPoint extends Common
13 13
 {
14
-    /**
15
-     * Latitude
16
-     * @var double
17
-     */
18
-    public $lat;
19
-
20
-    /**
21
-     * Longitude
22
-     * @var double
23
-     */
24
-    public $lng;
25
-
26
-    public static function fromArray(array $params)
27
-    {
28
-        $thisParams = new self();
29
-
30
-        foreach ($params as $key => $value) {
31
-            if (property_exists($thisParams, $key)) {
32
-                $thisParams->{$key} = $value;
33
-            }
34
-        }
35
-
36
-        return $thisParams;
37
-    }
14
+	/**
15
+	 * Latitude
16
+	 * @var double
17
+	 */
18
+	public $lat;
19
+
20
+	/**
21
+	 * Longitude
22
+	 * @var double
23
+	 */
24
+	public $lng;
25
+
26
+	public static function fromArray(array $params)
27
+	{
28
+		$thisParams = new self();
29
+
30
+		foreach ($params as $key => $value) {
31
+			if (property_exists($thisParams, $key)) {
32
+				$thisParams->{$key} = $value;
33
+			}
34
+		}
35
+
36
+		return $thisParams;
37
+	}
38 38
 }
39 39
\ No newline at end of file
Please login to merge, or discard this patch.
src/Route4Me/AddressNoteResponse.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -9,23 +9,23 @@
 block discarded – undo
9 9
  */
10 10
 class AddressNoteResponse extends Common
11 11
 {
12
-    public $status;
13
-    public $note_id;
14
-    public $upload_id;
15
-    public $note;
12
+	public $status;
13
+	public $note_id;
14
+	public $upload_id;
15
+	public $note;
16 16
 
17
-    public static function fromArray(array $params)
18
-    {
19
-        $addressNoteResponse = new self();
17
+	public static function fromArray(array $params)
18
+	{
19
+		$addressNoteResponse = new self();
20 20
 
21
-        foreach ($params as $key => $value) {
22
-            if (property_exists($addressNoteResponse, $key)) {
23
-                $addressNoteResponse->{$key} = $value;
24
-            } else {
25
-                throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key");
26
-            }
27
-        }
21
+		foreach ($params as $key => $value) {
22
+			if (property_exists($addressNoteResponse, $key)) {
23
+				$addressNoteResponse->{$key} = $value;
24
+			} else {
25
+				throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key");
26
+			}
27
+		}
28 28
 
29
-        return $addressNoteResponse;
30
-    }
29
+		return $addressNoteResponse;
30
+	}
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
src/Route4Me/ScheduleCalendarResponse.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -10,36 +10,36 @@
 block discarded – undo
10 10
  */
11 11
 class ScheduleCalendarResponse extends Common
12 12
 {
13
-    /**
14
-     * The address book contact quantity by dates
15
-     * (dates are in the string format, e.g. 2020-10-18).
16
-     * @var array
17
-     */
18
-    public $address_book = [];
13
+	/**
14
+	 * The address book contact quantity by dates
15
+	 * (dates are in the string format, e.g. 2020-10-18).
16
+	 * @var array
17
+	 */
18
+	public $address_book = [];
19 19
 
20
-    /*
20
+	/*
21 21
      * The order quantity by dates
22 22
      * (dates are in the string format, e.g. 2020-10-18).
23 23
      * @var array
24 24
      */
25
-    public $orders = [];
25
+	public $orders = [];
26 26
 
27
-    /*
27
+	/*
28 28
      * The order quantity by dates
29 29
      * (dates are in the string format, e.g. 2020-10-18).
30 30
      * @var array
31 31
      */
32
-    public $routes_count = [];
32
+	public $routes_count = [];
33 33
 
34
-    public static function fromArray(array $params)
35
-    {
36
-        $order = new self();
37
-        foreach ($params as $key => $value) {
38
-            if (property_exists($order, $key)) {
39
-                $order->{$key} = $value;
40
-            }
41
-        }
34
+	public static function fromArray(array $params)
35
+	{
36
+		$order = new self();
37
+		foreach ($params as $key => $value) {
38
+			if (property_exists($order, $key)) {
39
+				$order->{$key} = $value;
40
+			}
41
+		}
42 42
 
43
-        return $order;
44
-    }
43
+		return $order;
44
+	}
45 45
 }
Please login to merge, or discard this patch.
src/Route4Me/Address.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -208,7 +208,7 @@
 block discarded – undo
208 208
             ],
209 209
         ]);
210 210
 
211
-        return (bool) $address['deleted'];
211
+        return (bool)$address['deleted'];
212 212
     }
213 213
 
214 214
     public function moveDestinationToRoute($params)
Please login to merge, or discard this patch.
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -7,227 +7,227 @@
 block discarded – undo
7 7
 
8 8
 class Address extends Common
9 9
 {
10
-    public $route_destination_id;
11
-    public $alias;
12
-    public $member_id;
13
-    public $address;
14
-    public $addressUpdate;
15
-    public $is_depot = false;
16
-    public $lat;
17
-    public $lng;
18
-    public $route_id;
19
-    public $original_route_id;
20
-    public $optimization_problem_id;
21
-    public $sequence_no;
22
-    public $geocoded;
23
-    public $preferred_geocoding;
24
-    public $failed_geocoding;
25
-    public $geocodings = [];
26
-    public $contact_id;
27
-    public $is_visited;
28
-    public $customer_po;
29
-    public $invoice_no;
30
-    public $reference_no;
31
-    public $order_no;
32
-    public $weight;
33
-    public $cost;
34
-    public $revenue;
35
-    public $cube;
36
-    public $pieces;
37
-    public $email;
38
-    public $phone;
39
-    public $tracking_number;
40
-    public $destination_note_count;
41
-    public $drive_time_to_next_destination;
42
-    public $distance_to_next_destination;
43
-    public $generated_time_window_start;
44
-    public $generated_time_window_end;
45
-    public $time_window_start;
46
-    public $time_window_end;
47
-    public $time;
48
-    public $notes;
49
-    public $timestamp_last_visited;
50
-    public $custom_fields = [];
51
-    public $manifest = [];
52
-
53
-    public $first_name;
54
-    public $last_name;
55
-    public $is_departed;
56
-    public $timestamp_last_departed;
57
-    public $order_id;
58
-    public $priority;
59
-    public $curbside_lat;
60
-    public $curbside_lng;
61
-    public $time_window_start_2;
62
-    public $time_window_end_2;
63
-
64
-    public $timeframe_violation_state;
65
-    public $timeframe_violation_time;
66
-    public $timeframe_violation_rate;
67
-    public $route_name;
68
-    public $address_stop_type;
69
-    public $visited_lat;
70
-    public $visited_lng;
71
-    public $departed_lat;
72
-    public $departed_lng;
73
-    public $group;
74
-    public $abnormal_traffic_time_to_next_destination;
75
-    public $uncongested_time_to_next_destination;
76
-    public $traffic_time_to_next_destination;
77
-    public $channel_name;
78
-    public $pickup;
79
-    public $dropoff;
80
-    public $joint;
81
-    public $geofence_detected_visited_timestamp;
82
-    public $geofence_detected_departed_timestamp;
83
-    public $geofence_detected_service_time;
84
-    public $geofence_detected_visited_lat;
85
-    public $geofence_detected_visited_lng;
86
-    public $geofence_detected_departed_lat;
87
-    public $geofence_detected_departed_lng;
88
-    public $custom_fields_str_json;
89
-    public $custom_fields_config;
90
-    public $custom_fields_config_str_json;
91
-    public $bundle_count;
92
-    public $bundle_items;
93
-    public $order_inventory;
94
-    public $required_skills;
95
-    public $udu_distance_to_next_destination;
96
-    public $wait_time_to_next_destination;
97
-    public $path_to_next = [];
98
-    public $additional_status;
99
-    public $tags = [];
100
-
101
-    public function __construct()
102
-    {
103
-        Route4Me::setBaseUrl(Endpoint::BASE_URL);
104
-    }
105
-
106
-    public static function fromArray(array $params)
107
-    {
108
-        $address = new self();
109
-
110
-        foreach ($params as $key => $value) {
111
-            if (property_exists($address, $key)) {
112
-                $address->{$key} = $value;
113
-            } else {
114
-                throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key");
115
-            }
116
-        }
117
-
118
-        return $address;
119
-    }
120
-
121
-    public static function getAddress($routeId, $addressId)
122
-    {
123
-        $address = Route4Me::makeRequst([
124
-            'url'       => Endpoint::ADDRESS_V4,
125
-            'method'    => 'GET',
126
-            'query'     => [
127
-                'route_id'              => $routeId,
128
-                'route_destination_id'  => $addressId,
129
-            ],
130
-        ]);
131
-
132
-        return self::fromArray($address);
133
-    }
134
-
135
-    public function update()
136
-    {
137
-        $addressUpdate = Route4Me::makeRequst([
138
-            'url'       => Endpoint::ADDRESS_V4,
139
-            'method'    => 'PUT',
140
-            'body'      => $this->toArray(),
141
-            'query'     => [
142
-                'route_id'              => $this->route_id,
143
-                'route_destination_id'  => $this->route_destination_id,
144
-            ],
145
-        ]);
146
-
147
-        return self::fromArray($addressUpdate);
148
-    }
149
-
150
-    /*
10
+	public $route_destination_id;
11
+	public $alias;
12
+	public $member_id;
13
+	public $address;
14
+	public $addressUpdate;
15
+	public $is_depot = false;
16
+	public $lat;
17
+	public $lng;
18
+	public $route_id;
19
+	public $original_route_id;
20
+	public $optimization_problem_id;
21
+	public $sequence_no;
22
+	public $geocoded;
23
+	public $preferred_geocoding;
24
+	public $failed_geocoding;
25
+	public $geocodings = [];
26
+	public $contact_id;
27
+	public $is_visited;
28
+	public $customer_po;
29
+	public $invoice_no;
30
+	public $reference_no;
31
+	public $order_no;
32
+	public $weight;
33
+	public $cost;
34
+	public $revenue;
35
+	public $cube;
36
+	public $pieces;
37
+	public $email;
38
+	public $phone;
39
+	public $tracking_number;
40
+	public $destination_note_count;
41
+	public $drive_time_to_next_destination;
42
+	public $distance_to_next_destination;
43
+	public $generated_time_window_start;
44
+	public $generated_time_window_end;
45
+	public $time_window_start;
46
+	public $time_window_end;
47
+	public $time;
48
+	public $notes;
49
+	public $timestamp_last_visited;
50
+	public $custom_fields = [];
51
+	public $manifest = [];
52
+
53
+	public $first_name;
54
+	public $last_name;
55
+	public $is_departed;
56
+	public $timestamp_last_departed;
57
+	public $order_id;
58
+	public $priority;
59
+	public $curbside_lat;
60
+	public $curbside_lng;
61
+	public $time_window_start_2;
62
+	public $time_window_end_2;
63
+
64
+	public $timeframe_violation_state;
65
+	public $timeframe_violation_time;
66
+	public $timeframe_violation_rate;
67
+	public $route_name;
68
+	public $address_stop_type;
69
+	public $visited_lat;
70
+	public $visited_lng;
71
+	public $departed_lat;
72
+	public $departed_lng;
73
+	public $group;
74
+	public $abnormal_traffic_time_to_next_destination;
75
+	public $uncongested_time_to_next_destination;
76
+	public $traffic_time_to_next_destination;
77
+	public $channel_name;
78
+	public $pickup;
79
+	public $dropoff;
80
+	public $joint;
81
+	public $geofence_detected_visited_timestamp;
82
+	public $geofence_detected_departed_timestamp;
83
+	public $geofence_detected_service_time;
84
+	public $geofence_detected_visited_lat;
85
+	public $geofence_detected_visited_lng;
86
+	public $geofence_detected_departed_lat;
87
+	public $geofence_detected_departed_lng;
88
+	public $custom_fields_str_json;
89
+	public $custom_fields_config;
90
+	public $custom_fields_config_str_json;
91
+	public $bundle_count;
92
+	public $bundle_items;
93
+	public $order_inventory;
94
+	public $required_skills;
95
+	public $udu_distance_to_next_destination;
96
+	public $wait_time_to_next_destination;
97
+	public $path_to_next = [];
98
+	public $additional_status;
99
+	public $tags = [];
100
+
101
+	public function __construct()
102
+	{
103
+		Route4Me::setBaseUrl(Endpoint::BASE_URL);
104
+	}
105
+
106
+	public static function fromArray(array $params)
107
+	{
108
+		$address = new self();
109
+
110
+		foreach ($params as $key => $value) {
111
+			if (property_exists($address, $key)) {
112
+				$address->{$key} = $value;
113
+			} else {
114
+				throw new BadParam("Correct parameter must be provided. Wrong Parameter: $key");
115
+			}
116
+		}
117
+
118
+		return $address;
119
+	}
120
+
121
+	public static function getAddress($routeId, $addressId)
122
+	{
123
+		$address = Route4Me::makeRequst([
124
+			'url'       => Endpoint::ADDRESS_V4,
125
+			'method'    => 'GET',
126
+			'query'     => [
127
+				'route_id'              => $routeId,
128
+				'route_destination_id'  => $addressId,
129
+			],
130
+		]);
131
+
132
+		return self::fromArray($address);
133
+	}
134
+
135
+	public function update()
136
+	{
137
+		$addressUpdate = Route4Me::makeRequst([
138
+			'url'       => Endpoint::ADDRESS_V4,
139
+			'method'    => 'PUT',
140
+			'body'      => $this->toArray(),
141
+			'query'     => [
142
+				'route_id'              => $this->route_id,
143
+				'route_destination_id'  => $this->route_destination_id,
144
+			],
145
+		]);
146
+
147
+		return self::fromArray($addressUpdate);
148
+	}
149
+
150
+	/*
151 151
      * Marks an address as marked as visited/as departed
152 152
      * depending on which parameter is specified: 'is_visited' or 'is_departed'.
153 153
      */
154
-    public function markAddress($params)
155
-    {
156
-        $allQueryFields = ['route_id', 'route_destination_id'];
157
-        $allBodyFields = ['is_visited', 'is_departed'];
158
-
159
-        $result = Route4Me::makeRequst([
160
-            'url' => Endpoint::ADDRESS_V4,
161
-            'method'    => 'PUT',
162
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
163
-            'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
164
-        ]);
165
-
166
-        return $result;
167
-    }
168
-
169
-    /*
154
+	public function markAddress($params)
155
+	{
156
+		$allQueryFields = ['route_id', 'route_destination_id'];
157
+		$allBodyFields = ['is_visited', 'is_departed'];
158
+
159
+		$result = Route4Me::makeRequst([
160
+			'url' => Endpoint::ADDRESS_V4,
161
+			'method'    => 'PUT',
162
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
163
+			'body'      => Route4Me::generateRequestParameters($allBodyFields, $params),
164
+		]);
165
+
166
+		return $result;
167
+	}
168
+
169
+	/*
170 170
      * Marks an address as departed.
171 171
      */
172
-    public function markAsDeparted($params)
173
-    {
174
-        $allQueryFields = ['route_id', 'address_id', 'is_departed', 'member_id'];
172
+	public function markAsDeparted($params)
173
+	{
174
+		$allQueryFields = ['route_id', 'address_id', 'is_departed', 'member_id'];
175 175
 
176
-        $address = Route4Me::makeRequst([
177
-            'url'       => Endpoint::MARK_ADDRESS_DEPARTED,
178
-            'method'    => 'PUT',
179
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
180
-        ]);
176
+		$address = Route4Me::makeRequst([
177
+			'url'       => Endpoint::MARK_ADDRESS_DEPARTED,
178
+			'method'    => 'PUT',
179
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
180
+		]);
181 181
 
182
-        return $address;
183
-    }
182
+		return $address;
183
+	}
184 184
 
185
-    /*
185
+	/*
186 186
      * Marks an address as visited.
187 187
      */
188
-    public function markAsVisited($params)
189
-    {
190
-        $allQueryFields = ['route_id', 'address_id', 'is_visited', 'member_id'];
191
-
192
-        $address = Route4Me::makeRequst([
193
-            'url'       => Endpoint::UPDATE_ADDRESS_VISITED,
194
-            'method'    => 'PUT',
195
-            'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
196
-        ]);
197
-
198
-        return $address;
199
-    }
200
-
201
-    public function deleteAddress()
202
-    {
203
-        $address = Route4Me::makeRequst([
204
-            'url'       => Endpoint::ADDRESS_V4,
205
-            'method'    => 'DELETE',
206
-            'query'     => [
207
-                'route_id'              => $this->route_id,
208
-                'route_destination_id'  => $this->route_destination_id,
209
-            ],
210
-        ]);
211
-
212
-        return (bool) $address['deleted'];
213
-    }
214
-
215
-    public function moveDestinationToRoute($params)
216
-    {
217
-        $allBodyFields = ['to_route_id', 'route_destination_id', 'after_destination_id'];
218
-
219
-        $result = Route4Me::makeRequst([
220
-            'url'           => Endpoint::MOVE_ROUTE_DESTINATION,
221
-            'method'        => 'POST',
222
-            'body'          => Route4Me::generateRequestParameters($allBodyFields, $params),
223
-            'HTTPHEADER'    => 'Content-Type: multipart/form-data',
224
-        ]);
225
-
226
-        return $result;
227
-    }
228
-
229
-    public function getAddressId()
230
-    {
231
-        return $this->route_destination_id;
232
-    }
188
+	public function markAsVisited($params)
189
+	{
190
+		$allQueryFields = ['route_id', 'address_id', 'is_visited', 'member_id'];
191
+
192
+		$address = Route4Me::makeRequst([
193
+			'url'       => Endpoint::UPDATE_ADDRESS_VISITED,
194
+			'method'    => 'PUT',
195
+			'query'     => Route4Me::generateRequestParameters($allQueryFields, $params),
196
+		]);
197
+
198
+		return $address;
199
+	}
200
+
201
+	public function deleteAddress()
202
+	{
203
+		$address = Route4Me::makeRequst([
204
+			'url'       => Endpoint::ADDRESS_V4,
205
+			'method'    => 'DELETE',
206
+			'query'     => [
207
+				'route_id'              => $this->route_id,
208
+				'route_destination_id'  => $this->route_destination_id,
209
+			],
210
+		]);
211
+
212
+		return (bool) $address['deleted'];
213
+	}
214
+
215
+	public function moveDestinationToRoute($params)
216
+	{
217
+		$allBodyFields = ['to_route_id', 'route_destination_id', 'after_destination_id'];
218
+
219
+		$result = Route4Me::makeRequst([
220
+			'url'           => Endpoint::MOVE_ROUTE_DESTINATION,
221
+			'method'        => 'POST',
222
+			'body'          => Route4Me::generateRequestParameters($allBodyFields, $params),
223
+			'HTTPHEADER'    => 'Content-Type: multipart/form-data',
224
+		]);
225
+
226
+		return $result;
227
+	}
228
+
229
+	public function getAddressId()
230
+	{
231
+		return $this->route_destination_id;
232
+	}
233 233
 }
Please login to merge, or discard this patch.
UnitTestFiles/Test/AdvancedConstraintsUnitTests.php 2 patches
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -14,79 +14,79 @@
 block discarded – undo
14 14
 use Route4Me\V5\Addresses\RouteAdvancedConstraints;
15 15
 
16 16
 class AdvancedConstraintsUnitTests extends \PHPUnit\Framework\TestCase {
17
-    public static $problem;
17
+	public static $problem;
18 18
 
19
-    public static function setUpBeforeClass()
20
-    {
21
-        Route4Me::setApiKey(Constants::API_KEY);
22
-        self::$problem = null;
23
-    }
19
+	public static function setUpBeforeClass()
20
+	{
21
+		Route4Me::setApiKey(Constants::API_KEY);
22
+		self::$problem = null;
23
+	}
24 24
 
25
-    public function testAdvancedConstraintsExample12()
26
-    {
27
-        $addresses = array_map('str_getcsv', file(dirname(__FILE__).'/data/locations.csv'));
28
-        array_walk($addresses, function(&$a) use ($addresses) { $a = Address::fromArray(array_combine($addresses[0], $a)); });
29
-        array_shift($addresses);
25
+	public function testAdvancedConstraintsExample12()
26
+	{
27
+		$addresses = array_map('str_getcsv', file(dirname(__FILE__).'/data/locations.csv'));
28
+		array_walk($addresses, function(&$a) use ($addresses) { $a = Address::fromArray(array_combine($addresses[0], $a)); });
29
+		array_shift($addresses);
30 30
 
31
-        $parameters = RouteParameters::fromArray([
32
-            'algorithm_type' => AlgorithmType::ADVANCED_CVRP_TW,
33
-            'store_route' => false,
34
-            'rt' => true,
35
-            'parts' => 30,
36
-            'metric' => Metric::MATRIX,
37
-            'member_id' => 444333,
38
-            'route_name' => "Drivers Schedules - 3 Territories",
39
-            'optimize' => "Distance",
40
-            'distance_unit' => "mi",
41
-            'device_type' => DeviceType::WEB,
42
-            'travel_mode' => "Driving",
43
-            'advanced_constraints' => []
44
-        ]);
31
+		$parameters = RouteParameters::fromArray([
32
+			'algorithm_type' => AlgorithmType::ADVANCED_CVRP_TW,
33
+			'store_route' => false,
34
+			'rt' => true,
35
+			'parts' => 30,
36
+			'metric' => Metric::MATRIX,
37
+			'member_id' => 444333,
38
+			'route_name' => "Drivers Schedules - 3 Territories",
39
+			'optimize' => "Distance",
40
+			'distance_unit' => "mi",
41
+			'device_type' => DeviceType::WEB,
42
+			'travel_mode' => "Driving",
43
+			'advanced_constraints' => []
44
+		]);
45 45
 
46
-        $zones = [["ZONE 01"], ["ZONE 02"], ["ZONE 03"]];
46
+		$zones = [["ZONE 01"], ["ZONE 02"], ["ZONE 03"]];
47 47
 
48
-        for($i = 0; $i < 30; ++$i)
49
-        {
50
-            $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([
51
-                'tags' => [$zones[$i % 3]],
52
-                'members_count' => 1,
53
-                'available_time_windows' => [[(8 + 5) * 3600, (11 + 5) * 3600]],
54
-                'location_sequence_pattern' => [Address::fromArray([
55
-                    'address' => "RETAIL LOCATION",
56
-                    'alias' => "RETAIL LOCATION",
57
-                    'lat' => 25.8741751,
58
-                    'lng' => -80.1288583,
59
-                    'time' => 300
60
-                ])]
61
-            ]);
62
-        }
48
+		for($i = 0; $i < 30; ++$i)
49
+		{
50
+			$parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([
51
+				'tags' => [$zones[$i % 3]],
52
+				'members_count' => 1,
53
+				'available_time_windows' => [[(8 + 5) * 3600, (11 + 5) * 3600]],
54
+				'location_sequence_pattern' => [Address::fromArray([
55
+					'address' => "RETAIL LOCATION",
56
+					'alias' => "RETAIL LOCATION",
57
+					'lat' => 25.8741751,
58
+					'lng' => -80.1288583,
59
+					'time' => 300
60
+				])]
61
+			]);
62
+		}
63 63
     
64
-        $optimizationParameters = new OptimizationProblemParams();
65
-        $optimizationParameters->setAddresses($addresses);
66
-        $optimizationParameters->setParameters($parameters);
64
+		$optimizationParameters = new OptimizationProblemParams();
65
+		$optimizationParameters->setAddresses($addresses);
66
+		$optimizationParameters->setParameters($parameters);
67 67
 
68
-        self::$problem = OptimizationProblem::optimize($optimizationParameters);
68
+		self::$problem = OptimizationProblem::optimize($optimizationParameters);
69 69
 
70
-        $this->assertNotNull(self::$problem->optimization_problem_id);
71
-        $this->assertEquals(self::$problem->parameters->route_name, 'Drivers Schedules - 3 Territories');
72
-    }
70
+		$this->assertNotNull(self::$problem->optimization_problem_id);
71
+		$this->assertEquals(self::$problem->parameters->route_name, 'Drivers Schedules - 3 Territories');
72
+	}
73 73
 
74
-    public static function tearDownAfterClass()
75
-    {
76
-        if(!is_null(self::$problem->optimization_problem_id))
77
-        {
78
-            $params = [
79
-                'optimization_problem_ids' => ['0' => self::$problem->optimization_problem_id],
80
-                'redirect' => 0,
81
-            ];
74
+	public static function tearDownAfterClass()
75
+	{
76
+		if(!is_null(self::$problem->optimization_problem_id))
77
+		{
78
+			$params = [
79
+				'optimization_problem_ids' => ['0' => self::$problem->optimization_problem_id],
80
+				'redirect' => 0,
81
+			];
82 82
 
83
-            $result = self::$problem->removeOptimization($params);
83
+			$result = self::$problem->removeOptimization($params);
84 84
 
85
-            if ($result != null && $result['status'] == true) {
86
-                echo "The test optimization was removed <br>";
87
-            } else {
88
-                echo "Cannot remove the test optimization <br>";
89
-            }
90
-        }
91
-    }
85
+			if ($result != null && $result['status'] == true) {
86
+				echo "The test optimization was removed <br>";
87
+			} else {
88
+				echo "Cannot remove the test optimization <br>";
89
+			}
90
+		}
91
+	}
92 92
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
         $zones = [["ZONE 01"], ["ZONE 02"], ["ZONE 03"]];
47 47
 
48
-        for($i = 0; $i < 30; ++$i)
48
+        for ($i = 0; $i<30; ++$i)
49 49
         {
50 50
             $parameters->advanced_constraints[] = RouteAdvancedConstraints::fromArray([
51 51
                 'tags' => [$zones[$i % 3]],
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
     public static function tearDownAfterClass()
75 75
     {
76
-        if(!is_null(self::$problem->optimization_problem_id))
76
+        if (!is_null(self::$problem->optimization_problem_id))
77 77
         {
78 78
             $params = [
79 79
                 'optimization_problem_ids' => ['0' => self::$problem->optimization_problem_id],
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 
83 83
             $result = self::$problem->removeOptimization($params);
84 84
 
85
-            if ($result != null && $result['status'] == true) {
85
+            if ($result!=null && $result['status']==true) {
86 86
                 echo "The test optimization was removed <br>";
87 87
             } else {
88 88
                 echo "Cannot remove the test optimization <br>";
Please login to merge, or discard this patch.
UnitTestFiles/Test/OrderTests.php 2 patches
Indentation   +541 added lines, -541 removed lines patch added patch discarded remove patch
@@ -20,545 +20,545 @@
 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
-            [
157
-                'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
158
-                'cached_lat'                => 48.335991,
159
-                'cached_lng'                => 31.18287,
160
-                'address_alias'             => 'Auto test address',
161
-                'address_city'              => 'Philadelphia',
162
-                'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
163
-                'EXT_FIELD_first_name'      => 'Igor',
164
-                'EXT_FIELD_last_name'       => 'Progman',
165
-                'EXT_FIELD_email'           => '[email protected]',
166
-                'EXT_FIELD_phone'           => '380380380380',
167
-                'EXT_FIELD_custom_data'     => [
168
-                    0 => [
169
-                        'order_id'  => '10',
170
-                        'name'      => 'Bill Soul',
171
-                    ],
172
-                ],
173
-            ]
174
-        );
175
-    }
176
-
177
-    public function testGetOrders()
178
-    {
179
-        $order = new Order();
180
-
181
-        $orderParameters = Order::fromArray([
182
-            'offset'    => 0,
183
-            'limit'     => 5,
184
-        ]);
185
-
186
-        $response = $order->getOrders($orderParameters);
187
-
188
-        $this->assertNotNull($response);
189
-        $this->assertTrue(is_array($response));
190
-        $this->assertTrue(isset($response['total']));
191
-        $this->assertTrue(isset($response['results']));
192
-        $this->assertInstanceOf(
193
-            Order::class,
194
-            Order::fromArray($response['results'][0])
195
-        );
196
-    }
197
-
198
-    public function testCreateNewOrder()
199
-    {
200
-        $orderParameters = Order::fromArray([
201
-            'address_1'                 => '106 Liberty St, New York, NY 10006, USA',
202
-            'address_alias'             => 'BK Restaurant #: 2446',
203
-            'cached_lat'                => 40.709637,
204
-            'cached_lng'                => -74.011912,
205
-            'curbside_lat'              => 40.709637,
206
-            'curbside_lng'              => -74.011912,
207
-            'address_city'              => 'New York',
208
-            'EXT_FIELD_first_name'      => 'Lui',
209
-            'EXT_FIELD_last_name'       => 'Carol',
210
-            'EXT_FIELD_email'           => '[email protected]',
211
-            'EXT_FIELD_phone'           => '897946541',
212
-            'local_time_window_end'     => 39000,
213
-            'local_time_window_end_2'   => 46200,
214
-            'local_time_window_start'   => 37800,
215
-            'local_time_window_start_2' => 45000,
216
-            'local_timezone_string'     => 'America/New_York',
217
-            'order_icon'                => 'emoji/emoji-bank',
218
-        ]);
219
-
220
-        $order = new Order();
221
-
222
-        $response = $order->addOrder($orderParameters);
223
-
224
-        self::assertNotNull($response);
225
-        self::assertInstanceOf(Order::class, Order::fromArray($response));
226
-
227
-        self::$createdOrders[] = $response;
228
-    }
229
-
230
-    public function testAddOrdersToOptimization()
231
-    {
232
-        $body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_optimization_data.json'), true);
233
-
234
-        $optimizationProblemId = self::$createdProblems[0]->optimization_problem_id;
235
-
236
-        $orderParameters = [
237
-            'optimization_problem_id'   => $optimizationProblemId,
238
-            'redirect'                  => 0,
239
-            'device_type'               => 'web',
240
-            'addresses'                 => $body['addresses'],
241
-        ];
242
-
243
-        $order = new Order();
244
-
245
-        $response = $order->addOrder2Optimization($orderParameters);
246
-
247
-        self::assertNotNull($response);
248
-        self::assertInstanceOf(OptimizationProblem::class, OptimizationProblem::fromArray($response));
249
-    }
250
-
251
-    public function testAddOrdersToRoute()
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 testGetOrderByInsertedDate()
351
-    {
352
-        $orderParameters = Order::fromArray([
353
-            'day_added_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
354
-            'offset'            => 0,
355
-            'limit'             => 5,
356
-        ]);
357
-
358
-        $order = new Order();
359
-
360
-        $response = $order->getOrder($orderParameters);
361
-
362
-        $this->assertNotNull($response);
363
-        $this->assertTrue(is_array($response));
364
-        $this->assertTrue(isset($response['total']));
365
-        $this->assertTrue(isset($response['results']));
366
-        $this->assertInstanceOf(
367
-            Order::class,
368
-            Order::fromArray($response['results'][0])
369
-        );
370
-    }
371
-
372
-    public function testGetOrderByScheduledDate()
373
-    {
374
-        $orderParameters = Order::fromArray([
375
-            'day_scheduled_for_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
376
-            'offset'                    => 0,
377
-            'limit'                     => 5,
378
-        ]);
379
-
380
-        $order = new Order();
381
-
382
-        $response = $order->getOrder($orderParameters);
383
-
384
-        $this->assertNotNull($response);
385
-        $this->assertTrue(is_array($response));
386
-        $this->assertTrue(isset($response['total']));
387
-        $this->assertTrue(isset($response['results']));
388
-        $this->assertInstanceOf(
389
-            Order::class,
390
-            Order::fromArray($response['results'][0])
391
-        );
392
-    }
393
-
394
-    public function testGetOrdersByCustomFields()
395
-    {
396
-        $orderParameters = Order::fromArray([
397
-            'fields'    => 'order_id,member_id',
398
-            'offset'    => 0,
399
-            'limit'     => 5,
400
-        ]);
401
-
402
-        $order = new Order();
403
-
404
-        $response = $order->getOrder($orderParameters);
405
-
406
-        $response = $order->getOrder($orderParameters);
407
-
408
-        $this->assertNotNull($response);
409
-        $this->assertTrue(is_array($response));
410
-        $this->assertTrue(isset($response['total']));
411
-        $this->assertTrue(isset($response['results']));
412
-        $this->assertTrue(isset($response['fields']));
413
-        $this->assertInstanceOf(
414
-            Order::class,
415
-            Order::fromArray($response['results'][0])
416
-        );
417
-    }
418
-
419
-    public function testGetOrdersByScheduleFilter()
420
-    {
421
-        $orderParameters = Order::fromArray([
422
-            'limit'  => 5,
423
-            'filter' => [
424
-                'display'               => 'all',
425
-                'scheduled_for_YYMMDD'  => [
426
-                    date('Y-m-d', strtotime('-1 days')),
427
-                    date('Y-m-d', strtotime('1 days'))
428
-                ]
429
-            ]
430
-        ]);
431
-
432
-        $order = new Order();
433
-
434
-        $response = $order->getOrder($orderParameters);
435
-
436
-        $this->assertNotNull($response);
437
-        $this->assertTrue(is_array($response));
438
-        $this->assertTrue(isset($response['total']));
439
-        $this->assertTrue(isset($response['results']));
440
-        $this->assertInstanceOf(
441
-            Order::class,
442
-            Order::fromArray($response['results'][0])
443
-        );
444
-    }
445
-
446
-    public function testGetOrdersBySpecifiedText()
447
-    {
448
-        $orderParameters = Order::fromArray([
449
-            'query'     => 'Auto test',
450
-            'offset'    => 0,
451
-            'limit'     => 5,
452
-        ]);
453
-
454
-        $order = new Order();
455
-
456
-        $response = $order->getOrder($orderParameters);
457
-
458
-        $this->assertNotNull($response);
459
-        $this->assertTrue(is_array($response));
460
-        $this->assertTrue(isset($response['total']));
461
-        $this->assertTrue(isset($response['results']));
462
-        $this->assertInstanceOf(
463
-            Order::class,
464
-            Order::fromArray($response['results'][0])
465
-        );
466
-    }
467
-
468
-    public function testUpdateOrder()
469
-    {
470
-        $order = new Order();
471
-
472
-        // Update the order
473
-        self::$createdOrders[0]['address_2'] = 'Lviv';
474
-        self::$createdOrders[0]['EXT_FIELD_phone'] = '032268593';
475
-        self::$createdOrders[0]['EXT_FIELD_custom_data'] = [
476
-            0 => [
477
-                'customer_no' => '11',
478
-            ],
479
-        ];
480
-
481
-        $response = $order->updateOrder(self::$createdOrders[0]);
482
-
483
-        $this->assertNotNull($response);
484
-        $this->assertInstanceOf(Order::class, Order::fromArray($response));
485
-        $this->assertEquals('Lviv', $response['address_2']);
486
-        $this->assertEquals('032268593', $response['EXT_FIELD_phone']);
487
-        $this->assertEquals([
488
-                0 => '{"order_id":"10","name":"Bill Soul"}'
489
-            ],
490
-            $response['EXT_FIELD_custom_data']
491
-        );
492
-    }
493
-
494
-    public function testUpdateOrderWithCustomFiel()
495
-    {
496
-        $orderParameters = Order::fromArray([
497
-            'order_id'              => self::$createdOrders[0]['order_id'],
498
-            'custom_user_fields'    => [
499
-                OrderCustomField::fromArray([
500
-                    'order_custom_field_id'    => 93,
501
-                    'order_custom_field_value' => 'true'
502
-                ])
503
-            ]
504
-        ]);
505
-
506
-        $order = new Order();
507
-
508
-        $response = $order->updateOrder($orderParameters);
509
-
510
-        $this->assertNotNull($response);
511
-        $this->assertInstanceOf(Order::class, Order::fromArray($response));
512
-        $this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
513
-        $this->assertEquals(true, $response['custom_user_fields'][0]['order_custom_field_value']);
514
-    }
515
-
516
-    public static function tearDownAfterClass()
517
-    {
518
-        if (sizeof(self::$createdOrders)) {
519
-            $orderIDs = [];
520
-
521
-            foreach (self::$createdOrders as $ord) {
522
-                $orderIDs[] = $ord['order_id'];
523
-            }
524
-
525
-            $orderParameters = Order::fromArray([
526
-                'order_ids' => $orderIDs
527
-            ]);
528
-
529
-            $order = new Order();
530
-
531
-            $response = $order->removeOrder($orderParameters);
532
-
533
-            if (!is_null($response) &&
534
-                isset($response['status']) &&
535
-                $response['status']) {
536
-                echo "The test orders removed <br>";
537
-            }
538
-        }
539
-
540
-        if (sizeof(self::$createdProblems)>0) {
541
-            $optimizationProblemIDs = [];
542
-
543
-            foreach (self::$createdProblems as $problem) {
544
-                $optimizationProblemId = $problem->optimization_problem_id;
545
-
546
-                $optimizationProblemIDs[] = $optimizationProblemId;
547
-            }
548
-
549
-            $params = [
550
-                'optimization_problem_ids' => $optimizationProblemIDs,
551
-                'redirect'                 => 0,
552
-            ];
553
-
554
-            $problem = new OptimizationProblem();
555
-            $result = $problem->removeOptimization($params);
556
-
557
-            if ($result!=null && $result['status']==true) {
558
-                echo "The test optimizations were removed <br>";
559
-            } else {
560
-                echo "Cannot remove the test optimizations <br>";
561
-            }
562
-        }
563
-    }
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
+			[
157
+				'address_1'                 => '1358 E Luzerne St, Philadelphia, PA 19124, US',
158
+				'cached_lat'                => 48.335991,
159
+				'cached_lng'                => 31.18287,
160
+				'address_alias'             => 'Auto test address',
161
+				'address_city'              => 'Philadelphia',
162
+				'day_scheduled_for_YYMMDD'  => date('Y-m-d'),
163
+				'EXT_FIELD_first_name'      => 'Igor',
164
+				'EXT_FIELD_last_name'       => 'Progman',
165
+				'EXT_FIELD_email'           => '[email protected]',
166
+				'EXT_FIELD_phone'           => '380380380380',
167
+				'EXT_FIELD_custom_data'     => [
168
+					0 => [
169
+						'order_id'  => '10',
170
+						'name'      => 'Bill Soul',
171
+					],
172
+				],
173
+			]
174
+		);
175
+	}
176
+
177
+	public function testGetOrders()
178
+	{
179
+		$order = new Order();
180
+
181
+		$orderParameters = Order::fromArray([
182
+			'offset'    => 0,
183
+			'limit'     => 5,
184
+		]);
185
+
186
+		$response = $order->getOrders($orderParameters);
187
+
188
+		$this->assertNotNull($response);
189
+		$this->assertTrue(is_array($response));
190
+		$this->assertTrue(isset($response['total']));
191
+		$this->assertTrue(isset($response['results']));
192
+		$this->assertInstanceOf(
193
+			Order::class,
194
+			Order::fromArray($response['results'][0])
195
+		);
196
+	}
197
+
198
+	public function testCreateNewOrder()
199
+	{
200
+		$orderParameters = Order::fromArray([
201
+			'address_1'                 => '106 Liberty St, New York, NY 10006, USA',
202
+			'address_alias'             => 'BK Restaurant #: 2446',
203
+			'cached_lat'                => 40.709637,
204
+			'cached_lng'                => -74.011912,
205
+			'curbside_lat'              => 40.709637,
206
+			'curbside_lng'              => -74.011912,
207
+			'address_city'              => 'New York',
208
+			'EXT_FIELD_first_name'      => 'Lui',
209
+			'EXT_FIELD_last_name'       => 'Carol',
210
+			'EXT_FIELD_email'           => '[email protected]',
211
+			'EXT_FIELD_phone'           => '897946541',
212
+			'local_time_window_end'     => 39000,
213
+			'local_time_window_end_2'   => 46200,
214
+			'local_time_window_start'   => 37800,
215
+			'local_time_window_start_2' => 45000,
216
+			'local_timezone_string'     => 'America/New_York',
217
+			'order_icon'                => 'emoji/emoji-bank',
218
+		]);
219
+
220
+		$order = new Order();
221
+
222
+		$response = $order->addOrder($orderParameters);
223
+
224
+		self::assertNotNull($response);
225
+		self::assertInstanceOf(Order::class, Order::fromArray($response));
226
+
227
+		self::$createdOrders[] = $response;
228
+	}
229
+
230
+	public function testAddOrdersToOptimization()
231
+	{
232
+		$body = json_decode(file_get_contents(dirname(__FILE__).'/data/add_order_to_optimization_data.json'), true);
233
+
234
+		$optimizationProblemId = self::$createdProblems[0]->optimization_problem_id;
235
+
236
+		$orderParameters = [
237
+			'optimization_problem_id'   => $optimizationProblemId,
238
+			'redirect'                  => 0,
239
+			'device_type'               => 'web',
240
+			'addresses'                 => $body['addresses'],
241
+		];
242
+
243
+		$order = new Order();
244
+
245
+		$response = $order->addOrder2Optimization($orderParameters);
246
+
247
+		self::assertNotNull($response);
248
+		self::assertInstanceOf(OptimizationProblem::class, OptimizationProblem::fromArray($response));
249
+	}
250
+
251
+	public function testAddOrdersToRoute()
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 testGetOrderByInsertedDate()
351
+	{
352
+		$orderParameters = Order::fromArray([
353
+			'day_added_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
354
+			'offset'            => 0,
355
+			'limit'             => 5,
356
+		]);
357
+
358
+		$order = new Order();
359
+
360
+		$response = $order->getOrder($orderParameters);
361
+
362
+		$this->assertNotNull($response);
363
+		$this->assertTrue(is_array($response));
364
+		$this->assertTrue(isset($response['total']));
365
+		$this->assertTrue(isset($response['results']));
366
+		$this->assertInstanceOf(
367
+			Order::class,
368
+			Order::fromArray($response['results'][0])
369
+		);
370
+	}
371
+
372
+	public function testGetOrderByScheduledDate()
373
+	{
374
+		$orderParameters = Order::fromArray([
375
+			'day_scheduled_for_YYMMDD'  => date('Y-m-d', strtotime('0 days')),
376
+			'offset'                    => 0,
377
+			'limit'                     => 5,
378
+		]);
379
+
380
+		$order = new Order();
381
+
382
+		$response = $order->getOrder($orderParameters);
383
+
384
+		$this->assertNotNull($response);
385
+		$this->assertTrue(is_array($response));
386
+		$this->assertTrue(isset($response['total']));
387
+		$this->assertTrue(isset($response['results']));
388
+		$this->assertInstanceOf(
389
+			Order::class,
390
+			Order::fromArray($response['results'][0])
391
+		);
392
+	}
393
+
394
+	public function testGetOrdersByCustomFields()
395
+	{
396
+		$orderParameters = Order::fromArray([
397
+			'fields'    => 'order_id,member_id',
398
+			'offset'    => 0,
399
+			'limit'     => 5,
400
+		]);
401
+
402
+		$order = new Order();
403
+
404
+		$response = $order->getOrder($orderParameters);
405
+
406
+		$response = $order->getOrder($orderParameters);
407
+
408
+		$this->assertNotNull($response);
409
+		$this->assertTrue(is_array($response));
410
+		$this->assertTrue(isset($response['total']));
411
+		$this->assertTrue(isset($response['results']));
412
+		$this->assertTrue(isset($response['fields']));
413
+		$this->assertInstanceOf(
414
+			Order::class,
415
+			Order::fromArray($response['results'][0])
416
+		);
417
+	}
418
+
419
+	public function testGetOrdersByScheduleFilter()
420
+	{
421
+		$orderParameters = Order::fromArray([
422
+			'limit'  => 5,
423
+			'filter' => [
424
+				'display'               => 'all',
425
+				'scheduled_for_YYMMDD'  => [
426
+					date('Y-m-d', strtotime('-1 days')),
427
+					date('Y-m-d', strtotime('1 days'))
428
+				]
429
+			]
430
+		]);
431
+
432
+		$order = new Order();
433
+
434
+		$response = $order->getOrder($orderParameters);
435
+
436
+		$this->assertNotNull($response);
437
+		$this->assertTrue(is_array($response));
438
+		$this->assertTrue(isset($response['total']));
439
+		$this->assertTrue(isset($response['results']));
440
+		$this->assertInstanceOf(
441
+			Order::class,
442
+			Order::fromArray($response['results'][0])
443
+		);
444
+	}
445
+
446
+	public function testGetOrdersBySpecifiedText()
447
+	{
448
+		$orderParameters = Order::fromArray([
449
+			'query'     => 'Auto test',
450
+			'offset'    => 0,
451
+			'limit'     => 5,
452
+		]);
453
+
454
+		$order = new Order();
455
+
456
+		$response = $order->getOrder($orderParameters);
457
+
458
+		$this->assertNotNull($response);
459
+		$this->assertTrue(is_array($response));
460
+		$this->assertTrue(isset($response['total']));
461
+		$this->assertTrue(isset($response['results']));
462
+		$this->assertInstanceOf(
463
+			Order::class,
464
+			Order::fromArray($response['results'][0])
465
+		);
466
+	}
467
+
468
+	public function testUpdateOrder()
469
+	{
470
+		$order = new Order();
471
+
472
+		// Update the order
473
+		self::$createdOrders[0]['address_2'] = 'Lviv';
474
+		self::$createdOrders[0]['EXT_FIELD_phone'] = '032268593';
475
+		self::$createdOrders[0]['EXT_FIELD_custom_data'] = [
476
+			0 => [
477
+				'customer_no' => '11',
478
+			],
479
+		];
480
+
481
+		$response = $order->updateOrder(self::$createdOrders[0]);
482
+
483
+		$this->assertNotNull($response);
484
+		$this->assertInstanceOf(Order::class, Order::fromArray($response));
485
+		$this->assertEquals('Lviv', $response['address_2']);
486
+		$this->assertEquals('032268593', $response['EXT_FIELD_phone']);
487
+		$this->assertEquals([
488
+				0 => '{"order_id":"10","name":"Bill Soul"}'
489
+			],
490
+			$response['EXT_FIELD_custom_data']
491
+		);
492
+	}
493
+
494
+	public function testUpdateOrderWithCustomFiel()
495
+	{
496
+		$orderParameters = Order::fromArray([
497
+			'order_id'              => self::$createdOrders[0]['order_id'],
498
+			'custom_user_fields'    => [
499
+				OrderCustomField::fromArray([
500
+					'order_custom_field_id'    => 93,
501
+					'order_custom_field_value' => 'true'
502
+				])
503
+			]
504
+		]);
505
+
506
+		$order = new Order();
507
+
508
+		$response = $order->updateOrder($orderParameters);
509
+
510
+		$this->assertNotNull($response);
511
+		$this->assertInstanceOf(Order::class, Order::fromArray($response));
512
+		$this->assertEquals(93, $response['custom_user_fields'][0]['order_custom_field_id']);
513
+		$this->assertEquals(true, $response['custom_user_fields'][0]['order_custom_field_value']);
514
+	}
515
+
516
+	public static function tearDownAfterClass()
517
+	{
518
+		if (sizeof(self::$createdOrders)) {
519
+			$orderIDs = [];
520
+
521
+			foreach (self::$createdOrders as $ord) {
522
+				$orderIDs[] = $ord['order_id'];
523
+			}
524
+
525
+			$orderParameters = Order::fromArray([
526
+				'order_ids' => $orderIDs
527
+			]);
528
+
529
+			$order = new Order();
530
+
531
+			$response = $order->removeOrder($orderParameters);
532
+
533
+			if (!is_null($response) &&
534
+				isset($response['status']) &&
535
+				$response['status']) {
536
+				echo "The test orders removed <br>";
537
+			}
538
+		}
539
+
540
+		if (sizeof(self::$createdProblems)>0) {
541
+			$optimizationProblemIDs = [];
542
+
543
+			foreach (self::$createdProblems as $problem) {
544
+				$optimizationProblemId = $problem->optimization_problem_id;
545
+
546
+				$optimizationProblemIDs[] = $optimizationProblemId;
547
+			}
548
+
549
+			$params = [
550
+				'optimization_problem_ids' => $optimizationProblemIDs,
551
+				'redirect'                 => 0,
552
+			];
553
+
554
+			$problem = new OptimizationProblem();
555
+			$result = $problem->removeOptimization($params);
556
+
557
+			if ($result!=null && $result['status']==true) {
558
+				echo "The test optimizations were removed <br>";
559
+			} else {
560
+				echo "Cannot remove the test optimizations <br>";
561
+			}
562
+		}
563
+	}
564 564
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -324,8 +324,8 @@
 block discarded – undo
324 324
 
325 325
         self::assertNotNull($response);
326 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']);
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 329
 
330 330
         self::$createdOrders[] = $response;
331 331
     }
Please login to merge, or discard this patch.