@@ -12,267 +12,267 @@ |
||
12 | 12 | |
13 | 13 | class OptimizationProblem extends Common |
14 | 14 | { |
15 | - public $optimization_problem_id; |
|
16 | - public $user_errors = array(); |
|
17 | - public $state; |
|
18 | - public $optimization_errors = array(); |
|
19 | - public $parameters; |
|
20 | - public $sent_to_background; |
|
21 | - public $created_timestamp; |
|
22 | - public $scheduled_for; |
|
23 | - public $optimization_completed_timestamp; |
|
24 | - public $addresses = array(); |
|
25 | - public $routes = array(); |
|
26 | - public $links = array(); |
|
15 | + public $optimization_problem_id; |
|
16 | + public $user_errors = array(); |
|
17 | + public $state; |
|
18 | + public $optimization_errors = array(); |
|
19 | + public $parameters; |
|
20 | + public $sent_to_background; |
|
21 | + public $created_timestamp; |
|
22 | + public $scheduled_for; |
|
23 | + public $optimization_completed_timestamp; |
|
24 | + public $addresses = array(); |
|
25 | + public $routes = array(); |
|
26 | + public $links = array(); |
|
27 | 27 | |
28 | - function __construct() |
|
29 | - { |
|
30 | - $this->parameters = new RouteParameters; |
|
31 | - } |
|
28 | + function __construct() |
|
29 | + { |
|
30 | + $this->parameters = new RouteParameters; |
|
31 | + } |
|
32 | 32 | |
33 | - public static function fromArray(array $params) |
|
34 | - { |
|
35 | - $problem = new OptimizationProblem; |
|
36 | - $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
37 | - $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
38 | - $problem->state = Common::getValue($params, 'state', array()); |
|
39 | - $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
40 | - $problem->links = Common::getValue($params, 'links', array()); |
|
33 | + public static function fromArray(array $params) |
|
34 | + { |
|
35 | + $problem = new OptimizationProblem; |
|
36 | + $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
37 | + $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
38 | + $problem->state = Common::getValue($params, 'state', array()); |
|
39 | + $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
40 | + $problem->links = Common::getValue($params, 'links', array()); |
|
41 | 41 | |
42 | - if (isset($params['parameters'])) { |
|
43 | - $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
44 | - } |
|
42 | + if (isset($params['parameters'])) { |
|
43 | + $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
44 | + } |
|
45 | 45 | |
46 | - if (isset($params['addresses'])) { |
|
47 | - $addresses = array(); |
|
46 | + if (isset($params['addresses'])) { |
|
47 | + $addresses = array(); |
|
48 | 48 | |
49 | - foreach ($params['addresses'] as $address) { |
|
50 | - $addresses[] = Address::fromArray($address); |
|
51 | - } |
|
49 | + foreach ($params['addresses'] as $address) { |
|
50 | + $addresses[] = Address::fromArray($address); |
|
51 | + } |
|
52 | 52 | |
53 | - $problem->addresses = $addresses; |
|
54 | - } |
|
53 | + $problem->addresses = $addresses; |
|
54 | + } |
|
55 | 55 | |
56 | - if (isset($params['routes'])) { |
|
57 | - $routes = array(); |
|
56 | + if (isset($params['routes'])) { |
|
57 | + $routes = array(); |
|
58 | 58 | |
59 | - foreach ($params['routes'] as $route) { |
|
60 | - $routes[] = Route::fromArray($route); |
|
61 | - } |
|
59 | + foreach ($params['routes'] as $route) { |
|
60 | + $routes[] = Route::fromArray($route); |
|
61 | + } |
|
62 | 62 | |
63 | - $problem->routes = $routes; |
|
64 | - } |
|
63 | + $problem->routes = $routes; |
|
64 | + } |
|
65 | 65 | |
66 | - return $problem; |
|
67 | - } |
|
66 | + return $problem; |
|
67 | + } |
|
68 | 68 | |
69 | - public static function optimize(OptimizationProblemParams $params) |
|
70 | - { |
|
71 | - $optimize = Route4Me::makeRequst(array( |
|
72 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
73 | - 'method' => 'POST', |
|
74 | - 'query' => array( |
|
75 | - 'redirect' => isset($params->redirect) ? $params->redirect : null, |
|
76 | - 'directions' => isset($params->directions) ? $params->directions : null, |
|
77 | - 'format' => isset($params->format) ? $params->format : null, |
|
78 | - 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output : null, |
|
79 | - 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null |
|
80 | - ), |
|
81 | - 'body' => array( |
|
82 | - 'addresses' => $params->getAddressesArray(), |
|
83 | - 'parameters' => $params->getParametersArray() |
|
84 | - ) |
|
85 | - )); |
|
69 | + public static function optimize(OptimizationProblemParams $params) |
|
70 | + { |
|
71 | + $optimize = Route4Me::makeRequst(array( |
|
72 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
73 | + 'method' => 'POST', |
|
74 | + 'query' => array( |
|
75 | + 'redirect' => isset($params->redirect) ? $params->redirect : null, |
|
76 | + 'directions' => isset($params->directions) ? $params->directions : null, |
|
77 | + 'format' => isset($params->format) ? $params->format : null, |
|
78 | + 'route_path_output' => isset($params->route_path_output) ? $params->route_path_output : null, |
|
79 | + 'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null |
|
80 | + ), |
|
81 | + 'body' => array( |
|
82 | + 'addresses' => $params->getAddressesArray(), |
|
83 | + 'parameters' => $params->getParametersArray() |
|
84 | + ) |
|
85 | + )); |
|
86 | 86 | |
87 | - return OptimizationProblem::fromArray($optimize); |
|
88 | - } |
|
87 | + return OptimizationProblem::fromArray($optimize); |
|
88 | + } |
|
89 | 89 | |
90 | - public static function get($params) |
|
91 | - { |
|
92 | - $optimize = Route4Me::makeRequst(array( |
|
93 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
94 | - 'method' => 'GET', |
|
95 | - 'query' => array( |
|
96 | - 'state' => isset($params['state']) ? $params['state'] : null, |
|
97 | - 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
98 | - 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
99 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
100 | - ? $params['optimization_problem_id'] : null, |
|
101 | - 'wait_for_final_state' => isset($params['wait_for_final_state']) |
|
102 | - ? $params['wait_for_final_state'] : null, |
|
103 | - ) |
|
104 | - )); |
|
90 | + public static function get($params) |
|
91 | + { |
|
92 | + $optimize = Route4Me::makeRequst(array( |
|
93 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
94 | + 'method' => 'GET', |
|
95 | + 'query' => array( |
|
96 | + 'state' => isset($params['state']) ? $params['state'] : null, |
|
97 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
98 | + 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
99 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
100 | + ? $params['optimization_problem_id'] : null, |
|
101 | + 'wait_for_final_state' => isset($params['wait_for_final_state']) |
|
102 | + ? $params['wait_for_final_state'] : null, |
|
103 | + ) |
|
104 | + )); |
|
105 | 105 | |
106 | - if (isset($optimize['optimizations'])) { |
|
107 | - $problems = array(); |
|
106 | + if (isset($optimize['optimizations'])) { |
|
107 | + $problems = array(); |
|
108 | 108 | |
109 | - foreach($optimize['optimizations'] as $problem) { |
|
110 | - $problems[] = OptimizationProblem::fromArray($problem); |
|
111 | - } |
|
109 | + foreach($optimize['optimizations'] as $problem) { |
|
110 | + $problems[] = OptimizationProblem::fromArray($problem); |
|
111 | + } |
|
112 | 112 | |
113 | - return $problems; |
|
114 | - } else { |
|
115 | - return OptimizationProblem::fromArray($optimize); |
|
116 | - } |
|
117 | - } |
|
113 | + return $problems; |
|
114 | + } else { |
|
115 | + return OptimizationProblem::fromArray($optimize); |
|
116 | + } |
|
117 | + } |
|
118 | 118 | |
119 | - public static function reoptimize($params) |
|
120 | - { |
|
121 | - $param = new OptimizationProblemParams; |
|
122 | - $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
123 | - $param->reoptimize = 1; |
|
119 | + public static function reoptimize($params) |
|
120 | + { |
|
121 | + $param = new OptimizationProblemParams; |
|
122 | + $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
123 | + $param->reoptimize = 1; |
|
124 | 124 | |
125 | - return self::update((array)$param); |
|
126 | - } |
|
125 | + return self::update((array)$param); |
|
126 | + } |
|
127 | 127 | |
128 | - public static function update($params) |
|
129 | - { |
|
130 | - $optimize = Route4Me::makeRequst(array( |
|
131 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
132 | - 'method' => 'PUT', |
|
133 | - 'query' => array( |
|
134 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
135 | - ? $params['optimization_problem_id'] : null, |
|
136 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
137 | - 'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null, |
|
138 | - ) |
|
139 | - )); |
|
128 | + public static function update($params) |
|
129 | + { |
|
130 | + $optimize = Route4Me::makeRequst(array( |
|
131 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
132 | + 'method' => 'PUT', |
|
133 | + 'query' => array( |
|
134 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
135 | + ? $params['optimization_problem_id'] : null, |
|
136 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
137 | + 'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null, |
|
138 | + ) |
|
139 | + )); |
|
140 | 140 | |
141 | - return $optimize; |
|
142 | - } |
|
141 | + return $optimize; |
|
142 | + } |
|
143 | 143 | |
144 | - public function getOptimizationId() |
|
145 | - { |
|
146 | - return $this->optimization_problem_id; |
|
147 | - } |
|
144 | + public function getOptimizationId() |
|
145 | + { |
|
146 | + return $this->optimization_problem_id; |
|
147 | + } |
|
148 | 148 | |
149 | - public function getRoutes() |
|
150 | - { |
|
151 | - return $this->routes; |
|
152 | - } |
|
149 | + public function getRoutes() |
|
150 | + { |
|
151 | + return $this->routes; |
|
152 | + } |
|
153 | 153 | |
154 | - public function getRandomOptimizationId($offset,$limit) |
|
155 | - { |
|
156 | - $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
|
157 | - $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
154 | + public function getRandomOptimizationId($offset,$limit) |
|
155 | + { |
|
156 | + $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
|
157 | + $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
158 | 158 | |
159 | - $json = Route4Me::makeRequst(array( |
|
160 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
161 | - 'method' => 'GET', |
|
162 | - 'query' => $query |
|
163 | - )); |
|
159 | + $json = Route4Me::makeRequst(array( |
|
160 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
161 | + 'method' => 'GET', |
|
162 | + 'query' => $query |
|
163 | + )); |
|
164 | 164 | |
165 | - $optimizations = array(); |
|
166 | - foreach($json as $optimization) { |
|
167 | - if (gettype($optimization)!="array") continue; |
|
165 | + $optimizations = array(); |
|
166 | + foreach($json as $optimization) { |
|
167 | + if (gettype($optimization)!="array") continue; |
|
168 | 168 | |
169 | - foreach ($optimization as $otp1) { |
|
170 | - $optimizations[] = $otp1; |
|
171 | - } |
|
172 | - } |
|
169 | + foreach ($optimization as $otp1) { |
|
170 | + $optimizations[] = $otp1; |
|
171 | + } |
|
172 | + } |
|
173 | 173 | |
174 | - $num = rand(0,sizeof($optimizations)-1); |
|
174 | + $num = rand(0,sizeof($optimizations)-1); |
|
175 | 175 | |
176 | - $rOptimization = $optimizations[$num]; |
|
176 | + $rOptimization = $optimizations[$num]; |
|
177 | 177 | |
178 | - return $rOptimization['optimization_problem_id']; |
|
179 | - } |
|
178 | + return $rOptimization['optimization_problem_id']; |
|
179 | + } |
|
180 | 180 | |
181 | - public function getAddresses($opt_id) |
|
182 | - { |
|
183 | - if ($opt_id == null) return null; |
|
181 | + public function getAddresses($opt_id) |
|
182 | + { |
|
183 | + if ($opt_id == null) return null; |
|
184 | 184 | |
185 | - $params = array( "optimization_problem_id" => $opt_id ); |
|
185 | + $params = array( "optimization_problem_id" => $opt_id ); |
|
186 | 186 | |
187 | - $optimization = (array)$this->get($params); |
|
187 | + $optimization = (array)$this->get($params); |
|
188 | 188 | |
189 | - $addresses = $optimization["addresses"]; |
|
189 | + $addresses = $optimization["addresses"]; |
|
190 | 190 | |
191 | - return $addresses; |
|
192 | - } |
|
191 | + return $addresses; |
|
192 | + } |
|
193 | 193 | |
194 | - public function getRandomAddressFromOptimization($opt_id) |
|
195 | - { |
|
196 | - $addresses = (array)$this->getAddresses($opt_id); |
|
194 | + public function getRandomAddressFromOptimization($opt_id) |
|
195 | + { |
|
196 | + $addresses = (array)$this->getAddresses($opt_id); |
|
197 | 197 | |
198 | - if ($addresses == null) { |
|
199 | - echo "There are no addresses in this optimization!.. Try again."; |
|
200 | - return null; |
|
201 | - } |
|
198 | + if ($addresses == null) { |
|
199 | + echo "There are no addresses in this optimization!.. Try again."; |
|
200 | + return null; |
|
201 | + } |
|
202 | 202 | |
203 | - $num = rand(0,sizeof($addresses)-1); |
|
203 | + $num = rand(0,sizeof($addresses)-1); |
|
204 | 204 | |
205 | - $rAddress = $addresses[$num]; |
|
205 | + $rAddress = $addresses[$num]; |
|
206 | 206 | |
207 | - return $rAddress; |
|
208 | - } |
|
207 | + return $rAddress; |
|
208 | + } |
|
209 | 209 | |
210 | - public function removeAddress($params) |
|
211 | - { |
|
212 | - $response = Route4Me::makeRequst(array( |
|
213 | - 'url' => Endpoint::ADDRESS_V4, |
|
214 | - 'method' => 'DELETE', |
|
215 | - 'query' => array( |
|
216 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
217 | - ? $params['optimization_problem_id'] : null, |
|
218 | - 'route_destination_id' => isset($params['route_destination_id']) |
|
219 | - ? $params['route_destination_id'] : null, |
|
220 | - ) |
|
221 | - )); |
|
210 | + public function removeAddress($params) |
|
211 | + { |
|
212 | + $response = Route4Me::makeRequst(array( |
|
213 | + 'url' => Endpoint::ADDRESS_V4, |
|
214 | + 'method' => 'DELETE', |
|
215 | + 'query' => array( |
|
216 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
217 | + ? $params['optimization_problem_id'] : null, |
|
218 | + 'route_destination_id' => isset($params['route_destination_id']) |
|
219 | + ? $params['route_destination_id'] : null, |
|
220 | + ) |
|
221 | + )); |
|
222 | 222 | |
223 | - return $response; |
|
224 | - } |
|
223 | + return $response; |
|
224 | + } |
|
225 | 225 | |
226 | - public function removeOptimization($params) |
|
227 | - { |
|
228 | - $response = Route4Me::makeRequst(array( |
|
229 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
230 | - 'method' => 'DELETE', |
|
231 | - 'query' => array( |
|
232 | - 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
233 | - ), |
|
234 | - 'body' => array( |
|
235 | - 'optimization_problem_ids' => isset($params['optimization_problem_ids']) |
|
236 | - ? $params['optimization_problem_ids'] : null, |
|
237 | - ) |
|
238 | - )); |
|
226 | + public function removeOptimization($params) |
|
227 | + { |
|
228 | + $response = Route4Me::makeRequst(array( |
|
229 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
230 | + 'method' => 'DELETE', |
|
231 | + 'query' => array( |
|
232 | + 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
233 | + ), |
|
234 | + 'body' => array( |
|
235 | + 'optimization_problem_ids' => isset($params['optimization_problem_ids']) |
|
236 | + ? $params['optimization_problem_ids'] : null, |
|
237 | + ) |
|
238 | + )); |
|
239 | 239 | |
240 | - return $response; |
|
241 | - } |
|
240 | + return $response; |
|
241 | + } |
|
242 | 242 | |
243 | - public function getHybridOptimization($params) |
|
244 | - { |
|
245 | - $optimize = Route4Me::makeRequst(array( |
|
246 | - 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
247 | - 'method' => 'GET', |
|
248 | - 'query' => array( |
|
249 | - 'target_date_string' => isset($params['target_date_string']) |
|
250 | - ? $params['target_date_string'] : null, |
|
251 | - 'timezone_offset_minutes' => isset($params['timezone_offset_minutes']) |
|
252 | - ? $params['timezone_offset_minutes'] : null |
|
253 | - ) |
|
254 | - )); |
|
243 | + public function getHybridOptimization($params) |
|
244 | + { |
|
245 | + $optimize = Route4Me::makeRequst(array( |
|
246 | + 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
247 | + 'method' => 'GET', |
|
248 | + 'query' => array( |
|
249 | + 'target_date_string' => isset($params['target_date_string']) |
|
250 | + ? $params['target_date_string'] : null, |
|
251 | + 'timezone_offset_minutes' => isset($params['timezone_offset_minutes']) |
|
252 | + ? $params['timezone_offset_minutes'] : null |
|
253 | + ) |
|
254 | + )); |
|
255 | 255 | |
256 | - return $optimize; |
|
257 | - } |
|
256 | + return $optimize; |
|
257 | + } |
|
258 | 258 | |
259 | - Public function addDepotsToHybrid($params) |
|
260 | - { |
|
261 | - $depots = Route4Me::makeRequst(array( |
|
262 | - 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
263 | - 'method' => 'POST', |
|
264 | - 'query' => array( |
|
265 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
266 | - ? $params['optimization_problem_id'] : null, |
|
267 | - ), |
|
268 | - 'body' => array( |
|
269 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
270 | - ? $params['optimization_problem_id'] : null, |
|
271 | - 'delete_old_depots' => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null, |
|
272 | - 'new_depots' => isset($params['new_depots']) ? $params['new_depots'] : null, |
|
273 | - ) |
|
274 | - )); |
|
259 | + Public function addDepotsToHybrid($params) |
|
260 | + { |
|
261 | + $depots = Route4Me::makeRequst(array( |
|
262 | + 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
263 | + 'method' => 'POST', |
|
264 | + 'query' => array( |
|
265 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
266 | + ? $params['optimization_problem_id'] : null, |
|
267 | + ), |
|
268 | + 'body' => array( |
|
269 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) |
|
270 | + ? $params['optimization_problem_id'] : null, |
|
271 | + 'delete_old_depots' => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null, |
|
272 | + 'new_depots' => isset($params['new_depots']) ? $params['new_depots'] : null, |
|
273 | + ) |
|
274 | + )); |
|
275 | 275 | |
276 | - return $depots; |
|
277 | - } |
|
276 | + return $depots; |
|
277 | + } |
|
278 | 278 | } |
@@ -6,380 +6,380 @@ |
||
6 | 6 | |
7 | 7 | class Order extends Common |
8 | 8 | { |
9 | - public $address_1; |
|
10 | - public $address_2; |
|
11 | - public $cached_lat; |
|
12 | - public $cached_lng; |
|
13 | - public $curbside_lat; |
|
14 | - public $curbside_lng; |
|
15 | - public $address_alias; |
|
16 | - public $address_city; |
|
17 | - public $EXT_FIELD_first_name; |
|
18 | - public $EXT_FIELD_last_name; |
|
19 | - public $EXT_FIELD_email; |
|
20 | - public $EXT_FIELD_phone; |
|
21 | - public $EXT_FIELD_custom_data; |
|
9 | + public $address_1; |
|
10 | + public $address_2; |
|
11 | + public $cached_lat; |
|
12 | + public $cached_lng; |
|
13 | + public $curbside_lat; |
|
14 | + public $curbside_lng; |
|
15 | + public $address_alias; |
|
16 | + public $address_city; |
|
17 | + public $EXT_FIELD_first_name; |
|
18 | + public $EXT_FIELD_last_name; |
|
19 | + public $EXT_FIELD_email; |
|
20 | + public $EXT_FIELD_phone; |
|
21 | + public $EXT_FIELD_custom_data; |
|
22 | 22 | |
23 | - public $color; |
|
24 | - public $order_icon; |
|
25 | - public $local_time_window_start; |
|
26 | - public $local_time_window_end; |
|
27 | - public $local_time_window_start_2; |
|
28 | - public $local_time_window_end_2; |
|
29 | - public $service_time; |
|
23 | + public $color; |
|
24 | + public $order_icon; |
|
25 | + public $local_time_window_start; |
|
26 | + public $local_time_window_end; |
|
27 | + public $local_time_window_start_2; |
|
28 | + public $local_time_window_end_2; |
|
29 | + public $service_time; |
|
30 | 30 | |
31 | - public $day_scheduled_for_YYMMDD; |
|
31 | + public $day_scheduled_for_YYMMDD; |
|
32 | 32 | |
33 | - public $route_id; |
|
34 | - public $redirect; |
|
35 | - public $optimization_problem_id; |
|
36 | - public $order_id; |
|
37 | - public $order_ids; |
|
33 | + public $route_id; |
|
34 | + public $redirect; |
|
35 | + public $optimization_problem_id; |
|
36 | + public $order_id; |
|
37 | + public $order_ids; |
|
38 | 38 | |
39 | - public $day_added_YYMMDD; |
|
40 | - public $scheduled_for_YYMMDD; |
|
41 | - public $fields; |
|
42 | - public $offset; |
|
43 | - public $limit; |
|
44 | - public $query; |
|
39 | + public $day_added_YYMMDD; |
|
40 | + public $scheduled_for_YYMMDD; |
|
41 | + public $fields; |
|
42 | + public $offset; |
|
43 | + public $limit; |
|
44 | + public $query; |
|
45 | 45 | |
46 | - public $created_timestamp; |
|
47 | - public $order_status_id; |
|
48 | - public $member_id; |
|
49 | - public $address_state_id; |
|
50 | - public $address_country_id; |
|
51 | - public $address_zip; |
|
52 | - public $in_route_count; |
|
53 | - public $last_visited_timestamp; |
|
54 | - public $last_routed_timestamp; |
|
55 | - public $local_timezone_string; |
|
56 | - public $is_validated; |
|
57 | - public $is_pending; |
|
58 | - public $is_accepted; |
|
59 | - public $is_started; |
|
60 | - public $is_completed; |
|
61 | - public $custom_user_fields; |
|
46 | + public $created_timestamp; |
|
47 | + public $order_status_id; |
|
48 | + public $member_id; |
|
49 | + public $address_state_id; |
|
50 | + public $address_country_id; |
|
51 | + public $address_zip; |
|
52 | + public $in_route_count; |
|
53 | + public $last_visited_timestamp; |
|
54 | + public $last_routed_timestamp; |
|
55 | + public $local_timezone_string; |
|
56 | + public $is_validated; |
|
57 | + public $is_pending; |
|
58 | + public $is_accepted; |
|
59 | + public $is_started; |
|
60 | + public $is_completed; |
|
61 | + public $custom_user_fields; |
|
62 | 62 | |
63 | - public static function fromArray(array $params) { |
|
64 | - $order= new Order(); |
|
65 | - foreach($params as $key => $value) { |
|
66 | - if (property_exists($order, $key)) { |
|
67 | - $order->{$key} = $value; |
|
68 | - } |
|
69 | - } |
|
63 | + public static function fromArray(array $params) { |
|
64 | + $order= new Order(); |
|
65 | + foreach($params as $key => $value) { |
|
66 | + if (property_exists($order, $key)) { |
|
67 | + $order->{$key} = $value; |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | - return $order; |
|
72 | - } |
|
71 | + return $order; |
|
72 | + } |
|
73 | 73 | |
74 | - public static function addOrder($params) |
|
75 | - { |
|
76 | - $response = Route4Me::makeRequst(array( |
|
77 | - 'url' => Endpoint::ORDER_V4, |
|
78 | - 'method' => 'POST', |
|
79 | - 'body' => array( |
|
80 | - 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
81 | - 'address_2' => isset($params->address_2) ? $params->address_2: null, |
|
82 | - 'member_id' => isset($params->member_id) ? $params->member_id: null, |
|
83 | - 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
84 | - 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
85 | - 'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null, |
|
86 | - 'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null, |
|
87 | - 'color' => isset($params->color) ? $params->color : null, |
|
88 | - 'order_icon' => isset($params->order_icon) ? $params->order_icon : null, |
|
89 | - 'day_scheduled_for_YYMMDD' => isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null, |
|
90 | - 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
|
91 | - 'address_city' => isset($params->address_city) ? $params->address_city: null, |
|
92 | - 'address_state_id' => isset($params->address_state_id) ? $params->address_state_id: null, |
|
93 | - 'address_country_id' => isset($params->address_country_id) ? $params->address_country_id: null, |
|
94 | - 'address_zip' => isset($params->address_zip) ? $params->address_zip: null, |
|
95 | - 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start: null, |
|
96 | - 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end: null, |
|
97 | - 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null, |
|
98 | - 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null, |
|
99 | - 'service_time' => isset($params->service_time) ? $params->service_time: null, |
|
100 | - 'local_timezone_string' => isset($params->local_timezone_string) ? $params->local_timezone_string: null, |
|
101 | - 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null, |
|
102 | - 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null, |
|
103 | - 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null, |
|
104 | - 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null, |
|
105 | - 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null, |
|
106 | - 'is_validated' => isset($params->is_validated) ? $params->is_validated: null, |
|
107 | - 'is_pending' => isset($params->is_pending) ? $params->is_pending: null, |
|
108 | - 'is_accepted' => isset($params->is_accepted) ? $params->is_accepted: null, |
|
109 | - 'is_started' => isset($params->is_started) ? $params->is_started: null, |
|
110 | - 'is_completed' => isset($params->is_completed) ? $params->is_completed: null, |
|
111 | - 'custom_user_fields' => isset($params->custom_user_fields) ? $params->custom_user_fields: null |
|
112 | - ) |
|
113 | - )); |
|
74 | + public static function addOrder($params) |
|
75 | + { |
|
76 | + $response = Route4Me::makeRequst(array( |
|
77 | + 'url' => Endpoint::ORDER_V4, |
|
78 | + 'method' => 'POST', |
|
79 | + 'body' => array( |
|
80 | + 'address_1' => isset($params->address_1) ? $params->address_1: null, |
|
81 | + 'address_2' => isset($params->address_2) ? $params->address_2: null, |
|
82 | + 'member_id' => isset($params->member_id) ? $params->member_id: null, |
|
83 | + 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
84 | + 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
85 | + 'curbside_lat' => isset($params->curbside_lat) ? $params->curbside_lat : null, |
|
86 | + 'curbside_lng' => isset($params->curbside_lng) ? $params->curbside_lng : null, |
|
87 | + 'color' => isset($params->color) ? $params->color : null, |
|
88 | + 'order_icon' => isset($params->order_icon) ? $params->order_icon : null, |
|
89 | + 'day_scheduled_for_YYMMDD' => isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null, |
|
90 | + 'address_alias' => isset($params->address_alias) ? $params->address_alias : null, |
|
91 | + 'address_city' => isset($params->address_city) ? $params->address_city: null, |
|
92 | + 'address_state_id' => isset($params->address_state_id) ? $params->address_state_id: null, |
|
93 | + 'address_country_id' => isset($params->address_country_id) ? $params->address_country_id: null, |
|
94 | + 'address_zip' => isset($params->address_zip) ? $params->address_zip: null, |
|
95 | + 'local_time_window_start' => isset($params->local_time_window_start) ? $params->local_time_window_start: null, |
|
96 | + 'local_time_window_end' => isset($params->local_time_window_end) ? $params->local_time_window_end: null, |
|
97 | + 'local_time_window_start_2' => isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null, |
|
98 | + 'local_time_window_end_2' => isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null, |
|
99 | + 'service_time' => isset($params->service_time) ? $params->service_time: null, |
|
100 | + 'local_timezone_string' => isset($params->local_timezone_string) ? $params->local_timezone_string: null, |
|
101 | + 'EXT_FIELD_first_name' => isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null, |
|
102 | + 'EXT_FIELD_last_name' => isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null, |
|
103 | + 'EXT_FIELD_email' => isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null, |
|
104 | + 'EXT_FIELD_phone' => isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null, |
|
105 | + 'EXT_FIELD_custom_data' => isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null, |
|
106 | + 'is_validated' => isset($params->is_validated) ? $params->is_validated: null, |
|
107 | + 'is_pending' => isset($params->is_pending) ? $params->is_pending: null, |
|
108 | + 'is_accepted' => isset($params->is_accepted) ? $params->is_accepted: null, |
|
109 | + 'is_started' => isset($params->is_started) ? $params->is_started: null, |
|
110 | + 'is_completed' => isset($params->is_completed) ? $params->is_completed: null, |
|
111 | + 'custom_user_fields' => isset($params->custom_user_fields) ? $params->custom_user_fields: null |
|
112 | + ) |
|
113 | + )); |
|
114 | 114 | |
115 | - return $response; |
|
116 | - } |
|
115 | + return $response; |
|
116 | + } |
|
117 | 117 | |
118 | - public static function addOrder2Route($params,$body) |
|
119 | - { |
|
120 | - $response = Route4Me::makeRequst(array( |
|
121 | - 'url' => Endpoint::ROUTE_V4, |
|
122 | - 'method' => 'PUT', |
|
123 | - 'query' => array( |
|
124 | - 'route_id' => isset($params->route_id) ? $params->route_id: null, |
|
125 | - 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
126 | - ), |
|
127 | - 'body' => (array)$body |
|
128 | - )); |
|
118 | + public static function addOrder2Route($params,$body) |
|
119 | + { |
|
120 | + $response = Route4Me::makeRequst(array( |
|
121 | + 'url' => Endpoint::ROUTE_V4, |
|
122 | + 'method' => 'PUT', |
|
123 | + 'query' => array( |
|
124 | + 'route_id' => isset($params->route_id) ? $params->route_id: null, |
|
125 | + 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
126 | + ), |
|
127 | + 'body' => (array)$body |
|
128 | + )); |
|
129 | 129 | |
130 | - return $response; |
|
131 | - } |
|
130 | + return $response; |
|
131 | + } |
|
132 | 132 | |
133 | - public static function addOrder2Optimization($params,$body) |
|
134 | - { |
|
135 | - $response = Route4Me::makeRequst(array( |
|
136 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
137 | - 'method' => 'PUT', |
|
138 | - 'query' => array( |
|
139 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
140 | - 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
141 | - 'device_type' => isset($params['device_type']) ? $params['device_type'] : null |
|
142 | - ), |
|
143 | - 'body' => (array)$body |
|
144 | - )); |
|
133 | + public static function addOrder2Optimization($params,$body) |
|
134 | + { |
|
135 | + $response = Route4Me::makeRequst(array( |
|
136 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
137 | + 'method' => 'PUT', |
|
138 | + 'query' => array( |
|
139 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
140 | + 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
141 | + 'device_type' => isset($params['device_type']) ? $params['device_type'] : null |
|
142 | + ), |
|
143 | + 'body' => (array)$body |
|
144 | + )); |
|
145 | 145 | |
146 | - return $response; |
|
147 | - } |
|
146 | + return $response; |
|
147 | + } |
|
148 | 148 | |
149 | - public static function getOrder($params) |
|
150 | - { |
|
151 | - $response = Route4Me::makeRequst(array( |
|
152 | - 'url' => Endpoint::ORDER_V4, |
|
153 | - 'method' => 'GET', |
|
154 | - 'query' => array( |
|
155 | - 'order_id' => isset($params->order_id) ? $params->order_id: null, |
|
156 | - 'fields' => isset($params->fields) ? $params->fields: null, |
|
157 | - 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null, |
|
158 | - 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null, |
|
159 | - 'query' => isset($params->query) ? $params->query: null, |
|
160 | - 'offset' => isset($params->offset) ? $params->offset: null, |
|
161 | - 'limit' => isset($params->limit) ? $params->limit: null |
|
162 | - ) |
|
163 | - )); |
|
149 | + public static function getOrder($params) |
|
150 | + { |
|
151 | + $response = Route4Me::makeRequst(array( |
|
152 | + 'url' => Endpoint::ORDER_V4, |
|
153 | + 'method' => 'GET', |
|
154 | + 'query' => array( |
|
155 | + 'order_id' => isset($params->order_id) ? $params->order_id: null, |
|
156 | + 'fields' => isset($params->fields) ? $params->fields: null, |
|
157 | + 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null, |
|
158 | + 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null, |
|
159 | + 'query' => isset($params->query) ? $params->query: null, |
|
160 | + 'offset' => isset($params->offset) ? $params->offset: null, |
|
161 | + 'limit' => isset($params->limit) ? $params->limit: null |
|
162 | + ) |
|
163 | + )); |
|
164 | 164 | |
165 | - return $response; |
|
166 | - } |
|
165 | + return $response; |
|
166 | + } |
|
167 | 167 | |
168 | - public static function getOrders($params) |
|
169 | - { |
|
170 | - $response = Route4Me::makeRequst(array( |
|
171 | - 'url' => Endpoint::ORDER_V4, |
|
172 | - 'method' => 'GET', |
|
173 | - 'query' => array( |
|
174 | - 'offset' => isset($params->offset) ? $params->offset: null, |
|
175 | - 'limit' => isset($params->limit) ? $params->limit: null |
|
176 | - ) |
|
177 | - )); |
|
168 | + public static function getOrders($params) |
|
169 | + { |
|
170 | + $response = Route4Me::makeRequst(array( |
|
171 | + 'url' => Endpoint::ORDER_V4, |
|
172 | + 'method' => 'GET', |
|
173 | + 'query' => array( |
|
174 | + 'offset' => isset($params->offset) ? $params->offset: null, |
|
175 | + 'limit' => isset($params->limit) ? $params->limit: null |
|
176 | + ) |
|
177 | + )); |
|
178 | 178 | |
179 | - return $response; |
|
180 | - } |
|
179 | + return $response; |
|
180 | + } |
|
181 | 181 | |
182 | - public function getRandomOrderId($offset,$limit) |
|
183 | - { |
|
184 | - $params = array('offset' => $offset, 'limit' => $limit); |
|
182 | + public function getRandomOrderId($offset,$limit) |
|
183 | + { |
|
184 | + $params = array('offset' => $offset, 'limit' => $limit); |
|
185 | 185 | |
186 | - $orders = self::getOrders($params); |
|
186 | + $orders = self::getOrders($params); |
|
187 | 187 | |
188 | - if (is_null($orders)) return null; |
|
189 | - if (!isset($orders['results'])) return null; |
|
188 | + if (is_null($orders)) return null; |
|
189 | + if (!isset($orders['results'])) return null; |
|
190 | 190 | |
191 | - $randomIndex = rand(0, sizeof($orders['results'])-1); |
|
191 | + $randomIndex = rand(0, sizeof($orders['results'])-1); |
|
192 | 192 | |
193 | - $order = $orders['results'][$randomIndex]; |
|
193 | + $order = $orders['results'][$randomIndex]; |
|
194 | 194 | |
195 | - return $order['order_id']; |
|
196 | - } |
|
195 | + return $order['order_id']; |
|
196 | + } |
|
197 | 197 | |
198 | - public function getRandomOrder($offset,$limit) |
|
199 | - { |
|
200 | - $params = array('offset' => $offset, 'limit' => $limit); |
|
198 | + public function getRandomOrder($offset,$limit) |
|
199 | + { |
|
200 | + $params = array('offset' => $offset, 'limit' => $limit); |
|
201 | 201 | |
202 | - $orders = self::getOrders($params); |
|
202 | + $orders = self::getOrders($params); |
|
203 | 203 | |
204 | - if (is_null($orders)) return null; |
|
205 | - if (!isset($orders['results'])) return null; |
|
204 | + if (is_null($orders)) return null; |
|
205 | + if (!isset($orders['results'])) return null; |
|
206 | 206 | |
207 | - $randomIndex = rand(0, sizeof($orders['results'])-1); |
|
207 | + $randomIndex = rand(0, sizeof($orders['results'])-1); |
|
208 | 208 | |
209 | - $order = $orders['results'][$randomIndex]; |
|
209 | + $order = $orders['results'][$randomIndex]; |
|
210 | 210 | |
211 | - return $order; |
|
212 | - } |
|
211 | + return $order; |
|
212 | + } |
|
213 | 213 | |
214 | - public static function removeOrder($params) |
|
215 | - { |
|
216 | - $response = Route4Me::makeRequst(array( |
|
217 | - 'url' => Endpoint::ORDER_V4, |
|
218 | - 'method' => 'DELETE', |
|
219 | - 'body' => array( |
|
220 | - 'order_ids' => isset($params->order_ids) ? $params->order_ids: null |
|
221 | - ) |
|
222 | - )); |
|
214 | + public static function removeOrder($params) |
|
215 | + { |
|
216 | + $response = Route4Me::makeRequst(array( |
|
217 | + 'url' => Endpoint::ORDER_V4, |
|
218 | + 'method' => 'DELETE', |
|
219 | + 'body' => array( |
|
220 | + 'order_ids' => isset($params->order_ids) ? $params->order_ids: null |
|
221 | + ) |
|
222 | + )); |
|
223 | 223 | |
224 | - return $response; |
|
225 | - } |
|
224 | + return $response; |
|
225 | + } |
|
226 | 226 | |
227 | - public static function updateOrder($body) |
|
228 | - { |
|
229 | - $response = Route4Me::makeRequst(array( |
|
230 | - 'url' => Endpoint::ORDER_V4, |
|
231 | - 'method' => 'PUT', |
|
232 | - 'body' => (array)$body |
|
233 | - )); |
|
227 | + public static function updateOrder($body) |
|
228 | + { |
|
229 | + $response = Route4Me::makeRequst(array( |
|
230 | + 'url' => Endpoint::ORDER_V4, |
|
231 | + 'method' => 'PUT', |
|
232 | + 'body' => (array)$body |
|
233 | + )); |
|
234 | 234 | |
235 | - return $response; |
|
236 | - } |
|
235 | + return $response; |
|
236 | + } |
|
237 | 237 | |
238 | - public static function searchOrder($params) |
|
239 | - { |
|
240 | - $response = Route4Me::makeRequst(array( |
|
241 | - 'url' => Endpoint::ORDER_V4, |
|
242 | - 'method' => 'GET', |
|
243 | - 'query' => array( |
|
244 | - 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null, |
|
245 | - 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null, |
|
246 | - 'fields' => isset($params->fields) ? $params->fields: null, |
|
247 | - 'offset' => isset($params->offset) ? $params->offset: null, |
|
248 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
249 | - 'query' => isset($params->query) ? $params->query: null, |
|
250 | - ) |
|
251 | - )); |
|
238 | + public static function searchOrder($params) |
|
239 | + { |
|
240 | + $response = Route4Me::makeRequst(array( |
|
241 | + 'url' => Endpoint::ORDER_V4, |
|
242 | + 'method' => 'GET', |
|
243 | + 'query' => array( |
|
244 | + 'day_added_YYMMDD' => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null, |
|
245 | + 'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null, |
|
246 | + 'fields' => isset($params->fields) ? $params->fields: null, |
|
247 | + 'offset' => isset($params->offset) ? $params->offset: null, |
|
248 | + 'limit' => isset($params->limit) ? $params->limit: null, |
|
249 | + 'query' => isset($params->query) ? $params->query: null, |
|
250 | + ) |
|
251 | + )); |
|
252 | 252 | |
253 | - return $response; |
|
254 | - } |
|
253 | + return $response; |
|
254 | + } |
|
255 | 255 | |
256 | - public static function validateLatitude($lat) |
|
257 | - { |
|
258 | - if (!is_numeric($lat)) return false; |
|
256 | + public static function validateLatitude($lat) |
|
257 | + { |
|
258 | + if (!is_numeric($lat)) return false; |
|
259 | 259 | |
260 | - if ($lat>90 || $lat<-90) return false; |
|
260 | + if ($lat>90 || $lat<-90) return false; |
|
261 | 261 | |
262 | - return true; |
|
263 | - } |
|
262 | + return true; |
|
263 | + } |
|
264 | 264 | |
265 | - public static function validateLongitude($lng) |
|
266 | - { |
|
267 | - if (!is_numeric($lng)) return false; |
|
265 | + public static function validateLongitude($lng) |
|
266 | + { |
|
267 | + if (!is_numeric($lng)) return false; |
|
268 | 268 | |
269 | - if ($lng>180 || $lng<-180) return false; |
|
269 | + if ($lng>180 || $lng<-180) return false; |
|
270 | 270 | |
271 | - return true; |
|
272 | - } |
|
271 | + return true; |
|
272 | + } |
|
273 | 273 | |
274 | - public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
275 | - { |
|
276 | - $max_line_length = 512; |
|
277 | - $delemietr = ','; |
|
274 | + public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
275 | + { |
|
276 | + $max_line_length = 512; |
|
277 | + $delemietr = ','; |
|
278 | 278 | |
279 | - $results = array(); |
|
280 | - $results['fail'] = array(); |
|
281 | - $results['success'] = array(); |
|
279 | + $results = array(); |
|
280 | + $results['fail'] = array(); |
|
281 | + $results['success'] = array(); |
|
282 | 282 | |
283 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
283 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
284 | 284 | |
285 | - if (!empty($columns)) { |
|
286 | - array_push($results['fail'],'Empty CSV table'); |
|
287 | - return ($results); |
|
288 | - } |
|
285 | + if (!empty($columns)) { |
|
286 | + array_push($results['fail'],'Empty CSV table'); |
|
287 | + return ($results); |
|
288 | + } |
|
289 | 289 | |
290 | - $iRow=1; |
|
290 | + $iRow=1; |
|
291 | 291 | |
292 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
293 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null) !== $rows) { |
|
292 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
293 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null) !== $rows) { |
|
294 | 294 | |
295 | - $cached_lat = 0.000; |
|
295 | + $cached_lat = 0.000; |
|
296 | 296 | |
297 | - if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) { |
|
298 | - array_push($results['fail'],"$iRow --> Wrong cached_lat"); |
|
299 | - $iRow++; |
|
300 | - continue; |
|
301 | - } |
|
302 | - else $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
297 | + if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) { |
|
298 | + array_push($results['fail'],"$iRow --> Wrong cached_lat"); |
|
299 | + $iRow++; |
|
300 | + continue; |
|
301 | + } |
|
302 | + else $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
303 | 303 | |
304 | - $cached_lng = 0.000; |
|
304 | + $cached_lng = 0.000; |
|
305 | 305 | |
306 | - if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) { |
|
307 | - array_push($results['fail'],"$iRow --> Wrong cached_lng"); |
|
308 | - $iRow++; |
|
309 | - continue; |
|
310 | - } |
|
311 | - else $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
306 | + if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) { |
|
307 | + array_push($results['fail'],"$iRow --> Wrong cached_lng"); |
|
308 | + $iRow++; |
|
309 | + continue; |
|
310 | + } |
|
311 | + else $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
312 | 312 | |
313 | - if (isset($ordersFieldsMapping['curbside_lat'])) { |
|
314 | - if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
|
315 | - array_push($results['fail'],"$iRow --> Wrong curbside_lat"); |
|
316 | - $iRow++; |
|
317 | - continue; |
|
318 | - } |
|
319 | - } |
|
313 | + if (isset($ordersFieldsMapping['curbside_lat'])) { |
|
314 | + if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
|
315 | + array_push($results['fail'],"$iRow --> Wrong curbside_lat"); |
|
316 | + $iRow++; |
|
317 | + continue; |
|
318 | + } |
|
319 | + } |
|
320 | 320 | |
321 | - if (isset($ordersFieldsMapping['curbside_lng'])) { |
|
322 | - if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) { |
|
323 | - array_push($results['fail'],"$iRow --> Wrong curbside_lng"); |
|
324 | - $iRow++; |
|
325 | - continue; |
|
326 | - } |
|
327 | - } |
|
321 | + if (isset($ordersFieldsMapping['curbside_lng'])) { |
|
322 | + if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) { |
|
323 | + array_push($results['fail'],"$iRow --> Wrong curbside_lng"); |
|
324 | + $iRow++; |
|
325 | + continue; |
|
326 | + } |
|
327 | + } |
|
328 | 328 | |
329 | - $address = $rows[$ordersFieldsMapping['address_1']]; |
|
329 | + $address = $rows[$ordersFieldsMapping['address_1']]; |
|
330 | 330 | |
331 | - if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
332 | - if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
333 | - if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
334 | - if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
331 | + if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
332 | + if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
333 | + if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
334 | + if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
335 | 335 | |
336 | - echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
336 | + echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
337 | 337 | |
338 | - $orderParameters = Order::fromArray(array( |
|
339 | - "cached_lat" => $cached_lat, |
|
340 | - "cached_lng" => $cached_lng, |
|
341 | - "curbside_lat" => isset($ordersFieldsMapping['curbside_lat']) ? $rows[$ordersFieldsMapping['curbside_lat']] : null, |
|
342 | - "curbside_lng" => isset($ordersFieldsMapping['curbside_lng']) ? $rows[$ordersFieldsMapping['curbside_lng']] : null, |
|
343 | - "color" => isset($ordersFieldsMapping['color']) ? $rows[$ordersFieldsMapping['color']] : null, |
|
344 | - "day_scheduled_for_YYMMDD" => isset($ordersFieldsMapping['day_scheduled_for_YYMMDD']) |
|
345 | - ? $rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']] : null, |
|
346 | - "address_alias" => isset($ordersFieldsMapping['address_alias']) ? $rows[$ordersFieldsMapping['address_alias']] : null, |
|
347 | - "address_1" => $address, |
|
348 | - "address_2" => isset($ordersFieldsMapping['address_2']) ? $rows[$ordersFieldsMapping['address_2']] : null, |
|
349 | - "local_time_window_start" => isset($ordersFieldsMapping['local_time_window_start']) |
|
350 | - ? $rows[$ordersFieldsMapping['local_time_window_start']] : null, |
|
351 | - "local_time_window_end" => isset($ordersFieldsMapping['local_time_window_end']) |
|
352 | - ? $rows[$ordersFieldsMapping['local_time_window_end']] : null, |
|
353 | - "local_time_window_start_2" => isset($ordersFieldsMapping['local_time_window_start_2']) |
|
354 | - ? $rows[$ordersFieldsMapping['local_time_window_start_2']] : null, |
|
355 | - "local_time_window_end_2" => isset($ordersFieldsMapping['local_time_window_end_2']) |
|
356 | - ? $rows[$ordersFieldsMapping['local_time_window_end_2']] : null, |
|
357 | - "service_time" => isset($ordersFieldsMapping['service_time']) |
|
358 | - ? $rows[$ordersFieldsMapping['service_time']] : null, |
|
359 | - "EXT_FIELD_first_name" => isset($ordersFieldsMapping['EXT_FIELD_first_name']) |
|
360 | - ? $rows[$ordersFieldsMapping['EXT_FIELD_first_name']] : null, |
|
361 | - "EXT_FIELD_last_name" => isset($ordersFieldsMapping['EXT_FIELD_last_name']) |
|
362 | - ? $rows[$ordersFieldsMapping['EXT_FIELD_last_name']] : null, |
|
363 | - "EXT_FIELD_email" => isset($ordersFieldsMapping['EXT_FIELD_email']) |
|
364 | - ? $rows[$ordersFieldsMapping['EXT_FIELD_email']] : null, |
|
365 | - "EXT_FIELD_phone" => isset($ordersFieldsMapping['EXT_FIELD_phone']) |
|
366 | - ? $rows[$ordersFieldsMapping['EXT_FIELD_phone']] : null, |
|
367 | - "EXT_FIELD_custom_data" => isset($ordersFieldsMapping['EXT_FIELD_custom_data']) |
|
368 | - ? $rows[$ordersFieldsMapping['EXT_FIELD_custom_data']] : null, |
|
369 | - "order_icon" => isset($ordersFieldsMapping['order_icon']) ? $rows[$ordersFieldsMapping['order_icon']] : null, |
|
370 | - )); |
|
338 | + $orderParameters = Order::fromArray(array( |
|
339 | + "cached_lat" => $cached_lat, |
|
340 | + "cached_lng" => $cached_lng, |
|
341 | + "curbside_lat" => isset($ordersFieldsMapping['curbside_lat']) ? $rows[$ordersFieldsMapping['curbside_lat']] : null, |
|
342 | + "curbside_lng" => isset($ordersFieldsMapping['curbside_lng']) ? $rows[$ordersFieldsMapping['curbside_lng']] : null, |
|
343 | + "color" => isset($ordersFieldsMapping['color']) ? $rows[$ordersFieldsMapping['color']] : null, |
|
344 | + "day_scheduled_for_YYMMDD" => isset($ordersFieldsMapping['day_scheduled_for_YYMMDD']) |
|
345 | + ? $rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']] : null, |
|
346 | + "address_alias" => isset($ordersFieldsMapping['address_alias']) ? $rows[$ordersFieldsMapping['address_alias']] : null, |
|
347 | + "address_1" => $address, |
|
348 | + "address_2" => isset($ordersFieldsMapping['address_2']) ? $rows[$ordersFieldsMapping['address_2']] : null, |
|
349 | + "local_time_window_start" => isset($ordersFieldsMapping['local_time_window_start']) |
|
350 | + ? $rows[$ordersFieldsMapping['local_time_window_start']] : null, |
|
351 | + "local_time_window_end" => isset($ordersFieldsMapping['local_time_window_end']) |
|
352 | + ? $rows[$ordersFieldsMapping['local_time_window_end']] : null, |
|
353 | + "local_time_window_start_2" => isset($ordersFieldsMapping['local_time_window_start_2']) |
|
354 | + ? $rows[$ordersFieldsMapping['local_time_window_start_2']] : null, |
|
355 | + "local_time_window_end_2" => isset($ordersFieldsMapping['local_time_window_end_2']) |
|
356 | + ? $rows[$ordersFieldsMapping['local_time_window_end_2']] : null, |
|
357 | + "service_time" => isset($ordersFieldsMapping['service_time']) |
|
358 | + ? $rows[$ordersFieldsMapping['service_time']] : null, |
|
359 | + "EXT_FIELD_first_name" => isset($ordersFieldsMapping['EXT_FIELD_first_name']) |
|
360 | + ? $rows[$ordersFieldsMapping['EXT_FIELD_first_name']] : null, |
|
361 | + "EXT_FIELD_last_name" => isset($ordersFieldsMapping['EXT_FIELD_last_name']) |
|
362 | + ? $rows[$ordersFieldsMapping['EXT_FIELD_last_name']] : null, |
|
363 | + "EXT_FIELD_email" => isset($ordersFieldsMapping['EXT_FIELD_email']) |
|
364 | + ? $rows[$ordersFieldsMapping['EXT_FIELD_email']] : null, |
|
365 | + "EXT_FIELD_phone" => isset($ordersFieldsMapping['EXT_FIELD_phone']) |
|
366 | + ? $rows[$ordersFieldsMapping['EXT_FIELD_phone']] : null, |
|
367 | + "EXT_FIELD_custom_data" => isset($ordersFieldsMapping['EXT_FIELD_custom_data']) |
|
368 | + ? $rows[$ordersFieldsMapping['EXT_FIELD_custom_data']] : null, |
|
369 | + "order_icon" => isset($ordersFieldsMapping['order_icon']) ? $rows[$ordersFieldsMapping['order_icon']] : null, |
|
370 | + )); |
|
371 | 371 | |
372 | - $order = new Order(); |
|
372 | + $order = new Order(); |
|
373 | 373 | |
374 | - $orderResults = $order->addOrder($orderParameters); |
|
374 | + $orderResults = $order->addOrder($orderParameters); |
|
375 | 375 | |
376 | - array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
377 | - } |
|
378 | - else { |
|
379 | - array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
380 | - } |
|
376 | + array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
377 | + } |
|
378 | + else { |
|
379 | + array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
380 | + } |
|
381 | 381 | |
382 | - $iRow++; |
|
383 | - } |
|
384 | - } |
|
382 | + $iRow++; |
|
383 | + } |
|
384 | + } |
|
385 | 385 | } |
@@ -6,141 +6,141 @@ |
||
6 | 6 | |
7 | 7 | class Geocoding extends Common |
8 | 8 | { |
9 | - public $strExportFormat; |
|
10 | - public $format; |
|
11 | - public $addresses; |
|
12 | - public $pk; |
|
13 | - public $offset; |
|
14 | - public $limit; |
|
15 | - public $housenumber; |
|
16 | - public $zipcode; |
|
9 | + public $strExportFormat; |
|
10 | + public $format; |
|
11 | + public $addresses; |
|
12 | + public $pk; |
|
13 | + public $offset; |
|
14 | + public $limit; |
|
15 | + public $housenumber; |
|
16 | + public $zipcode; |
|
17 | 17 | |
18 | - public static function fromArray(array $params) |
|
19 | - { |
|
20 | - $geocoding = new Geocoding(); |
|
21 | - |
|
22 | - foreach($params as $key => $value) { |
|
23 | - if (property_exists($geocoding, $key)) { |
|
24 | - $geocoding->{$key} = $value; |
|
25 | - } |
|
26 | - } |
|
27 | - |
|
28 | - return $geocoding; |
|
29 | - } |
|
18 | + public static function fromArray(array $params) |
|
19 | + { |
|
20 | + $geocoding = new Geocoding(); |
|
21 | + |
|
22 | + foreach($params as $key => $value) { |
|
23 | + if (property_exists($geocoding, $key)) { |
|
24 | + $geocoding->{$key} = $value; |
|
25 | + } |
|
26 | + } |
|
27 | + |
|
28 | + return $geocoding; |
|
29 | + } |
|
30 | 30 | |
31 | - public static function forwardGeocoding($params) |
|
32 | - { |
|
33 | - $body = array( |
|
34 | - 'strExportFormat' => isset($params['strExportFormat']) ? $params['strExportFormat']: null, |
|
35 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
36 | - ); |
|
31 | + public static function forwardGeocoding($params) |
|
32 | + { |
|
33 | + $body = array( |
|
34 | + 'strExportFormat' => isset($params['strExportFormat']) ? $params['strExportFormat']: null, |
|
35 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
36 | + ); |
|
37 | 37 | |
38 | - $fgCoding = Route4Me::makeRequst(array( |
|
39 | - 'url' => Endpoint::GEOCODER, |
|
40 | - 'method' => 'POST', |
|
41 | - 'body' => $body, |
|
42 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
43 | - )); |
|
44 | - |
|
45 | - return $fgCoding; |
|
46 | - } |
|
38 | + $fgCoding = Route4Me::makeRequst(array( |
|
39 | + 'url' => Endpoint::GEOCODER, |
|
40 | + 'method' => 'POST', |
|
41 | + 'body' => $body, |
|
42 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
43 | + )); |
|
44 | + |
|
45 | + return $fgCoding; |
|
46 | + } |
|
47 | 47 | |
48 | - public static function reverseGeocoding($params) |
|
49 | - { |
|
50 | - $query = array( |
|
51 | - 'format' => isset($params['format']) ? $params['format']: null, |
|
52 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
53 | - 'detailed' => isset($params['detailed']) ? $params['detailed'] : null, |
|
54 | - ); |
|
48 | + public static function reverseGeocoding($params) |
|
49 | + { |
|
50 | + $query = array( |
|
51 | + 'format' => isset($params['format']) ? $params['format']: null, |
|
52 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
53 | + 'detailed' => isset($params['detailed']) ? $params['detailed'] : null, |
|
54 | + ); |
|
55 | 55 | |
56 | - $fgcoding = Route4Me::makeRequst(array( |
|
57 | - 'url' => Endpoint::GEOCODER, |
|
58 | - 'method' => 'POST', |
|
59 | - 'query' => $query |
|
60 | - )); |
|
61 | - |
|
62 | - return $fgcoding; |
|
63 | - } |
|
56 | + $fgcoding = Route4Me::makeRequst(array( |
|
57 | + 'url' => Endpoint::GEOCODER, |
|
58 | + 'method' => 'POST', |
|
59 | + 'query' => $query |
|
60 | + )); |
|
61 | + |
|
62 | + return $fgcoding; |
|
63 | + } |
|
64 | 64 | |
65 | - public static function getStreetData($params) |
|
66 | - { |
|
67 | - $url_query = Endpoint::STREET_DATA; |
|
65 | + public static function getStreetData($params) |
|
66 | + { |
|
67 | + $url_query = Endpoint::STREET_DATA; |
|
68 | 68 | |
69 | - if (isset($params['pk'])) { |
|
70 | - $url_query.=$params['pk'].'/'; |
|
71 | - } |
|
69 | + if (isset($params['pk'])) { |
|
70 | + $url_query.=$params['pk'].'/'; |
|
71 | + } |
|
72 | 72 | |
73 | - if (isset($params['offset'])) { |
|
74 | - $url_query.=$params['offset'].'/'; |
|
75 | - } |
|
73 | + if (isset($params['offset'])) { |
|
74 | + $url_query.=$params['offset'].'/'; |
|
75 | + } |
|
76 | 76 | |
77 | - if (isset($params['limit'])) { |
|
78 | - $url_query.=$params['limit'].'/'; |
|
79 | - } |
|
77 | + if (isset($params['limit'])) { |
|
78 | + $url_query.=$params['limit'].'/'; |
|
79 | + } |
|
80 | 80 | |
81 | - $query = array(); |
|
81 | + $query = array(); |
|
82 | 82 | |
83 | - $response = Route4Me::makeUrlRequst($url_query, array( |
|
84 | - 'method' => 'GET', |
|
85 | - 'query' => $query |
|
86 | - )); |
|
83 | + $response = Route4Me::makeUrlRequst($url_query, array( |
|
84 | + 'method' => 'GET', |
|
85 | + 'query' => $query |
|
86 | + )); |
|
87 | 87 | |
88 | - return $response; |
|
89 | - } |
|
88 | + return $response; |
|
89 | + } |
|
90 | 90 | |
91 | - public static function getZipCode($params) |
|
92 | - { |
|
93 | - $url_query = Endpoint::STREET_DATA_ZIPCODE; |
|
91 | + public static function getZipCode($params) |
|
92 | + { |
|
93 | + $url_query = Endpoint::STREET_DATA_ZIPCODE; |
|
94 | 94 | |
95 | - if (isset($params['zipcode'])) { |
|
96 | - $url_query.=$params['zipcode'].'/'; |
|
97 | - } |
|
95 | + if (isset($params['zipcode'])) { |
|
96 | + $url_query.=$params['zipcode'].'/'; |
|
97 | + } |
|
98 | 98 | |
99 | - if (isset($params['offset'])) { |
|
100 | - $url_query.=$params['offset'].'/'; |
|
101 | - } |
|
99 | + if (isset($params['offset'])) { |
|
100 | + $url_query.=$params['offset'].'/'; |
|
101 | + } |
|
102 | 102 | |
103 | - if (isset($params['limit'])) { |
|
104 | - $url_query.=$params['limit'].'/'; |
|
105 | - } |
|
103 | + if (isset($params['limit'])) { |
|
104 | + $url_query.=$params['limit'].'/'; |
|
105 | + } |
|
106 | 106 | |
107 | - $query = array(); |
|
107 | + $query = array(); |
|
108 | 108 | |
109 | - $response = Route4Me::makeUrlRequst($url_query, array( |
|
110 | - 'method' => 'GET', |
|
111 | - 'query' => $query |
|
112 | - )); |
|
109 | + $response = Route4Me::makeUrlRequst($url_query, array( |
|
110 | + 'method' => 'GET', |
|
111 | + 'query' => $query |
|
112 | + )); |
|
113 | 113 | |
114 | - return $response; |
|
115 | - } |
|
114 | + return $response; |
|
115 | + } |
|
116 | 116 | |
117 | - public static function getService($params) |
|
118 | - { |
|
119 | - $url_query = Endpoint::STREET_DATA_SERVICE; |
|
117 | + public static function getService($params) |
|
118 | + { |
|
119 | + $url_query = Endpoint::STREET_DATA_SERVICE; |
|
120 | 120 | |
121 | - if (isset($params['zipcode'])) { |
|
122 | - $url_query.=$params['zipcode'].'/'; |
|
123 | - } |
|
121 | + if (isset($params['zipcode'])) { |
|
122 | + $url_query.=$params['zipcode'].'/'; |
|
123 | + } |
|
124 | 124 | |
125 | - if (isset($params['housenumber'])) { |
|
126 | - $url_query.=$params['housenumber'].'/'; |
|
127 | - } |
|
125 | + if (isset($params['housenumber'])) { |
|
126 | + $url_query.=$params['housenumber'].'/'; |
|
127 | + } |
|
128 | 128 | |
129 | - if (isset($params['offset'])) { |
|
130 | - $url_query.=$params['offset'].'/'; |
|
131 | - } |
|
129 | + if (isset($params['offset'])) { |
|
130 | + $url_query.=$params['offset'].'/'; |
|
131 | + } |
|
132 | 132 | |
133 | - if (isset($params['limit'])) { |
|
134 | - $url_query.=$params['limit'].'/'; |
|
135 | - } |
|
133 | + if (isset($params['limit'])) { |
|
134 | + $url_query.=$params['limit'].'/'; |
|
135 | + } |
|
136 | 136 | |
137 | - $query = array(); |
|
137 | + $query = array(); |
|
138 | 138 | |
139 | - $response = Route4Me::makeUrlRequst($url_query, array( |
|
140 | - 'method' => 'GET', |
|
141 | - 'query' => $query |
|
142 | - )); |
|
139 | + $response = Route4Me::makeUrlRequst($url_query, array( |
|
140 | + 'method' => 'GET', |
|
141 | + 'query' => $query |
|
142 | + )); |
|
143 | 143 | |
144 | - return $response; |
|
145 | - } |
|
144 | + return $response; |
|
145 | + } |
|
146 | 146 | } |
@@ -6,88 +6,88 @@ |
||
6 | 6 | |
7 | 7 | class ActivityParameters extends Common |
8 | 8 | { |
9 | - public $route_id; |
|
10 | - public $device_id; |
|
11 | - public $member_id; |
|
12 | - public $team; |
|
13 | - public $limit; |
|
14 | - public $offset; |
|
15 | - public $start; |
|
16 | - public $end; |
|
17 | - public $activity_type; |
|
18 | - public $activity_message; |
|
9 | + public $route_id; |
|
10 | + public $device_id; |
|
11 | + public $member_id; |
|
12 | + public $team; |
|
13 | + public $limit; |
|
14 | + public $offset; |
|
15 | + public $start; |
|
16 | + public $end; |
|
17 | + public $activity_type; |
|
18 | + public $activity_message; |
|
19 | 19 | |
20 | - public $activity_id; |
|
21 | - public $activity_timestamp; |
|
22 | - public $route_destination_id; |
|
23 | - public $note_id; |
|
24 | - public $member; |
|
25 | - public $note_type; |
|
26 | - public $note_contents; |
|
27 | - public $route_name; |
|
28 | - public $note_file; |
|
29 | - public $destination_name; |
|
30 | - public $destination_alias; |
|
20 | + public $activity_id; |
|
21 | + public $activity_timestamp; |
|
22 | + public $route_destination_id; |
|
23 | + public $note_id; |
|
24 | + public $member; |
|
25 | + public $note_type; |
|
26 | + public $note_contents; |
|
27 | + public $route_name; |
|
28 | + public $note_file; |
|
29 | + public $destination_name; |
|
30 | + public $destination_alias; |
|
31 | 31 | |
32 | - public static function fromArray(array $params) |
|
33 | - { |
|
34 | - $activityparameters = new ActivityParameters(); |
|
32 | + public static function fromArray(array $params) |
|
33 | + { |
|
34 | + $activityparameters = new ActivityParameters(); |
|
35 | 35 | |
36 | - foreach($params as $key => $value) { |
|
37 | - if (property_exists($activityparameters, $key)) { |
|
38 | - $activityparameters->{$key} = $value; |
|
39 | - } |
|
40 | - } |
|
36 | + foreach($params as $key => $value) { |
|
37 | + if (property_exists($activityparameters, $key)) { |
|
38 | + $activityparameters->{$key} = $value; |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - return $activityparameters; |
|
43 | - } |
|
42 | + return $activityparameters; |
|
43 | + } |
|
44 | 44 | |
45 | - public static function get($params) |
|
46 | - { |
|
47 | - $activity = Route4Me::makeRequst(array( |
|
48 | - 'url' => Endpoint::GET_ACTIVITIES, |
|
49 | - 'method' => 'GET', |
|
50 | - 'query' => array( |
|
51 | - 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
52 | - 'team' => isset($params->team) ? $params->team : null, |
|
53 | - 'limit' => isset($params->limit) ? $params->limit : null, |
|
54 | - 'offset' => isset($params->offset) ? $params->offset : null, |
|
55 | - 'start' => isset($params->start) ? $params->start : null, |
|
56 | - ) |
|
57 | - )); |
|
45 | + public static function get($params) |
|
46 | + { |
|
47 | + $activity = Route4Me::makeRequst(array( |
|
48 | + 'url' => Endpoint::GET_ACTIVITIES, |
|
49 | + 'method' => 'GET', |
|
50 | + 'query' => array( |
|
51 | + 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
52 | + 'team' => isset($params->team) ? $params->team : null, |
|
53 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
54 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
55 | + 'start' => isset($params->start) ? $params->start : null, |
|
56 | + ) |
|
57 | + )); |
|
58 | 58 | |
59 | - return $activity; |
|
60 | - } |
|
59 | + return $activity; |
|
60 | + } |
|
61 | 61 | |
62 | - public static function searcActivities($params) |
|
63 | - { |
|
64 | - $activity = Route4Me::makeRequst(array( |
|
65 | - 'url' => Endpoint::GET_ACTIVITIES, |
|
66 | - 'method' => 'GET', |
|
67 | - 'query' => array( |
|
68 | - 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
69 | - 'limit' => isset($params->limit) ? $params->limit : null, |
|
70 | - 'offset' => isset($params->offset) ? $params->offset : null, |
|
71 | - 'activity_type' => isset($params->activity_type) ? $params->activity_type : null, |
|
72 | - ) |
|
73 | - )); |
|
62 | + public static function searcActivities($params) |
|
63 | + { |
|
64 | + $activity = Route4Me::makeRequst(array( |
|
65 | + 'url' => Endpoint::GET_ACTIVITIES, |
|
66 | + 'method' => 'GET', |
|
67 | + 'query' => array( |
|
68 | + 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
69 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
70 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
71 | + 'activity_type' => isset($params->activity_type) ? $params->activity_type : null, |
|
72 | + ) |
|
73 | + )); |
|
74 | 74 | |
75 | - return $activity; |
|
76 | - } |
|
75 | + return $activity; |
|
76 | + } |
|
77 | 77 | |
78 | - public static function sendUserMessage($postParameters) |
|
79 | - { |
|
80 | - $result = Route4Me::makeRequst(array( |
|
81 | - 'url' => Endpoint::ACTIVITY_FEED, |
|
82 | - 'method' => 'POST', |
|
83 | - 'body' => array( |
|
84 | - 'activity_type' => isset($postParameters->activity_type) ? $postParameters->activity_type : null, |
|
85 | - 'activity_message' => isset($postParameters->activity_message) ? $postParameters->activity_message : null, |
|
86 | - 'route_id' => isset($postParameters->route_id) ? $postParameters->route_id : null, |
|
87 | - ) |
|
88 | - )); |
|
78 | + public static function sendUserMessage($postParameters) |
|
79 | + { |
|
80 | + $result = Route4Me::makeRequst(array( |
|
81 | + 'url' => Endpoint::ACTIVITY_FEED, |
|
82 | + 'method' => 'POST', |
|
83 | + 'body' => array( |
|
84 | + 'activity_type' => isset($postParameters->activity_type) ? $postParameters->activity_type : null, |
|
85 | + 'activity_message' => isset($postParameters->activity_message) ? $postParameters->activity_message : null, |
|
86 | + 'route_id' => isset($postParameters->route_id) ? $postParameters->route_id : null, |
|
87 | + ) |
|
88 | + )); |
|
89 | 89 | |
90 | - return $result; |
|
91 | - } |
|
90 | + return $result; |
|
91 | + } |
|
92 | 92 | |
93 | 93 | } |
@@ -97,19 +97,19 @@ |
||
97 | 97 | |
98 | 98 | public function updateTerritory($params) |
99 | 99 | { |
100 | - //var_dump($params); die(""); |
|
100 | + //var_dump($params); die(""); |
|
101 | 101 | $response = Route4Me::makeRequst(array( |
102 | 102 | 'url' => Endpoint::TERRITORY_V4, |
103 | 103 | 'method' => 'PUT', |
104 | 104 | 'query' => array( |
105 | - 'territory_id' => isset($params->territory_id) ? $params->territory_id : null |
|
106 | - ), |
|
107 | - 'body' => array( |
|
108 | - 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
109 | - 'member_id' => isset($params->member_id) ? $params->member_id : null, |
|
110 | - 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
111 | - 'territory' => isset($params->territory) ? $params->territory : null |
|
112 | - ) |
|
105 | + 'territory_id' => isset($params->territory_id) ? $params->territory_id : null |
|
106 | + ), |
|
107 | + 'body' => array( |
|
108 | + 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
109 | + 'member_id' => isset($params->member_id) ? $params->member_id : null, |
|
110 | + 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
|
111 | + 'territory' => isset($params->territory) ? $params->territory : null |
|
112 | + ) |
|
113 | 113 | |
114 | 114 | )); |
115 | 115 |
@@ -7,341 +7,341 @@ |
||
7 | 7 | |
8 | 8 | class Route4Me |
9 | 9 | { |
10 | - static public $apiKey; |
|
11 | - static public $baseUrl = Endpoint::BASE_URL; |
|
10 | + static public $apiKey; |
|
11 | + static public $baseUrl = Endpoint::BASE_URL; |
|
12 | 12 | |
13 | - public static function setApiKey($apiKey) |
|
14 | - { |
|
15 | - self::$apiKey = $apiKey; |
|
16 | - } |
|
13 | + public static function setApiKey($apiKey) |
|
14 | + { |
|
15 | + self::$apiKey = $apiKey; |
|
16 | + } |
|
17 | 17 | |
18 | - public static function getApiKey() |
|
19 | - { |
|
20 | - return self::$apiKey; |
|
21 | - } |
|
18 | + public static function getApiKey() |
|
19 | + { |
|
20 | + return self::$apiKey; |
|
21 | + } |
|
22 | 22 | |
23 | - public static function setBaseUrl($baseUrl) |
|
24 | - { |
|
25 | - self::$baseUrl = $baseUrl; |
|
26 | - } |
|
23 | + public static function setBaseUrl($baseUrl) |
|
24 | + { |
|
25 | + self::$baseUrl = $baseUrl; |
|
26 | + } |
|
27 | 27 | |
28 | - public static function getBaseUrl() |
|
29 | - { |
|
30 | - return self::$baseUrl; |
|
31 | - } |
|
28 | + public static function getBaseUrl() |
|
29 | + { |
|
30 | + return self::$baseUrl; |
|
31 | + } |
|
32 | 32 | |
33 | - public static function fileUploadRequest($options) { |
|
34 | - $query = isset($options['query']) ? |
|
35 | - array_filter($options['query']) : array(); |
|
33 | + public static function fileUploadRequest($options) { |
|
34 | + $query = isset($options['query']) ? |
|
35 | + array_filter($options['query']) : array(); |
|
36 | 36 | |
37 | - if (sizeof($query)==0) return null; |
|
37 | + if (sizeof($query)==0) return null; |
|
38 | 38 | |
39 | - $body = isset($options['body']) ? |
|
40 | - array_filter($options['body']) : null; |
|
39 | + $body = isset($options['body']) ? |
|
40 | + array_filter($options['body']) : null; |
|
41 | 41 | |
42 | - $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
|
43 | - if ($fname=='') return null; |
|
42 | + $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
|
43 | + if ($fname=='') return null; |
|
44 | 44 | |
45 | - $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname); |
|
45 | + $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname); |
|
46 | 46 | |
47 | - $url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge( |
|
48 | - array( 'api_key' => self::getApiKey()), $query) |
|
49 | - ); |
|
47 | + $url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge( |
|
48 | + array( 'api_key' => self::getApiKey()), $query) |
|
49 | + ); |
|
50 | 50 | |
51 | - $ch = curl_init($url); |
|
51 | + $ch = curl_init($url); |
|
52 | 52 | |
53 | - $curlOpts = array( |
|
54 | - CURLOPT_POST => true, |
|
55 | - CURLOPT_RETURNTRANSFER => false, |
|
56 | - CURLOPT_TIMEOUT => 60, |
|
57 | - CURLOPT_FOLLOWLOCATION => true, |
|
58 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
59 | - CURLOPT_SSL_VERIFYPEER => FALSE |
|
60 | - ); |
|
53 | + $curlOpts = array( |
|
54 | + CURLOPT_POST => true, |
|
55 | + CURLOPT_RETURNTRANSFER => false, |
|
56 | + CURLOPT_TIMEOUT => 60, |
|
57 | + CURLOPT_FOLLOWLOCATION => true, |
|
58 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
59 | + CURLOPT_SSL_VERIFYPEER => FALSE |
|
60 | + ); |
|
61 | 61 | |
62 | - curl_setopt_array($ch, $curlOpts); |
|
62 | + curl_setopt_array($ch, $curlOpts); |
|
63 | 63 | |
64 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
64 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
65 | 65 | |
66 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
67 | - "Content-Type: multipart/form-data", |
|
68 | - 'Content-Disposition: form-data; name="strFilename"' |
|
69 | - )); |
|
70 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
71 | - curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); |
|
66 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
67 | + "Content-Type: multipart/form-data", |
|
68 | + 'Content-Disposition: form-data; name="strFilename"' |
|
69 | + )); |
|
70 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
71 | + curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); |
|
72 | 72 | |
73 | - $result = curl_exec($ch); |
|
73 | + $result = curl_exec($ch); |
|
74 | 74 | |
75 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
76 | - curl_close($ch); |
|
75 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
76 | + curl_close($ch); |
|
77 | 77 | |
78 | - $json = json_decode($result, true); |
|
78 | + $json = json_decode($result, true); |
|
79 | 79 | |
80 | - if (200 == $code) { |
|
81 | - return $json; |
|
82 | - } elseif (isset($json['errors'])) { |
|
83 | - throw new ApiError(implode(', ', $json['errors'])); |
|
84 | - } else { |
|
85 | - throw new ApiError('Something wrong'); |
|
86 | - } |
|
87 | - } |
|
80 | + if (200 == $code) { |
|
81 | + return $json; |
|
82 | + } elseif (isset($json['errors'])) { |
|
83 | + throw new ApiError(implode(', ', $json['errors'])); |
|
84 | + } else { |
|
85 | + throw new ApiError('Something wrong'); |
|
86 | + } |
|
87 | + } |
|
88 | 88 | |
89 | - public static function makeRequst($options) { |
|
90 | - $errorHandler = new myErrorHandler(); |
|
89 | + public static function makeRequst($options) { |
|
90 | + $errorHandler = new myErrorHandler(); |
|
91 | 91 | |
92 | - $old_error_handler = set_error_handler(array( $errorHandler, "proc_error")); |
|
93 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
94 | - $query = isset($options['query']) ? |
|
95 | - array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
92 | + $old_error_handler = set_error_handler(array( $errorHandler, "proc_error")); |
|
93 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
94 | + $query = isset($options['query']) ? |
|
95 | + array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
96 | 96 | |
97 | - $body = isset($options['body']) ? $options['body'] : null; |
|
98 | - $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
99 | - $headers = array( |
|
100 | - "User-Agent: Route4Me php-sdk" |
|
101 | - ); |
|
97 | + $body = isset($options['body']) ? $options['body'] : null; |
|
98 | + $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
99 | + $headers = array( |
|
100 | + "User-Agent: Route4Me php-sdk" |
|
101 | + ); |
|
102 | 102 | |
103 | - if (isset($options['HTTPHEADER'])) { |
|
104 | - $headers[]=$options['HTTPHEADER']; |
|
105 | - } |
|
103 | + if (isset($options['HTTPHEADER'])) { |
|
104 | + $headers[]=$options['HTTPHEADER']; |
|
105 | + } |
|
106 | 106 | |
107 | - if (isset($options['HTTPHEADERS'])) { |
|
108 | - foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header; |
|
109 | - } |
|
107 | + if (isset($options['HTTPHEADERS'])) { |
|
108 | + foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header; |
|
109 | + } |
|
110 | 110 | |
111 | - $ch = curl_init(); |
|
112 | - $url = $options['url'] . '?' . http_build_query(array_merge( |
|
113 | - $query, array( 'api_key' => self::getApiKey()) |
|
114 | - )); |
|
111 | + $ch = curl_init(); |
|
112 | + $url = $options['url'] . '?' . http_build_query(array_merge( |
|
113 | + $query, array( 'api_key' => self::getApiKey()) |
|
114 | + )); |
|
115 | 115 | |
116 | - $baseUrl=self::getBaseUrl(); |
|
116 | + $baseUrl=self::getBaseUrl(); |
|
117 | 117 | |
118 | - $curlOpts = arraY( |
|
119 | - CURLOPT_URL => $baseUrl. $url, |
|
120 | - CURLOPT_RETURNTRANSFER => true, |
|
121 | - CURLOPT_TIMEOUT => 80, |
|
122 | - CURLOPT_FOLLOWLOCATION => true, |
|
123 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
124 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
125 | - CURLOPT_HTTPHEADER => $headers |
|
126 | - ); |
|
118 | + $curlOpts = arraY( |
|
119 | + CURLOPT_URL => $baseUrl. $url, |
|
120 | + CURLOPT_RETURNTRANSFER => true, |
|
121 | + CURLOPT_TIMEOUT => 80, |
|
122 | + CURLOPT_FOLLOWLOCATION => true, |
|
123 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
124 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
125 | + CURLOPT_HTTPHEADER => $headers |
|
126 | + ); |
|
127 | 127 | |
128 | - curl_setopt_array($ch, $curlOpts); |
|
128 | + curl_setopt_array($ch, $curlOpts); |
|
129 | 129 | |
130 | - if ($file !=null) { |
|
131 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
|
132 | - $fp=fopen($file,'r'); |
|
133 | - curl_setopt($ch, CURLOPT_INFILE , $fp); |
|
134 | - curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
|
135 | - } |
|
130 | + if ($file !=null) { |
|
131 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
|
132 | + $fp=fopen($file,'r'); |
|
133 | + curl_setopt($ch, CURLOPT_INFILE , $fp); |
|
134 | + curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
|
135 | + } |
|
136 | 136 | |
137 | - switch($method) { |
|
138 | - case 'DELETE': |
|
139 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
137 | + switch($method) { |
|
138 | + case 'DELETE': |
|
139 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
140 | 140 | |
141 | - if (isset($body)) { |
|
141 | + if (isset($body)) { |
|
142 | 142 | |
143 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
144 | - } |
|
145 | - break; |
|
146 | - case 'DELETEARRAY': |
|
147 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
148 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
149 | - break; |
|
150 | - case 'PUT': |
|
151 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
143 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
144 | + } |
|
145 | + break; |
|
146 | + case 'DELETEARRAY': |
|
147 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
148 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
149 | + break; |
|
150 | + case 'PUT': |
|
151 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
152 | 152 | |
153 | - if (isset($body)) { |
|
154 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
155 | - } |
|
156 | - break; |
|
157 | - case 'POST': |
|
158 | - if (isset($body)) { |
|
159 | - $bodyData = json_encode($body); |
|
160 | - if (isset($options['HTTPHEADER'])) { |
|
161 | - if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) $bodyData = $body; |
|
162 | - } |
|
153 | + if (isset($body)) { |
|
154 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
155 | + } |
|
156 | + break; |
|
157 | + case 'POST': |
|
158 | + if (isset($body)) { |
|
159 | + $bodyData = json_encode($body); |
|
160 | + if (isset($options['HTTPHEADER'])) { |
|
161 | + if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) $bodyData = $body; |
|
162 | + } |
|
163 | 163 | |
164 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
165 | - } |
|
166 | - break; |
|
167 | - case 'ADD': |
|
168 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
169 | - } |
|
164 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
165 | + } |
|
166 | + break; |
|
167 | + case 'ADD': |
|
168 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
169 | + } |
|
170 | 170 | |
171 | - $result = curl_exec($ch); |
|
171 | + $result = curl_exec($ch); |
|
172 | 172 | |
173 | - $isxml=FALSE; |
|
174 | - $jxml=""; |
|
175 | - if (strpos($result, '<?xml')>-1) |
|
176 | - { |
|
177 | - $xml = simplexml_load_string($result); |
|
178 | - //$jxml = json_encode($xml); |
|
179 | - $jxml=self::object2array($xml); |
|
180 | - $isxml = TRUE; |
|
181 | - } |
|
173 | + $isxml=FALSE; |
|
174 | + $jxml=""; |
|
175 | + if (strpos($result, '<?xml')>-1) |
|
176 | + { |
|
177 | + $xml = simplexml_load_string($result); |
|
178 | + //$jxml = json_encode($xml); |
|
179 | + $jxml=self::object2array($xml); |
|
180 | + $isxml = TRUE; |
|
181 | + } |
|
182 | 182 | |
183 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
184 | - curl_close($ch); |
|
183 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
184 | + curl_close($ch); |
|
185 | 185 | |
186 | - if (200 == $code) { |
|
187 | - if ($isxml) { |
|
188 | - $json = $jxml; |
|
189 | - } else $json = json_decode($result, true); |
|
186 | + if (200 == $code) { |
|
187 | + if ($isxml) { |
|
188 | + $json = $jxml; |
|
189 | + } else $json = json_decode($result, true); |
|
190 | 190 | |
191 | - if (isset($json['errors'])) { |
|
192 | - throw new ApiError(implode(', ', $json['errors'])); |
|
193 | - } else { |
|
194 | - return $json; |
|
195 | - } |
|
196 | - } elseif (409 == $code) { |
|
197 | - throw new ApiError('Wrong API key'); |
|
198 | - } else { |
|
199 | - throw new ApiError('Something wrong'); |
|
200 | - } |
|
201 | - } |
|
191 | + if (isset($json['errors'])) { |
|
192 | + throw new ApiError(implode(', ', $json['errors'])); |
|
193 | + } else { |
|
194 | + return $json; |
|
195 | + } |
|
196 | + } elseif (409 == $code) { |
|
197 | + throw new ApiError('Wrong API key'); |
|
198 | + } else { |
|
199 | + throw new ApiError('Something wrong'); |
|
200 | + } |
|
201 | + } |
|
202 | 202 | |
203 | - public static function object2array($object) |
|
204 | - { |
|
205 | - return @json_decode(@json_encode($object),1); |
|
206 | - } |
|
203 | + public static function object2array($object) |
|
204 | + { |
|
205 | + return @json_decode(@json_encode($object),1); |
|
206 | + } |
|
207 | 207 | |
208 | - public static function makeUrlRequst($url, $options) { |
|
209 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
210 | - $query = isset($options['query']) ? |
|
211 | - array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
212 | - $body = isset($options['body']) ? $options['body'] : null; |
|
213 | - $ch = curl_init(); |
|
208 | + public static function makeUrlRequst($url, $options) { |
|
209 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
210 | + $query = isset($options['query']) ? |
|
211 | + array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
212 | + $body = isset($options['body']) ? $options['body'] : null; |
|
213 | + $ch = curl_init(); |
|
214 | 214 | |
215 | - $curlOpts = arraY( |
|
216 | - CURLOPT_URL => $url, |
|
217 | - CURLOPT_RETURNTRANSFER => true, |
|
218 | - CURLOPT_TIMEOUT => 60, |
|
219 | - CURLOPT_FOLLOWLOCATION => true, |
|
220 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
221 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
222 | - CURLOPT_HTTPHEADER => array( |
|
223 | - 'User-Agent' => 'Route4Me php-sdk' |
|
224 | - ) |
|
225 | - ); |
|
215 | + $curlOpts = arraY( |
|
216 | + CURLOPT_URL => $url, |
|
217 | + CURLOPT_RETURNTRANSFER => true, |
|
218 | + CURLOPT_TIMEOUT => 60, |
|
219 | + CURLOPT_FOLLOWLOCATION => true, |
|
220 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
221 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
222 | + CURLOPT_HTTPHEADER => array( |
|
223 | + 'User-Agent' => 'Route4Me php-sdk' |
|
224 | + ) |
|
225 | + ); |
|
226 | 226 | |
227 | - curl_setopt_array($ch, $curlOpts); |
|
227 | + curl_setopt_array($ch, $curlOpts); |
|
228 | 228 | |
229 | - switch($method) { |
|
230 | - case 'DELETE': |
|
231 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
229 | + switch($method) { |
|
230 | + case 'DELETE': |
|
231 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
232 | 232 | |
233 | - if (isset($body)) { |
|
234 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
235 | - } |
|
236 | - break; |
|
237 | - case 'DELETEARRAY': |
|
238 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
239 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
240 | - break; |
|
241 | - case 'PUT': |
|
242 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
243 | - if (isset($query)) { |
|
244 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
245 | - } |
|
233 | + if (isset($body)) { |
|
234 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
235 | + } |
|
236 | + break; |
|
237 | + case 'DELETEARRAY': |
|
238 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
239 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
240 | + break; |
|
241 | + case 'PUT': |
|
242 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
243 | + if (isset($query)) { |
|
244 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
245 | + } |
|
246 | 246 | |
247 | - if (isset($body)) { |
|
248 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
249 | - } |
|
250 | - break; |
|
251 | - case 'POST': |
|
252 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
253 | - if (isset($query)) { |
|
254 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
255 | - } |
|
247 | + if (isset($body)) { |
|
248 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
249 | + } |
|
250 | + break; |
|
251 | + case 'POST': |
|
252 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
253 | + if (isset($query)) { |
|
254 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
255 | + } |
|
256 | 256 | |
257 | - if (isset($body)) { |
|
258 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
259 | - } |
|
260 | - break; |
|
261 | - case 'ADD': |
|
262 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
263 | - } |
|
257 | + if (isset($body)) { |
|
258 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
259 | + } |
|
260 | + break; |
|
261 | + case 'ADD': |
|
262 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
263 | + } |
|
264 | 264 | |
265 | - $result = curl_exec($ch); |
|
265 | + $result = curl_exec($ch); |
|
266 | 266 | |
267 | - $isxml=FALSE; |
|
268 | - $jxml=""; |
|
269 | - if (strpos($result, '<?xml')>-1) |
|
270 | - { |
|
271 | - $xml = simplexml_load_string($result); |
|
272 | - $jxml = json_encode($xml); |
|
273 | - $isxml = TRUE; |
|
274 | - } |
|
267 | + $isxml=FALSE; |
|
268 | + $jxml=""; |
|
269 | + if (strpos($result, '<?xml')>-1) |
|
270 | + { |
|
271 | + $xml = simplexml_load_string($result); |
|
272 | + $jxml = json_encode($xml); |
|
273 | + $isxml = TRUE; |
|
274 | + } |
|
275 | 275 | |
276 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
277 | - curl_close($ch); |
|
276 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
277 | + curl_close($ch); |
|
278 | 278 | |
279 | - if ($isxml) { |
|
280 | - $json = $jxml; |
|
281 | - } else $json = json_decode($result, true); |
|
279 | + if ($isxml) { |
|
280 | + $json = $jxml; |
|
281 | + } else $json = json_decode($result, true); |
|
282 | 282 | |
283 | - if (200 == $code) { |
|
284 | - return $json; |
|
285 | - } elseif (isset($json['errors'])) { |
|
286 | - throw new ApiError(implode(', ', $json['errors'])); |
|
287 | - } else { |
|
288 | - throw new ApiError('Something wrong'); |
|
289 | - } |
|
290 | - } |
|
283 | + if (200 == $code) { |
|
284 | + return $json; |
|
285 | + } elseif (isset($json['errors'])) { |
|
286 | + throw new ApiError(implode(', ', $json['errors'])); |
|
287 | + } else { |
|
288 | + throw new ApiError('Something wrong'); |
|
289 | + } |
|
290 | + } |
|
291 | 291 | |
292 | - /** |
|
293 | - * Prints on the screen main keys and values of the array |
|
294 | - * |
|
295 | - */ |
|
296 | - public static function simplePrint($results, $deepPrinting=null) |
|
297 | - { |
|
298 | - if (isset($results)) { |
|
299 | - if (is_array($results)) { |
|
300 | - foreach ($results as $key=>$result) { |
|
301 | - if (is_array($result)) { |
|
302 | - foreach ($result as $key1=>$result1) { |
|
303 | - if (is_array($result1)) { |
|
304 | - if ($deepPrinting) { |
|
305 | - echo "<br>$key1 ------><br>"; |
|
306 | - Route4Me::simplePrint($result1,true); |
|
307 | - echo "------<br>"; |
|
308 | - } else { |
|
309 | - echo $key1." --> "."Array() <br>"; |
|
310 | - } |
|
311 | - } else { |
|
312 | - if (is_object($result1)) { |
|
313 | - if ($deepPrinting) { |
|
314 | - echo "<br>$key1 ------><br>"; |
|
315 | - $oarray=(array)$result1; |
|
316 | - Route4Me::simplePrint($oarray,true); |
|
317 | - echo "------<br>"; |
|
318 | - } else { |
|
319 | - echo $key1." --> "."Object <br>"; |
|
320 | - } |
|
321 | - } else { |
|
322 | - if (!is_null($result1)) echo $key1." --> ".$result1."<br>"; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
326 | - } else { |
|
327 | - if (is_object($result)) { |
|
328 | - if ($deepPrinting) { |
|
329 | - echo "<br>$key ------><br>"; |
|
330 | - $oarray=(array)$result; |
|
331 | - Route4Me::simplePrint($oarray,true); |
|
332 | - echo "------<br>"; |
|
333 | - } else { |
|
334 | - echo $key." --> "."Object <br>"; |
|
335 | - } |
|
336 | - } else { |
|
337 | - if (!is_null($result)) echo $key." --> ".$result."<br>"; |
|
338 | - } |
|
292 | + /** |
|
293 | + * Prints on the screen main keys and values of the array |
|
294 | + * |
|
295 | + */ |
|
296 | + public static function simplePrint($results, $deepPrinting=null) |
|
297 | + { |
|
298 | + if (isset($results)) { |
|
299 | + if (is_array($results)) { |
|
300 | + foreach ($results as $key=>$result) { |
|
301 | + if (is_array($result)) { |
|
302 | + foreach ($result as $key1=>$result1) { |
|
303 | + if (is_array($result1)) { |
|
304 | + if ($deepPrinting) { |
|
305 | + echo "<br>$key1 ------><br>"; |
|
306 | + Route4Me::simplePrint($result1,true); |
|
307 | + echo "------<br>"; |
|
308 | + } else { |
|
309 | + echo $key1." --> "."Array() <br>"; |
|
310 | + } |
|
311 | + } else { |
|
312 | + if (is_object($result1)) { |
|
313 | + if ($deepPrinting) { |
|
314 | + echo "<br>$key1 ------><br>"; |
|
315 | + $oarray=(array)$result1; |
|
316 | + Route4Me::simplePrint($oarray,true); |
|
317 | + echo "------<br>"; |
|
318 | + } else { |
|
319 | + echo $key1." --> "."Object <br>"; |
|
320 | + } |
|
321 | + } else { |
|
322 | + if (!is_null($result1)) echo $key1." --> ".$result1."<br>"; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | + } else { |
|
327 | + if (is_object($result)) { |
|
328 | + if ($deepPrinting) { |
|
329 | + echo "<br>$key ------><br>"; |
|
330 | + $oarray=(array)$result; |
|
331 | + Route4Me::simplePrint($oarray,true); |
|
332 | + echo "------<br>"; |
|
333 | + } else { |
|
334 | + echo $key." --> "."Object <br>"; |
|
335 | + } |
|
336 | + } else { |
|
337 | + if (!is_null($result)) echo $key." --> ".$result."<br>"; |
|
338 | + } |
|
339 | 339 | |
340 | - } |
|
341 | - //echo "<br>"; |
|
342 | - } |
|
343 | - } |
|
344 | - } |
|
345 | - } |
|
340 | + } |
|
341 | + //echo "<br>"; |
|
342 | + } |
|
343 | + } |
|
344 | + } |
|
345 | + } |
|
346 | 346 | |
347 | 347 | } |
@@ -11,480 +11,480 @@ |
||
11 | 11 | |
12 | 12 | class Route extends Common |
13 | 13 | { |
14 | - public $route_id; |
|
15 | - public $member_id; |
|
16 | - public $route_destination_id; |
|
17 | - public $optimization_problem_id; |
|
18 | - public $vehicle_alias; |
|
19 | - public $driver_alias; |
|
20 | - public $trip_distance; |
|
21 | - public $mpg; |
|
22 | - public $gas_price; |
|
23 | - public $route_duration_sec; |
|
24 | - public $destination_count; |
|
25 | - public $parameters; |
|
26 | - public $addresses = array(); |
|
27 | - public $links = array(); |
|
28 | - public $directions = array(); |
|
29 | - public $path = array(); |
|
30 | - public $tracking_history = array(); |
|
31 | - public $recipient_email; |
|
32 | - public $httpheaders; |
|
33 | - public $is_unrouted; |
|
34 | - public $time; |
|
14 | + public $route_id; |
|
15 | + public $member_id; |
|
16 | + public $route_destination_id; |
|
17 | + public $optimization_problem_id; |
|
18 | + public $vehicle_alias; |
|
19 | + public $driver_alias; |
|
20 | + public $trip_distance; |
|
21 | + public $mpg; |
|
22 | + public $gas_price; |
|
23 | + public $route_duration_sec; |
|
24 | + public $destination_count; |
|
25 | + public $parameters; |
|
26 | + public $addresses = array(); |
|
27 | + public $links = array(); |
|
28 | + public $directions = array(); |
|
29 | + public $path = array(); |
|
30 | + public $tracking_history = array(); |
|
31 | + public $recipient_email; |
|
32 | + public $httpheaders; |
|
33 | + public $is_unrouted; |
|
34 | + public $time; |
|
35 | 35 | |
36 | - public $dev_lat; |
|
37 | - public $dev_lng; |
|
36 | + public $dev_lat; |
|
37 | + public $dev_lng; |
|
38 | 38 | |
39 | - public $user_route_rating; |
|
40 | - public $member_email; |
|
41 | - public $member_first_name; |
|
42 | - public $member_last_name; |
|
43 | - public $channel_name; |
|
44 | - public $route_cost; |
|
45 | - public $route_revenue; |
|
46 | - public $net_revenue_per_distance_unit; |
|
47 | - public $created_timestamp; |
|
48 | - public $planned_total_route_duration; |
|
49 | - public $actual_travel_distance; |
|
50 | - public $actual_travel_time; |
|
51 | - public $actual_footsteps; |
|
52 | - public $working_time; |
|
53 | - public $driving_time; |
|
54 | - public $idling_time; |
|
55 | - public $paying_miles; |
|
56 | - public $geofence_polygon_type; |
|
57 | - public $geofence_polygon_size; |
|
58 | - public $notes; |
|
59 | - public $member_config_storage; |
|
39 | + public $user_route_rating; |
|
40 | + public $member_email; |
|
41 | + public $member_first_name; |
|
42 | + public $member_last_name; |
|
43 | + public $channel_name; |
|
44 | + public $route_cost; |
|
45 | + public $route_revenue; |
|
46 | + public $net_revenue_per_distance_unit; |
|
47 | + public $created_timestamp; |
|
48 | + public $planned_total_route_duration; |
|
49 | + public $actual_travel_distance; |
|
50 | + public $actual_travel_time; |
|
51 | + public $actual_footsteps; |
|
52 | + public $working_time; |
|
53 | + public $driving_time; |
|
54 | + public $idling_time; |
|
55 | + public $paying_miles; |
|
56 | + public $geofence_polygon_type; |
|
57 | + public $geofence_polygon_size; |
|
58 | + public $notes; |
|
59 | + public $member_config_storage; |
|
60 | 60 | |
61 | - public static function fromArray(array $params) |
|
62 | - { |
|
63 | - $route = new Route(); |
|
64 | - $route->route_id = Common::getValue($params, 'route_id'); |
|
65 | - $route->member_id = Common::getValue($params, 'member_id'); |
|
66 | - $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
67 | - $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
68 | - $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
69 | - $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
70 | - $route->mpg = Common::getValue($params, 'mpg'); |
|
71 | - $route->gas_price = Common::getValue($params, 'gas_price'); |
|
72 | - $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
73 | - $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
74 | - $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
61 | + public static function fromArray(array $params) |
|
62 | + { |
|
63 | + $route = new Route(); |
|
64 | + $route->route_id = Common::getValue($params, 'route_id'); |
|
65 | + $route->member_id = Common::getValue($params, 'member_id'); |
|
66 | + $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
67 | + $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
68 | + $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
69 | + $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
70 | + $route->mpg = Common::getValue($params, 'mpg'); |
|
71 | + $route->gas_price = Common::getValue($params, 'gas_price'); |
|
72 | + $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
73 | + $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
74 | + $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
75 | 75 | |
76 | - // Make RouteParameters |
|
77 | - if (isset($params['parameters'])) { |
|
78 | - $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
79 | - } |
|
76 | + // Make RouteParameters |
|
77 | + if (isset($params['parameters'])) { |
|
78 | + $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
79 | + } |
|
80 | 80 | |
81 | - if (isset($params['addresses'])) { |
|
82 | - $addresses = array(); |
|
83 | - foreach ($params['addresses'] as $address) { |
|
84 | - $addresses[] = Address::fromArray($address); |
|
85 | - } |
|
81 | + if (isset($params['addresses'])) { |
|
82 | + $addresses = array(); |
|
83 | + foreach ($params['addresses'] as $address) { |
|
84 | + $addresses[] = Address::fromArray($address); |
|
85 | + } |
|
86 | 86 | |
87 | - $route->addresses = $addresses; |
|
88 | - } |
|
87 | + $route->addresses = $addresses; |
|
88 | + } |
|
89 | 89 | |
90 | - $route->links = Common::getValue($params, 'links', array()); |
|
91 | - $route->directions = Common::getValue($params, 'directions', array()); |
|
92 | - $route->path = Common::getValue($params, 'path', array()); |
|
93 | - $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
90 | + $route->links = Common::getValue($params, 'links', array()); |
|
91 | + $route->directions = Common::getValue($params, 'directions', array()); |
|
92 | + $route->path = Common::getValue($params, 'path', array()); |
|
93 | + $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
94 | 94 | |
95 | - return $route; |
|
96 | - } |
|
95 | + return $route; |
|
96 | + } |
|
97 | 97 | |
98 | - public static function getRoutes($routeId=null, $params=null) |
|
99 | - { |
|
100 | - $result = Route4Me::makeRequst(array( |
|
101 | - 'url' => Endpoint::ROUTE_V4, |
|
102 | - 'method' => 'GET', |
|
103 | - 'query' => array( |
|
104 | - 'api_key' => Route4Me::getApiKey(), |
|
105 | - 'route_id' => !is_null($routeId) ? implode(',', (array) $routeId) : null, |
|
106 | - 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
107 | - 'query' => isset($params['query']) ? $params['query'] : null, |
|
108 | - 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
109 | - 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null, |
|
110 | - 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
111 | - 'offset' => isset($params['offset']) ? $params['offset'] : null |
|
112 | - ) |
|
113 | - )); |
|
98 | + public static function getRoutes($routeId=null, $params=null) |
|
99 | + { |
|
100 | + $result = Route4Me::makeRequst(array( |
|
101 | + 'url' => Endpoint::ROUTE_V4, |
|
102 | + 'method' => 'GET', |
|
103 | + 'query' => array( |
|
104 | + 'api_key' => Route4Me::getApiKey(), |
|
105 | + 'route_id' => !is_null($routeId) ? implode(',', (array) $routeId) : null, |
|
106 | + 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
107 | + 'query' => isset($params['query']) ? $params['query'] : null, |
|
108 | + 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
109 | + 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null, |
|
110 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
111 | + 'offset' => isset($params['offset']) ? $params['offset'] : null |
|
112 | + ) |
|
113 | + )); |
|
114 | 114 | |
115 | - if ($routeId) { |
|
116 | - return Route::fromArray($result); die(""); |
|
117 | - } else { |
|
118 | - $routes = array(); |
|
119 | - foreach($result as $route) { |
|
120 | - $routes[] = Route::fromArray($route); |
|
121 | - } |
|
122 | - return $routes; |
|
123 | - } |
|
124 | - } |
|
115 | + if ($routeId) { |
|
116 | + return Route::fromArray($result); die(""); |
|
117 | + } else { |
|
118 | + $routes = array(); |
|
119 | + foreach($result as $route) { |
|
120 | + $routes[] = Route::fromArray($route); |
|
121 | + } |
|
122 | + return $routes; |
|
123 | + } |
|
124 | + } |
|
125 | 125 | |
126 | - public function getRoutePoints($routeId, $params) |
|
127 | - { |
|
128 | - $result = Route4Me::makeRequst(array( |
|
129 | - 'url' => Endpoint::ROUTE_V4, |
|
130 | - 'method' => 'GET', |
|
131 | - 'query' => array( |
|
132 | - 'api_key' => Route4Me::getApiKey(), |
|
133 | - 'route_id' => $routeId, |
|
134 | - 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
135 | - 'compress_path_points' => isset($params['compress_path_points']) ? $params['compress_path_points'] : null, |
|
136 | - 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
137 | - ) |
|
138 | - )); |
|
126 | + public function getRoutePoints($routeId, $params) |
|
127 | + { |
|
128 | + $result = Route4Me::makeRequst(array( |
|
129 | + 'url' => Endpoint::ROUTE_V4, |
|
130 | + 'method' => 'GET', |
|
131 | + 'query' => array( |
|
132 | + 'api_key' => Route4Me::getApiKey(), |
|
133 | + 'route_id' => $routeId, |
|
134 | + 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
135 | + 'compress_path_points' => isset($params['compress_path_points']) ? $params['compress_path_points'] : null, |
|
136 | + 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
137 | + ) |
|
138 | + )); |
|
139 | 139 | |
140 | - return $result; |
|
141 | - } |
|
140 | + return $result; |
|
141 | + } |
|
142 | 142 | |
143 | - public function duplicateRoute($route_id) |
|
144 | - { |
|
145 | - $result = Route4Me::makeRequst(array( |
|
146 | - 'url' => Endpoint::ROUTE_DUPLICATE, |
|
147 | - 'method' => 'GET', |
|
148 | - 'query' => array( |
|
149 | - 'api_key' => Route4Me::getApiKey(), |
|
150 | - 'route_id' => $route_id, |
|
151 | - 'to' => 'none', |
|
152 | - ) |
|
153 | - )); |
|
143 | + public function duplicateRoute($route_id) |
|
144 | + { |
|
145 | + $result = Route4Me::makeRequst(array( |
|
146 | + 'url' => Endpoint::ROUTE_DUPLICATE, |
|
147 | + 'method' => 'GET', |
|
148 | + 'query' => array( |
|
149 | + 'api_key' => Route4Me::getApiKey(), |
|
150 | + 'route_id' => $route_id, |
|
151 | + 'to' => 'none', |
|
152 | + ) |
|
153 | + )); |
|
154 | 154 | |
155 | - return $result; |
|
156 | - } |
|
155 | + return $result; |
|
156 | + } |
|
157 | 157 | |
158 | - public function resequenceRoute($params) |
|
159 | - { |
|
160 | - $result = Route4Me::makeRequst(array( |
|
161 | - 'url' => Endpoint::ROUTE_V4, |
|
162 | - 'method' => 'PUT', |
|
163 | - 'query' => array( |
|
164 | - 'api_key' => Route4Me::getApiKey(), |
|
165 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
166 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
167 | - ), |
|
168 | - 'body' => array( |
|
169 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
170 | - ) |
|
171 | - )); |
|
158 | + public function resequenceRoute($params) |
|
159 | + { |
|
160 | + $result = Route4Me::makeRequst(array( |
|
161 | + 'url' => Endpoint::ROUTE_V4, |
|
162 | + 'method' => 'PUT', |
|
163 | + 'query' => array( |
|
164 | + 'api_key' => Route4Me::getApiKey(), |
|
165 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
166 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
167 | + ), |
|
168 | + 'body' => array( |
|
169 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
170 | + ) |
|
171 | + )); |
|
172 | 172 | |
173 | - return $result; |
|
174 | - } |
|
173 | + return $result; |
|
174 | + } |
|
175 | 175 | |
176 | - public function resequenceAllAddresses($params) |
|
177 | - { |
|
178 | - $result = Route4Me::makeRequst(array( |
|
179 | - 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
180 | - 'method' => 'GET', |
|
181 | - 'query' => array( |
|
182 | - 'api_key' => Route4Me::getApiKey(), |
|
183 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
184 | - 'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null, |
|
185 | - 'optimize' => isset($params['optimize']) ? $params['optimize'] : null, |
|
186 | - ) |
|
187 | - )); |
|
176 | + public function resequenceAllAddresses($params) |
|
177 | + { |
|
178 | + $result = Route4Me::makeRequst(array( |
|
179 | + 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
180 | + 'method' => 'GET', |
|
181 | + 'query' => array( |
|
182 | + 'api_key' => Route4Me::getApiKey(), |
|
183 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
184 | + 'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null, |
|
185 | + 'optimize' => isset($params['optimize']) ? $params['optimize'] : null, |
|
186 | + ) |
|
187 | + )); |
|
188 | 188 | |
189 | - return $result; |
|
190 | - } |
|
189 | + return $result; |
|
190 | + } |
|
191 | 191 | |
192 | - public function mergeRoutes($params) |
|
193 | - { |
|
194 | - $result = Route4Me::makeRequst(array( |
|
195 | - 'url' => Endpoint::ROUTES_MERGE, |
|
196 | - 'method' => 'POST', |
|
197 | - 'query' => array( |
|
198 | - 'api_key' => Route4Me::getApiKey(), |
|
199 | - ), |
|
200 | - 'body' => array( |
|
201 | - 'route_ids' => isset($params['route_ids']) ? $params['route_ids'] : null, |
|
202 | - 'depot_address' => isset($params['depot_address']) ? $params['depot_address'] : null, |
|
203 | - 'remove_origin' => isset($params['remove_origin']) ? $params['remove_origin'] : null, |
|
204 | - 'depot_lat' => isset($params['depot_lat']) ? $params['depot_lat'] : null, |
|
205 | - 'depot_lat' => isset($params['depot_lat']) ? $params['depot_lat'] : null |
|
206 | - ), |
|
207 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
208 | - )); |
|
192 | + public function mergeRoutes($params) |
|
193 | + { |
|
194 | + $result = Route4Me::makeRequst(array( |
|
195 | + 'url' => Endpoint::ROUTES_MERGE, |
|
196 | + 'method' => 'POST', |
|
197 | + 'query' => array( |
|
198 | + 'api_key' => Route4Me::getApiKey(), |
|
199 | + ), |
|
200 | + 'body' => array( |
|
201 | + 'route_ids' => isset($params['route_ids']) ? $params['route_ids'] : null, |
|
202 | + 'depot_address' => isset($params['depot_address']) ? $params['depot_address'] : null, |
|
203 | + 'remove_origin' => isset($params['remove_origin']) ? $params['remove_origin'] : null, |
|
204 | + 'depot_lat' => isset($params['depot_lat']) ? $params['depot_lat'] : null, |
|
205 | + 'depot_lat' => isset($params['depot_lat']) ? $params['depot_lat'] : null |
|
206 | + ), |
|
207 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
208 | + )); |
|
209 | 209 | |
210 | - return $result; |
|
211 | - } |
|
210 | + return $result; |
|
211 | + } |
|
212 | 212 | |
213 | - public function shareRoute($params) |
|
214 | - { |
|
215 | - $result = Route4Me::makeRequst(array( |
|
216 | - 'url' => Endpoint::ROUTE_SHARE, |
|
217 | - 'method' => 'POST', |
|
218 | - 'query' => array( |
|
219 | - 'api_key' => Route4Me::getApiKey(), |
|
220 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
221 | - 'response_format' => isset($params['response_format']) ? $params['response_format'] : null, |
|
222 | - ), |
|
223 | - 'body' => array( |
|
224 | - 'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null, |
|
225 | - ), |
|
226 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
227 | - )); |
|
213 | + public function shareRoute($params) |
|
214 | + { |
|
215 | + $result = Route4Me::makeRequst(array( |
|
216 | + 'url' => Endpoint::ROUTE_SHARE, |
|
217 | + 'method' => 'POST', |
|
218 | + 'query' => array( |
|
219 | + 'api_key' => Route4Me::getApiKey(), |
|
220 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
221 | + 'response_format' => isset($params['response_format']) ? $params['response_format'] : null, |
|
222 | + ), |
|
223 | + 'body' => array( |
|
224 | + 'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null, |
|
225 | + ), |
|
226 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
227 | + )); |
|
228 | 228 | |
229 | - return $result; |
|
230 | - } |
|
229 | + return $result; |
|
230 | + } |
|
231 | 231 | |
232 | - // Returns random route_id from existing routes between $offset and $offset+$limit |
|
233 | - public function getRandomRouteId($offset,$limit) |
|
234 | - { |
|
235 | - $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
|
236 | - $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
232 | + // Returns random route_id from existing routes between $offset and $offset+$limit |
|
233 | + public function getRandomRouteId($offset,$limit) |
|
234 | + { |
|
235 | + $query['limit'] = isset($params['limit']) ? $params['limit'] : 30; |
|
236 | + $query['offset'] = isset($params['offset']) ? $params['offset'] : 0; |
|
237 | 237 | |
238 | - $json = Route4Me::makeRequst(array( |
|
239 | - 'url' => Endpoint::ROUTE_V4, |
|
240 | - 'method' => 'GET', |
|
241 | - 'query' => $query |
|
242 | - )); |
|
238 | + $json = Route4Me::makeRequst(array( |
|
239 | + 'url' => Endpoint::ROUTE_V4, |
|
240 | + 'method' => 'GET', |
|
241 | + 'query' => $query |
|
242 | + )); |
|
243 | 243 | |
244 | - if (sizeof($json)>0) { |
|
245 | - $routes = array(); |
|
244 | + if (sizeof($json)>0) { |
|
245 | + $routes = array(); |
|
246 | 246 | |
247 | - foreach($json as $route) { |
|
248 | - $routes[] = Route::fromArray($route); |
|
249 | - } |
|
247 | + foreach($json as $route) { |
|
248 | + $routes[] = Route::fromArray($route); |
|
249 | + } |
|
250 | 250 | |
251 | - $num=rand(0,sizeof($routes)-1); |
|
252 | - $rRoute=(array)$routes[$num]; |
|
251 | + $num=rand(0,sizeof($routes)-1); |
|
252 | + $rRoute=(array)$routes[$num]; |
|
253 | 253 | |
254 | - if (is_array($rRoute)) { |
|
255 | - return $rRoute["route_id"]; |
|
256 | - } else { |
|
257 | - return null; |
|
258 | - } |
|
259 | - } else { |
|
260 | - echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
261 | - return null; |
|
262 | - } |
|
263 | - } |
|
254 | + if (is_array($rRoute)) { |
|
255 | + return $rRoute["route_id"]; |
|
256 | + } else { |
|
257 | + return null; |
|
258 | + } |
|
259 | + } else { |
|
260 | + echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
261 | + return null; |
|
262 | + } |
|
263 | + } |
|
264 | 264 | |
265 | - public function update() |
|
266 | - { |
|
267 | - $route = Route4Me::makeRequst(array( |
|
268 | - 'url' => Endpoint::ROUTE_V4, |
|
269 | - 'method' => 'PUT', |
|
270 | - 'query' => array( |
|
271 | - 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
272 | - ), |
|
273 | - 'body' => array ( |
|
274 | - 'parameters' => $this->parameters, |
|
275 | - ), |
|
276 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
277 | - )); |
|
265 | + public function update() |
|
266 | + { |
|
267 | + $route = Route4Me::makeRequst(array( |
|
268 | + 'url' => Endpoint::ROUTE_V4, |
|
269 | + 'method' => 'PUT', |
|
270 | + 'query' => array( |
|
271 | + 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
272 | + ), |
|
273 | + 'body' => array ( |
|
274 | + 'parameters' => $this->parameters, |
|
275 | + ), |
|
276 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
277 | + )); |
|
278 | 278 | |
279 | - return Route::fromArray($route); |
|
280 | - } |
|
279 | + return Route::fromArray($route); |
|
280 | + } |
|
281 | 281 | |
282 | - public function updateAddress($address=null) |
|
283 | - { |
|
284 | - $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
285 | - : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
282 | + public function updateAddress($address=null) |
|
283 | + { |
|
284 | + $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
285 | + : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
286 | 286 | |
287 | - $result = Route4Me::makeRequst(array( |
|
288 | - 'url' => Endpoint::ADDRESS_V4, |
|
289 | - 'method' => 'PUT', |
|
290 | - 'query' => array( |
|
291 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
292 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
293 | - ), |
|
294 | - 'body' => $body, |
|
295 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
296 | - )); |
|
287 | + $result = Route4Me::makeRequst(array( |
|
288 | + 'url' => Endpoint::ADDRESS_V4, |
|
289 | + 'method' => 'PUT', |
|
290 | + 'query' => array( |
|
291 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
292 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
293 | + ), |
|
294 | + 'body' => $body, |
|
295 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
296 | + )); |
|
297 | 297 | |
298 | - return $result; |
|
299 | - } |
|
298 | + return $result; |
|
299 | + } |
|
300 | 300 | |
301 | - public function updateRouteAddress() |
|
302 | - { |
|
303 | - $result = Route4Me::makeRequst(array( |
|
304 | - 'url' => Endpoint::ADDRESS_V4, |
|
305 | - 'method' => 'PUT', |
|
306 | - 'query' => array( |
|
307 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
308 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
309 | - ), |
|
310 | - 'body' => array( |
|
311 | - "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
312 | - "addresses" => isset($this->addresses) ? $this->addresses : null |
|
313 | - ), |
|
314 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
315 | - )); |
|
301 | + public function updateRouteAddress() |
|
302 | + { |
|
303 | + $result = Route4Me::makeRequst(array( |
|
304 | + 'url' => Endpoint::ADDRESS_V4, |
|
305 | + 'method' => 'PUT', |
|
306 | + 'query' => array( |
|
307 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
308 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
309 | + ), |
|
310 | + 'body' => array( |
|
311 | + "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
312 | + "addresses" => isset($this->addresses) ? $this->addresses : null |
|
313 | + ), |
|
314 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
315 | + )); |
|
316 | 316 | |
317 | - return $result; |
|
318 | - } |
|
317 | + return $result; |
|
318 | + } |
|
319 | 319 | |
320 | - public function addAddresses($params) |
|
321 | - { |
|
322 | - $route = Route4Me::makeRequst(array( |
|
323 | - 'url' => Endpoint::ROUTE_V4, |
|
324 | - 'method' => 'PUT', |
|
325 | - 'query' => array( |
|
326 | - 'api_key' => Route4Me::getApiKey(), |
|
327 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null |
|
328 | - ), |
|
329 | - 'body' => array( |
|
330 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null |
|
331 | - ), |
|
332 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
333 | - )); |
|
320 | + public function addAddresses($params) |
|
321 | + { |
|
322 | + $route = Route4Me::makeRequst(array( |
|
323 | + 'url' => Endpoint::ROUTE_V4, |
|
324 | + 'method' => 'PUT', |
|
325 | + 'query' => array( |
|
326 | + 'api_key' => Route4Me::getApiKey(), |
|
327 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null |
|
328 | + ), |
|
329 | + 'body' => array( |
|
330 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null |
|
331 | + ), |
|
332 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
333 | + )); |
|
334 | 334 | |
335 | - return Route::fromArray($route); |
|
336 | - } |
|
335 | + return Route::fromArray($route); |
|
336 | + } |
|
337 | 337 | |
338 | - public function insertAddressOptimalPosition(array $params) |
|
339 | - { |
|
340 | - $route = Route4Me::makeRequst(array( |
|
341 | - 'url' => Endpoint::ROUTE_V4, |
|
342 | - 'method' => 'PUT', |
|
343 | - 'query' => array( |
|
344 | - 'api_key' => Route4Me::getApiKey(), |
|
345 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
346 | - ), |
|
347 | - 'body' => array( |
|
348 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
349 | - 'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null, |
|
350 | - ) |
|
351 | - )); |
|
338 | + public function insertAddressOptimalPosition(array $params) |
|
339 | + { |
|
340 | + $route = Route4Me::makeRequst(array( |
|
341 | + 'url' => Endpoint::ROUTE_V4, |
|
342 | + 'method' => 'PUT', |
|
343 | + 'query' => array( |
|
344 | + 'api_key' => Route4Me::getApiKey(), |
|
345 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
346 | + ), |
|
347 | + 'body' => array( |
|
348 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
349 | + 'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null, |
|
350 | + ) |
|
351 | + )); |
|
352 | 352 | |
353 | - return Route::fromArray($route); |
|
354 | - } |
|
353 | + return Route::fromArray($route); |
|
354 | + } |
|
355 | 355 | |
356 | - public function addNoteFile($params) |
|
357 | - { |
|
358 | - $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
359 | - $rpath = realpath($fname); |
|
356 | + public function addNoteFile($params) |
|
357 | + { |
|
358 | + $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
359 | + $rpath = realpath($fname); |
|
360 | 360 | |
361 | - $result= Route4Me::makeRequst(array( |
|
362 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
363 | - 'method' => 'POST', |
|
364 | - 'query' => array( |
|
365 | - 'api_key' => Route4Me::getApiKey(), |
|
366 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
367 | - 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
368 | - 'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null, |
|
369 | - 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
370 | - 'device_type' => isset($params['device_type']) ? $params['device_type'] : null, |
|
371 | - 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
372 | - ), |
|
373 | - 'body' => array( |
|
374 | - 'strUpdateType' => isset($params['strUpdateType']) ? $params['strUpdateType'] : null, |
|
375 | - 'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null, |
|
376 | - 'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null, |
|
377 | - ), |
|
378 | - 'FILE' => $rpath, |
|
361 | + $result= Route4Me::makeRequst(array( |
|
362 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
363 | + 'method' => 'POST', |
|
364 | + 'query' => array( |
|
365 | + 'api_key' => Route4Me::getApiKey(), |
|
366 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
367 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
368 | + 'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null, |
|
369 | + 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
370 | + 'device_type' => isset($params['device_type']) ? $params['device_type'] : null, |
|
371 | + 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
372 | + ), |
|
373 | + 'body' => array( |
|
374 | + 'strUpdateType' => isset($params['strUpdateType']) ? $params['strUpdateType'] : null, |
|
375 | + 'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null, |
|
376 | + 'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null, |
|
377 | + ), |
|
378 | + 'FILE' => $rpath, |
|
379 | 379 | |
380 | - 'HTTPHEADER' => array( |
|
381 | - 'Content-Type: application/x-www-form-urlencoded' |
|
382 | - ) |
|
383 | - )); |
|
380 | + 'HTTPHEADER' => array( |
|
381 | + 'Content-Type: application/x-www-form-urlencoded' |
|
382 | + ) |
|
383 | + )); |
|
384 | 384 | |
385 | - return $result; |
|
386 | - } |
|
385 | + return $result; |
|
386 | + } |
|
387 | 387 | |
388 | - public function delete($route_id) |
|
389 | - { |
|
390 | - $result = Route4Me::makeRequst(array( |
|
391 | - 'url' => Endpoint::ROUTE_V4, |
|
392 | - 'method' => 'DELETE', |
|
393 | - 'query' => array( 'route_id' => $route_id ) |
|
394 | - )); |
|
388 | + public function delete($route_id) |
|
389 | + { |
|
390 | + $result = Route4Me::makeRequst(array( |
|
391 | + 'url' => Endpoint::ROUTE_V4, |
|
392 | + 'method' => 'DELETE', |
|
393 | + 'query' => array( 'route_id' => $route_id ) |
|
394 | + )); |
|
395 | 395 | |
396 | - $result = Route4Me::makeRequst(array( |
|
397 | - 'url' => Endpoint::ROUTES_DELETE, |
|
398 | - 'method' => 'DELETE', |
|
399 | - 'query' => array( |
|
400 | - 'api_key' => Route4Me::getApiKey(), |
|
401 | - 'route_id' => $route_id, |
|
402 | - ) |
|
403 | - )); |
|
396 | + $result = Route4Me::makeRequst(array( |
|
397 | + 'url' => Endpoint::ROUTES_DELETE, |
|
398 | + 'method' => 'DELETE', |
|
399 | + 'query' => array( |
|
400 | + 'api_key' => Route4Me::getApiKey(), |
|
401 | + 'route_id' => $route_id, |
|
402 | + ) |
|
403 | + )); |
|
404 | 404 | |
405 | - return $result; |
|
406 | - } |
|
405 | + return $result; |
|
406 | + } |
|
407 | 407 | |
408 | - public function GetAddressesFromRoute($route_id) |
|
409 | - { |
|
410 | - $route1=Route::getRoutes($route_id,null); |
|
411 | - if (isset($route1)) { |
|
412 | - return $route1->addresses; |
|
413 | - } else { |
|
414 | - return null; |
|
415 | - } |
|
416 | - } |
|
408 | + public function GetAddressesFromRoute($route_id) |
|
409 | + { |
|
410 | + $route1=Route::getRoutes($route_id,null); |
|
411 | + if (isset($route1)) { |
|
412 | + return $route1->addresses; |
|
413 | + } else { |
|
414 | + return null; |
|
415 | + } |
|
416 | + } |
|
417 | 417 | |
418 | - public function GetRandomAddressFromRoute($route_id) |
|
419 | - { |
|
420 | - $route1 = Route::getRoutes($route_id,null); |
|
418 | + public function GetRandomAddressFromRoute($route_id) |
|
419 | + { |
|
420 | + $route1 = Route::getRoutes($route_id,null); |
|
421 | 421 | |
422 | - if (isset($route1)) { |
|
423 | - $addresses = $route1->addresses; |
|
422 | + if (isset($route1)) { |
|
423 | + $addresses = $route1->addresses; |
|
424 | 424 | |
425 | - $rnd = rand(0,sizeof($addresses)-1); |
|
425 | + $rnd = rand(0,sizeof($addresses)-1); |
|
426 | 426 | |
427 | - return $addresses[$rnd]; |
|
427 | + return $addresses[$rnd]; |
|
428 | 428 | |
429 | - } else { |
|
430 | - return null; |
|
431 | - } |
|
432 | - } |
|
429 | + } else { |
|
430 | + return null; |
|
431 | + } |
|
432 | + } |
|
433 | 433 | |
434 | - public function getRouteId() |
|
435 | - { |
|
436 | - return $this->route_id; |
|
437 | - } |
|
434 | + public function getRouteId() |
|
435 | + { |
|
436 | + return $this->route_id; |
|
437 | + } |
|
438 | 438 | |
439 | - public function getOptimizationId() |
|
440 | - { |
|
441 | - return $this->optimization_problem_id; |
|
442 | - } |
|
439 | + public function getOptimizationId() |
|
440 | + { |
|
441 | + return $this->optimization_problem_id; |
|
442 | + } |
|
443 | 443 | |
444 | - public function GetLastLocation(array $params) |
|
445 | - { |
|
446 | - $route = Route4Me::makeRequst(array( |
|
447 | - 'url' => Endpoint::ROUTE_V4, |
|
448 | - 'method' => 'GET', |
|
449 | - 'query' => array( |
|
450 | - 'api_key' => Route4Me::getApiKey(), |
|
451 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
452 | - 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null |
|
453 | - ) |
|
454 | - )); |
|
444 | + public function GetLastLocation(array $params) |
|
445 | + { |
|
446 | + $route = Route4Me::makeRequst(array( |
|
447 | + 'url' => Endpoint::ROUTE_V4, |
|
448 | + 'method' => 'GET', |
|
449 | + 'query' => array( |
|
450 | + 'api_key' => Route4Me::getApiKey(), |
|
451 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
452 | + 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null |
|
453 | + ) |
|
454 | + )); |
|
455 | 455 | |
456 | - return Route::fromArray($route); |
|
457 | - } |
|
456 | + return Route::fromArray($route); |
|
457 | + } |
|
458 | 458 | |
459 | - public function GetTrackingHistoryFromTimeRange(array $params) |
|
460 | - { |
|
461 | - $route = Route4Me::makeRequst(array( |
|
462 | - 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
463 | - 'method' => 'GET', |
|
464 | - 'query' => array( |
|
465 | - 'api_key' => Route4Me::getApiKey(), |
|
466 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
467 | - 'format' => isset($params['format']) ? $params['format'] : null, |
|
468 | - 'time_period' => isset($params['time_period']) ? $params['time_period'] : null, |
|
469 | - 'start_date' => isset($params['start_date']) ? $params['start_date'] : null, |
|
470 | - 'end_date' => isset($params['end_date']) ? $params['end_date'] : null |
|
471 | - ) |
|
472 | - )); |
|
459 | + public function GetTrackingHistoryFromTimeRange(array $params) |
|
460 | + { |
|
461 | + $route = Route4Me::makeRequst(array( |
|
462 | + 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
463 | + 'method' => 'GET', |
|
464 | + 'query' => array( |
|
465 | + 'api_key' => Route4Me::getApiKey(), |
|
466 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
467 | + 'format' => isset($params['format']) ? $params['format'] : null, |
|
468 | + 'time_period' => isset($params['time_period']) ? $params['time_period'] : null, |
|
469 | + 'start_date' => isset($params['start_date']) ? $params['start_date'] : null, |
|
470 | + 'end_date' => isset($params['end_date']) ? $params['end_date'] : null |
|
471 | + ) |
|
472 | + )); |
|
473 | 473 | |
474 | - return $route; |
|
475 | - } |
|
474 | + return $route; |
|
475 | + } |
|
476 | 476 | |
477 | - public function GetAssetTracking(array $params) |
|
478 | - { |
|
479 | - $route = Route4Me::makeRequst(array( |
|
480 | - 'url' => Endpoint::STATUS_V4, |
|
481 | - 'method' => 'GET', |
|
482 | - 'query' => array( |
|
483 | - 'api_key' => Route4Me::getApiKey(), |
|
484 | - 'tracking' => isset($params['tracking']) ? $params['tracking'] : null |
|
485 | - ) |
|
486 | - )); |
|
477 | + public function GetAssetTracking(array $params) |
|
478 | + { |
|
479 | + $route = Route4Me::makeRequst(array( |
|
480 | + 'url' => Endpoint::STATUS_V4, |
|
481 | + 'method' => 'GET', |
|
482 | + 'query' => array( |
|
483 | + 'api_key' => Route4Me::getApiKey(), |
|
484 | + 'tracking' => isset($params['tracking']) ? $params['tracking'] : null |
|
485 | + ) |
|
486 | + )); |
|
487 | 487 | |
488 | - return $route; |
|
489 | - } |
|
488 | + return $route; |
|
489 | + } |
|
490 | 490 | } |
@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | class Common |
6 | 6 | { |
7 | - public static function getValue($array, $item, $default = null) |
|
8 | - { |
|
9 | - return (isset($array[$item])) ? $array[$item] : $default; |
|
10 | - } |
|
7 | + public static 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 | } |
@@ -6,549 +6,549 @@ |
||
6 | 6 | |
7 | 7 | class AddressBookLocation extends Common |
8 | 8 | { |
9 | - public $address_id; |
|
10 | - public $address_group; |
|
11 | - public $address_alias; |
|
12 | - public $address_1; |
|
13 | - public $address_2; |
|
14 | - public $first_name; |
|
15 | - public $last_name; |
|
16 | - public $address_email; |
|
17 | - public $address_phone_number; |
|
18 | - public $address_city; |
|
19 | - public $address_state_id; |
|
20 | - public $address_country_id; |
|
21 | - public $address_zip; |
|
22 | - public $cached_lat; |
|
23 | - public $cached_lng; |
|
24 | - public $curbside_lat; |
|
25 | - public $curbside_lng; |
|
26 | - public $color; |
|
27 | - public $address_custom_data; |
|
28 | - public $schedule; |
|
9 | + public $address_id; |
|
10 | + public $address_group; |
|
11 | + public $address_alias; |
|
12 | + public $address_1; |
|
13 | + public $address_2; |
|
14 | + public $first_name; |
|
15 | + public $last_name; |
|
16 | + public $address_email; |
|
17 | + public $address_phone_number; |
|
18 | + public $address_city; |
|
19 | + public $address_state_id; |
|
20 | + public $address_country_id; |
|
21 | + public $address_zip; |
|
22 | + public $cached_lat; |
|
23 | + public $cached_lng; |
|
24 | + public $curbside_lat; |
|
25 | + public $curbside_lng; |
|
26 | + public $color; |
|
27 | + public $address_custom_data; |
|
28 | + public $schedule; |
|
29 | 29 | |
30 | - public $created_timestamp; |
|
31 | - public $member_id; |
|
32 | - public $schedule_blacklist; |
|
33 | - public $in_route_count; |
|
34 | - public $last_visited_timestamp; |
|
35 | - public $last_routed_timestamp; |
|
36 | - public $local_time_window_start; |
|
37 | - public $local_time_window_end; |
|
38 | - public $local_time_window_start_2; |
|
39 | - public $local_time_window_end_2; |
|
40 | - public $service_time; |
|
41 | - public $local_timezone_string; |
|
42 | - public $address_icon; |
|
43 | - public $address_stop_type; |
|
44 | - public $address_cube; |
|
45 | - public $address_pieces; |
|
46 | - public $address_reference_no; |
|
47 | - public $address_revenue; |
|
48 | - public $address_weight; |
|
49 | - public $address_priority; |
|
50 | - public $address_customer_po; |
|
30 | + public $created_timestamp; |
|
31 | + public $member_id; |
|
32 | + public $schedule_blacklist; |
|
33 | + public $in_route_count; |
|
34 | + public $last_visited_timestamp; |
|
35 | + public $last_routed_timestamp; |
|
36 | + public $local_time_window_start; |
|
37 | + public $local_time_window_end; |
|
38 | + public $local_time_window_start_2; |
|
39 | + public $local_time_window_end_2; |
|
40 | + public $service_time; |
|
41 | + public $local_timezone_string; |
|
42 | + public $address_icon; |
|
43 | + public $address_stop_type; |
|
44 | + public $address_cube; |
|
45 | + public $address_pieces; |
|
46 | + public $address_reference_no; |
|
47 | + public $address_revenue; |
|
48 | + public $address_weight; |
|
49 | + public $address_priority; |
|
50 | + public $address_customer_po; |
|
51 | 51 | |
52 | - public static function fromArray(array $params) |
|
53 | - { |
|
54 | - $addressbooklocation = new AddressBookLocation(); |
|
52 | + public static function fromArray(array $params) |
|
53 | + { |
|
54 | + $addressbooklocation = new AddressBookLocation(); |
|
55 | 55 | |
56 | - foreach($params as $key => $value) { |
|
57 | - if (property_exists($addressbooklocation, $key)) { |
|
58 | - $addressbooklocation->{$key} = $value; |
|
59 | - } |
|
60 | - } |
|
56 | + foreach($params as $key => $value) { |
|
57 | + if (property_exists($addressbooklocation, $key)) { |
|
58 | + $addressbooklocation->{$key} = $value; |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - return $addressbooklocation; |
|
63 | - } |
|
62 | + return $addressbooklocation; |
|
63 | + } |
|
64 | 64 | |
65 | - public static function getAddressBookLocation($addressId) |
|
66 | - { |
|
67 | - $ablocations = Route4Me::makeRequst(array( |
|
68 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
69 | - 'method' => 'GET', |
|
70 | - 'query' => array( |
|
71 | - 'query' => $addressId, |
|
72 | - 'limit' => 30 |
|
73 | - ) |
|
74 | - )); |
|
65 | + public static function getAddressBookLocation($addressId) |
|
66 | + { |
|
67 | + $ablocations = Route4Me::makeRequst(array( |
|
68 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
69 | + 'method' => 'GET', |
|
70 | + 'query' => array( |
|
71 | + 'query' => $addressId, |
|
72 | + 'limit' => 30 |
|
73 | + ) |
|
74 | + )); |
|
75 | 75 | |
76 | - return $ablocations; |
|
77 | - } |
|
76 | + return $ablocations; |
|
77 | + } |
|
78 | 78 | |
79 | - public static function searchRoutedLocation($params) |
|
80 | - { |
|
81 | - $result= Route4Me::makeRequst(array( |
|
82 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
83 | - 'method' => 'GET', |
|
84 | - 'query' => array( |
|
85 | - 'display' => isset($params['display']) ? $params['display'] : null, |
|
86 | - 'query' => isset($params['query']) ? $params['query'] : null, |
|
87 | - 'fields' => isset($params['fields']) ? $params['fields'] : null, |
|
88 | - 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
89 | - 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
90 | - ) |
|
91 | - )); |
|
79 | + public static function searchRoutedLocation($params) |
|
80 | + { |
|
81 | + $result= Route4Me::makeRequst(array( |
|
82 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
83 | + 'method' => 'GET', |
|
84 | + 'query' => array( |
|
85 | + 'display' => isset($params['display']) ? $params['display'] : null, |
|
86 | + 'query' => isset($params['query']) ? $params['query'] : null, |
|
87 | + 'fields' => isset($params['fields']) ? $params['fields'] : null, |
|
88 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
89 | + 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
90 | + ) |
|
91 | + )); |
|
92 | 92 | |
93 | - return $result; |
|
94 | - } |
|
93 | + return $result; |
|
94 | + } |
|
95 | 95 | |
96 | - public static function getAddressBookLocations($params) |
|
97 | - { |
|
98 | - $ablocations = Route4Me::makeRequst(array( |
|
99 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
100 | - 'method' => 'GET', |
|
101 | - 'query' => array( |
|
102 | - 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
103 | - 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
104 | - ) |
|
105 | - )); |
|
96 | + public static function getAddressBookLocations($params) |
|
97 | + { |
|
98 | + $ablocations = Route4Me::makeRequst(array( |
|
99 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
100 | + 'method' => 'GET', |
|
101 | + 'query' => array( |
|
102 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
103 | + 'offset' => isset($params['offset']) ? $params['offset'] : null, |
|
104 | + ) |
|
105 | + )); |
|
106 | 106 | |
107 | - return $ablocations; |
|
108 | - } |
|
107 | + return $ablocations; |
|
108 | + } |
|
109 | 109 | |
110 | - public static function getAddressBookLocationsByIDs($ids) |
|
111 | - { |
|
112 | - $ablocations = Route4Me::makeRequst(array( |
|
113 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
114 | - 'method' => 'GET', |
|
115 | - 'query' => array( |
|
116 | - 'address_id' => $ids |
|
117 | - ) |
|
118 | - )); |
|
110 | + public static function getAddressBookLocationsByIDs($ids) |
|
111 | + { |
|
112 | + $ablocations = Route4Me::makeRequst(array( |
|
113 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
114 | + 'method' => 'GET', |
|
115 | + 'query' => array( |
|
116 | + 'address_id' => $ids |
|
117 | + ) |
|
118 | + )); |
|
119 | 119 | |
120 | - return $ablocations; |
|
121 | - } |
|
120 | + return $ablocations; |
|
121 | + } |
|
122 | 122 | |
123 | - public static function getRandomAddressBookLocation($params) |
|
124 | - { |
|
125 | - $ablocations = Route4Me::makeRequst(array( |
|
126 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
127 | - 'method' => 'GET', |
|
128 | - 'query' => array( |
|
129 | - 'limit' => isset($params['limit']) ? $params['limit'] : 0, |
|
130 | - 'offset' => isset($params['offset']) ? $params['offset'] : 10, |
|
131 | - ) |
|
132 | - )); |
|
123 | + public static function getRandomAddressBookLocation($params) |
|
124 | + { |
|
125 | + $ablocations = Route4Me::makeRequst(array( |
|
126 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
127 | + 'method' => 'GET', |
|
128 | + 'query' => array( |
|
129 | + 'limit' => isset($params['limit']) ? $params['limit'] : 0, |
|
130 | + 'offset' => isset($params['offset']) ? $params['offset'] : 10, |
|
131 | + ) |
|
132 | + )); |
|
133 | 133 | |
134 | - if (isset($ablocations["results"])) { |
|
135 | - $locationsSize = sizeof($ablocations["results"]); |
|
134 | + if (isset($ablocations["results"])) { |
|
135 | + $locationsSize = sizeof($ablocations["results"]); |
|
136 | 136 | |
137 | - if ($locationsSize > 0) { |
|
138 | - $randomLocationIndex = rand(0, $locationsSize - 1); |
|
139 | - return $ablocations["results"][$randomLocationIndex]; |
|
140 | - } |
|
141 | - } |
|
137 | + if ($locationsSize > 0) { |
|
138 | + $randomLocationIndex = rand(0, $locationsSize - 1); |
|
139 | + return $ablocations["results"][$randomLocationIndex]; |
|
140 | + } |
|
141 | + } |
|
142 | 142 | |
143 | - return null; |
|
144 | - } |
|
143 | + return null; |
|
144 | + } |
|
145 | 145 | |
146 | - public static function addAdressBookLocation($params) |
|
147 | - { |
|
148 | - $body = array(); |
|
149 | - $abLocations = new AddressBookLocation(); |
|
146 | + public static function addAdressBookLocation($params) |
|
147 | + { |
|
148 | + $body = array(); |
|
149 | + $abLocations = new AddressBookLocation(); |
|
150 | 150 | |
151 | - foreach($params as $key => $value) { |
|
152 | - if ($key == "address_id") continue; |
|
153 | - if (property_exists($abLocations, $key)) { |
|
154 | - if (isset($params->{$key})) { |
|
155 | - $body[$key] = $params->{$key}; |
|
156 | - } |
|
157 | - } |
|
158 | - } |
|
151 | + foreach($params as $key => $value) { |
|
152 | + if ($key == "address_id") continue; |
|
153 | + if (property_exists($abLocations, $key)) { |
|
154 | + if (isset($params->{$key})) { |
|
155 | + $body[$key] = $params->{$key}; |
|
156 | + } |
|
157 | + } |
|
158 | + } |
|
159 | 159 | |
160 | - $response = Route4Me::makeRequst(array( |
|
161 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
162 | - 'method' => 'POST', |
|
163 | - 'body' => $body |
|
164 | - )); |
|
160 | + $response = Route4Me::makeRequst(array( |
|
161 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
162 | + 'method' => 'POST', |
|
163 | + 'body' => $body |
|
164 | + )); |
|
165 | 165 | |
166 | - return $response; |
|
167 | - } |
|
166 | + return $response; |
|
167 | + } |
|
168 | 168 | |
169 | - public function deleteAdressBookLocation($address_ids) |
|
170 | - { |
|
171 | - $result = Route4Me::makeRequst(array( |
|
172 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
173 | - 'method' => 'DELETEARRAY', |
|
174 | - 'query' => array( |
|
175 | - 'address_ids' => $address_ids |
|
176 | - ) |
|
177 | - )); |
|
169 | + public function deleteAdressBookLocation($address_ids) |
|
170 | + { |
|
171 | + $result = Route4Me::makeRequst(array( |
|
172 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
173 | + 'method' => 'DELETEARRAY', |
|
174 | + 'query' => array( |
|
175 | + 'address_ids' => $address_ids |
|
176 | + ) |
|
177 | + )); |
|
178 | 178 | |
179 | - return $result; |
|
180 | - } |
|
179 | + return $result; |
|
180 | + } |
|
181 | 181 | |
182 | - public function updateAdressBookLocation($params) |
|
183 | - { |
|
184 | - $body = array(); |
|
185 | - $abLocations = new AddressBookLocation(); |
|
182 | + public function updateAdressBookLocation($params) |
|
183 | + { |
|
184 | + $body = array(); |
|
185 | + $abLocations = new AddressBookLocation(); |
|
186 | 186 | |
187 | - foreach($params as $key => $value) { |
|
188 | - if (property_exists($abLocations, $key)) { |
|
189 | - if (isset($params->{$key})) { |
|
190 | - $body[$key] = $params->{$key}; |
|
191 | - } |
|
192 | - } |
|
193 | - } |
|
187 | + foreach($params as $key => $value) { |
|
188 | + if (property_exists($abLocations, $key)) { |
|
189 | + if (isset($params->{$key})) { |
|
190 | + $body[$key] = $params->{$key}; |
|
191 | + } |
|
192 | + } |
|
193 | + } |
|
194 | 194 | |
195 | - $response = Route4Me::makeRequst(array( |
|
196 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
197 | - 'method' => 'PUT', |
|
198 | - 'body' => $body, |
|
199 | - )); |
|
195 | + $response = Route4Me::makeRequst(array( |
|
196 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
197 | + 'method' => 'PUT', |
|
198 | + 'body' => $body, |
|
199 | + )); |
|
200 | 200 | |
201 | - return $response; |
|
202 | - } |
|
201 | + return $response; |
|
202 | + } |
|
203 | 203 | |
204 | - public static function get($params) |
|
205 | - { |
|
206 | - $ablocations = Route4Me::makeRequst(array( |
|
207 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
208 | - 'method' => 'ADD', |
|
209 | - 'query' => array( |
|
210 | - 'first_name' => isset($params->first_name) ? $params->first_name : null, |
|
211 | - 'address_1' => isset($params->address_1) ? $params->address_1 : null, |
|
212 | - 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
213 | - 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
214 | - ) |
|
215 | - )); |
|
204 | + public static function get($params) |
|
205 | + { |
|
206 | + $ablocations = Route4Me::makeRequst(array( |
|
207 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
208 | + 'method' => 'ADD', |
|
209 | + 'query' => array( |
|
210 | + 'first_name' => isset($params->first_name) ? $params->first_name : null, |
|
211 | + 'address_1' => isset($params->address_1) ? $params->address_1 : null, |
|
212 | + 'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null, |
|
213 | + 'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null, |
|
214 | + ) |
|
215 | + )); |
|
216 | 216 | |
217 | - return $ablocations; |
|
218 | - } |
|
217 | + return $ablocations; |
|
218 | + } |
|
219 | 219 | |
220 | - public static function validateScheduleMode($scheduleMode) |
|
221 | - { |
|
222 | - $schedMmodes = array("daily","weekly","monthly","annually"); |
|
220 | + public static function validateScheduleMode($scheduleMode) |
|
221 | + { |
|
222 | + $schedMmodes = array("daily","weekly","monthly","annually"); |
|
223 | 223 | |
224 | - if (in_array($scheduleMode, $schedMmodes)) |
|
225 | - return TRUE; |
|
226 | - else |
|
227 | - return FALSE; |
|
228 | - } |
|
224 | + if (in_array($scheduleMode, $schedMmodes)) |
|
225 | + return TRUE; |
|
226 | + else |
|
227 | + return FALSE; |
|
228 | + } |
|
229 | 229 | |
230 | - public static function validateScheduleEnable($scheduleEnabled) |
|
231 | - { |
|
232 | - $schedEnambles = array(TRUE,FALSE); |
|
230 | + public static function validateScheduleEnable($scheduleEnabled) |
|
231 | + { |
|
232 | + $schedEnambles = array(TRUE,FALSE); |
|
233 | 233 | |
234 | - if (in_array($scheduleEnabled, $schedEnambles)) |
|
235 | - return TRUE; |
|
236 | - else |
|
237 | - return FALSE; |
|
238 | - } |
|
234 | + if (in_array($scheduleEnabled, $schedEnambles)) |
|
235 | + return TRUE; |
|
236 | + else |
|
237 | + return FALSE; |
|
238 | + } |
|
239 | 239 | |
240 | - public static function validateScheduleEvery($scheduleEvery) |
|
241 | - { |
|
242 | - if (is_numeric($scheduleEvery)) |
|
243 | - return TRUE; |
|
244 | - else |
|
245 | - return FALSE; |
|
246 | - } |
|
240 | + public static function validateScheduleEvery($scheduleEvery) |
|
241 | + { |
|
242 | + if (is_numeric($scheduleEvery)) |
|
243 | + return TRUE; |
|
244 | + else |
|
245 | + return FALSE; |
|
246 | + } |
|
247 | 247 | |
248 | - public static function validateScheduleWeekDays($scheduleWeekDays) |
|
249 | - { |
|
250 | - $weekdays = explode(',', $scheduleWeekDays); |
|
248 | + public static function validateScheduleWeekDays($scheduleWeekDays) |
|
249 | + { |
|
250 | + $weekdays = explode(',', $scheduleWeekDays); |
|
251 | 251 | |
252 | - if (sizeof($weekdays) < 1) return FALSE; |
|
252 | + if (sizeof($weekdays) < 1) return FALSE; |
|
253 | 253 | |
254 | - $isValid = TRUE; |
|
254 | + $isValid = TRUE; |
|
255 | 255 | |
256 | - for ($i=0; $i < sizeof($weekdays); $i++) { |
|
257 | - if (is_numeric($weekdays[$i])) { |
|
258 | - $wday = intval($weekdays[$i]); |
|
259 | - if ($wday < 1 || $wday > 7) $isValid = FALSE; |
|
260 | - } |
|
261 | - else $isValid = FALSE; |
|
262 | - } |
|
256 | + for ($i=0; $i < sizeof($weekdays); $i++) { |
|
257 | + if (is_numeric($weekdays[$i])) { |
|
258 | + $wday = intval($weekdays[$i]); |
|
259 | + if ($wday < 1 || $wday > 7) $isValid = FALSE; |
|
260 | + } |
|
261 | + else $isValid = FALSE; |
|
262 | + } |
|
263 | 263 | |
264 | - return $isValid; |
|
265 | - } |
|
264 | + return $isValid; |
|
265 | + } |
|
266 | 266 | |
267 | - public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
268 | - { |
|
269 | - $schedMonthlyMmodes = array("dates","nth"); |
|
267 | + public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
268 | + { |
|
269 | + $schedMonthlyMmodes = array("dates","nth"); |
|
270 | 270 | |
271 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) |
|
272 | - return TRUE; |
|
273 | - else |
|
274 | - return FALSE; |
|
275 | - } |
|
271 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) |
|
272 | + return TRUE; |
|
273 | + else |
|
274 | + return FALSE; |
|
275 | + } |
|
276 | 276 | |
277 | - public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
278 | - { |
|
279 | - $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
277 | + public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
278 | + { |
|
279 | + $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
280 | 280 | |
281 | - if (sizeof($monthlyDates) <1) return FALSE; |
|
281 | + if (sizeof($monthlyDates) <1) return FALSE; |
|
282 | 282 | |
283 | - $isValid = TRUE; |
|
283 | + $isValid = TRUE; |
|
284 | 284 | |
285 | - for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
286 | - if (is_numeric($monthlyDates[$i])) { |
|
287 | - $mday = intval($monthlyDates[$i]); |
|
288 | - if ($mday <1 || $mday > 31) $isValid = FALSE; |
|
289 | - } |
|
290 | - else $isValid = FALSE; |
|
291 | - } |
|
285 | + for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
286 | + if (is_numeric($monthlyDates[$i])) { |
|
287 | + $mday = intval($monthlyDates[$i]); |
|
288 | + if ($mday <1 || $mday > 31) $isValid = FALSE; |
|
289 | + } |
|
290 | + else $isValid = FALSE; |
|
291 | + } |
|
292 | 292 | |
293 | - return $isValid; |
|
294 | - } |
|
293 | + return $isValid; |
|
294 | + } |
|
295 | 295 | |
296 | - public static function validateScheduleNthN($scheduleNthN) |
|
297 | - { |
|
298 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
296 | + public static function validateScheduleNthN($scheduleNthN) |
|
297 | + { |
|
298 | + if (!is_numeric($scheduleNthN)) return FALSE; |
|
299 | 299 | |
300 | - $schedNthNs = array(1,2,3,4,5,-1); |
|
300 | + $schedNthNs = array(1,2,3,4,5,-1); |
|
301 | 301 | |
302 | - if (in_array($scheduleNthN, $schedNthNs)) |
|
303 | - return TRUE; |
|
304 | - else |
|
305 | - return FALSE; |
|
306 | - } |
|
302 | + if (in_array($scheduleNthN, $schedNthNs)) |
|
303 | + return TRUE; |
|
304 | + else |
|
305 | + return FALSE; |
|
306 | + } |
|
307 | 307 | |
308 | - public static function validateScheduleNthWhat($scheduleNthWhat) |
|
309 | - { |
|
310 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
308 | + public static function validateScheduleNthWhat($scheduleNthWhat) |
|
309 | + { |
|
310 | + if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
311 | 311 | |
312 | - $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
312 | + $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
313 | 313 | |
314 | - if (in_array($scheduleNthWhat, $schedNthWhats)) |
|
315 | - return TRUE; |
|
316 | - else |
|
317 | - return FALSE; |
|
318 | - } |
|
314 | + if (in_array($scheduleNthWhat, $schedNthWhats)) |
|
315 | + return TRUE; |
|
316 | + else |
|
317 | + return FALSE; |
|
318 | + } |
|
319 | 319 | |
320 | - /* Function adds the locations (with/without schedule) from the CSV file. |
|
320 | + /* Function adds the locations (with/without schedule) from the CSV file. |
|
321 | 321 | * $csvFileHandle - a file handler. |
322 | 322 | * Returns array $results which contains two arrays: fail and succes. |
323 | 323 | */ |
324 | - public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
325 | - { |
|
326 | - $max_line_length = 512; |
|
327 | - $delemietr = ','; |
|
324 | + public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
325 | + { |
|
326 | + $max_line_length = 512; |
|
327 | + $delemietr = ','; |
|
328 | 328 | |
329 | - $results = array(); |
|
330 | - $results['fail'] = array(); |
|
331 | - $results['success'] = array(); |
|
329 | + $results = array(); |
|
330 | + $results['fail'] = array(); |
|
331 | + $results['success'] = array(); |
|
332 | 332 | |
333 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
333 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
334 | 334 | |
335 | - if (empty($columns)) { |
|
336 | - array_push($results['fail'],'Empty CSV table'); |
|
337 | - return ($results); |
|
338 | - } |
|
335 | + if (empty($columns)) { |
|
336 | + array_push($results['fail'],'Empty CSV table'); |
|
337 | + return ($results); |
|
338 | + } |
|
339 | 339 | |
340 | - $iRow = 1; |
|
340 | + $iRow = 1; |
|
341 | 341 | |
342 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
343 | - if ($rows[$locationsFieldsMapping['cached_lat']] |
|
344 | - && $rows[$locationsFieldsMapping['cached_lng']] |
|
345 | - && $rows[$locationsFieldsMapping['address_1']] |
|
346 | - && array(null) !== $rows) { |
|
347 | - $curSchedule = ""; |
|
348 | - $mode = ""; |
|
342 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) { |
|
343 | + if ($rows[$locationsFieldsMapping['cached_lat']] |
|
344 | + && $rows[$locationsFieldsMapping['cached_lng']] |
|
345 | + && $rows[$locationsFieldsMapping['address_1']] |
|
346 | + && array(null) !== $rows) { |
|
347 | + $curSchedule = ""; |
|
348 | + $mode = ""; |
|
349 | 349 | |
350 | - if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
351 | - if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
352 | - $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
353 | - $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
354 | - } else { |
|
355 | - array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); |
|
356 | - $curSchedule = ""; |
|
357 | - } |
|
358 | - } else { |
|
359 | - array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); |
|
360 | - $curSchedule = ""; |
|
361 | - } |
|
350 | + if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
351 | + if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
352 | + $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
353 | + $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
354 | + } else { |
|
355 | + array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); |
|
356 | + $curSchedule = ""; |
|
357 | + } |
|
358 | + } else { |
|
359 | + array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); |
|
360 | + $curSchedule = ""; |
|
361 | + } |
|
362 | 362 | |
363 | - if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
364 | - if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
365 | - $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
366 | - } else { |
|
367 | - array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); |
|
368 | - $curSchedule = ""; |
|
369 | - } |
|
370 | - } |
|
363 | + if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
364 | + if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
365 | + $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
366 | + } else { |
|
367 | + array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set "); |
|
368 | + $curSchedule = ""; |
|
369 | + } |
|
370 | + } |
|
371 | 371 | |
372 | - if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
373 | - if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
374 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
375 | - if ($mode == 'daily') { |
|
376 | - $curSchedule = trim($curSchedule,','); |
|
377 | - $curSchedule.='}'; |
|
378 | - } |
|
379 | - } else { |
|
380 | - array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); |
|
381 | - $curSchedule = ""; |
|
382 | - } |
|
383 | - } |
|
372 | + if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
373 | + if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
374 | + $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
375 | + if ($mode == 'daily') { |
|
376 | + $curSchedule = trim($curSchedule,','); |
|
377 | + $curSchedule.='}'; |
|
378 | + } |
|
379 | + } else { |
|
380 | + array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); |
|
381 | + $curSchedule = ""; |
|
382 | + } |
|
383 | + } |
|
384 | 384 | |
385 | - if ($mode!='daily') { |
|
386 | - switch ($mode) { |
|
387 | - case 'weekly': |
|
388 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
389 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
390 | - $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
391 | - } else { |
|
392 | - array_push($results['fail'],"$iRow --> Wrong weekdays"); |
|
393 | - $curSchedule = ""; |
|
394 | - } |
|
395 | - } else { |
|
396 | - array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); |
|
397 | - $curSchedule = ""; |
|
398 | - } |
|
399 | - break; |
|
400 | - case 'monthly': |
|
401 | - $monthlyMode = ""; |
|
402 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
403 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
404 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
405 | - $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
406 | - } else { |
|
407 | - array_push($results['fail'],"$iRow --> Wrong monthly mode"); |
|
408 | - $curSchedule = ""; |
|
409 | - } |
|
410 | - } else { |
|
411 | - array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); |
|
412 | - $curSchedule = ""; |
|
413 | - } |
|
385 | + if ($mode!='daily') { |
|
386 | + switch ($mode) { |
|
387 | + case 'weekly': |
|
388 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
389 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
390 | + $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
391 | + } else { |
|
392 | + array_push($results['fail'],"$iRow --> Wrong weekdays"); |
|
393 | + $curSchedule = ""; |
|
394 | + } |
|
395 | + } else { |
|
396 | + array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); |
|
397 | + $curSchedule = ""; |
|
398 | + } |
|
399 | + break; |
|
400 | + case 'monthly': |
|
401 | + $monthlyMode = ""; |
|
402 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
403 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
404 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
405 | + $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
406 | + } else { |
|
407 | + array_push($results['fail'],"$iRow --> Wrong monthly mode"); |
|
408 | + $curSchedule = ""; |
|
409 | + } |
|
410 | + } else { |
|
411 | + array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); |
|
412 | + $curSchedule = ""; |
|
413 | + } |
|
414 | 414 | |
415 | - if ($monthlyMode != "") { |
|
416 | - switch ($monthlyMode) { |
|
417 | - case 'dates': |
|
418 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
419 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
420 | - $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
421 | - } else { |
|
422 | - array_push($results['fail'],"$iRow --> Wrong monthly dates"); |
|
423 | - $curSchedule = ""; |
|
424 | - } |
|
425 | - } |
|
426 | - break; |
|
427 | - case 'nth': |
|
428 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
429 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
430 | - $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
431 | - } else { |
|
432 | - array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); |
|
433 | - $curSchedule = ""; |
|
434 | - } |
|
435 | - } else { |
|
436 | - array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); |
|
437 | - $curSchedule = ""; |
|
438 | - } |
|
415 | + if ($monthlyMode != "") { |
|
416 | + switch ($monthlyMode) { |
|
417 | + case 'dates': |
|
418 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
419 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
420 | + $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
421 | + } else { |
|
422 | + array_push($results['fail'],"$iRow --> Wrong monthly dates"); |
|
423 | + $curSchedule = ""; |
|
424 | + } |
|
425 | + } |
|
426 | + break; |
|
427 | + case 'nth': |
|
428 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
429 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
430 | + $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
431 | + } else { |
|
432 | + array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); |
|
433 | + $curSchedule = ""; |
|
434 | + } |
|
435 | + } else { |
|
436 | + array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); |
|
437 | + $curSchedule = ""; |
|
438 | + } |
|
439 | 439 | |
440 | - if ($curSchedule != "") { |
|
441 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
442 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
443 | - $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
444 | - } else { |
|
445 | - array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); |
|
446 | - $curSchedule = ""; |
|
447 | - } |
|
448 | - } else { |
|
449 | - array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); |
|
450 | - $curSchedule = ""; |
|
451 | - } |
|
452 | - } |
|
453 | - break; |
|
454 | - } |
|
455 | - } |
|
456 | - break; |
|
457 | - default: |
|
458 | - $curSchedule = ""; |
|
459 | - break; |
|
460 | - } |
|
461 | - } |
|
440 | + if ($curSchedule != "") { |
|
441 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
442 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
443 | + $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
444 | + } else { |
|
445 | + array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); |
|
446 | + $curSchedule = ""; |
|
447 | + } |
|
448 | + } else { |
|
449 | + array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); |
|
450 | + $curSchedule = ""; |
|
451 | + } |
|
452 | + } |
|
453 | + break; |
|
454 | + } |
|
455 | + } |
|
456 | + break; |
|
457 | + default: |
|
458 | + $curSchedule = ""; |
|
459 | + break; |
|
460 | + } |
|
461 | + } |
|
462 | 462 | |
463 | - if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") { |
|
464 | - $iRow++; |
|
465 | - continue; |
|
466 | - } |
|
463 | + if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") { |
|
464 | + $iRow++; |
|
465 | + continue; |
|
466 | + } |
|
467 | 467 | |
468 | - $curSchedule =strtolower($curSchedule); |
|
468 | + $curSchedule =strtolower($curSchedule); |
|
469 | 469 | |
470 | - $curSchedule = '[{'.$curSchedule.'}]'; |
|
470 | + $curSchedule = '[{'.$curSchedule.'}]'; |
|
471 | 471 | |
472 | - $oSchedule = json_decode($curSchedule,TRUE); |
|
472 | + $oSchedule = json_decode($curSchedule,TRUE); |
|
473 | 473 | |
474 | - $AdressBookLocationParameters = AddressBookLocation::fromArray(array( |
|
475 | - "cached_lat" => $rows[$locationsFieldsMapping['cached_lat']], |
|
476 | - "cached_lng" => $rows[$locationsFieldsMapping['cached_lng']], |
|
477 | - "curbside_lat" => isset($locationsFieldsMapping['curbside_lat']) |
|
478 | - ? $rows[$locationsFieldsMapping['curbside_lat']] : null, |
|
479 | - "curbside_lng" => isset($locationsFieldsMapping['curbside_lng']) |
|
480 | - ? $rows[$locationsFieldsMapping['curbside_lng']] : null, |
|
481 | - "address_alias" => isset($locationsFieldsMapping['address_alias']) |
|
482 | - ? $rows[$locationsFieldsMapping['address_alias']] : null, |
|
483 | - "address_1" => $rows[$locationsFieldsMapping['address_1']], |
|
484 | - "address_2" => isset($locationsFieldsMapping['address_2']) |
|
485 | - ? $rows[$locationsFieldsMapping['address_2']] : null, |
|
486 | - "address_city" => isset($locationsFieldsMapping['address_city']) |
|
487 | - ? $rows[$locationsFieldsMapping['address_city']] : null, |
|
488 | - "address_state_id" => isset($locationsFieldsMapping['address_state_id']) |
|
489 | - ? $rows[$locationsFieldsMapping['address_state_id']] : null, |
|
490 | - "address_zip" => isset($locationsFieldsMapping['address_zip']) |
|
491 | - ? $rows[$locationsFieldsMapping['address_zip']] : null, |
|
492 | - "address_phone_number" => isset($locationsFieldsMapping['address_phone_number']) |
|
493 | - ? $rows[$locationsFieldsMapping['address_phone_number']] : null, |
|
494 | - "schedule" => isset($oSchedule) ? $oSchedule : null, |
|
495 | - "address_group" => isset($locationsFieldsMapping['address_group']) |
|
496 | - ? $rows[$locationsFieldsMapping['address_group']] : null, |
|
497 | - "first_name" => isset($locationsFieldsMapping['first_name']) |
|
498 | - ? $rows[$locationsFieldsMapping['first_name']] : null, |
|
499 | - "last_name" => isset($locationsFieldsMapping['last_name']) |
|
500 | - ? $rows[$locationsFieldsMapping['last_name']] : null, |
|
501 | - "local_time_window_start" => isset($locationsFieldsMapping['local_time_window_start']) |
|
502 | - ? $rows[$locationsFieldsMapping['local_time_window_start']] : null, |
|
503 | - "local_time_window_end" => isset($locationsFieldsMapping['local_time_window_end']) |
|
504 | - ? $rows[$locationsFieldsMapping['local_time_window_end']] : null, |
|
505 | - "local_time_window_start_2" => isset($locationsFieldsMapping['local_time_window_start_2']) |
|
506 | - ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null, |
|
507 | - "local_time_window_end_2" => isset($locationsFieldsMapping['local_time_window_end_2']) |
|
508 | - ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null, |
|
509 | - "address_email" => isset($locationsFieldsMapping['address_email']) |
|
510 | - ? $rows[$locationsFieldsMapping['address_email']] : null, |
|
511 | - "address_country_id" => isset($locationsFieldsMapping['address_country_id']) |
|
512 | - ? $rows[$locationsFieldsMapping['address_country_id']] : null, |
|
513 | - "address_custom_data" => isset($locationsFieldsMapping['address_custom_data']) |
|
514 | - ? $rows[$locationsFieldsMapping['address_custom_data']] : null, |
|
515 | - "schedule_blacklist" => isset($locationsFieldsMapping['schedule_blacklist']) |
|
516 | - ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null, |
|
517 | - "service_time" => isset($locationsFieldsMapping['service_time']) |
|
518 | - ? $rows[$locationsFieldsMapping['service_time']] : null, |
|
519 | - "local_timezone_string" => isset($locationsFieldsMapping['local_timezone_string']) |
|
520 | - ? $rows[$locationsFieldsMapping['local_timezone_string']] : null, |
|
521 | - "color" => isset($locationsFieldsMapping['color']) |
|
522 | - ? $rows[$locationsFieldsMapping['color']] : null, |
|
523 | - "address_icon" => isset($locationsFieldsMapping['address_icon']) |
|
524 | - ? $rows[$locationsFieldsMapping['address_icon']] : null, |
|
525 | - "address_stop_type" => isset($locationsFieldsMapping['address_stop_type']) |
|
526 | - ? $rows[$locationsFieldsMapping['address_stop_type']] : null, |
|
527 | - "address_cube" => isset($locationsFieldsMapping['address_cube']) |
|
528 | - ? $rows[$locationsFieldsMapping['address_cube']] : null, |
|
529 | - "address_pieces" => isset($locationsFieldsMapping['address_pieces']) |
|
530 | - ? $rows[$locationsFieldsMapping['address_pieces']] : null, |
|
531 | - "address_reference_no" => isset($locationsFieldsMapping['address_reference_no']) |
|
532 | - ? $rows[$locationsFieldsMapping['address_reference_no']] : null, |
|
533 | - "address_revenue" => isset($locationsFieldsMapping['address_revenue']) |
|
534 | - ? $rows[$locationsFieldsMapping['address_revenue']] : null, |
|
535 | - "address_weight" => isset($locationsFieldsMapping['address_weight']) |
|
536 | - ? $rows[$locationsFieldsMapping['address_weight']] : null, |
|
537 | - "address_priority" => isset($locationsFieldsMapping['address_priority']) |
|
538 | - ? $rows[$locationsFieldsMapping['address_priority']] : null, |
|
539 | - "address_customer_po" => isset($locationsFieldsMapping['address_customer_po']) |
|
540 | - ? $rows[$locationsFieldsMapping['address_customer_po']] : null, |
|
541 | - )); |
|
474 | + $AdressBookLocationParameters = AddressBookLocation::fromArray(array( |
|
475 | + "cached_lat" => $rows[$locationsFieldsMapping['cached_lat']], |
|
476 | + "cached_lng" => $rows[$locationsFieldsMapping['cached_lng']], |
|
477 | + "curbside_lat" => isset($locationsFieldsMapping['curbside_lat']) |
|
478 | + ? $rows[$locationsFieldsMapping['curbside_lat']] : null, |
|
479 | + "curbside_lng" => isset($locationsFieldsMapping['curbside_lng']) |
|
480 | + ? $rows[$locationsFieldsMapping['curbside_lng']] : null, |
|
481 | + "address_alias" => isset($locationsFieldsMapping['address_alias']) |
|
482 | + ? $rows[$locationsFieldsMapping['address_alias']] : null, |
|
483 | + "address_1" => $rows[$locationsFieldsMapping['address_1']], |
|
484 | + "address_2" => isset($locationsFieldsMapping['address_2']) |
|
485 | + ? $rows[$locationsFieldsMapping['address_2']] : null, |
|
486 | + "address_city" => isset($locationsFieldsMapping['address_city']) |
|
487 | + ? $rows[$locationsFieldsMapping['address_city']] : null, |
|
488 | + "address_state_id" => isset($locationsFieldsMapping['address_state_id']) |
|
489 | + ? $rows[$locationsFieldsMapping['address_state_id']] : null, |
|
490 | + "address_zip" => isset($locationsFieldsMapping['address_zip']) |
|
491 | + ? $rows[$locationsFieldsMapping['address_zip']] : null, |
|
492 | + "address_phone_number" => isset($locationsFieldsMapping['address_phone_number']) |
|
493 | + ? $rows[$locationsFieldsMapping['address_phone_number']] : null, |
|
494 | + "schedule" => isset($oSchedule) ? $oSchedule : null, |
|
495 | + "address_group" => isset($locationsFieldsMapping['address_group']) |
|
496 | + ? $rows[$locationsFieldsMapping['address_group']] : null, |
|
497 | + "first_name" => isset($locationsFieldsMapping['first_name']) |
|
498 | + ? $rows[$locationsFieldsMapping['first_name']] : null, |
|
499 | + "last_name" => isset($locationsFieldsMapping['last_name']) |
|
500 | + ? $rows[$locationsFieldsMapping['last_name']] : null, |
|
501 | + "local_time_window_start" => isset($locationsFieldsMapping['local_time_window_start']) |
|
502 | + ? $rows[$locationsFieldsMapping['local_time_window_start']] : null, |
|
503 | + "local_time_window_end" => isset($locationsFieldsMapping['local_time_window_end']) |
|
504 | + ? $rows[$locationsFieldsMapping['local_time_window_end']] : null, |
|
505 | + "local_time_window_start_2" => isset($locationsFieldsMapping['local_time_window_start_2']) |
|
506 | + ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null, |
|
507 | + "local_time_window_end_2" => isset($locationsFieldsMapping['local_time_window_end_2']) |
|
508 | + ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null, |
|
509 | + "address_email" => isset($locationsFieldsMapping['address_email']) |
|
510 | + ? $rows[$locationsFieldsMapping['address_email']] : null, |
|
511 | + "address_country_id" => isset($locationsFieldsMapping['address_country_id']) |
|
512 | + ? $rows[$locationsFieldsMapping['address_country_id']] : null, |
|
513 | + "address_custom_data" => isset($locationsFieldsMapping['address_custom_data']) |
|
514 | + ? $rows[$locationsFieldsMapping['address_custom_data']] : null, |
|
515 | + "schedule_blacklist" => isset($locationsFieldsMapping['schedule_blacklist']) |
|
516 | + ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null, |
|
517 | + "service_time" => isset($locationsFieldsMapping['service_time']) |
|
518 | + ? $rows[$locationsFieldsMapping['service_time']] : null, |
|
519 | + "local_timezone_string" => isset($locationsFieldsMapping['local_timezone_string']) |
|
520 | + ? $rows[$locationsFieldsMapping['local_timezone_string']] : null, |
|
521 | + "color" => isset($locationsFieldsMapping['color']) |
|
522 | + ? $rows[$locationsFieldsMapping['color']] : null, |
|
523 | + "address_icon" => isset($locationsFieldsMapping['address_icon']) |
|
524 | + ? $rows[$locationsFieldsMapping['address_icon']] : null, |
|
525 | + "address_stop_type" => isset($locationsFieldsMapping['address_stop_type']) |
|
526 | + ? $rows[$locationsFieldsMapping['address_stop_type']] : null, |
|
527 | + "address_cube" => isset($locationsFieldsMapping['address_cube']) |
|
528 | + ? $rows[$locationsFieldsMapping['address_cube']] : null, |
|
529 | + "address_pieces" => isset($locationsFieldsMapping['address_pieces']) |
|
530 | + ? $rows[$locationsFieldsMapping['address_pieces']] : null, |
|
531 | + "address_reference_no" => isset($locationsFieldsMapping['address_reference_no']) |
|
532 | + ? $rows[$locationsFieldsMapping['address_reference_no']] : null, |
|
533 | + "address_revenue" => isset($locationsFieldsMapping['address_revenue']) |
|
534 | + ? $rows[$locationsFieldsMapping['address_revenue']] : null, |
|
535 | + "address_weight" => isset($locationsFieldsMapping['address_weight']) |
|
536 | + ? $rows[$locationsFieldsMapping['address_weight']] : null, |
|
537 | + "address_priority" => isset($locationsFieldsMapping['address_priority']) |
|
538 | + ? $rows[$locationsFieldsMapping['address_priority']] : null, |
|
539 | + "address_customer_po" => isset($locationsFieldsMapping['address_customer_po']) |
|
540 | + ? $rows[$locationsFieldsMapping['address_customer_po']] : null, |
|
541 | + )); |
|
542 | 542 | |
543 | - $abContacts = new AddressBookLocation(); |
|
543 | + $abContacts = new AddressBookLocation(); |
|
544 | 544 | |
545 | - $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
545 | + $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
546 | 546 | |
547 | - array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
548 | - } |
|
549 | - } |
|
547 | + array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
548 | + } |
|
549 | + } |
|
550 | 550 | |
551 | - return $results; |
|
552 | - } |
|
551 | + return $results; |
|
552 | + } |
|
553 | 553 | } |
554 | - |
|
555 | 554 | \ No newline at end of file |
555 | + |
|
556 | 556 | \ No newline at end of file |