@@ -8,85 +8,85 @@ |
||
8 | 8 | |
9 | 9 | class OptimizationProblemParams extends Common |
10 | 10 | { |
11 | - public $optimization_problem_id; |
|
12 | - public $reoptimize; |
|
13 | - public $addresses = array(); |
|
14 | - public $parameters; |
|
15 | - public $directions; |
|
16 | - public $format; |
|
17 | - public $route_path_output; |
|
18 | - public $optimized_callback_url; |
|
11 | + public $optimization_problem_id; |
|
12 | + public $reoptimize; |
|
13 | + public $addresses = array(); |
|
14 | + public $parameters; |
|
15 | + public $directions; |
|
16 | + public $format; |
|
17 | + public $route_path_output; |
|
18 | + public $optimized_callback_url; |
|
19 | 19 | |
20 | - public static function fromArray($params) |
|
21 | - { |
|
22 | - $param = new OptimizationProblemParams; |
|
23 | - if (!isset($params['addresses'])) { |
|
24 | - throw new BadParam('addresses must be provided.'); |
|
25 | - } |
|
20 | + public static function fromArray($params) |
|
21 | + { |
|
22 | + $param = new OptimizationProblemParams; |
|
23 | + if (!isset($params['addresses'])) { |
|
24 | + throw new BadParam('addresses must be provided.'); |
|
25 | + } |
|
26 | 26 | |
27 | - if (!isset($params['parameters'])) { |
|
28 | - throw new BadParam('parameters must be provided.'); |
|
29 | - } |
|
27 | + if (!isset($params['parameters'])) { |
|
28 | + throw new BadParam('parameters must be provided.'); |
|
29 | + } |
|
30 | 30 | |
31 | - if ($params['parameters'] instanceof RouteParameters) { |
|
32 | - $param->setParameters($params['parameters']); |
|
33 | - } else { |
|
34 | - $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
|
35 | - } |
|
31 | + if ($params['parameters'] instanceof RouteParameters) { |
|
32 | + $param->setParameters($params['parameters']); |
|
33 | + } else { |
|
34 | + $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
|
35 | + } |
|
36 | 36 | |
37 | - foreach($params['addresses'] as $address) { |
|
38 | - if (!($address instanceof Address)) { |
|
39 | - $address = Address::fromArray($address); |
|
40 | - } |
|
41 | - $param->addAddress($address); |
|
42 | - } |
|
37 | + foreach($params['addresses'] as $address) { |
|
38 | + if (!($address instanceof Address)) { |
|
39 | + $address = Address::fromArray($address); |
|
40 | + } |
|
41 | + $param->addAddress($address); |
|
42 | + } |
|
43 | 43 | |
44 | - $param->directions = self::getValue($params, 'directions'); |
|
45 | - $param->format = self::getValue($params, 'format'); |
|
46 | - $param->route_path_output = self::getValue($params, 'route_path_output'); |
|
47 | - $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url'); |
|
48 | - $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id'); |
|
49 | - $param->reoptimize = self::getValue($params, 'reoptimize'); |
|
44 | + $param->directions = self::getValue($params, 'directions'); |
|
45 | + $param->format = self::getValue($params, 'format'); |
|
46 | + $param->route_path_output = self::getValue($params, 'route_path_output'); |
|
47 | + $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url'); |
|
48 | + $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id'); |
|
49 | + $param->reoptimize = self::getValue($params, 'reoptimize'); |
|
50 | 50 | |
51 | - return $param; |
|
52 | - } |
|
51 | + return $param; |
|
52 | + } |
|
53 | 53 | |
54 | - public function __construct() |
|
55 | - { |
|
56 | - $this->parameters = new RouteParameters; |
|
57 | - } |
|
54 | + public function __construct() |
|
55 | + { |
|
56 | + $this->parameters = new RouteParameters; |
|
57 | + } |
|
58 | 58 | |
59 | - public function setParameters(RouteParameters $params) |
|
60 | - { |
|
61 | - $this->parameters = $params; |
|
62 | - return $this; |
|
63 | - } |
|
59 | + public function setParameters(RouteParameters $params) |
|
60 | + { |
|
61 | + $this->parameters = $params; |
|
62 | + return $this; |
|
63 | + } |
|
64 | 64 | |
65 | - public function addAddress(Address $address) |
|
66 | - { |
|
67 | - $this->addresses[] = $address; |
|
68 | - return $this; |
|
69 | - } |
|
65 | + public function addAddress(Address $address) |
|
66 | + { |
|
67 | + $this->addresses[] = $address; |
|
68 | + return $this; |
|
69 | + } |
|
70 | 70 | |
71 | - public function getAddressesArray() |
|
72 | - { |
|
73 | - $addresses = array(); |
|
74 | - foreach($this->addresses as $address) { |
|
75 | - $addresses[] = $address->toArray(); |
|
76 | - } |
|
77 | - return $addresses; |
|
78 | - } |
|
71 | + public function getAddressesArray() |
|
72 | + { |
|
73 | + $addresses = array(); |
|
74 | + foreach($this->addresses as $address) { |
|
75 | + $addresses[] = $address->toArray(); |
|
76 | + } |
|
77 | + return $addresses; |
|
78 | + } |
|
79 | 79 | |
80 | - public function getParametersArray() |
|
81 | - { |
|
82 | - return $this->parameters->toArray(); |
|
83 | - } |
|
80 | + public function getParametersArray() |
|
81 | + { |
|
82 | + return $this->parameters->toArray(); |
|
83 | + } |
|
84 | 84 | |
85 | - public function setAddresses(array $addresses) |
|
86 | - { |
|
87 | - foreach ($addresses as $address) { |
|
88 | - $this->addAddress($address); |
|
89 | - } |
|
90 | - return $this; |
|
91 | - } |
|
85 | + public function setAddresses(array $addresses) |
|
86 | + { |
|
87 | + foreach ($addresses as $address) { |
|
88 | + $this->addAddress($address); |
|
89 | + } |
|
90 | + return $this; |
|
91 | + } |
|
92 | 92 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
35 | 35 | } |
36 | 36 | |
37 | - foreach($params['addresses'] as $address) { |
|
37 | + foreach ($params['addresses'] as $address) { |
|
38 | 38 | if (!($address instanceof Address)) { |
39 | 39 | $address = Address::fromArray($address); |
40 | 40 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public function getAddressesArray() |
72 | 72 | { |
73 | 73 | $addresses = array(); |
74 | - foreach($this->addresses as $address) { |
|
74 | + foreach ($this->addresses as $address) { |
|
75 | 75 | $addresses[] = $address->toArray(); |
76 | 76 | } |
77 | 77 | return $addresses; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | //and finally send curl request |
111 | 111 | $result = curl_exec_redir($this->ch); |
112 | 112 | if(curl_errno($this->ch)) |
113 | - { |
|
113 | + { |
|
114 | 114 | if($this->debug) |
115 | 115 | { |
116 | 116 | echo "Error Occured in Curl\n"; |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | return false; |
121 | 121 | } |
122 | 122 | else |
123 | - { |
|
123 | + { |
|
124 | 124 | return $result; |
125 | 125 | } |
126 | 126 | } |
@@ -372,53 +372,53 @@ discard block |
||
372 | 372 | */ |
373 | 373 | function curl_exec_redir($ch) |
374 | 374 | { |
375 | - static $curl_loops = 0; |
|
376 | - static $curl_max_loops = 20; |
|
377 | - if ($curl_loops++ >= $curl_max_loops) |
|
378 | - { |
|
379 | - $curl_loops = 0; |
|
380 | - return FALSE; |
|
381 | - } |
|
382 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); |
|
383 | - curl_setopt($ch, CURLOPT_HEADER, true); |
|
384 | - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
385 | - curl_setopt($ch, CURLOPT_VERBOSE, false); |
|
386 | - $data = curl_exec($ch); |
|
387 | - $data = str_replace("\r", "\n", str_replace("\r\n", "\n", $data)); |
|
388 | - list($header, $data) = explode("\n\n", $data, 2); |
|
389 | - $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
375 | + static $curl_loops = 0; |
|
376 | + static $curl_max_loops = 20; |
|
377 | + if ($curl_loops++ >= $curl_max_loops) |
|
378 | + { |
|
379 | + $curl_loops = 0; |
|
380 | + return FALSE; |
|
381 | + } |
|
382 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); |
|
383 | + curl_setopt($ch, CURLOPT_HEADER, true); |
|
384 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
|
385 | + curl_setopt($ch, CURLOPT_VERBOSE, false); |
|
386 | + $data = curl_exec($ch); |
|
387 | + $data = str_replace("\r", "\n", str_replace("\r\n", "\n", $data)); |
|
388 | + list($header, $data) = explode("\n\n", $data, 2); |
|
389 | + $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
390 | 390 | |
391 | - //echo "*** Got HTTP code: $http_code ***\n"; |
|
392 | - //echo "** Got headers: \n$header\n\n"; |
|
391 | + //echo "*** Got HTTP code: $http_code ***\n"; |
|
392 | + //echo "** Got headers: \n$header\n\n"; |
|
393 | 393 | |
394 | - if ( $http_code == 301 || $http_code == 302 ) |
|
395 | - { |
|
396 | - // If we're redirected, we should revert to GET |
|
394 | + if ( $http_code == 301 || $http_code == 302 ) |
|
395 | + { |
|
396 | + // If we're redirected, we should revert to GET |
|
397 | 397 | curl_setopt($ch, CURLOPT_HTTPGET,true); |
398 | 398 | |
399 | - $matches = array(); |
|
400 | - preg_match('/Location:\s*(.*?)(\n|$)/i', $header, $matches); |
|
401 | - $url = @parse_url(trim($matches[1])); |
|
402 | - if (!$url) |
|
403 | - { |
|
404 | - //couldn't process the url to redirect to |
|
405 | - $curl_loops = 0; |
|
406 | - return $data; |
|
407 | - } |
|
408 | - $last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); |
|
409 | - if (empty($url['scheme'])) |
|
410 | - $url['scheme'] = $last_url['scheme']; |
|
411 | - if (empty($url['host'])) |
|
412 | - $url['host'] = $last_url['host']; |
|
413 | - if (empty($url['path'])) |
|
414 | - $url['path'] = $last_url['path']; |
|
415 | - $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (!empty($url['query'])?'?'.$url['query']:''); |
|
416 | - //echo "Being redirected to $new_url\n"; |
|
417 | - curl_setopt($ch, CURLOPT_URL, $new_url); |
|
418 | - return curl_exec_redir($ch); |
|
419 | - } else { |
|
420 | - $curl_loops=0; |
|
421 | - return $data; |
|
422 | - } |
|
399 | + $matches = array(); |
|
400 | + preg_match('/Location:\s*(.*?)(\n|$)/i', $header, $matches); |
|
401 | + $url = @parse_url(trim($matches[1])); |
|
402 | + if (!$url) |
|
403 | + { |
|
404 | + //couldn't process the url to redirect to |
|
405 | + $curl_loops = 0; |
|
406 | + return $data; |
|
407 | + } |
|
408 | + $last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); |
|
409 | + if (empty($url['scheme'])) |
|
410 | + $url['scheme'] = $last_url['scheme']; |
|
411 | + if (empty($url['host'])) |
|
412 | + $url['host'] = $last_url['host']; |
|
413 | + if (empty($url['path'])) |
|
414 | + $url['path'] = $last_url['path']; |
|
415 | + $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (!empty($url['query'])?'?'.$url['query']:''); |
|
416 | + //echo "Being redirected to $new_url\n"; |
|
417 | + curl_setopt($ch, CURLOPT_URL, $new_url); |
|
418 | + return curl_exec_redir($ch); |
|
419 | + } else { |
|
420 | + $curl_loops=0; |
|
421 | + return $data; |
|
422 | + } |
|
423 | 423 | } |
424 | 424 | ?> |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | |
4 | 4 | class Curl_HTTP_Client |
5 | 5 | { |
6 | - var $ch ; |
|
6 | + var $ch; |
|
7 | 7 | var $debug = false; |
8 | 8 | var $error_msg; |
9 | 9 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | //set error in case http return code bigger than 300 |
22 | 22 | curl_setopt($this->ch, CURLOPT_FAILONERROR, true); |
23 | 23 | // use gzip if possible |
24 | - curl_setopt($this->ch,CURLOPT_ENCODING , 'gzip, deflate'); |
|
24 | + curl_setopt($this->ch, CURLOPT_ENCODING, 'gzip, deflate'); |
|
25 | 25 | // do not veryfy ssl |
26 | 26 | // this is important for windows |
27 | 27 | // as well for being able to access pages with non valid cert |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @param string pass |
34 | 34 | * @access public |
35 | 35 | */ |
36 | - function set_credentials($username,$password) |
|
36 | + function set_credentials($username, $password) |
|
37 | 37 | { |
38 | 38 | curl_setopt($this->ch, CURLOPT_USERPWD, "$username:$password"); |
39 | 39 | } |
@@ -83,22 +83,22 @@ discard block |
||
83 | 83 | * @return string data |
84 | 84 | * @access public |
85 | 85 | */ |
86 | - function send_post_data($url, $postdata, $ip=null, $timeout=10) |
|
86 | + function send_post_data($url, $postdata, $ip = null, $timeout = 10) |
|
87 | 87 | { |
88 | 88 | |
89 | 89 | //set various curl options first |
90 | 90 | // set url to post to |
91 | - curl_setopt($this->ch, CURLOPT_URL,$url); |
|
91 | + curl_setopt($this->ch, CURLOPT_URL, $url); |
|
92 | 92 | // return into a variable rather than displaying it |
93 | - curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,true); |
|
93 | + curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); |
|
94 | 94 | //bind to specific ip address if it is sent trough arguments |
95 | - if($ip) |
|
95 | + if ($ip) |
|
96 | 96 | { |
97 | - if($this->debug) |
|
97 | + if ($this->debug) |
|
98 | 98 | { |
99 | 99 | echo "Binding to ip $ip\n"; |
100 | 100 | } |
101 | - curl_setopt($this->ch,CURLOPT_INTERFACE,$ip); |
|
101 | + curl_setopt($this->ch, CURLOPT_INTERFACE, $ip); |
|
102 | 102 | } |
103 | 103 | //set curl function timeout to $timeout |
104 | 104 | curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout); |
@@ -109,13 +109,13 @@ discard block |
||
109 | 109 | curl_setopt($this->ch, CURLOPT_POSTFIELDS, $postdata); |
110 | 110 | //and finally send curl request |
111 | 111 | $result = curl_exec_redir($this->ch); |
112 | - if(curl_errno($this->ch)) |
|
112 | + if (curl_errno($this->ch)) |
|
113 | 113 | { |
114 | - if($this->debug) |
|
114 | + if ($this->debug) |
|
115 | 115 | { |
116 | 116 | echo "Error Occured in Curl\n"; |
117 | - echo "Error number: " .curl_errno($this->ch) ."\n"; |
|
118 | - echo "Error message: " .curl_error($this->ch)."\n"; |
|
117 | + echo "Error number: ".curl_errno($this->ch)."\n"; |
|
118 | + echo "Error message: ".curl_error($this->ch)."\n"; |
|
119 | 119 | } |
120 | 120 | return false; |
121 | 121 | } |
@@ -133,35 +133,35 @@ discard block |
||
133 | 133 | * @return string data |
134 | 134 | * @access public |
135 | 135 | */ |
136 | - function fetch_url($url, $ip=null, $timeout=5) |
|
136 | + function fetch_url($url, $ip = null, $timeout = 5) |
|
137 | 137 | { |
138 | 138 | // set url to post to |
139 | - curl_setopt($this->ch, CURLOPT_URL,$url); |
|
139 | + curl_setopt($this->ch, CURLOPT_URL, $url); |
|
140 | 140 | |
141 | 141 | //set method to get |
142 | - curl_setopt($this->ch, CURLOPT_HTTPGET,true); |
|
142 | + curl_setopt($this->ch, CURLOPT_HTTPGET, true); |
|
143 | 143 | // return into a variable rather than displaying it |
144 | - curl_setopt($this->ch, CURLOPT_RETURNTRANSFER,true); |
|
144 | + curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); |
|
145 | 145 | //bind to specific ip address if it is sent trough arguments |
146 | - if($ip) |
|
146 | + if ($ip) |
|
147 | 147 | { |
148 | - if($this->debug) |
|
148 | + if ($this->debug) |
|
149 | 149 | { |
150 | 150 | echo "Binding to ip $ip\n"; |
151 | 151 | } |
152 | - curl_setopt($this->ch,CURLOPT_INTERFACE,$ip); |
|
152 | + curl_setopt($this->ch, CURLOPT_INTERFACE, $ip); |
|
153 | 153 | } |
154 | 154 | //set curl function timeout to $timeout |
155 | 155 | curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout); |
156 | 156 | //and finally send curl request |
157 | 157 | $result = curl_exec_redir($this->ch); |
158 | - if(curl_errno($this->ch)) |
|
158 | + if (curl_errno($this->ch)) |
|
159 | 159 | { |
160 | - if($this->debug) |
|
160 | + if ($this->debug) |
|
161 | 161 | { |
162 | 162 | echo "Error Occured in Curl\n"; |
163 | - echo "Error number: " .curl_errno($this->ch) ."\n"; |
|
164 | - echo "Error message: " .curl_error($this->ch)."\n"; |
|
163 | + echo "Error number: ".curl_errno($this->ch)."\n"; |
|
164 | + echo "Error message: ".curl_error($this->ch)."\n"; |
|
165 | 165 | } |
166 | 166 | return false; |
167 | 167 | } |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | * @return boolean true on success false othervise |
181 | 181 | * @access public |
182 | 182 | */ |
183 | - function fetch_into_file($url, $fp, $ip=null, $timeout=5) |
|
183 | + function fetch_into_file($url, $fp, $ip = null, $timeout = 5) |
|
184 | 184 | { |
185 | 185 | // set url to post to |
186 | - curl_setopt($this->ch, CURLOPT_URL,$url); |
|
186 | + curl_setopt($this->ch, CURLOPT_URL, $url); |
|
187 | 187 | //set method to get |
188 | 188 | curl_setopt($this->ch, CURLOPT_HTTPGET, true); |
189 | 189 | // store data into file rather than displaying it |
190 | 190 | curl_setopt($this->ch, CURLOPT_FILE, $fp); |
191 | 191 | //bind to specific ip address if it is sent trough arguments |
192 | - if($ip) |
|
192 | + if ($ip) |
|
193 | 193 | { |
194 | - if($this->debug) |
|
194 | + if ($this->debug) |
|
195 | 195 | { |
196 | 196 | echo "Binding to ip $ip\n"; |
197 | 197 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout); |
202 | 202 | //and finally send curl request |
203 | 203 | $result = curl_exec_redir($this->ch); |
204 | - if(curl_errno($this->ch)) |
|
204 | + if (curl_errno($this->ch)) |
|
205 | 205 | { |
206 | - if($this->debug) |
|
206 | + if ($this->debug) |
|
207 | 207 | { |
208 | 208 | echo "Error Occured in Curl\n"; |
209 | - echo "Error number: " .curl_errno($this->ch) ."\n"; |
|
210 | - echo "Error message: " .curl_error($this->ch)."\n"; |
|
209 | + echo "Error number: ".curl_errno($this->ch)."\n"; |
|
210 | + echo "Error message: ".curl_error($this->ch)."\n"; |
|
211 | 211 | } |
212 | 212 | return false; |
213 | 213 | } |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * @return string data |
229 | 229 | * @access public |
230 | 230 | */ |
231 | - function send_multipart_post_data($url, $postdata, $file_field_array=array(), $ip=null, $timeout=30) |
|
231 | + function send_multipart_post_data($url, $postdata, $file_field_array = array(), $ip = null, $timeout = 30) |
|
232 | 232 | { |
233 | 233 | //set various curl options first |
234 | 234 | // set url to post to |
@@ -236,13 +236,13 @@ discard block |
||
236 | 236 | // return into a variable rather than displaying it |
237 | 237 | curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); |
238 | 238 | //bind to specific ip address if it is sent trough arguments |
239 | - if($ip) |
|
239 | + if ($ip) |
|
240 | 240 | { |
241 | - if($this->debug) |
|
241 | + if ($this->debug) |
|
242 | 242 | { |
243 | 243 | echo "Binding to ip $ip\n"; |
244 | 244 | } |
245 | - curl_setopt($this->ch,CURLOPT_INTERFACE,$ip); |
|
245 | + curl_setopt($this->ch, CURLOPT_INTERFACE, $ip); |
|
246 | 246 | } |
247 | 247 | //set curl function timeout to $timeout |
248 | 248 | curl_setopt($this->ch, CURLOPT_TIMEOUT, $timeout); |
@@ -257,28 +257,28 @@ discard block |
||
257 | 257 | //generate post string |
258 | 258 | $post_array = array(); |
259 | 259 | $post_string_array = array(); |
260 | - if(!is_array($postdata)) |
|
260 | + if (!is_array($postdata)) |
|
261 | 261 | { |
262 | 262 | return false; |
263 | 263 | } |
264 | - foreach($postdata as $key=>$value) |
|
264 | + foreach ($postdata as $key=>$value) |
|
265 | 265 | { |
266 | 266 | $post_array[$key] = $value; |
267 | 267 | $post_string_array[] = urlencode($key)."=".urlencode($value); |
268 | 268 | } |
269 | - $post_string = implode("&",$post_string_array); |
|
270 | - if($this->debug) |
|
269 | + $post_string = implode("&", $post_string_array); |
|
270 | + if ($this->debug) |
|
271 | 271 | { |
272 | 272 | echo "Post String: $post_string\n"; |
273 | 273 | } |
274 | 274 | // set post string |
275 | 275 | //curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_string); |
276 | 276 | // set multipart form data - file array field-value pairs |
277 | - if(!empty($file_field_array)) |
|
277 | + if (!empty($file_field_array)) |
|
278 | 278 | { |
279 | - foreach($file_field_array as $var_name => $var_value) |
|
279 | + foreach ($file_field_array as $var_name => $var_value) |
|
280 | 280 | { |
281 | - if(strpos(PHP_OS, "WIN") !== false) $var_value = str_replace("/", "\\", $var_value); // win hack |
|
281 | + if (strpos(PHP_OS, "WIN")!==false) $var_value = str_replace("/", "\\", $var_value); // win hack |
|
282 | 282 | $file_field_array[$var_name] = "@".$var_value; |
283 | 283 | } |
284 | 284 | } |
@@ -287,13 +287,13 @@ discard block |
||
287 | 287 | curl_setopt($this->ch, CURLOPT_POSTFIELDS, $result_post); |
288 | 288 | //and finally send curl request |
289 | 289 | $result = curl_exec_redir($this->ch); |
290 | - if(curl_errno($this->ch)) |
|
290 | + if (curl_errno($this->ch)) |
|
291 | 291 | { |
292 | - if($this->debug) |
|
292 | + if ($this->debug) |
|
293 | 293 | { |
294 | 294 | echo "Error Occured in Curl\n"; |
295 | - echo "Error number: " .curl_errno($this->ch) ."\n"; |
|
296 | - echo "Error message: " .curl_error($this->ch)."\n"; |
|
295 | + echo "Error number: ".curl_errno($this->ch)."\n"; |
|
296 | + echo "Error message: ".curl_error($this->ch)."\n"; |
|
297 | 297 | } |
298 | 298 | return false; |
299 | 299 | } |
@@ -310,8 +310,8 @@ discard block |
||
310 | 310 | function store_cookies($cookie_file) |
311 | 311 | { |
312 | 312 | // use cookies on each request (cookies stored in $cookie_file) |
313 | - curl_setopt ($this->ch, CURLOPT_COOKIEJAR, $cookie_file); |
|
314 | - curl_setopt ($this->ch, CURLOPT_COOKIEFILE, $cookie_file); |
|
313 | + curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookie_file); |
|
314 | + curl_setopt($this->ch, CURLOPT_COOKIEFILE, $cookie_file); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | */ |
322 | 322 | function set_cookie($cookie) |
323 | 323 | { |
324 | - curl_setopt ($this->ch, CURLOPT_COOKIE, $cookie); |
|
324 | + curl_setopt($this->ch, CURLOPT_COOKIE, $cookie); |
|
325 | 325 | } |
326 | 326 | /** |
327 | 327 | * Get last URL info |
@@ -349,8 +349,8 @@ discard block |
||
349 | 349 | */ |
350 | 350 | function get_error_msg() |
351 | 351 | { |
352 | - $err = "Error number: " .curl_errno($this->ch) ."\n"; |
|
353 | - $err .="Error message: " .curl_error($this->ch)."\n"; |
|
352 | + $err = "Error number: ".curl_errno($this->ch)."\n"; |
|
353 | + $err .= "Error message: ".curl_error($this->ch)."\n"; |
|
354 | 354 | return $err; |
355 | 355 | } |
356 | 356 | |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | { |
375 | 375 | static $curl_loops = 0; |
376 | 376 | static $curl_max_loops = 20; |
377 | - if ($curl_loops++ >= $curl_max_loops) |
|
377 | + if ($curl_loops++>=$curl_max_loops) |
|
378 | 378 | { |
379 | 379 | $curl_loops = 0; |
380 | 380 | return FALSE; |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | //echo "*** Got HTTP code: $http_code ***\n"; |
392 | 392 | //echo "** Got headers: \n$header\n\n"; |
393 | 393 | |
394 | - if ( $http_code == 301 || $http_code == 302 ) |
|
394 | + if ($http_code==301 || $http_code==302) |
|
395 | 395 | { |
396 | 396 | // If we're redirected, we should revert to GET |
397 | - curl_setopt($ch, CURLOPT_HTTPGET,true); |
|
397 | + curl_setopt($ch, CURLOPT_HTTPGET, true); |
|
398 | 398 | |
399 | 399 | $matches = array(); |
400 | 400 | preg_match('/Location:\s*(.*?)(\n|$)/i', $header, $matches); |
@@ -412,12 +412,12 @@ discard block |
||
412 | 412 | $url['host'] = $last_url['host']; |
413 | 413 | if (empty($url['path'])) |
414 | 414 | $url['path'] = $last_url['path']; |
415 | - $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (!empty($url['query'])?'?'.$url['query']:''); |
|
415 | + $new_url = $url['scheme'].'://'.$url['host'].$url['path'].(!empty($url['query']) ? '?'.$url['query'] : ''); |
|
416 | 416 | //echo "Being redirected to $new_url\n"; |
417 | 417 | curl_setopt($ch, CURLOPT_URL, $new_url); |
418 | 418 | return curl_exec_redir($ch); |
419 | 419 | } else { |
420 | - $curl_loops=0; |
|
420 | + $curl_loops = 0; |
|
421 | 421 | return $data; |
422 | 422 | } |
423 | 423 | } |
@@ -118,8 +118,7 @@ discard block |
||
118 | 118 | echo "Error message: " .curl_error($this->ch)."\n"; |
119 | 119 | } |
120 | 120 | return false; |
121 | - } |
|
122 | - else |
|
121 | + } else |
|
123 | 122 | { |
124 | 123 | return $result; |
125 | 124 | } |
@@ -164,8 +163,7 @@ discard block |
||
164 | 163 | echo "Error message: " .curl_error($this->ch)."\n"; |
165 | 164 | } |
166 | 165 | return false; |
167 | - } |
|
168 | - else |
|
166 | + } else |
|
169 | 167 | { |
170 | 168 | return $result; |
171 | 169 | } |
@@ -210,8 +208,7 @@ discard block |
||
210 | 208 | echo "Error message: " .curl_error($this->ch)."\n"; |
211 | 209 | } |
212 | 210 | return false; |
213 | - } |
|
214 | - else |
|
211 | + } else |
|
215 | 212 | { |
216 | 213 | return true; |
217 | 214 | } |
@@ -278,7 +275,10 @@ discard block |
||
278 | 275 | { |
279 | 276 | foreach($file_field_array as $var_name => $var_value) |
280 | 277 | { |
281 | - if(strpos(PHP_OS, "WIN") !== false) $var_value = str_replace("/", "\\", $var_value); // win hack |
|
278 | + if(strpos(PHP_OS, "WIN") !== false) { |
|
279 | + $var_value = str_replace("/", "\\", $var_value); |
|
280 | + } |
|
281 | + // win hack |
|
282 | 282 | $file_field_array[$var_name] = "@".$var_value; |
283 | 283 | } |
284 | 284 | } |
@@ -296,8 +296,7 @@ discard block |
||
296 | 296 | echo "Error message: " .curl_error($this->ch)."\n"; |
297 | 297 | } |
298 | 298 | return false; |
299 | - } |
|
300 | - else |
|
299 | + } else |
|
301 | 300 | { |
302 | 301 | return $result; |
303 | 302 | } |
@@ -406,12 +405,15 @@ discard block |
||
406 | 405 | return $data; |
407 | 406 | } |
408 | 407 | $last_url = parse_url(curl_getinfo($ch, CURLINFO_EFFECTIVE_URL)); |
409 | - if (empty($url['scheme'])) |
|
410 | - $url['scheme'] = $last_url['scheme']; |
|
411 | - if (empty($url['host'])) |
|
412 | - $url['host'] = $last_url['host']; |
|
413 | - if (empty($url['path'])) |
|
414 | - $url['path'] = $last_url['path']; |
|
408 | + if (empty($url['scheme'])) { |
|
409 | + $url['scheme'] = $last_url['scheme']; |
|
410 | + } |
|
411 | + if (empty($url['host'])) { |
|
412 | + $url['host'] = $last_url['host']; |
|
413 | + } |
|
414 | + if (empty($url['path'])) { |
|
415 | + $url['path'] = $last_url['path']; |
|
416 | + } |
|
415 | 417 | $new_url = $url['scheme'] . '://' . $url['host'] . $url['path'] . (!empty($url['query'])?'?'.$url['query']:''); |
416 | 418 | //echo "Being redirected to $new_url\n"; |
417 | 419 | curl_setopt($ch, CURLOPT_URL, $new_url); |
@@ -37,45 +37,45 @@ discard block |
||
37 | 37 | |
38 | 38 | public static function fromArray(array $params) { |
39 | 39 | $order= new Order(); |
40 | - foreach($params as $key => $value) { |
|
41 | - if (property_exists($order, $key)) { |
|
42 | - $order->{$key} = $value; |
|
43 | - } |
|
40 | + foreach($params as $key => $value) { |
|
41 | + if (property_exists($order, $key)) { |
|
42 | + $order->{$key} = $value; |
|
43 | + } |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return $order; |
47 | 47 | } |
48 | 48 | |
49 | 49 | public static function addOrder($params) |
50 | - { |
|
51 | - $response = Route4Me::makeRequst(array( |
|
52 | - 'url' => self::$apiUrl, |
|
53 | - 'method' => 'POST', |
|
54 | - 'body' => array( |
|
50 | + { |
|
51 | + $response = Route4Me::makeRequst(array( |
|
52 | + 'url' => self::$apiUrl, |
|
53 | + 'method' => 'POST', |
|
54 | + 'body' => array( |
|
55 | 55 | 'address_1' => isset($params->address_1) ? $params->address_1: null, |
56 | - 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
57 | - 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
58 | - 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
|
59 | - 'address_city' => isset($params->address_1) ? $params->address_city: null, |
|
60 | - 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null, |
|
61 | - 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null, |
|
62 | - 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null, |
|
63 | - 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null, |
|
64 | - 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null, |
|
56 | + 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
57 | + 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
58 | + 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
|
59 | + 'address_city' => isset($params->address_1) ? $params->address_city: null, |
|
60 | + 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null, |
|
61 | + 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null, |
|
62 | + 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null, |
|
63 | + 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null, |
|
64 | + 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null, |
|
65 | 65 | ) |
66 | - )); |
|
66 | + )); |
|
67 | 67 | |
68 | 68 | return $response; |
69 | 69 | } |
70 | 70 | |
71 | 71 | public static function addOrder2Route($params,$body) |
72 | - { |
|
73 | - $response = Route4Me::makeRequst(array( |
|
74 | - 'url' => self::$apiUrlRoute, |
|
75 | - 'method' => 'PUT', |
|
76 | - 'query' => array( |
|
72 | + { |
|
73 | + $response = Route4Me::makeRequst(array( |
|
74 | + 'url' => self::$apiUrlRoute, |
|
75 | + 'method' => 'PUT', |
|
76 | + 'query' => array( |
|
77 | 77 | 'route_id' => isset($params->route_id) ? $params->route_id: null, |
78 | - 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
78 | + 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
79 | 79 | ), |
80 | 80 | 'body' => (array)$body |
81 | 81 | )); |
@@ -84,13 +84,13 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | public static function addOrder2Destination($params,$body) |
87 | - { |
|
88 | - $response = Route4Me::makeRequst(array( |
|
89 | - 'url' => self::$apiUrlOpt, |
|
90 | - 'method' => 'PUT', |
|
91 | - 'query' => array( |
|
87 | + { |
|
88 | + $response = Route4Me::makeRequst(array( |
|
89 | + 'url' => self::$apiUrlOpt, |
|
90 | + 'method' => 'PUT', |
|
91 | + 'query' => array( |
|
92 | 92 | 'optimization_problem_id' => isset($params->optimization_problem_id) ? $params->optimization_problem_id: null, |
93 | - 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
93 | + 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
94 | 94 | ), |
95 | 95 | 'body' => (array)$body |
96 | 96 | )); |
@@ -99,58 +99,58 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | public static function getOrder($params) |
102 | - { |
|
103 | - $response = Route4Me::makeRequst(array( |
|
104 | - 'url' => self::$apiUrl, |
|
105 | - 'method' => 'GET', |
|
106 | - 'query' => array( |
|
102 | + { |
|
103 | + $response = Route4Me::makeRequst(array( |
|
104 | + 'url' => self::$apiUrl, |
|
105 | + 'method' => 'GET', |
|
106 | + 'query' => array( |
|
107 | 107 | 'order_id' => isset($params->order_id) ? $params->order_id: null, |
108 | 108 | ) |
109 | - )); |
|
109 | + )); |
|
110 | 110 | |
111 | 111 | return $response; |
112 | 112 | } |
113 | 113 | |
114 | 114 | public static function getOrders() |
115 | - { |
|
116 | - $response = Route4Me::makeRequst(array( |
|
117 | - 'url' => self::$apiUrl, |
|
118 | - 'method' => 'GET' |
|
119 | - )); |
|
115 | + { |
|
116 | + $response = Route4Me::makeRequst(array( |
|
117 | + 'url' => self::$apiUrl, |
|
118 | + 'method' => 'GET' |
|
119 | + )); |
|
120 | 120 | |
121 | 121 | return $response; |
122 | 122 | } |
123 | 123 | |
124 | 124 | public static function removeOrder($params) |
125 | - { |
|
126 | - $response = Route4Me::makeRequst(array( |
|
127 | - 'url' => self::$apiUrl, |
|
128 | - 'method' => 'DELETE', |
|
129 | - 'body' => array( |
|
125 | + { |
|
126 | + $response = Route4Me::makeRequst(array( |
|
127 | + 'url' => self::$apiUrl, |
|
128 | + 'method' => 'DELETE', |
|
129 | + 'body' => array( |
|
130 | 130 | 'order_ids' => isset($params->order_ids) ? $params->order_ids: null |
131 | 131 | ) |
132 | - )); |
|
132 | + )); |
|
133 | 133 | |
134 | 134 | return $response; |
135 | 135 | } |
136 | 136 | |
137 | 137 | public static function updateOrder($body) |
138 | - { |
|
139 | - $response = Route4Me::makeRequst(array( |
|
140 | - 'url' => self::$apiUrl, |
|
141 | - 'method' => 'PUT', |
|
142 | - 'body' => (array)$body |
|
143 | - )); |
|
138 | + { |
|
139 | + $response = Route4Me::makeRequst(array( |
|
140 | + 'url' => self::$apiUrl, |
|
141 | + 'method' => 'PUT', |
|
142 | + 'body' => (array)$body |
|
143 | + )); |
|
144 | 144 | |
145 | 145 | return $response; |
146 | 146 | } |
147 | 147 | |
148 | 148 | public static function searchOrder($params) |
149 | - { |
|
150 | - $response = Route4Me::makeRequst(array( |
|
151 | - 'url' => self::$apiUrl, |
|
152 | - 'method' => 'GET', |
|
153 | - 'query' => array( |
|
149 | + { |
|
150 | + $response = Route4Me::makeRequst(array( |
|
151 | + 'url' => self::$apiUrl, |
|
152 | + 'method' => 'GET', |
|
153 | + 'query' => array( |
|
154 | 154 | 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null, |
155 | 155 | 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null, |
156 | 156 | 'fields' => isset($params->fields) ? $params->fields: null, |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | 'limit' => isset($params->limit) ? $params->limit: null, |
159 | 159 | 'query' => isset($params->query) ? $params->query: null, |
160 | 160 | ) |
161 | - )); |
|
161 | + )); |
|
162 | 162 | |
163 | 163 | return $response; |
164 | 164 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | public $limit; |
34 | 34 | public $query; |
35 | 35 | |
36 | - public function __construct () { } |
|
36 | + public function __construct() { } |
|
37 | 37 | |
38 | 38 | public static function fromArray(array $params) { |
39 | - $order= new Order(); |
|
40 | - foreach($params as $key => $value) { |
|
39 | + $order = new Order(); |
|
40 | + foreach ($params as $key => $value) { |
|
41 | 41 | if (property_exists($order, $key)) { |
42 | 42 | $order->{$key} = $value; |
43 | 43 | } |
@@ -52,29 +52,29 @@ discard block |
||
52 | 52 | 'url' => self::$apiUrl, |
53 | 53 | 'method' => 'POST', |
54 | 54 | 'body' => array( |
55 | - 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
55 | + 'address_1' => isset($params->address_1) ? $params->address_1 : null, |
|
56 | 56 | 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
57 | 57 | 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
58 | 58 | 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
59 | - 'address_city' => isset($params->address_1) ? $params->address_city: null, |
|
60 | - 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null, |
|
61 | - 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null, |
|
62 | - 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null, |
|
63 | - 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null, |
|
64 | - 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null, |
|
59 | + 'address_city' => isset($params->address_1) ? $params->address_city : null, |
|
60 | + 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name : null, |
|
61 | + 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name : null, |
|
62 | + 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email : null, |
|
63 | + 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone : null, |
|
64 | + 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data : null, |
|
65 | 65 | ) |
66 | 66 | )); |
67 | 67 | |
68 | 68 | return $response; |
69 | 69 | } |
70 | 70 | |
71 | - public static function addOrder2Route($params,$body) |
|
71 | + public static function addOrder2Route($params, $body) |
|
72 | 72 | { |
73 | 73 | $response = Route4Me::makeRequst(array( |
74 | 74 | 'url' => self::$apiUrlRoute, |
75 | 75 | 'method' => 'PUT', |
76 | 76 | 'query' => array( |
77 | - 'route_id' => isset($params->route_id) ? $params->route_id: null, |
|
77 | + 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
78 | 78 | 'redirect' => isset($params->redirect) ? $params->redirect : null |
79 | 79 | ), |
80 | 80 | 'body' => (array)$body |
@@ -83,13 +83,13 @@ discard block |
||
83 | 83 | return $response; |
84 | 84 | } |
85 | 85 | |
86 | - public static function addOrder2Destination($params,$body) |
|
86 | + public static function addOrder2Destination($params, $body) |
|
87 | 87 | { |
88 | 88 | $response = Route4Me::makeRequst(array( |
89 | 89 | 'url' => self::$apiUrlOpt, |
90 | 90 | 'method' => 'PUT', |
91 | 91 | 'query' => array( |
92 | - 'optimization_problem_id' => isset($params->optimization_problem_id) ? $params->optimization_problem_id: null, |
|
92 | + 'optimization_problem_id' => isset($params->optimization_problem_id) ? $params->optimization_problem_id : null, |
|
93 | 93 | 'redirect' => isset($params->redirect) ? $params->redirect : null |
94 | 94 | ), |
95 | 95 | 'body' => (array)$body |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | 'url' => self::$apiUrl, |
105 | 105 | 'method' => 'GET', |
106 | 106 | 'query' => array( |
107 | - 'order_id' => isset($params->order_id) ? $params->order_id: null, |
|
107 | + 'order_id' => isset($params->order_id) ? $params->order_id : null, |
|
108 | 108 | ) |
109 | 109 | )); |
110 | 110 | |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | 'url' => self::$apiUrl, |
128 | 128 | 'method' => 'DELETE', |
129 | 129 | 'body' => array( |
130 | - 'order_ids' => isset($params->order_ids) ? $params->order_ids: null |
|
130 | + 'order_ids' => isset($params->order_ids) ? $params->order_ids : null |
|
131 | 131 | ) |
132 | 132 | )); |
133 | 133 | |
@@ -151,12 +151,12 @@ discard block |
||
151 | 151 | 'url' => self::$apiUrl, |
152 | 152 | 'method' => 'GET', |
153 | 153 | 'query' => array( |
154 | - 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null, |
|
155 | - 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null, |
|
156 | - 'fields' => isset($params->fields) ? $params->fields: null, |
|
157 | - 'offset' => isset($params->offset) ? $params->offset: null, |
|
158 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
159 | - 'query' => isset($params->query) ? $params->query: null, |
|
154 | + 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD : null, |
|
155 | + 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD : null, |
|
156 | + 'fields' => isset($params->fields) ? $params->fields : null, |
|
157 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
158 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
159 | + 'query' => isset($params->query) ? $params->query : null, |
|
160 | 160 | ) |
161 | 161 | )); |
162 | 162 |
@@ -23,10 +23,10 @@ discard block |
||
23 | 23 | |
24 | 24 | public static function fromArray(array $params) { |
25 | 25 | $geocoding = new Geocoding(); |
26 | - foreach($params as $key => $value) { |
|
27 | - if (property_exists($geocoding, $key)) { |
|
28 | - $geocoding->{$key} = $value; |
|
29 | - } |
|
26 | + foreach($params as $key => $value) { |
|
27 | + if (property_exists($geocoding, $key)) { |
|
28 | + $geocoding->{$key} = $value; |
|
29 | + } |
|
30 | 30 | } |
31 | 31 | return $geocoding; |
32 | 32 | } |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | { |
36 | 36 | //Route4Me::simplePrint($params); |
37 | 37 | $query = array( |
38 | - 'format' => isset($params['format']) ? $params['format']: null, |
|
39 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
40 | - ); |
|
38 | + 'format' => isset($params['format']) ? $params['format']: null, |
|
39 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
40 | + ); |
|
41 | 41 | //var_dump($query); |
42 | 42 | $fgcoding = Route4Me::makeRequst(array( |
43 | - 'url' => self::$apiUrl, |
|
44 | - 'method' => 'POST', |
|
45 | - 'query' => $query |
|
46 | - )); |
|
43 | + 'url' => self::$apiUrl, |
|
44 | + 'method' => 'POST', |
|
45 | + 'query' => $query |
|
46 | + )); |
|
47 | 47 | |
48 | 48 | return $fgcoding; |
49 | 49 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | $query = array(); |
65 | 65 | |
66 | 66 | $response = Route4Me::makeUrlRequst($url_query, array( |
67 | - 'method' => 'GET', |
|
68 | - 'query' => $query |
|
69 | - )); |
|
67 | + 'method' => 'GET', |
|
68 | + 'query' => $query |
|
69 | + )); |
|
70 | 70 | |
71 | 71 | return $response; |
72 | 72 | } |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | $query = array(); |
88 | 88 | |
89 | 89 | $response = Route4Me::makeUrlRequst($url_query, array( |
90 | - 'method' => 'GET', |
|
91 | - 'query' => $query |
|
92 | - )); |
|
90 | + 'method' => 'GET', |
|
91 | + 'query' => $query |
|
92 | + )); |
|
93 | 93 | |
94 | 94 | return $response; |
95 | 95 | } |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | $query = array(); |
114 | 114 | |
115 | 115 | $response = Route4Me::makeUrlRequst($url_query, array( |
116 | - 'method' => 'GET', |
|
117 | - 'query' => $query |
|
118 | - )); |
|
116 | + 'method' => 'GET', |
|
117 | + 'query' => $query |
|
118 | + )); |
|
119 | 119 | |
120 | 120 | return $response; |
121 | 121 | } |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | public $housenumber; |
20 | 20 | public $zipcode; |
21 | 21 | |
22 | - public function __construct () { } |
|
22 | + public function __construct() { } |
|
23 | 23 | |
24 | 24 | public static function fromArray(array $params) { |
25 | 25 | $geocoding = new Geocoding(); |
26 | - foreach($params as $key => $value) { |
|
26 | + foreach ($params as $key => $value) { |
|
27 | 27 | if (property_exists($geocoding, $key)) { |
28 | 28 | $geocoding->{$key} = $value; |
29 | 29 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | //Route4Me::simplePrint($params); |
37 | 37 | $query = array( |
38 | - 'format' => isset($params['format']) ? $params['format']: null, |
|
38 | + 'format' => isset($params['format']) ? $params['format'] : null, |
|
39 | 39 | 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
40 | 40 | ); |
41 | 41 | //var_dump($query); |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | { |
53 | 53 | $url_query = self::$api_street; |
54 | 54 | if (isset($params['pk'])) { |
55 | - $url_query.=$params['pk'].'/'; |
|
55 | + $url_query .= $params['pk'].'/'; |
|
56 | 56 | } |
57 | 57 | if (isset($params['offset'])) { |
58 | - $url_query.=$params['offset'].'/'; |
|
58 | + $url_query .= $params['offset'].'/'; |
|
59 | 59 | } |
60 | 60 | if (isset($params['limit'])) { |
61 | - $url_query.=$params['limit'].'/'; |
|
61 | + $url_query .= $params['limit'].'/'; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | $query = array(); |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | { |
76 | 76 | $url_query = self::$api_zipcode; |
77 | 77 | if (isset($params['zipcode'])) { |
78 | - $url_query.=$params['zipcode'].'/'; |
|
78 | + $url_query .= $params['zipcode'].'/'; |
|
79 | 79 | } |
80 | 80 | if (isset($params['offset'])) { |
81 | - $url_query.=$params['offset'].'/'; |
|
81 | + $url_query .= $params['offset'].'/'; |
|
82 | 82 | } |
83 | 83 | if (isset($params['limit'])) { |
84 | - $url_query.=$params['limit'].'/'; |
|
84 | + $url_query .= $params['limit'].'/'; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | $query = array(); |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | { |
99 | 99 | $url_query = self::$api_service; |
100 | 100 | if (isset($params['zipcode'])) { |
101 | - $url_query.=$params['zipcode'].'/'; |
|
101 | + $url_query .= $params['zipcode'].'/'; |
|
102 | 102 | } |
103 | 103 | if (isset($params['housenumber'])) { |
104 | - $url_query.=$params['housenumber'].'/'; |
|
104 | + $url_query .= $params['housenumber'].'/'; |
|
105 | 105 | } |
106 | 106 | if (isset($params['offset'])) { |
107 | - $url_query.=$params['offset'].'/'; |
|
107 | + $url_query .= $params['offset'].'/'; |
|
108 | 108 | } |
109 | 109 | if (isset($params['limit'])) { |
110 | - $url_query.=$params['limit'].'/'; |
|
110 | + $url_query .= $params['limit'].'/'; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $query = array(); |
@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | class Common |
6 | 6 | { |
7 | - static public function getValue($array, $item, $default = null) |
|
8 | - { |
|
9 | - return (isset($array[$item])) ? $array[$item] : $default; |
|
10 | - } |
|
7 | + static public function getValue($array, $item, $default = null) |
|
8 | + { |
|
9 | + return (isset($array[$item])) ? $array[$item] : $default; |
|
10 | + } |
|
11 | 11 | |
12 | - public function toArray() |
|
13 | - { |
|
14 | - $params = array_filter(get_object_vars($this), function($item) { |
|
15 | - return ($item !== null) && !(is_array($item) && !count($item)); |
|
16 | - }); |
|
12 | + public function toArray() |
|
13 | + { |
|
14 | + $params = array_filter(get_object_vars($this), function($item) { |
|
15 | + return ($item !== null) && !(is_array($item) && !count($item)); |
|
16 | + }); |
|
17 | 17 | |
18 | - return $params; |
|
19 | - } |
|
18 | + return $params; |
|
19 | + } |
|
20 | 20 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | public function toArray() |
13 | 13 | { |
14 | 14 | $params = array_filter(get_object_vars($this), function($item) { |
15 | - return ($item !== null) && !(is_array($item) && !count($item)); |
|
15 | + return ($item!==null) && !(is_array($item) && !count($item)); |
|
16 | 16 | }); |
17 | 17 | |
18 | 18 | return $params; |
@@ -20,93 +20,93 @@ |
||
20 | 20 | |
21 | 21 | public static function fromArray(array $params) { |
22 | 22 | if (!isset($params['territory_name'])) { |
23 | - throw new BadParam('Territory name must be provided'); |
|
24 | - } |
|
23 | + throw new BadParam('Territory name must be provided'); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | if (!isset($params['territory_color'])) { |
27 | - throw new BadParam('Territory color must be provided'); |
|
28 | - } |
|
27 | + throw new BadParam('Territory color must be provided'); |
|
28 | + } |
|
29 | 29 | |
30 | 30 | if (!isset($params['territory'])) { |
31 | - throw new BadParam('Territory must be provided'); |
|
32 | - } |
|
31 | + throw new BadParam('Territory must be provided'); |
|
32 | + } |
|
33 | 33 | |
34 | 34 | $avoidancezoneparameters = new AvoidanceZone(); |
35 | - foreach($params as $key => $value) { |
|
36 | - if (property_exists($avoidancezoneparameters, $key)) { |
|
37 | - $avoidancezoneparameters->{$key} = $value; |
|
38 | - } |
|
35 | + foreach($params as $key => $value) { |
|
36 | + if (property_exists($avoidancezoneparameters, $key)) { |
|
37 | + $avoidancezoneparameters->{$key} = $value; |
|
38 | + } |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return $avoidancezoneparameters; |
42 | 42 | } |
43 | 43 | |
44 | 44 | public static function getAvoidanceZone($territory_id) |
45 | - { |
|
46 | - $avoidancezone = Route4Me::makeRequst(array( |
|
47 | - 'url' => self::$apiUrl, |
|
48 | - 'method' => 'GET', |
|
49 | - 'query' => array( |
|
50 | - 'territory_id' => $territory_id |
|
51 | - ) |
|
52 | - )); |
|
45 | + { |
|
46 | + $avoidancezone = Route4Me::makeRequst(array( |
|
47 | + 'url' => self::$apiUrl, |
|
48 | + 'method' => 'GET', |
|
49 | + 'query' => array( |
|
50 | + 'territory_id' => $territory_id |
|
51 | + ) |
|
52 | + )); |
|
53 | 53 | |
54 | - return $avoidancezone; |
|
55 | - } |
|
54 | + return $avoidancezone; |
|
55 | + } |
|
56 | 56 | |
57 | 57 | public static function getAvoidanceZones($params) |
58 | - { |
|
59 | - $avoidancezones = Route4Me::makeRequst(array( |
|
60 | - 'url' => self::$apiUrl, |
|
61 | - 'method' => 'GET', |
|
62 | - 'query' => array( |
|
63 | - 'offset' => isset($params->offset) ? $params->offset: null, |
|
64 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
65 | - ) |
|
66 | - )); |
|
58 | + { |
|
59 | + $avoidancezones = Route4Me::makeRequst(array( |
|
60 | + 'url' => self::$apiUrl, |
|
61 | + 'method' => 'GET', |
|
62 | + 'query' => array( |
|
63 | + 'offset' => isset($params->offset) ? $params->offset: null, |
|
64 | + 'limit' => isset($params->limit) ? $params->limit: null, |
|
65 | + ) |
|
66 | + )); |
|
67 | 67 | |
68 | - return $avoidancezones; |
|
69 | - } |
|
68 | + return $avoidancezones; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | public static function addAvoidanceZone($params) |
72 | - { |
|
73 | - $abcontacts = Route4Me::makeRequst(array( |
|
74 | - 'url' => self::$apiUrl, |
|
75 | - 'method' => 'ADD', |
|
76 | - 'query' => array( |
|
77 | - 'territory_name' => isset($params->territory_name) ? $params->territory_name: null, |
|
78 | - 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
79 | - 'territory' => isset($params->territory) ? $params->territory : null, |
|
80 | - ) |
|
81 | - )); |
|
72 | + { |
|
73 | + $abcontacts = Route4Me::makeRequst(array( |
|
74 | + 'url' => self::$apiUrl, |
|
75 | + 'method' => 'ADD', |
|
76 | + 'query' => array( |
|
77 | + 'territory_name' => isset($params->territory_name) ? $params->territory_name: null, |
|
78 | + 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
79 | + 'territory' => isset($params->territory) ? $params->territory : null, |
|
80 | + ) |
|
81 | + )); |
|
82 | 82 | |
83 | 83 | return $abcontacts; |
84 | 84 | } |
85 | 85 | |
86 | 86 | public function deleteAvoidanceZone($territory_id) |
87 | - { |
|
88 | - $result = Route4Me::makeRequst(array( |
|
89 | - 'url' => self::$apiUrl, |
|
90 | - 'method' => 'DELETEARRAY', |
|
91 | - 'query' => array( |
|
92 | - 'territory_id' => $territory_id |
|
93 | - ) |
|
94 | - )); |
|
87 | + { |
|
88 | + $result = Route4Me::makeRequst(array( |
|
89 | + 'url' => self::$apiUrl, |
|
90 | + 'method' => 'DELETEARRAY', |
|
91 | + 'query' => array( |
|
92 | + 'territory_id' => $territory_id |
|
93 | + ) |
|
94 | + )); |
|
95 | 95 | |
96 | - return $result; |
|
97 | - } |
|
96 | + return $result; |
|
97 | + } |
|
98 | 98 | |
99 | 99 | public function updateAvoidanceZone($params) |
100 | - { |
|
101 | - $avoidancezone = Route4Me::makeRequst(array( |
|
102 | - 'url' => self::$apiUrl, |
|
103 | - 'method' => 'PUT', |
|
104 | - 'query' => (array)$params, |
|
100 | + { |
|
101 | + $avoidancezone = Route4Me::makeRequst(array( |
|
102 | + 'url' => self::$apiUrl, |
|
103 | + 'method' => 'PUT', |
|
104 | + 'query' => (array)$params, |
|
105 | 105 | |
106 | - )); |
|
106 | + )); |
|
107 | 107 | |
108 | - return $avoidancezone; |
|
109 | - } |
|
108 | + return $avoidancezone; |
|
109 | + } |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | ?> |
113 | 113 | \ No newline at end of file |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | { |
9 | 9 | static public $apiUrl = '/api.v4/avoidance.php'; |
10 | 10 | |
11 | - public $territory_id; // Avoidance zone id |
|
11 | + public $territory_id; // Avoidance zone id |
|
12 | 12 | public $territory_name; |
13 | 13 | public $territory_color; |
14 | 14 | public $member_id; |
15 | 15 | public $territory; // Territory parameters |
16 | 16 | |
17 | - public function __construct () { |
|
17 | + public function __construct() { |
|
18 | 18 | |
19 | 19 | } |
20 | 20 | |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | $avoidancezoneparameters = new AvoidanceZone(); |
35 | - foreach($params as $key => $value) { |
|
35 | + foreach ($params as $key => $value) { |
|
36 | 36 | if (property_exists($avoidancezoneparameters, $key)) { |
37 | 37 | $avoidancezoneparameters->{$key} = $value; |
38 | 38 | } |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | 'url' => self::$apiUrl, |
61 | 61 | 'method' => 'GET', |
62 | 62 | 'query' => array( |
63 | - 'offset' => isset($params->offset) ? $params->offset: null, |
|
64 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
63 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
64 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
65 | 65 | ) |
66 | 66 | )); |
67 | 67 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | 'url' => self::$apiUrl, |
75 | 75 | 'method' => 'ADD', |
76 | 76 | 'query' => array( |
77 | - 'territory_name' => isset($params->territory_name) ? $params->territory_name: null, |
|
77 | + 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
78 | 78 | 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
79 | 79 | 'territory' => isset($params->territory) ? $params->territory : null, |
80 | 80 | ) |
@@ -9,55 +9,55 @@ discard block |
||
9 | 9 | |
10 | 10 | class Address extends Common |
11 | 11 | { |
12 | - static public $apiUrl = '/api.v4/address.php'; |
|
12 | + static public $apiUrl = '/api.v4/address.php'; |
|
13 | 13 | static public $apiUrlMove='/actions/route/move_route_destination.php'; |
14 | 14 | static public $apiUrDeparted='/api/route/mark_address_departed.php'; |
15 | 15 | static public $apiUrVisited='/actions/address/update_address_visited.php'; |
16 | 16 | |
17 | - public $route_destination_id; |
|
18 | - public $alias; |
|
19 | - public $member_id; |
|
20 | - public $address; |
|
21 | - public $is_depot = false; |
|
22 | - public $lat; |
|
23 | - public $lng; |
|
24 | - public $route_id; |
|
25 | - public $original_route_id; |
|
26 | - public $optimization_problem_id; |
|
27 | - public $sequence_no; |
|
28 | - public $geocoded; |
|
29 | - public $preferred_geocoding; |
|
30 | - public $failed_geocoding; |
|
31 | - public $geocodings = array(); |
|
32 | - public $contact_id; |
|
33 | - public $is_visited; |
|
34 | - public $customer_po; |
|
35 | - public $invoice_no; |
|
36 | - public $reference_no; |
|
37 | - public $order_no; |
|
38 | - public $weight; |
|
39 | - public $cost; |
|
40 | - public $revenue; |
|
41 | - public $cube; |
|
42 | - public $pieces; |
|
43 | - public $email; |
|
44 | - public $phone; |
|
45 | - public $destination_note_count; |
|
46 | - public $drive_time_to_next_destination; |
|
47 | - public $distance_to_next_destination; |
|
48 | - public $generated_time_window_start; |
|
49 | - public $generated_time_window_end; |
|
50 | - public $time_window_start; |
|
51 | - public $time_window_end; |
|
52 | - public $time; |
|
17 | + public $route_destination_id; |
|
18 | + public $alias; |
|
19 | + public $member_id; |
|
20 | + public $address; |
|
21 | + public $is_depot = false; |
|
22 | + public $lat; |
|
23 | + public $lng; |
|
24 | + public $route_id; |
|
25 | + public $original_route_id; |
|
26 | + public $optimization_problem_id; |
|
27 | + public $sequence_no; |
|
28 | + public $geocoded; |
|
29 | + public $preferred_geocoding; |
|
30 | + public $failed_geocoding; |
|
31 | + public $geocodings = array(); |
|
32 | + public $contact_id; |
|
33 | + public $is_visited; |
|
34 | + public $customer_po; |
|
35 | + public $invoice_no; |
|
36 | + public $reference_no; |
|
37 | + public $order_no; |
|
38 | + public $weight; |
|
39 | + public $cost; |
|
40 | + public $revenue; |
|
41 | + public $cube; |
|
42 | + public $pieces; |
|
43 | + public $email; |
|
44 | + public $phone; |
|
45 | + public $destination_note_count; |
|
46 | + public $drive_time_to_next_destination; |
|
47 | + public $distance_to_next_destination; |
|
48 | + public $generated_time_window_start; |
|
49 | + public $generated_time_window_end; |
|
50 | + public $time_window_start; |
|
51 | + public $time_window_end; |
|
52 | + public $time; |
|
53 | 53 | public $notes; |
54 | - public $timestamp_last_visited; |
|
55 | - public $custom_fields = array(); |
|
56 | - public $manifest = array(); |
|
54 | + public $timestamp_last_visited; |
|
55 | + public $custom_fields = array(); |
|
56 | + public $manifest = array(); |
|
57 | 57 | |
58 | - public static function fromArray(array $params) |
|
59 | - { |
|
60 | - /*if (!isset($params['address'])) { |
|
58 | + public static function fromArray(array $params) |
|
59 | + { |
|
60 | + /*if (!isset($params['address'])) { |
|
61 | 61 | throw new BadParam('address must be provided'); |
62 | 62 | } |
63 | 63 | |
@@ -69,124 +69,124 @@ discard block |
||
69 | 69 | throw new BadParam('lng must be provided'); |
70 | 70 | }*/ |
71 | 71 | |
72 | - $address = new Address(); |
|
73 | - foreach($params as $key => $value) { |
|
74 | - if (property_exists($address, $key)) { |
|
75 | - $address->{$key} = $value; |
|
76 | - } |
|
77 | - } |
|
72 | + $address = new Address(); |
|
73 | + foreach($params as $key => $value) { |
|
74 | + if (property_exists($address, $key)) { |
|
75 | + $address->{$key} = $value; |
|
76 | + } |
|
77 | + } |
|
78 | + |
|
79 | + return $address; |
|
80 | + } |
|
81 | + |
|
82 | + public static function getAddress($routeId, $addressId) |
|
83 | + { |
|
84 | + $address = Route4Me::makeRequst(array( |
|
85 | + 'url' => self::$apiUrl, |
|
86 | + 'method' => 'GET', |
|
87 | + 'query' => array( |
|
88 | + 'route_id' => $routeId, |
|
89 | + 'route_destination_id' => $addressId, |
|
90 | + ) |
|
91 | + )); |
|
92 | + |
|
93 | + return Address::fromArray($address); |
|
94 | + } |
|
78 | 95 | |
79 | - return $address; |
|
80 | - } |
|
81 | - |
|
82 | - public static function getAddress($routeId, $addressId) |
|
83 | - { |
|
84 | - $address = Route4Me::makeRequst(array( |
|
85 | - 'url' => self::$apiUrl, |
|
86 | - 'method' => 'GET', |
|
87 | - 'query' => array( |
|
88 | - 'route_id' => $routeId, |
|
89 | - 'route_destination_id' => $addressId, |
|
90 | - ) |
|
91 | - )); |
|
92 | - |
|
93 | - return Address::fromArray($address); |
|
94 | - } |
|
95 | - |
|
96 | - public function update() |
|
97 | - { |
|
98 | - $address = Route4Me::makeRequst(array( |
|
99 | - 'url' => self::$apiUrl, |
|
100 | - 'method' => 'PUT', |
|
101 | - 'body' => $this->toArray(), |
|
102 | - 'query' => array( |
|
103 | - 'route_id' => $this->route_id, |
|
104 | - 'route_destination_id' => $this->route_destination_id, |
|
105 | - ), |
|
106 | - )); |
|
107 | - |
|
108 | - return Address::fromArray($address); |
|
109 | - } |
|
96 | + public function update() |
|
97 | + { |
|
98 | + $address = Route4Me::makeRequst(array( |
|
99 | + 'url' => self::$apiUrl, |
|
100 | + 'method' => 'PUT', |
|
101 | + 'body' => $this->toArray(), |
|
102 | + 'query' => array( |
|
103 | + 'route_id' => $this->route_id, |
|
104 | + 'route_destination_id' => $this->route_destination_id, |
|
105 | + ), |
|
106 | + )); |
|
107 | + |
|
108 | + return Address::fromArray($address); |
|
109 | + } |
|
110 | 110 | |
111 | 111 | public function markAddress($params, $body) |
112 | - { |
|
113 | - $result = Route4Me::makeRequst(array( |
|
114 | - 'url' => self::$apiUrl, |
|
115 | - 'method' => 'PUT', |
|
116 | - 'query' => array( |
|
117 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
118 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
119 | - ), |
|
120 | - 'body' => $body |
|
121 | - )); |
|
122 | - |
|
123 | - return $result; |
|
124 | - } |
|
112 | + { |
|
113 | + $result = Route4Me::makeRequst(array( |
|
114 | + 'url' => self::$apiUrl, |
|
115 | + 'method' => 'PUT', |
|
116 | + 'query' => array( |
|
117 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
118 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
119 | + ), |
|
120 | + 'body' => $body |
|
121 | + )); |
|
122 | + |
|
123 | + return $result; |
|
124 | + } |
|
125 | 125 | |
126 | 126 | public function markAsDeparted($params) |
127 | 127 | { |
128 | 128 | $address = Route4Me::makeRequst(array( |
129 | - 'url' => self::$apiUrDeparted, |
|
130 | - 'method' => 'GET', |
|
131 | - 'query' => array( |
|
132 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
133 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
134 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
135 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
136 | - ), |
|
137 | - )); |
|
138 | - |
|
139 | - return $address; |
|
129 | + 'url' => self::$apiUrDeparted, |
|
130 | + 'method' => 'GET', |
|
131 | + 'query' => array( |
|
132 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
133 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
134 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
135 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
136 | + ), |
|
137 | + )); |
|
138 | + |
|
139 | + return $address; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | public function markAsVisited($params) |
143 | 143 | { |
144 | 144 | $address = Route4Me::makeRequst(array( |
145 | - 'url' => self::$apiUrVisited, |
|
146 | - 'method' => 'GET', |
|
147 | - 'query' => array( |
|
148 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
149 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
150 | - 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
151 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
152 | - ), |
|
153 | - )); |
|
154 | - |
|
155 | - return $address; |
|
145 | + 'url' => self::$apiUrVisited, |
|
146 | + 'method' => 'GET', |
|
147 | + 'query' => array( |
|
148 | + 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
149 | + 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
150 | + 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
151 | + 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
152 | + ), |
|
153 | + )); |
|
154 | + |
|
155 | + return $address; |
|
156 | 156 | } |
157 | 157 | |
158 | - public function delete() |
|
159 | - { |
|
160 | - $address = Route4Me::makeRequst(array( |
|
161 | - 'url' => self::$apiUrl, |
|
162 | - 'method' => 'DELETE', |
|
163 | - 'query' => array( |
|
164 | - 'route_id' => $this->route_id, |
|
165 | - 'route_destination_id' => $this->route_destination_id, |
|
166 | - ) |
|
167 | - )); |
|
168 | - |
|
169 | - return (bool)$address['deleted']; |
|
170 | - } |
|
158 | + public function delete() |
|
159 | + { |
|
160 | + $address = Route4Me::makeRequst(array( |
|
161 | + 'url' => self::$apiUrl, |
|
162 | + 'method' => 'DELETE', |
|
163 | + 'query' => array( |
|
164 | + 'route_id' => $this->route_id, |
|
165 | + 'route_destination_id' => $this->route_destination_id, |
|
166 | + ) |
|
167 | + )); |
|
168 | + |
|
169 | + return (bool)$address['deleted']; |
|
170 | + } |
|
171 | 171 | |
172 | 172 | public function MoveDestinationToRoute($params) |
173 | 173 | { |
174 | 174 | $result = Route4Me::makeRequst(array( |
175 | - 'url' => self::$apiUrlMove, |
|
176 | - 'method' => 'POST', |
|
177 | - 'query' => array( |
|
178 | - 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
179 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
180 | - 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
181 | - ) |
|
182 | - )); |
|
183 | - |
|
184 | - return $result; |
|
175 | + 'url' => self::$apiUrlMove, |
|
176 | + 'method' => 'POST', |
|
177 | + 'query' => array( |
|
178 | + 'to_route_id' => isset($params['to_route_id']) ? $params['to_route_id'] : null, |
|
179 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
180 | + 'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null |
|
181 | + ) |
|
182 | + )); |
|
183 | + |
|
184 | + return $result; |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
188 | - function getAddressId() |
|
189 | - { |
|
190 | - return $this->route_destination_id; |
|
191 | - } |
|
188 | + function getAddressId() |
|
189 | + { |
|
190 | + return $this->route_destination_id; |
|
191 | + } |
|
192 | 192 | } |
@@ -10,9 +10,9 @@ discard block |
||
10 | 10 | class Address extends Common |
11 | 11 | { |
12 | 12 | static public $apiUrl = '/api.v4/address.php'; |
13 | - static public $apiUrlMove='/actions/route/move_route_destination.php'; |
|
14 | - static public $apiUrDeparted='/api/route/mark_address_departed.php'; |
|
15 | - static public $apiUrVisited='/actions/address/update_address_visited.php'; |
|
13 | + static public $apiUrlMove = '/actions/route/move_route_destination.php'; |
|
14 | + static public $apiUrDeparted = '/api/route/mark_address_departed.php'; |
|
15 | + static public $apiUrVisited = '/actions/address/update_address_visited.php'; |
|
16 | 16 | |
17 | 17 | public $route_destination_id; |
18 | 18 | public $alias; |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | }*/ |
71 | 71 | |
72 | 72 | $address = new Address(); |
73 | - foreach($params as $key => $value) { |
|
73 | + foreach ($params as $key => $value) { |
|
74 | 74 | if (property_exists($address, $key)) { |
75 | 75 | $address->{$key} = $value; |
76 | 76 | } |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | 'url' => self::$apiUrl, |
115 | 115 | 'method' => 'PUT', |
116 | 116 | 'query' => array( |
117 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
117 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
118 | 118 | 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
119 | 119 | ), |
120 | 120 | 'body' => $body |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | 'url' => self::$apiUrDeparted, |
130 | 130 | 'method' => 'GET', |
131 | 131 | 'query' => array( |
132 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
133 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
134 | - 'is_departed' => isset($params['is_departed']) ? $params['is_departed']: null, |
|
135 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
132 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
133 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
134 | + 'is_departed' => isset($params['is_departed']) ? $params['is_departed'] : null, |
|
135 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
136 | 136 | ), |
137 | 137 | )); |
138 | 138 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | 'url' => self::$apiUrVisited, |
146 | 146 | 'method' => 'GET', |
147 | 147 | 'query' => array( |
148 | - 'route_id' => isset($params['route_id']) ? $params['route_id']: null, |
|
149 | - 'address_id' => isset($params['address_id']) ? $params['address_id']: null, |
|
150 | - 'is_visited' => isset($params['is_visited']) ? $params['is_visited']: null, |
|
151 | - 'member_id' => isset($params['member_id']) ? $params['member_id']: null, |
|
148 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
149 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
150 | + 'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null, |
|
151 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null, |
|
152 | 152 | ), |
153 | 153 | )); |
154 | 154 |
@@ -8,7 +8,6 @@ |
||
8 | 8 | use Route4Me\OptimizationProblemParams; |
9 | 9 | use Route4Me\Route; |
10 | 10 | use Route4Me\Route4Me; |
11 | -use GuzzleHttp\Client; |
|
12 | 11 | |
13 | 12 | class OptimizationProblem extends Common |
14 | 13 | { |
@@ -9,102 +9,102 @@ |
||
9 | 9 | |
10 | 10 | class TrackSetParams extends Common |
11 | 11 | { |
12 | - public $format; |
|
13 | - public $member_id; |
|
14 | - public $route_id; |
|
15 | - public $tx_id; |
|
16 | - public $vehicle_id; |
|
17 | - public $course; |
|
18 | - public $speed; |
|
19 | - public $lat; |
|
20 | - public $lng; |
|
21 | - public $altitude; |
|
22 | - public $device_type; |
|
23 | - public $device_guid; |
|
24 | - public $device_timestamp; |
|
25 | - public $app_version; |
|
26 | - |
|
27 | - public static function fromArray(array $params) |
|
28 | - { |
|
29 | - $param = new TrackSetParams; |
|
30 | - |
|
31 | - if (!isset($params['format'])) { |
|
32 | - throw new BadParam("format must be provided."); |
|
33 | - } |
|
34 | - |
|
35 | - $types = array( |
|
36 | - Format::SERIALIZED, |
|
37 | - Format::CSV, |
|
38 | - Format::XML |
|
39 | - ); |
|
40 | - if (!in_array($params['format'], $types)) { |
|
41 | - throw new BadParam("format is invalid."); |
|
42 | - } |
|
43 | - |
|
44 | - if (!isset($params['route_id'])) { |
|
45 | - throw new BadParam("route_id must be provided."); |
|
46 | - } |
|
47 | - |
|
48 | - if (!isset($params['member_id'])) { |
|
49 | - throw new BadParam("member_id must be provided."); |
|
50 | - } |
|
51 | - |
|
52 | - if (!isset($params['course'])) { |
|
53 | - throw new BadParam("course must be provided."); |
|
54 | - } |
|
55 | - |
|
56 | - if (!isset($params['speed'])) { |
|
57 | - throw new BadParam("speed must be provided."); |
|
58 | - } |
|
59 | - |
|
60 | - if (!isset($params['lat'])) { |
|
61 | - throw new BadParam("lat must be provided."); |
|
62 | - } |
|
63 | - |
|
64 | - if (!isset($params['lng'])) { |
|
65 | - throw new BadParam("lng must be provided."); |
|
66 | - } |
|
67 | - |
|
68 | - if (!isset($params['device_type'])) { |
|
69 | - throw new BadParam("device_type must be provided."); |
|
70 | - } |
|
71 | - |
|
72 | - $deviceTypes = array( |
|
73 | - DeviceType::IPHONE, |
|
74 | - DeviceType::IPAD, |
|
75 | - DeviceType::ANDROID_PHONE, |
|
76 | - DeviceType::ANDROID_TABLET |
|
77 | - ); |
|
78 | - if (!in_array($params['device_type'], $deviceTypes)) { |
|
79 | - throw new BadParam("device_type is invalid."); |
|
80 | - } |
|
81 | - |
|
82 | - if (!isset($params['device_guid'])) { |
|
83 | - throw new BadParam("device_guid must be provided."); |
|
84 | - } |
|
85 | - |
|
86 | - if (isset($params['device_timestamp'])) { |
|
87 | - $template = '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/i'; |
|
88 | - if (!preg_match($template, $params['device_timestamp'])) { |
|
89 | - throw new BadParam("device_timestamp is invalid."); |
|
90 | - } |
|
91 | - } |
|
92 | - |
|
93 | - $param->format = self::getValue($params, 'format'); |
|
94 | - $param->route_id = self::getValue($params, 'route_id'); |
|
95 | - $param->member_id = self::getValue($params, 'member_id'); |
|
96 | - $param->course = self::getValue($params, 'course'); |
|
97 | - $param->speed = self::getValue($params, 'speed'); |
|
98 | - $param->lat = self::getValue($params, 'lat'); |
|
99 | - $param->lng = self::getValue($params, 'lng'); |
|
100 | - $param->device_type = self::getValue($params, 'device_type'); |
|
101 | - $param->device_guid = self::getValue($params, 'device_guid'); |
|
102 | - $param->device_timestamp = self::getValue($params, 'device_timestamp'); |
|
103 | - $param->vehicle_id = self::getValue($params, 'vehicle_id'); |
|
104 | - $param->altitude = self::getValue($params, 'altitude'); |
|
105 | - $param->app_version = self::getValue($params, 'app_version'); |
|
106 | - $param->tx_id = self::getValue($params, 'tx_id'); |
|
107 | - |
|
108 | - return $param; |
|
109 | - } |
|
12 | + public $format; |
|
13 | + public $member_id; |
|
14 | + public $route_id; |
|
15 | + public $tx_id; |
|
16 | + public $vehicle_id; |
|
17 | + public $course; |
|
18 | + public $speed; |
|
19 | + public $lat; |
|
20 | + public $lng; |
|
21 | + public $altitude; |
|
22 | + public $device_type; |
|
23 | + public $device_guid; |
|
24 | + public $device_timestamp; |
|
25 | + public $app_version; |
|
26 | + |
|
27 | + public static function fromArray(array $params) |
|
28 | + { |
|
29 | + $param = new TrackSetParams; |
|
30 | + |
|
31 | + if (!isset($params['format'])) { |
|
32 | + throw new BadParam("format must be provided."); |
|
33 | + } |
|
34 | + |
|
35 | + $types = array( |
|
36 | + Format::SERIALIZED, |
|
37 | + Format::CSV, |
|
38 | + Format::XML |
|
39 | + ); |
|
40 | + if (!in_array($params['format'], $types)) { |
|
41 | + throw new BadParam("format is invalid."); |
|
42 | + } |
|
43 | + |
|
44 | + if (!isset($params['route_id'])) { |
|
45 | + throw new BadParam("route_id must be provided."); |
|
46 | + } |
|
47 | + |
|
48 | + if (!isset($params['member_id'])) { |
|
49 | + throw new BadParam("member_id must be provided."); |
|
50 | + } |
|
51 | + |
|
52 | + if (!isset($params['course'])) { |
|
53 | + throw new BadParam("course must be provided."); |
|
54 | + } |
|
55 | + |
|
56 | + if (!isset($params['speed'])) { |
|
57 | + throw new BadParam("speed must be provided."); |
|
58 | + } |
|
59 | + |
|
60 | + if (!isset($params['lat'])) { |
|
61 | + throw new BadParam("lat must be provided."); |
|
62 | + } |
|
63 | + |
|
64 | + if (!isset($params['lng'])) { |
|
65 | + throw new BadParam("lng must be provided."); |
|
66 | + } |
|
67 | + |
|
68 | + if (!isset($params['device_type'])) { |
|
69 | + throw new BadParam("device_type must be provided."); |
|
70 | + } |
|
71 | + |
|
72 | + $deviceTypes = array( |
|
73 | + DeviceType::IPHONE, |
|
74 | + DeviceType::IPAD, |
|
75 | + DeviceType::ANDROID_PHONE, |
|
76 | + DeviceType::ANDROID_TABLET |
|
77 | + ); |
|
78 | + if (!in_array($params['device_type'], $deviceTypes)) { |
|
79 | + throw new BadParam("device_type is invalid."); |
|
80 | + } |
|
81 | + |
|
82 | + if (!isset($params['device_guid'])) { |
|
83 | + throw new BadParam("device_guid must be provided."); |
|
84 | + } |
|
85 | + |
|
86 | + if (isset($params['device_timestamp'])) { |
|
87 | + $template = '/[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}/i'; |
|
88 | + if (!preg_match($template, $params['device_timestamp'])) { |
|
89 | + throw new BadParam("device_timestamp is invalid."); |
|
90 | + } |
|
91 | + } |
|
92 | + |
|
93 | + $param->format = self::getValue($params, 'format'); |
|
94 | + $param->route_id = self::getValue($params, 'route_id'); |
|
95 | + $param->member_id = self::getValue($params, 'member_id'); |
|
96 | + $param->course = self::getValue($params, 'course'); |
|
97 | + $param->speed = self::getValue($params, 'speed'); |
|
98 | + $param->lat = self::getValue($params, 'lat'); |
|
99 | + $param->lng = self::getValue($params, 'lng'); |
|
100 | + $param->device_type = self::getValue($params, 'device_type'); |
|
101 | + $param->device_guid = self::getValue($params, 'device_guid'); |
|
102 | + $param->device_timestamp = self::getValue($params, 'device_timestamp'); |
|
103 | + $param->vehicle_id = self::getValue($params, 'vehicle_id'); |
|
104 | + $param->altitude = self::getValue($params, 'altitude'); |
|
105 | + $param->app_version = self::getValue($params, 'app_version'); |
|
106 | + $param->tx_id = self::getValue($params, 'tx_id'); |
|
107 | + |
|
108 | + return $param; |
|
109 | + } |
|
110 | 110 | } |
@@ -11,21 +11,21 @@ |
||
11 | 11 | |
12 | 12 | public static function fromArray(array $params) { |
13 | 13 | $vehicle= new Vehicle(); |
14 | - foreach($params as $key => $value) { |
|
15 | - if (property_exists($vehicle, $key)) { |
|
16 | - $vehicle->{$key} = $value; |
|
17 | - } |
|
14 | + foreach($params as $key => $value) { |
|
15 | + if (property_exists($vehicle, $key)) { |
|
16 | + $vehicle->{$key} = $value; |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | return $order; |
21 | 21 | } |
22 | 22 | |
23 | 23 | public static function getVehicles() |
24 | - { |
|
25 | - $response = Route4Me::makeRequst(array( |
|
26 | - 'url' => self::$apiUrl, |
|
27 | - 'method' => 'GET' |
|
28 | - )); |
|
24 | + { |
|
25 | + $response = Route4Me::makeRequst(array( |
|
26 | + 'url' => self::$apiUrl, |
|
27 | + 'method' => 'GET' |
|
28 | + )); |
|
29 | 29 | |
30 | 30 | return $response; |
31 | 31 | } |
@@ -7,11 +7,11 @@ |
||
7 | 7 | { |
8 | 8 | static public $apiUrl = '/api/vehicles/view_vehicles.php'; |
9 | 9 | |
10 | - public function __construct () { } |
|
10 | + public function __construct() { } |
|
11 | 11 | |
12 | 12 | public static function fromArray(array $params) { |
13 | - $vehicle= new Vehicle(); |
|
14 | - foreach($params as $key => $value) { |
|
13 | + $vehicle = new Vehicle(); |
|
14 | + foreach ($params as $key => $value) { |
|
15 | 15 | if (property_exists($vehicle, $key)) { |
16 | 16 | $vehicle->{$key} = $value; |
17 | 17 | } |