@@ -6,185 +6,185 @@ discard block |
||
6 | 6 | |
7 | 7 | class OptimizationProblem extends Common |
8 | 8 | { |
9 | - /** |
|
10 | - * Optimization problem ID |
|
11 | - * @var string |
|
12 | - */ |
|
13 | - public $optimization_problem_id; |
|
14 | - |
|
15 | - /** |
|
16 | - * Smart Optimization Problem ID |
|
17 | - * @var string |
|
18 | - */ |
|
19 | - public $smart_optimization_id; |
|
20 | - |
|
21 | - /** |
|
22 | - * An array of the user errors. |
|
23 | - * @var string[] |
|
24 | - */ |
|
25 | - public $user_errors = []; |
|
26 | - |
|
27 | - /** |
|
28 | - * An optimization problem state.<br> |
|
29 | - * Available values: |
|
30 | - * - OptimizationStateNew = 0, |
|
31 | - * - Initial = 1, |
|
32 | - * - MatrixProcessing = 2, |
|
33 | - * - Optimizing = 3, |
|
34 | - * - Optimized = 4, |
|
35 | - * - Error = 5, |
|
36 | - * - ComputingDirections = 6, |
|
37 | - * - OptimizationStateInQueue = 7 |
|
38 | - * @var int |
|
39 | - */ |
|
40 | - public $state; |
|
41 | - |
|
42 | - /** |
|
43 | - * An array of the optimization errors. |
|
44 | - * @var string[] |
|
45 | - */ |
|
46 | - public $optimization_errors = []; |
|
47 | - |
|
48 | - /** |
|
49 | - * Route Parameters. |
|
50 | - * @var RouteParameters |
|
51 | - */ |
|
52 | - public $parameters; |
|
53 | - |
|
54 | - /** |
|
55 | - * If true it means the solution was not returned (it is being computed in the background). |
|
56 | - * @var boolean |
|
57 | - */ |
|
58 | - public $sent_to_background; |
|
59 | - |
|
60 | - /** |
|
61 | - * When the optimization problem was created. |
|
62 | - * @var long |
|
63 | - */ |
|
64 | - public $created_timestamp; |
|
65 | - |
|
66 | - /** |
|
67 | - * An Unix Timestamp the Optimization Problem was scheduled for. |
|
68 | - * @var long |
|
69 | - */ |
|
70 | - public $scheduled_for; |
|
71 | - |
|
72 | - /** |
|
73 | - * When the optimization completed. |
|
74 | - * @var long |
|
75 | - */ |
|
76 | - public $optimization_completed_timestamp; |
|
77 | - |
|
78 | - /** |
|
79 | - * An array ot the Address type objects. |
|
80 | - * @var Address[] |
|
81 | - */ |
|
82 | - public $addresses = []; |
|
83 | - |
|
84 | - /** |
|
85 | - * An array ot the DataObjectRoute type objects.<br> |
|
86 | - * The routes included in the optimization problem. |
|
87 | - * @var Route[] |
|
88 | - */ |
|
89 | - public $routes = []; |
|
90 | - |
|
91 | - /** @var string[] $links |
|
92 | - * The links to the GET operations for the optimization problem. |
|
93 | - */ |
|
94 | - public $links = []; |
|
95 | - |
|
96 | - public function __construct() |
|
97 | - { |
|
98 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
99 | - $this->parameters = new RouteParameters(); |
|
100 | - } |
|
101 | - |
|
102 | - public static function fromArray(array $params) |
|
103 | - { |
|
104 | - $problem = new self(); |
|
105 | - $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
106 | - $problem->user_errors = Common::getValue($params, 'user_errors', []); |
|
107 | - $problem->state = Common::getValue($params, 'state', []); |
|
108 | - $problem->sent_to_background = Common::getValue($params, 'sent_to_background', []); |
|
109 | - $problem->links = Common::getValue($params, 'links', []); |
|
110 | - |
|
111 | - if (isset($params['parameters'])) { |
|
112 | - $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
113 | - } |
|
114 | - |
|
115 | - if (isset($params['addresses'])) { |
|
116 | - $addresses = []; |
|
117 | - |
|
118 | - foreach ($params['addresses'] as $address) { |
|
119 | - $addresses[] = Address::fromArray($address); |
|
120 | - } |
|
121 | - |
|
122 | - $problem->addresses = $addresses; |
|
123 | - } |
|
124 | - |
|
125 | - if (isset($params['routes'])) { |
|
126 | - $routes = []; |
|
127 | - |
|
128 | - foreach ($params['routes'] as $route) { |
|
129 | - $routes[] = Route::fromArray($route); |
|
130 | - } |
|
131 | - |
|
132 | - $problem->routes = $routes; |
|
133 | - } |
|
134 | - |
|
135 | - return $problem; |
|
136 | - } |
|
137 | - |
|
138 | - public static function optimize(OptimizationProblemParams $params) |
|
139 | - { |
|
140 | - $allQueryFields = ['redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url']; |
|
141 | - |
|
142 | - $optimize = Route4Me::makeRequst([ |
|
143 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
144 | - 'method' => 'POST', |
|
145 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
146 | - 'body' => [ |
|
147 | - 'addresses' => $params->getAddressesArray(), |
|
148 | - 'depots' => $params->getDepotsArray(), |
|
149 | - 'parameters' => $params->getParametersArray(), |
|
150 | - ], |
|
151 | - ]); |
|
152 | - |
|
153 | - return self::fromArray($optimize); |
|
154 | - } |
|
155 | - |
|
156 | - public static function get($params) |
|
157 | - { |
|
158 | - $allQueryFields = ['state', 'limit', 'format', 'offset', |
|
159 | - 'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ]; |
|
160 | - |
|
161 | - $result = Route4Me::makeRequst([ |
|
162 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
163 | - 'method' => 'GET', |
|
164 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
165 | - ]); |
|
166 | - |
|
167 | - if (isset($result['optimizations'])) { |
|
168 | - $problems = []; |
|
169 | - |
|
170 | - foreach ($result['optimizations'] as $problem) { |
|
171 | - $problems[] = self::fromArray($problem); |
|
172 | - } |
|
173 | - |
|
174 | - return $problems; |
|
175 | - } else { |
|
176 | - return self::fromArray($result); |
|
177 | - } |
|
178 | - } |
|
179 | - |
|
180 | - public function reoptimize($params) |
|
181 | - { |
|
182 | - $param['reoptimize'] = 1; |
|
183 | - |
|
184 | - return self::update($params); |
|
185 | - } |
|
186 | - |
|
187 | - /* |
|
9 | + /** |
|
10 | + * Optimization problem ID |
|
11 | + * @var string |
|
12 | + */ |
|
13 | + public $optimization_problem_id; |
|
14 | + |
|
15 | + /** |
|
16 | + * Smart Optimization Problem ID |
|
17 | + * @var string |
|
18 | + */ |
|
19 | + public $smart_optimization_id; |
|
20 | + |
|
21 | + /** |
|
22 | + * An array of the user errors. |
|
23 | + * @var string[] |
|
24 | + */ |
|
25 | + public $user_errors = []; |
|
26 | + |
|
27 | + /** |
|
28 | + * An optimization problem state.<br> |
|
29 | + * Available values: |
|
30 | + * - OptimizationStateNew = 0, |
|
31 | + * - Initial = 1, |
|
32 | + * - MatrixProcessing = 2, |
|
33 | + * - Optimizing = 3, |
|
34 | + * - Optimized = 4, |
|
35 | + * - Error = 5, |
|
36 | + * - ComputingDirections = 6, |
|
37 | + * - OptimizationStateInQueue = 7 |
|
38 | + * @var int |
|
39 | + */ |
|
40 | + public $state; |
|
41 | + |
|
42 | + /** |
|
43 | + * An array of the optimization errors. |
|
44 | + * @var string[] |
|
45 | + */ |
|
46 | + public $optimization_errors = []; |
|
47 | + |
|
48 | + /** |
|
49 | + * Route Parameters. |
|
50 | + * @var RouteParameters |
|
51 | + */ |
|
52 | + public $parameters; |
|
53 | + |
|
54 | + /** |
|
55 | + * If true it means the solution was not returned (it is being computed in the background). |
|
56 | + * @var boolean |
|
57 | + */ |
|
58 | + public $sent_to_background; |
|
59 | + |
|
60 | + /** |
|
61 | + * When the optimization problem was created. |
|
62 | + * @var long |
|
63 | + */ |
|
64 | + public $created_timestamp; |
|
65 | + |
|
66 | + /** |
|
67 | + * An Unix Timestamp the Optimization Problem was scheduled for. |
|
68 | + * @var long |
|
69 | + */ |
|
70 | + public $scheduled_for; |
|
71 | + |
|
72 | + /** |
|
73 | + * When the optimization completed. |
|
74 | + * @var long |
|
75 | + */ |
|
76 | + public $optimization_completed_timestamp; |
|
77 | + |
|
78 | + /** |
|
79 | + * An array ot the Address type objects. |
|
80 | + * @var Address[] |
|
81 | + */ |
|
82 | + public $addresses = []; |
|
83 | + |
|
84 | + /** |
|
85 | + * An array ot the DataObjectRoute type objects.<br> |
|
86 | + * The routes included in the optimization problem. |
|
87 | + * @var Route[] |
|
88 | + */ |
|
89 | + public $routes = []; |
|
90 | + |
|
91 | + /** @var string[] $links |
|
92 | + * The links to the GET operations for the optimization problem. |
|
93 | + */ |
|
94 | + public $links = []; |
|
95 | + |
|
96 | + public function __construct() |
|
97 | + { |
|
98 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
99 | + $this->parameters = new RouteParameters(); |
|
100 | + } |
|
101 | + |
|
102 | + public static function fromArray(array $params) |
|
103 | + { |
|
104 | + $problem = new self(); |
|
105 | + $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
106 | + $problem->user_errors = Common::getValue($params, 'user_errors', []); |
|
107 | + $problem->state = Common::getValue($params, 'state', []); |
|
108 | + $problem->sent_to_background = Common::getValue($params, 'sent_to_background', []); |
|
109 | + $problem->links = Common::getValue($params, 'links', []); |
|
110 | + |
|
111 | + if (isset($params['parameters'])) { |
|
112 | + $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
113 | + } |
|
114 | + |
|
115 | + if (isset($params['addresses'])) { |
|
116 | + $addresses = []; |
|
117 | + |
|
118 | + foreach ($params['addresses'] as $address) { |
|
119 | + $addresses[] = Address::fromArray($address); |
|
120 | + } |
|
121 | + |
|
122 | + $problem->addresses = $addresses; |
|
123 | + } |
|
124 | + |
|
125 | + if (isset($params['routes'])) { |
|
126 | + $routes = []; |
|
127 | + |
|
128 | + foreach ($params['routes'] as $route) { |
|
129 | + $routes[] = Route::fromArray($route); |
|
130 | + } |
|
131 | + |
|
132 | + $problem->routes = $routes; |
|
133 | + } |
|
134 | + |
|
135 | + return $problem; |
|
136 | + } |
|
137 | + |
|
138 | + public static function optimize(OptimizationProblemParams $params) |
|
139 | + { |
|
140 | + $allQueryFields = ['redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url']; |
|
141 | + |
|
142 | + $optimize = Route4Me::makeRequst([ |
|
143 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
144 | + 'method' => 'POST', |
|
145 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
146 | + 'body' => [ |
|
147 | + 'addresses' => $params->getAddressesArray(), |
|
148 | + 'depots' => $params->getDepotsArray(), |
|
149 | + 'parameters' => $params->getParametersArray(), |
|
150 | + ], |
|
151 | + ]); |
|
152 | + |
|
153 | + return self::fromArray($optimize); |
|
154 | + } |
|
155 | + |
|
156 | + public static function get($params) |
|
157 | + { |
|
158 | + $allQueryFields = ['state', 'limit', 'format', 'offset', |
|
159 | + 'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ]; |
|
160 | + |
|
161 | + $result = Route4Me::makeRequst([ |
|
162 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
163 | + 'method' => 'GET', |
|
164 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
165 | + ]); |
|
166 | + |
|
167 | + if (isset($result['optimizations'])) { |
|
168 | + $problems = []; |
|
169 | + |
|
170 | + foreach ($result['optimizations'] as $problem) { |
|
171 | + $problems[] = self::fromArray($problem); |
|
172 | + } |
|
173 | + |
|
174 | + return $problems; |
|
175 | + } else { |
|
176 | + return self::fromArray($result); |
|
177 | + } |
|
178 | + } |
|
179 | + |
|
180 | + public function reoptimize($params) |
|
181 | + { |
|
182 | + $param['reoptimize'] = 1; |
|
183 | + |
|
184 | + return self::update($params); |
|
185 | + } |
|
186 | + |
|
187 | + /* |
|
188 | 188 | * Updates an existing optimization problem.<br> |
189 | 189 | * @param array $params with items: |
190 | 190 | * - optimization_problem_id : query parameter. ID of an updated optimization; |
@@ -193,151 +193,151 @@ discard block |
||
193 | 193 | * - parameters : body parameter. Modified route parameters; |
194 | 194 | * @return Optimization problem |
195 | 195 | */ |
196 | - public static function update($params) |
|
197 | - { |
|
198 | - $allQueryFields = ['optimization_problem_id', 'reoptimize']; |
|
199 | - $allBodyFields = ['addresses', 'parameters']; |
|
200 | - |
|
201 | - $query = is_array($params) |
|
202 | - ? (isset($params['optimization_problem_id']) || isset($params['parameters'])) |
|
203 | - ? Route4Me::generateRequestParameters($allQueryFields, $params) |
|
204 | - : null |
|
205 | - : (isset($params->optimization_problem_id) || isset($params->parameters)) |
|
206 | - ? Route4Me::generateRequestParameters($allQueryFields, $params) |
|
207 | - : null; |
|
208 | - |
|
209 | - $body = is_array($params) |
|
210 | - ? (isset($params['addresses']) && sizeof($params['addresses'])>0) || |
|
211 | - (isset($params['parameters']) && sizeof($params['parameters'])>0) |
|
212 | - ? Route4Me::generateRequestParameters($allBodyFields, $params) |
|
213 | - : null |
|
214 | - : (isset($params->addresses) && sizeof($params->addresses)>0) || |
|
215 | - (isset($params->parameters) && sizeof($params->parameters)>0) |
|
216 | - ? Route4Me::generateRequestParameters($allBodyFields, $params) |
|
217 | - : null; |
|
218 | - |
|
219 | - $optimize = Route4Me::makeRequst([ |
|
220 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
221 | - 'method' => 'PUT', |
|
222 | - 'query' => $query, |
|
223 | - 'body' => $body, |
|
224 | - ]); |
|
225 | - |
|
226 | - return $optimize; |
|
227 | - } |
|
228 | - |
|
229 | - public function getOptimizationId() |
|
230 | - { |
|
231 | - return $this->optimization_problem_id; |
|
232 | - } |
|
233 | - |
|
234 | - public function getRoutes() |
|
235 | - { |
|
236 | - return $this->routes; |
|
237 | - } |
|
238 | - |
|
239 | - public function getRandomOptimizationId($offset, $limit) |
|
240 | - { |
|
241 | - $optimizations = self::get(['offset' => $offset, 'limit' => $limit]); |
|
242 | - |
|
243 | - $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
244 | - |
|
245 | - if (!isset($rOptimization->optimization_problem_id)) { |
|
246 | - if (sizeof($optimizations) > 9) { |
|
247 | - $this->getRandomOptimizationId($offset, $limit); |
|
248 | - } else { |
|
249 | - return null; |
|
250 | - } |
|
251 | - } |
|
252 | - |
|
253 | - return $rOptimization->optimization_problem_id; |
|
254 | - } |
|
255 | - |
|
256 | - public function getAddresses($opt_id) |
|
257 | - { |
|
258 | - if (null == $opt_id) { |
|
259 | - return null; |
|
260 | - } |
|
261 | - |
|
262 | - $params = ['optimization_problem_id' => $opt_id]; |
|
263 | - |
|
264 | - $optimization = (array) $this->get($params); |
|
265 | - |
|
266 | - $addresses = $optimization['addresses']; |
|
267 | - |
|
268 | - return $addresses; |
|
269 | - } |
|
270 | - |
|
271 | - public function getRandomAddressFromOptimization($opt_id) |
|
272 | - { |
|
273 | - $addresses = (array) $this->getAddresses($opt_id); |
|
274 | - |
|
275 | - if (null == $addresses) { |
|
276 | - echo 'There are no addresses in this optimization!.. Try again.'; |
|
277 | - |
|
278 | - return null; |
|
279 | - } |
|
280 | - |
|
281 | - $num = rand(0, sizeof($addresses) - 1); |
|
282 | - |
|
283 | - $rAddress = $addresses[$num]; |
|
284 | - |
|
285 | - return $rAddress; |
|
286 | - } |
|
287 | - |
|
288 | - public function removeAddress($params) |
|
289 | - { |
|
290 | - $allQueryFields = ['optimization_problem_id', 'route_destination_id']; |
|
291 | - |
|
292 | - $response = Route4Me::makeRequst([ |
|
293 | - 'url' => Endpoint::ADDRESS_V4, |
|
294 | - 'method' => 'DELETE', |
|
295 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
296 | - ]); |
|
297 | - |
|
298 | - return $response; |
|
299 | - } |
|
300 | - |
|
301 | - public function removeOptimization($params) |
|
302 | - { |
|
303 | - $allQueryFields = ['redirect']; |
|
304 | - $allBodyFields = ['optimization_problem_ids']; |
|
305 | - |
|
306 | - $response = Route4Me::makeRequst([ |
|
307 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
308 | - 'method' => 'DELETE', |
|
309 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
310 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
311 | - ]); |
|
312 | - |
|
313 | - return $response; |
|
314 | - } |
|
315 | - |
|
316 | - public function getHybridOptimization($params) |
|
317 | - { |
|
318 | - $allQueryFields = ['target_date_string', 'timezone_offset_minutes']; |
|
319 | - |
|
320 | - $optimize = Route4Me::makeRequst([ |
|
321 | - 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
322 | - 'method' => 'GET', |
|
323 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
324 | - ]); |
|
196 | + public static function update($params) |
|
197 | + { |
|
198 | + $allQueryFields = ['optimization_problem_id', 'reoptimize']; |
|
199 | + $allBodyFields = ['addresses', 'parameters']; |
|
200 | + |
|
201 | + $query = is_array($params) |
|
202 | + ? (isset($params['optimization_problem_id']) || isset($params['parameters'])) |
|
203 | + ? Route4Me::generateRequestParameters($allQueryFields, $params) |
|
204 | + : null |
|
205 | + : (isset($params->optimization_problem_id) || isset($params->parameters)) |
|
206 | + ? Route4Me::generateRequestParameters($allQueryFields, $params) |
|
207 | + : null; |
|
208 | + |
|
209 | + $body = is_array($params) |
|
210 | + ? (isset($params['addresses']) && sizeof($params['addresses'])>0) || |
|
211 | + (isset($params['parameters']) && sizeof($params['parameters'])>0) |
|
212 | + ? Route4Me::generateRequestParameters($allBodyFields, $params) |
|
213 | + : null |
|
214 | + : (isset($params->addresses) && sizeof($params->addresses)>0) || |
|
215 | + (isset($params->parameters) && sizeof($params->parameters)>0) |
|
216 | + ? Route4Me::generateRequestParameters($allBodyFields, $params) |
|
217 | + : null; |
|
218 | + |
|
219 | + $optimize = Route4Me::makeRequst([ |
|
220 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
221 | + 'method' => 'PUT', |
|
222 | + 'query' => $query, |
|
223 | + 'body' => $body, |
|
224 | + ]); |
|
225 | + |
|
226 | + return $optimize; |
|
227 | + } |
|
228 | + |
|
229 | + public function getOptimizationId() |
|
230 | + { |
|
231 | + return $this->optimization_problem_id; |
|
232 | + } |
|
233 | + |
|
234 | + public function getRoutes() |
|
235 | + { |
|
236 | + return $this->routes; |
|
237 | + } |
|
238 | + |
|
239 | + public function getRandomOptimizationId($offset, $limit) |
|
240 | + { |
|
241 | + $optimizations = self::get(['offset' => $offset, 'limit' => $limit]); |
|
242 | + |
|
243 | + $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
244 | + |
|
245 | + if (!isset($rOptimization->optimization_problem_id)) { |
|
246 | + if (sizeof($optimizations) > 9) { |
|
247 | + $this->getRandomOptimizationId($offset, $limit); |
|
248 | + } else { |
|
249 | + return null; |
|
250 | + } |
|
251 | + } |
|
252 | + |
|
253 | + return $rOptimization->optimization_problem_id; |
|
254 | + } |
|
255 | + |
|
256 | + public function getAddresses($opt_id) |
|
257 | + { |
|
258 | + if (null == $opt_id) { |
|
259 | + return null; |
|
260 | + } |
|
261 | + |
|
262 | + $params = ['optimization_problem_id' => $opt_id]; |
|
263 | + |
|
264 | + $optimization = (array) $this->get($params); |
|
265 | + |
|
266 | + $addresses = $optimization['addresses']; |
|
267 | + |
|
268 | + return $addresses; |
|
269 | + } |
|
270 | + |
|
271 | + public function getRandomAddressFromOptimization($opt_id) |
|
272 | + { |
|
273 | + $addresses = (array) $this->getAddresses($opt_id); |
|
274 | + |
|
275 | + if (null == $addresses) { |
|
276 | + echo 'There are no addresses in this optimization!.. Try again.'; |
|
277 | + |
|
278 | + return null; |
|
279 | + } |
|
280 | + |
|
281 | + $num = rand(0, sizeof($addresses) - 1); |
|
282 | + |
|
283 | + $rAddress = $addresses[$num]; |
|
284 | + |
|
285 | + return $rAddress; |
|
286 | + } |
|
287 | + |
|
288 | + public function removeAddress($params) |
|
289 | + { |
|
290 | + $allQueryFields = ['optimization_problem_id', 'route_destination_id']; |
|
291 | + |
|
292 | + $response = Route4Me::makeRequst([ |
|
293 | + 'url' => Endpoint::ADDRESS_V4, |
|
294 | + 'method' => 'DELETE', |
|
295 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
296 | + ]); |
|
297 | + |
|
298 | + return $response; |
|
299 | + } |
|
300 | + |
|
301 | + public function removeOptimization($params) |
|
302 | + { |
|
303 | + $allQueryFields = ['redirect']; |
|
304 | + $allBodyFields = ['optimization_problem_ids']; |
|
305 | + |
|
306 | + $response = Route4Me::makeRequst([ |
|
307 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
308 | + 'method' => 'DELETE', |
|
309 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
310 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
311 | + ]); |
|
312 | + |
|
313 | + return $response; |
|
314 | + } |
|
315 | + |
|
316 | + public function getHybridOptimization($params) |
|
317 | + { |
|
318 | + $allQueryFields = ['target_date_string', 'timezone_offset_minutes']; |
|
319 | + |
|
320 | + $optimize = Route4Me::makeRequst([ |
|
321 | + 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
322 | + 'method' => 'GET', |
|
323 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
324 | + ]); |
|
325 | 325 | |
326 | - return $optimize; |
|
327 | - } |
|
326 | + return $optimize; |
|
327 | + } |
|
328 | 328 | |
329 | - public function addDepotsToHybrid($params) |
|
330 | - { |
|
331 | - $allQueryFields = ['optimization_problem_id']; |
|
332 | - $allBodyFields = ['optimization_problem_id', 'delete_old_depots', 'new_depots']; |
|
329 | + public function addDepotsToHybrid($params) |
|
330 | + { |
|
331 | + $allQueryFields = ['optimization_problem_id']; |
|
332 | + $allBodyFields = ['optimization_problem_id', 'delete_old_depots', 'new_depots']; |
|
333 | 333 | |
334 | - $depots = Route4Me::makeRequst([ |
|
335 | - 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
336 | - 'method' => 'POST', |
|
337 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
338 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
339 | - ]); |
|
334 | + $depots = Route4Me::makeRequst([ |
|
335 | + 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
336 | + 'method' => 'POST', |
|
337 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
338 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
339 | + ]); |
|
340 | 340 | |
341 | - return $depots; |
|
342 | - } |
|
341 | + return $depots; |
|
342 | + } |
|
343 | 343 | } |
@@ -9,9 +9,9 @@ |
||
9 | 9 | */ |
10 | 10 | class TelematicsVendorsResponse |
11 | 11 | { |
12 | - /** |
|
13 | - * An array of the telematics vendors. |
|
14 | - * @var type TelematicsVendors[] |
|
15 | - */ |
|
16 | - public $vendors = []; |
|
12 | + /** |
|
13 | + * An array of the telematics vendors. |
|
14 | + * @var type TelematicsVendors[] |
|
15 | + */ |
|
16 | + public $vendors = []; |
|
17 | 17 | } |
@@ -9,88 +9,88 @@ |
||
9 | 9 | */ |
10 | 10 | class TelematicsConnectionParameters extends Common |
11 | 11 | { |
12 | - /** |
|
13 | - * Account ID |
|
14 | - * @var type string |
|
15 | - */ |
|
16 | - public $account_id; |
|
12 | + /** |
|
13 | + * Account ID |
|
14 | + * @var type string |
|
15 | + */ |
|
16 | + public $account_id; |
|
17 | 17 | |
18 | - /** |
|
19 | - * User name |
|
20 | - * @var type string |
|
21 | - */ |
|
22 | - public $username; |
|
18 | + /** |
|
19 | + * User name |
|
20 | + * @var type string |
|
21 | + */ |
|
22 | + public $username; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Password |
|
26 | - * @var type string |
|
27 | - */ |
|
28 | - public $password; |
|
24 | + /** |
|
25 | + * Password |
|
26 | + * @var type string |
|
27 | + */ |
|
28 | + public $password; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Connection host |
|
32 | - * @var type string |
|
33 | - */ |
|
34 | - public $host; |
|
30 | + /** |
|
31 | + * Connection host |
|
32 | + * @var type string |
|
33 | + */ |
|
34 | + public $host; |
|
35 | 35 | |
36 | - /** |
|
37 | - * An unique ID of a telematics vendor. |
|
38 | - * @var type integer |
|
39 | - */ |
|
40 | - public $vendor_id; |
|
36 | + /** |
|
37 | + * An unique ID of a telematics vendor. |
|
38 | + * @var type integer |
|
39 | + */ |
|
40 | + public $vendor_id; |
|
41 | 41 | |
42 | - /** |
|
43 | - * Telematics connection name |
|
44 | - * @var type string |
|
45 | - */ |
|
46 | - public $name; |
|
42 | + /** |
|
43 | + * Telematics connection name |
|
44 | + * @var type string |
|
45 | + */ |
|
46 | + public $name; |
|
47 | 47 | |
48 | - /** |
|
49 | - * Vehicle tracking interval in seconds |
|
50 | - * @var type integer |
|
51 | - */ |
|
52 | - public $vehicle_position_refresh_rate; |
|
48 | + /** |
|
49 | + * Vehicle tracking interval in seconds |
|
50 | + * @var type integer |
|
51 | + */ |
|
52 | + public $vehicle_position_refresh_rate; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Connection token |
|
56 | - * @var type string |
|
57 | - */ |
|
58 | - public $connection_token; |
|
54 | + /** |
|
55 | + * Connection token |
|
56 | + * @var type string |
|
57 | + */ |
|
58 | + public $connection_token; |
|
59 | 59 | |
60 | - /** |
|
61 | - * Connection user ID |
|
62 | - * @var type integer |
|
63 | - */ |
|
64 | - public $user_id; |
|
60 | + /** |
|
61 | + * Connection user ID |
|
62 | + * @var type integer |
|
63 | + */ |
|
64 | + public $user_id; |
|
65 | 65 | |
66 | - /** |
|
67 | - * Connection ID |
|
68 | - * @var type integer |
|
69 | - */ |
|
70 | - public $id; |
|
66 | + /** |
|
67 | + * Connection ID |
|
68 | + * @var type integer |
|
69 | + */ |
|
70 | + public $id; |
|
71 | 71 | |
72 | - /** |
|
73 | - * Telemetics connection type |
|
74 | - * @var type string |
|
75 | - */ |
|
76 | - public $vendor; |
|
72 | + /** |
|
73 | + * Telemetics connection type |
|
74 | + * @var type string |
|
75 | + */ |
|
76 | + public $vendor; |
|
77 | 77 | |
78 | - /** |
|
79 | - * Validate connections credentials. |
|
80 | - * @var type Boolean |
|
81 | - */ |
|
82 | - public $validate_remote_credentials; |
|
78 | + /** |
|
79 | + * Validate connections credentials. |
|
80 | + * @var type Boolean |
|
81 | + */ |
|
82 | + public $validate_remote_credentials; |
|
83 | 83 | |
84 | - public static function fromArray(array $params) |
|
85 | - { |
|
86 | - $thisParams = new self(); |
|
84 | + public static function fromArray(array $params) |
|
85 | + { |
|
86 | + $thisParams = new self(); |
|
87 | 87 | |
88 | - foreach ($params as $key => $value) { |
|
89 | - if (property_exists($thisParams, $key)) { |
|
90 | - $thisParams->{$key} = $value; |
|
91 | - } |
|
92 | - } |
|
88 | + foreach ($params as $key => $value) { |
|
89 | + if (property_exists($thisParams, $key)) { |
|
90 | + $thisParams->{$key} = $value; |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - return $thisParams; |
|
95 | - } |
|
94 | + return $thisParams; |
|
95 | + } |
|
96 | 96 | } |
@@ -11,279 +11,279 @@ |
||
11 | 11 | */ |
12 | 12 | class TelematicsConnection extends \Route4Me\Common |
13 | 13 | { |
14 | - /** |
|
15 | - * Telematics connection access account_id |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - public $account_id; |
|
14 | + /** |
|
15 | + * Telematics connection access account_id |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + public $account_id; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Telematics connection access username |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - public $username; |
|
20 | + /** |
|
21 | + * Telematics connection access username |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + public $username; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Telematics connection access password |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - public $password; |
|
26 | + /** |
|
27 | + * Telematics connection access password |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + public $password; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Telematics connection access host |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - public $host; |
|
32 | + /** |
|
33 | + * Telematics connection access host |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + public $host; |
|
37 | 37 | |
38 | - /** |
|
39 | - * Telematics connection access api_key |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - public $api_key; |
|
38 | + /** |
|
39 | + * Telematics connection access api_key |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + public $api_key; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Telemetics connection type ID |
|
46 | - * @var integer |
|
47 | - */ |
|
48 | - public $vendor_id; |
|
44 | + /** |
|
45 | + * Telemetics connection type ID |
|
46 | + * @var integer |
|
47 | + */ |
|
48 | + public $vendor_id; |
|
49 | 49 | |
50 | - /** |
|
51 | - * Telemetics connection name |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - public $name; |
|
50 | + /** |
|
51 | + * Telemetics connection name |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + public $name; |
|
55 | 55 | |
56 | - /** |
|
57 | - * Vehicle tracking interval in seconds. |
|
58 | - * @var integer |
|
59 | - */ |
|
60 | - public $vehicle_position_refresh_rate; |
|
56 | + /** |
|
57 | + * Vehicle tracking interval in seconds. |
|
58 | + * @var integer |
|
59 | + */ |
|
60 | + public $vehicle_position_refresh_rate; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Maximum idle time |
|
64 | - * @var integer |
|
65 | - */ |
|
66 | - public $max_idle_time; |
|
62 | + /** |
|
63 | + * Maximum idle time |
|
64 | + * @var integer |
|
65 | + */ |
|
66 | + public $max_idle_time; |
|
67 | 67 | |
68 | - /** |
|
69 | - * Disable/enable vehicle tracking |
|
70 | - * @var integer |
|
71 | - */ |
|
72 | - public $is_enabled; |
|
68 | + /** |
|
69 | + * Disable/enable vehicle tracking |
|
70 | + * @var integer |
|
71 | + */ |
|
72 | + public $is_enabled; |
|
73 | 73 | |
74 | - /** |
|
75 | - * The last timestamp, when the vehicles reloaded. |
|
76 | - * @var integer |
|
77 | - */ |
|
78 | - public $last_vehicles_reload; |
|
74 | + /** |
|
75 | + * The last timestamp, when the vehicles reloaded. |
|
76 | + * @var integer |
|
77 | + */ |
|
78 | + public $last_vehicles_reload; |
|
79 | 79 | |
80 | - /** |
|
81 | - * The last timestamp, when the addresses reloaded. |
|
82 | - * @var integer |
|
83 | - */ |
|
84 | - public $last_addresses_reload; |
|
80 | + /** |
|
81 | + * The last timestamp, when the addresses reloaded. |
|
82 | + * @var integer |
|
83 | + */ |
|
84 | + public $last_addresses_reload; |
|
85 | 85 | |
86 | - /** |
|
87 | - * The last timestamp, when the positions reloaded. |
|
88 | - * @var integer |
|
89 | - */ |
|
90 | - public $last_position_reload; |
|
86 | + /** |
|
87 | + * The last timestamp, when the positions reloaded. |
|
88 | + * @var integer |
|
89 | + */ |
|
90 | + public $last_position_reload; |
|
91 | 91 | |
92 | - /** |
|
93 | - * Telematics connection access token |
|
94 | - * @var string |
|
95 | - */ |
|
96 | - public $connection_token; |
|
92 | + /** |
|
93 | + * Telematics connection access token |
|
94 | + * @var string |
|
95 | + */ |
|
96 | + public $connection_token; |
|
97 | 97 | |
98 | - /** |
|
99 | - * Connection user ID |
|
100 | - * @var integer |
|
101 | - */ |
|
102 | - public $user_id; |
|
98 | + /** |
|
99 | + * Connection user ID |
|
100 | + * @var integer |
|
101 | + */ |
|
102 | + public $user_id; |
|
103 | 103 | |
104 | - /** |
|
105 | - * When the connection updated |
|
106 | - * @var string |
|
107 | - */ |
|
108 | - public $updated_at; |
|
104 | + /** |
|
105 | + * When the connection updated |
|
106 | + * @var string |
|
107 | + */ |
|
108 | + public $updated_at; |
|
109 | 109 | |
110 | - /** |
|
111 | - * When the connection created |
|
112 | - * @var string |
|
113 | - */ |
|
114 | - public $created_at; |
|
110 | + /** |
|
111 | + * When the connection created |
|
112 | + * @var string |
|
113 | + */ |
|
114 | + public $created_at; |
|
115 | 115 | |
116 | - /** |
|
117 | - * Telemetics connection ID |
|
118 | - * @var integer |
|
119 | - */ |
|
120 | - public $id; |
|
116 | + /** |
|
117 | + * Telemetics connection ID |
|
118 | + * @var integer |
|
119 | + */ |
|
120 | + public $id; |
|
121 | 121 | |
122 | - /** |
|
123 | - * Metadata, custom key-value storage. |
|
124 | - * @var array |
|
125 | - */ |
|
126 | - public $metadata; |
|
122 | + /** |
|
123 | + * Metadata, custom key-value storage. |
|
124 | + * @var array |
|
125 | + */ |
|
126 | + public $metadata; |
|
127 | 127 | |
128 | - /** |
|
129 | - * Total vehicles number |
|
130 | - * @var integer |
|
131 | - */ |
|
132 | - public $total_vehicles_count; |
|
128 | + /** |
|
129 | + * Total vehicles number |
|
130 | + * @var integer |
|
131 | + */ |
|
132 | + public $total_vehicles_count; |
|
133 | 133 | |
134 | - /** |
|
135 | - * Total addresses number |
|
136 | - * @var integer |
|
137 | - */ |
|
138 | - public $total_addresses_count; |
|
134 | + /** |
|
135 | + * Total addresses number |
|
136 | + * @var integer |
|
137 | + */ |
|
138 | + public $total_addresses_count; |
|
139 | 139 | |
140 | - /** |
|
141 | - * Synchronized vehicles number |
|
142 | - * @var integer |
|
143 | - */ |
|
144 | - public $synced_vehicles_count; |
|
140 | + /** |
|
141 | + * Synchronized vehicles number |
|
142 | + * @var integer |
|
143 | + */ |
|
144 | + public $synced_vehicles_count; |
|
145 | 145 | |
146 | - /** |
|
147 | - * Telemetics connection vendor |
|
148 | - * @var string |
|
149 | - */ |
|
150 | - public $vendor; |
|
146 | + /** |
|
147 | + * Telemetics connection vendor |
|
148 | + * @var string |
|
149 | + */ |
|
150 | + public $vendor; |
|
151 | 151 | |
152 | - /** |
|
153 | - * Validate connections credentials.<br> |
|
154 | - * If true, the connection validated. |
|
155 | - * @var Boolean |
|
156 | - */ |
|
157 | - public $validate_remote_credentials; |
|
152 | + /** |
|
153 | + * Validate connections credentials.<br> |
|
154 | + * If true, the connection validated. |
|
155 | + * @var Boolean |
|
156 | + */ |
|
157 | + public $validate_remote_credentials; |
|
158 | 158 | |
159 | - public static function fromArray(array $params) |
|
160 | - { |
|
161 | - $thisParams = new self(); |
|
159 | + public static function fromArray(array $params) |
|
160 | + { |
|
161 | + $thisParams = new self(); |
|
162 | 162 | |
163 | - foreach ($params as $key => $value) { |
|
164 | - if (property_exists($thisParams, $key)) { |
|
165 | - $thisParams->{$key} = $value; |
|
166 | - } |
|
167 | - } |
|
163 | + foreach ($params as $key => $value) { |
|
164 | + if (property_exists($thisParams, $key)) { |
|
165 | + $thisParams->{$key} = $value; |
|
166 | + } |
|
167 | + } |
|
168 | 168 | |
169 | - return $thisParams; |
|
170 | - } |
|
169 | + return $thisParams; |
|
170 | + } |
|
171 | 171 | |
172 | - /** |
|
173 | - * Create a telematics connection. |
|
174 | - * @param $apiToken string : API token |
|
175 | - * @param $params TelematicsConnectionParameters : Telematics connection parameters |
|
176 | - * @return array Array from a TelematicsConnection type object |
|
177 | - * @throws \Route4Me\Exception\ApiError |
|
178 | - */ |
|
179 | - public function createTelematicsConnection($apiToken, $params) |
|
180 | - { |
|
181 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
172 | + /** |
|
173 | + * Create a telematics connection. |
|
174 | + * @param $apiToken string : API token |
|
175 | + * @param $params TelematicsConnectionParameters : Telematics connection parameters |
|
176 | + * @return array Array from a TelematicsConnection type object |
|
177 | + * @throws \Route4Me\Exception\ApiError |
|
178 | + */ |
|
179 | + public function createTelematicsConnection($apiToken, $params) |
|
180 | + { |
|
181 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
182 | 182 | |
183 | - $excludeFields = ['id', 'connection_token']; |
|
183 | + $excludeFields = ['id', 'connection_token']; |
|
184 | 184 | |
185 | - $allBodyFields = Route4Me::getObjectProperties(new TelematicsConnectionParameters(), $excludeFields); |
|
185 | + $allBodyFields = Route4Me::getObjectProperties(new TelematicsConnectionParameters(), $excludeFields); |
|
186 | 186 | |
187 | - $result = Route4Me::makeRequst([ |
|
188 | - 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
189 | - 'method' => 'POST', |
|
190 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
191 | - 'query' => ['api_token' => $apiToken], |
|
192 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
193 | - ]); |
|
187 | + $result = Route4Me::makeRequst([ |
|
188 | + 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
189 | + 'method' => 'POST', |
|
190 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
191 | + 'query' => ['api_token' => $apiToken], |
|
192 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
193 | + ]); |
|
194 | 194 | |
195 | - return $result; |
|
196 | - } |
|
195 | + return $result; |
|
196 | + } |
|
197 | 197 | |
198 | - /** |
|
199 | - * Delete a telematics connection. |
|
200 | - * @param $apiToken string : API token |
|
201 | - * @param $connectionToken string : connection token |
|
202 | - * @return array Array from a TelematicsConnection type object |
|
203 | - * @throws \Route4Me\Exception\ApiError |
|
204 | - */ |
|
205 | - public function deleteTelematicsConnection($apiToken, $connectionToken) |
|
206 | - { |
|
207 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
198 | + /** |
|
199 | + * Delete a telematics connection. |
|
200 | + * @param $apiToken string : API token |
|
201 | + * @param $connectionToken string : connection token |
|
202 | + * @return array Array from a TelematicsConnection type object |
|
203 | + * @throws \Route4Me\Exception\ApiError |
|
204 | + */ |
|
205 | + public function deleteTelematicsConnection($apiToken, $connectionToken) |
|
206 | + { |
|
207 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
208 | 208 | |
209 | - $result = Route4Me::makeRequst([ |
|
210 | - 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
211 | - 'method' => 'DELETE', |
|
212 | - 'query' => [ |
|
213 | - 'api_token' => $apiToken, |
|
214 | - 'connection_token' => $connectionToken |
|
215 | - ], |
|
216 | - ]); |
|
209 | + $result = Route4Me::makeRequst([ |
|
210 | + 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
211 | + 'method' => 'DELETE', |
|
212 | + 'query' => [ |
|
213 | + 'api_token' => $apiToken, |
|
214 | + 'connection_token' => $connectionToken |
|
215 | + ], |
|
216 | + ]); |
|
217 | 217 | |
218 | - return $result; |
|
219 | - } |
|
218 | + return $result; |
|
219 | + } |
|
220 | 220 | |
221 | - /** |
|
222 | - * Get all telematics connections. |
|
223 | - * @param $apiToken string : API token |
|
224 | - * @return array Array of the TelematicsConnection type objects |
|
225 | - * @throws \Route4Me\Exception\ApiError |
|
226 | - */ |
|
227 | - public function getTelematicsConnections($apiToken) |
|
228 | - { |
|
229 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
221 | + /** |
|
222 | + * Get all telematics connections. |
|
223 | + * @param $apiToken string : API token |
|
224 | + * @return array Array of the TelematicsConnection type objects |
|
225 | + * @throws \Route4Me\Exception\ApiError |
|
226 | + */ |
|
227 | + public function getTelematicsConnections($apiToken) |
|
228 | + { |
|
229 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
230 | 230 | |
231 | - $result = Route4Me::makeRequst([ |
|
232 | - 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
233 | - 'method' => 'GET', |
|
234 | - 'query' => [ |
|
235 | - 'api_token' => $apiToken |
|
236 | - ], |
|
237 | - ]); |
|
231 | + $result = Route4Me::makeRequst([ |
|
232 | + 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
233 | + 'method' => 'GET', |
|
234 | + 'query' => [ |
|
235 | + 'api_token' => $apiToken |
|
236 | + ], |
|
237 | + ]); |
|
238 | 238 | |
239 | - return $result; |
|
240 | - } |
|
239 | + return $result; |
|
240 | + } |
|
241 | 241 | |
242 | - /** |
|
243 | - * Get a telematics connection |
|
244 | - * @param $apiToken string : API token |
|
245 | - * @param $connectionToken string : connection token |
|
246 | - * @return array Array from a TelematicsConnection type object |
|
247 | - * @throws \Route4Me\Exception\ApiError |
|
248 | - */ |
|
249 | - public function getTelematicsConnection($apiToken, $connectionToken) |
|
250 | - { |
|
251 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
242 | + /** |
|
243 | + * Get a telematics connection |
|
244 | + * @param $apiToken string : API token |
|
245 | + * @param $connectionToken string : connection token |
|
246 | + * @return array Array from a TelematicsConnection type object |
|
247 | + * @throws \Route4Me\Exception\ApiError |
|
248 | + */ |
|
249 | + public function getTelematicsConnection($apiToken, $connectionToken) |
|
250 | + { |
|
251 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
252 | 252 | |
253 | - $result = Route4Me::makeRequst([ |
|
254 | - 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
255 | - 'method' => 'GE', |
|
256 | - 'query' => [ |
|
257 | - 'api_token' => $apiToken, |
|
258 | - 'connection_token' => $connectionToken |
|
259 | - ], |
|
260 | - ]); |
|
253 | + $result = Route4Me::makeRequst([ |
|
254 | + 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
255 | + 'method' => 'GE', |
|
256 | + 'query' => [ |
|
257 | + 'api_token' => $apiToken, |
|
258 | + 'connection_token' => $connectionToken |
|
259 | + ], |
|
260 | + ]); |
|
261 | 261 | |
262 | - return $result; |
|
263 | - } |
|
262 | + return $result; |
|
263 | + } |
|
264 | 264 | |
265 | - /** |
|
266 | - * Update telematics connection |
|
267 | - * @param $apiToken string : API token |
|
268 | - * @param $connectionToken string : connection token |
|
269 | - * @param $teleConParams TelematicsConnectionParameters : Telematics connection parameters |
|
270 | - * @return array Array from a TelematicsConnection type object |
|
271 | - * @throws \Route4Me\Exception\ApiError |
|
272 | - */ |
|
273 | - public function updateTelematicsConnection($apiToken, $connectionToken, $teleConParams) |
|
274 | - { |
|
275 | - $excludeFields = ['id', 'connection_token']; |
|
265 | + /** |
|
266 | + * Update telematics connection |
|
267 | + * @param $apiToken string : API token |
|
268 | + * @param $connectionToken string : connection token |
|
269 | + * @param $teleConParams TelematicsConnectionParameters : Telematics connection parameters |
|
270 | + * @return array Array from a TelematicsConnection type object |
|
271 | + * @throws \Route4Me\Exception\ApiError |
|
272 | + */ |
|
273 | + public function updateTelematicsConnection($apiToken, $connectionToken, $teleConParams) |
|
274 | + { |
|
275 | + $excludeFields = ['id', 'connection_token']; |
|
276 | 276 | |
277 | - $allBodyFields = Route4Me::getObjectProperties(new TelematicsConnectionParameters(), $excludeFields); |
|
277 | + $allBodyFields = Route4Me::getObjectProperties(new TelematicsConnectionParameters(), $excludeFields); |
|
278 | 278 | |
279 | - $result = Route4Me::makeRequst([ |
|
280 | - 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
281 | - 'method' => 'PUT', |
|
282 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $teleConParams), |
|
283 | - 'query' => ['api_token' => $apiToken, 'connection_token' => $connectionToken], |
|
284 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
285 | - ]); |
|
279 | + $result = Route4Me::makeRequst([ |
|
280 | + 'url' => Endpoint::TELEMATICS_CONNECTION, |
|
281 | + 'method' => 'PUT', |
|
282 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $teleConParams), |
|
283 | + 'query' => ['api_token' => $apiToken, 'connection_token' => $connectionToken], |
|
284 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data', |
|
285 | + ]); |
|
286 | 286 | |
287 | - return $result; |
|
288 | - } |
|
287 | + return $result; |
|
288 | + } |
|
289 | 289 | } |
@@ -8,9 +8,9 @@ |
||
8 | 8 | */ |
9 | 9 | class TelematicsVendorResponse extends Common |
10 | 10 | { |
11 | - /** |
|
12 | - * Telematics Vendor |
|
13 | - * @var type TelematicsVendor |
|
14 | - */ |
|
15 | - public $vendor; |
|
11 | + /** |
|
12 | + * Telematics Vendor |
|
13 | + * @var type TelematicsVendor |
|
14 | + */ |
|
15 | + public $vendor; |
|
16 | 16 | } |
@@ -7,42 +7,42 @@ |
||
7 | 7 | */ |
8 | 8 | class TelematicsRegisterMemberResponse extends \Route4Me\Common |
9 | 9 | { |
10 | - /** |
|
11 | - * API token |
|
12 | - * Use for the operations: |
|
13 | - * Get Telematics Connections, Register Telematics Connection |
|
14 | - * @var type string |
|
15 | - */ |
|
16 | - public $api_token; |
|
10 | + /** |
|
11 | + * API token |
|
12 | + * Use for the operations: |
|
13 | + * Get Telematics Connections, Register Telematics Connection |
|
14 | + * @var type string |
|
15 | + */ |
|
16 | + public $api_token; |
|
17 | 17 | |
18 | - /** |
|
19 | - * When the registered member updated |
|
20 | - * @var type string |
|
21 | - */ |
|
22 | - public $updated_at; |
|
18 | + /** |
|
19 | + * When the registered member updated |
|
20 | + * @var type string |
|
21 | + */ |
|
22 | + public $updated_at; |
|
23 | 23 | |
24 | - /** |
|
25 | - * When the registered member created |
|
26 | - * @var type |
|
27 | - */ |
|
28 | - public $created_at; |
|
24 | + /** |
|
25 | + * When the registered member created |
|
26 | + * @var type |
|
27 | + */ |
|
28 | + public $created_at; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Telemetics member ID |
|
32 | - * @var type |
|
33 | - */ |
|
34 | - public $id; |
|
30 | + /** |
|
31 | + * Telemetics member ID |
|
32 | + * @var type |
|
33 | + */ |
|
34 | + public $id; |
|
35 | 35 | |
36 | - public static function fromArray(array $params) |
|
37 | - { |
|
38 | - $thisParams = new self(); |
|
36 | + public static function fromArray(array $params) |
|
37 | + { |
|
38 | + $thisParams = new self(); |
|
39 | 39 | |
40 | - foreach ($params as $key => $value) { |
|
41 | - if (property_exists($thisParams, $key)) { |
|
42 | - $thisParams->{$key} = $value; |
|
43 | - } |
|
44 | - } |
|
40 | + foreach ($params as $key => $value) { |
|
41 | + if (property_exists($thisParams, $key)) { |
|
42 | + $thisParams->{$key} = $value; |
|
43 | + } |
|
44 | + } |
|
45 | 45 | |
46 | - return $thisParams; |
|
47 | - } |
|
46 | + return $thisParams; |
|
47 | + } |
|
48 | 48 | } |
@@ -7,112 +7,112 @@ |
||
7 | 7 | |
8 | 8 | class CreateConnectionResponse extends Common |
9 | 9 | { |
10 | - /** |
|
11 | - * Telematics connection access account_id |
|
12 | - * @var string |
|
13 | - */ |
|
14 | - public $account_id; |
|
15 | - |
|
16 | - /** |
|
17 | - * Telematics connection access api_key |
|
18 | - * @var string |
|
19 | - */ |
|
20 | - public $api_key; |
|
21 | - |
|
22 | - /** |
|
23 | - * Telematics connection access token |
|
24 | - * @var string |
|
25 | - */ |
|
26 | - public $connection_token; |
|
27 | - |
|
28 | - /** |
|
29 | - * When the connection created |
|
30 | - * @var string |
|
31 | - */ |
|
32 | - public $created_at; |
|
33 | - |
|
34 | - /** |
|
35 | - * Telemetics connection ID |
|
36 | - * @var integer |
|
37 | - */ |
|
38 | - public $id; |
|
39 | - |
|
40 | - /** |
|
41 | - * Metadata, custom key-value storage. |
|
42 | - * @var array |
|
43 | - */ |
|
44 | - public $metadata; |
|
45 | - |
|
46 | - /** |
|
47 | - * Telemetics connection name |
|
48 | - * @var string |
|
49 | - */ |
|
50 | - public $name; |
|
51 | - |
|
52 | - /** |
|
53 | - * Telematics connection access password |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $password; |
|
57 | - |
|
58 | - /** |
|
59 | - * Synchronized vehicles number |
|
60 | - * @var integer |
|
61 | - */ |
|
62 | - public $synced_vehicles_count; |
|
63 | - |
|
64 | - /** |
|
65 | - * Total vehicles number |
|
66 | - * @var integer |
|
67 | - */ |
|
68 | - public $total_vehicles_count; |
|
69 | - |
|
70 | - /** |
|
71 | - * When the connection updated |
|
72 | - * @var string |
|
73 | - */ |
|
74 | - public $updated_at; |
|
75 | - |
|
76 | - /** |
|
77 | - * Connection user ID |
|
78 | - * @var integer |
|
79 | - */ |
|
80 | - public $user_id; |
|
81 | - |
|
82 | - /** |
|
83 | - * Telematics connection access username |
|
84 | - * @var string |
|
85 | - */ |
|
86 | - public $username; |
|
87 | - |
|
88 | - /** |
|
89 | - * Vehicle tracking interval in seconds. |
|
90 | - * @var integer |
|
91 | - */ |
|
92 | - public $vehicle_position_refresh_rate; |
|
93 | - |
|
94 | - /** |
|
95 | - * Telemetics connection vendor |
|
96 | - * @var string |
|
97 | - */ |
|
98 | - public $vendor ; |
|
99 | - |
|
100 | - /** |
|
101 | - * Telemetics connection type ID |
|
102 | - * @var integer |
|
103 | - */ |
|
104 | - public $vendor_id ; |
|
105 | - |
|
106 | - public static function fromArray(array $params) |
|
107 | - { |
|
108 | - $thisParams = new self(); |
|
109 | - |
|
110 | - foreach ($params as $key => $value) { |
|
111 | - if (property_exists($thisParams, $key)) { |
|
112 | - $thisParams->{$key} = $value; |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - return $thisParams; |
|
117 | - } |
|
10 | + /** |
|
11 | + * Telematics connection access account_id |
|
12 | + * @var string |
|
13 | + */ |
|
14 | + public $account_id; |
|
15 | + |
|
16 | + /** |
|
17 | + * Telematics connection access api_key |
|
18 | + * @var string |
|
19 | + */ |
|
20 | + public $api_key; |
|
21 | + |
|
22 | + /** |
|
23 | + * Telematics connection access token |
|
24 | + * @var string |
|
25 | + */ |
|
26 | + public $connection_token; |
|
27 | + |
|
28 | + /** |
|
29 | + * When the connection created |
|
30 | + * @var string |
|
31 | + */ |
|
32 | + public $created_at; |
|
33 | + |
|
34 | + /** |
|
35 | + * Telemetics connection ID |
|
36 | + * @var integer |
|
37 | + */ |
|
38 | + public $id; |
|
39 | + |
|
40 | + /** |
|
41 | + * Metadata, custom key-value storage. |
|
42 | + * @var array |
|
43 | + */ |
|
44 | + public $metadata; |
|
45 | + |
|
46 | + /** |
|
47 | + * Telemetics connection name |
|
48 | + * @var string |
|
49 | + */ |
|
50 | + public $name; |
|
51 | + |
|
52 | + /** |
|
53 | + * Telematics connection access password |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $password; |
|
57 | + |
|
58 | + /** |
|
59 | + * Synchronized vehicles number |
|
60 | + * @var integer |
|
61 | + */ |
|
62 | + public $synced_vehicles_count; |
|
63 | + |
|
64 | + /** |
|
65 | + * Total vehicles number |
|
66 | + * @var integer |
|
67 | + */ |
|
68 | + public $total_vehicles_count; |
|
69 | + |
|
70 | + /** |
|
71 | + * When the connection updated |
|
72 | + * @var string |
|
73 | + */ |
|
74 | + public $updated_at; |
|
75 | + |
|
76 | + /** |
|
77 | + * Connection user ID |
|
78 | + * @var integer |
|
79 | + */ |
|
80 | + public $user_id; |
|
81 | + |
|
82 | + /** |
|
83 | + * Telematics connection access username |
|
84 | + * @var string |
|
85 | + */ |
|
86 | + public $username; |
|
87 | + |
|
88 | + /** |
|
89 | + * Vehicle tracking interval in seconds. |
|
90 | + * @var integer |
|
91 | + */ |
|
92 | + public $vehicle_position_refresh_rate; |
|
93 | + |
|
94 | + /** |
|
95 | + * Telemetics connection vendor |
|
96 | + * @var string |
|
97 | + */ |
|
98 | + public $vendor ; |
|
99 | + |
|
100 | + /** |
|
101 | + * Telemetics connection type ID |
|
102 | + * @var integer |
|
103 | + */ |
|
104 | + public $vendor_id ; |
|
105 | + |
|
106 | + public static function fromArray(array $params) |
|
107 | + { |
|
108 | + $thisParams = new self(); |
|
109 | + |
|
110 | + foreach ($params as $key => $value) { |
|
111 | + if (property_exists($thisParams, $key)) { |
|
112 | + $thisParams->{$key} = $value; |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + return $thisParams; |
|
117 | + } |
|
118 | 118 | } |
119 | 119 | \ No newline at end of file |
@@ -11,172 +11,172 @@ |
||
11 | 11 | */ |
12 | 12 | class TelematicsVendor extends Common |
13 | 13 | { |
14 | - /** |
|
15 | - * Unique ID of a telematics vendor. |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - public $id; |
|
14 | + /** |
|
15 | + * Unique ID of a telematics vendor. |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + public $id; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Vendor name |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - public $name; |
|
20 | + /** |
|
21 | + * Vendor name |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + public $name; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Vendor slug |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - public $slug; |
|
26 | + /** |
|
27 | + * Vendor slug |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + public $slug; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Vendor description |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - public $description; |
|
32 | + /** |
|
33 | + * Vendor description |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + public $description; |
|
37 | 37 | |
38 | - /** |
|
39 | - * URL to the telematics vendor's logo. |
|
40 | - * @var string |
|
41 | - */ |
|
42 | - public $logo_url; |
|
38 | + /** |
|
39 | + * URL to the telematics vendor's logo. |
|
40 | + * @var string |
|
41 | + */ |
|
42 | + public $logo_url; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Website URL of a telematics vendor. |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - public $website_url; |
|
44 | + /** |
|
45 | + * Website URL of a telematics vendor. |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + public $website_url; |
|
49 | 49 | |
50 | - /** |
|
51 | - * API URL of a telematics vendor. |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - public $api_docs_url; |
|
50 | + /** |
|
51 | + * API URL of a telematics vendor. |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + public $api_docs_url; |
|
55 | 55 | |
56 | - /** |
|
57 | - * If 1, the vendor is integrated in Route4Me |
|
58 | - * @var string |
|
59 | - */ |
|
60 | - public $is_integrated; |
|
56 | + /** |
|
57 | + * If 1, the vendor is integrated in Route4Me |
|
58 | + * @var string |
|
59 | + */ |
|
60 | + public $is_integrated; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Vendors size. |
|
64 | - * <para>Accepted values:</para> |
|
65 | - * <para>global, regional, local. </para> |
|
66 | - * @var string |
|
67 | - */ |
|
68 | - public $size; |
|
62 | + /** |
|
63 | + * Vendors size. |
|
64 | + * <para>Accepted values:</para> |
|
65 | + * <para>global, regional, local. </para> |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + public $size; |
|
69 | 69 | |
70 | - /** |
|
71 | - * An array of the countries, the vendor is operating. |
|
72 | - * @var Country[] |
|
73 | - */ |
|
74 | - public $countries = []; |
|
70 | + /** |
|
71 | + * An array of the countries, the vendor is operating. |
|
72 | + * @var Country[] |
|
73 | + */ |
|
74 | + public $countries = []; |
|
75 | 75 | |
76 | - /** |
|
77 | - * An array the vendor features |
|
78 | - * @var TelematicsVendorFeature[] |
|
79 | - */ |
|
80 | - public $features = []; |
|
76 | + /** |
|
77 | + * An array the vendor features |
|
78 | + * @var TelematicsVendorFeature[] |
|
79 | + */ |
|
80 | + public $features = []; |
|
81 | 81 | |
82 | - public static function fromArray(array $params) |
|
83 | - { |
|
84 | - $vendorsParameters = new self(); |
|
85 | - |
|
86 | - foreach ($params as $key => $value) { |
|
87 | - if (property_exists($vendorsParameters, $key)) { |
|
88 | - $vendorsParameters->{$key} = $value; |
|
89 | - } |
|
90 | - } |
|
91 | - |
|
92 | - return $vendorsParameters; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Get vendor(s), search for vendors, compare vendors. |
|
97 | - * @param TelematicsVendorParameters $params |
|
98 | - * @return TelematicsVendorResponse or TelematicsVendorsResponse. |
|
99 | - */ |
|
100 | - public static function GetTelematicsVendors($params) |
|
101 | - { |
|
102 | - Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); |
|
103 | - |
|
104 | - $allQueryFields = ['vendor_id', 'is_integrated', 'page', 'per_page', 'country', 'feature', 'search', 'vendors']; |
|
105 | - |
|
106 | - $vendors = Route4Me::makeRequst([ |
|
107 | - 'url' => '', |
|
108 | - 'method' => 'GET', |
|
109 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
110 | - ]); |
|
111 | - |
|
112 | - return $vendors; |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Returns a random telematics vendor (for tests). |
|
117 | - * @param $offset integer |
|
118 | - * @param $limit integer |
|
119 | - * @return Telematics vendor |
|
120 | - */ |
|
121 | - public static function GetRandomVendorID($offset, $limit) |
|
122 | - { |
|
123 | - $allVendors = self::GetTelematicsVendors(null); |
|
124 | - $vendorsNumber = sizeof($allVendors['vendors']); |
|
125 | - |
|
126 | - if ($vendorsNumber < $limit) { |
|
127 | - if ($vendorsNumber > $offset) { |
|
128 | - $limit = $vendorsNumber; |
|
129 | - } else { |
|
130 | - if ($vendorsNumber == $offset) { |
|
131 | - return $allVendors['vendors'][$offset]->{'vendor_id'}; |
|
132 | - } else { |
|
133 | - echo 'The vendors numbers are less than offset'; |
|
134 | - |
|
135 | - return null; |
|
136 | - } |
|
137 | - } |
|
138 | - } |
|
139 | - |
|
140 | - $randNumber = rand($offset, $limit); |
|
141 | - |
|
142 | - return $allVendors['vendors'][$randNumber]['id']; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Register telematics member |
|
147 | - * @param TelematicsVendorParameters $params contains: |
|
148 | - * @param integer member_id : member ID |
|
149 | - * @param string api_key : API key |
|
150 | - * @return array from a TelematicsRegisterMemberResponse type object |
|
151 | - * @throws \Route4Me\Exception\ApiError |
|
152 | - */ |
|
153 | - public static function RegisterTelematicsMember($params) |
|
154 | - { |
|
155 | - Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
156 | - |
|
157 | - $allQueryFields = ['member_id', 'api_key']; |
|
158 | - |
|
159 | - $vendors = Route4Me::makeRequst([ |
|
160 | - 'url' => Endpoint::TELEMATICS_REGISTER_MEMBER, |
|
161 | - 'method' => 'GET', |
|
162 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
163 | - ]); |
|
164 | - |
|
165 | - return $vendors; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Get a vendor by ID |
|
170 | - * @param string $vendorId |
|
171 | - * @return TelematicsVendor type object |
|
172 | - */ |
|
173 | - public static function getVendorById($vendorId) |
|
174 | - { |
|
175 | - if ($vendorId!=null) { |
|
176 | - return self::GetTelematicsVendors($vendorId); |
|
177 | - } else { |
|
178 | - return null; |
|
179 | - } |
|
180 | - } |
|
82 | + public static function fromArray(array $params) |
|
83 | + { |
|
84 | + $vendorsParameters = new self(); |
|
85 | + |
|
86 | + foreach ($params as $key => $value) { |
|
87 | + if (property_exists($vendorsParameters, $key)) { |
|
88 | + $vendorsParameters->{$key} = $value; |
|
89 | + } |
|
90 | + } |
|
91 | + |
|
92 | + return $vendorsParameters; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Get vendor(s), search for vendors, compare vendors. |
|
97 | + * @param TelematicsVendorParameters $params |
|
98 | + * @return TelematicsVendorResponse or TelematicsVendorsResponse. |
|
99 | + */ |
|
100 | + public static function GetTelematicsVendors($params) |
|
101 | + { |
|
102 | + Route4Me::setBaseUrl(Endpoint::TELEMATICS_VENDORS); |
|
103 | + |
|
104 | + $allQueryFields = ['vendor_id', 'is_integrated', 'page', 'per_page', 'country', 'feature', 'search', 'vendors']; |
|
105 | + |
|
106 | + $vendors = Route4Me::makeRequst([ |
|
107 | + 'url' => '', |
|
108 | + 'method' => 'GET', |
|
109 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
110 | + ]); |
|
111 | + |
|
112 | + return $vendors; |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Returns a random telematics vendor (for tests). |
|
117 | + * @param $offset integer |
|
118 | + * @param $limit integer |
|
119 | + * @return Telematics vendor |
|
120 | + */ |
|
121 | + public static function GetRandomVendorID($offset, $limit) |
|
122 | + { |
|
123 | + $allVendors = self::GetTelematicsVendors(null); |
|
124 | + $vendorsNumber = sizeof($allVendors['vendors']); |
|
125 | + |
|
126 | + if ($vendorsNumber < $limit) { |
|
127 | + if ($vendorsNumber > $offset) { |
|
128 | + $limit = $vendorsNumber; |
|
129 | + } else { |
|
130 | + if ($vendorsNumber == $offset) { |
|
131 | + return $allVendors['vendors'][$offset]->{'vendor_id'}; |
|
132 | + } else { |
|
133 | + echo 'The vendors numbers are less than offset'; |
|
134 | + |
|
135 | + return null; |
|
136 | + } |
|
137 | + } |
|
138 | + } |
|
139 | + |
|
140 | + $randNumber = rand($offset, $limit); |
|
141 | + |
|
142 | + return $allVendors['vendors'][$randNumber]['id']; |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Register telematics member |
|
147 | + * @param TelematicsVendorParameters $params contains: |
|
148 | + * @param integer member_id : member ID |
|
149 | + * @param string api_key : API key |
|
150 | + * @return array from a TelematicsRegisterMemberResponse type object |
|
151 | + * @throws \Route4Me\Exception\ApiError |
|
152 | + */ |
|
153 | + public static function RegisterTelematicsMember($params) |
|
154 | + { |
|
155 | + Route4Me::setBaseUrl(Endpoint::BASE_URL); |
|
156 | + |
|
157 | + $allQueryFields = ['member_id', 'api_key']; |
|
158 | + |
|
159 | + $vendors = Route4Me::makeRequst([ |
|
160 | + 'url' => Endpoint::TELEMATICS_REGISTER_MEMBER, |
|
161 | + 'method' => 'GET', |
|
162 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
163 | + ]); |
|
164 | + |
|
165 | + return $vendors; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Get a vendor by ID |
|
170 | + * @param string $vendorId |
|
171 | + * @return TelematicsVendor type object |
|
172 | + */ |
|
173 | + public static function getVendorById($vendorId) |
|
174 | + { |
|
175 | + if ($vendorId!=null) { |
|
176 | + return self::GetTelematicsVendors($vendorId); |
|
177 | + } else { |
|
178 | + return null; |
|
179 | + } |
|
180 | + } |
|
181 | 181 | |
182 | 182 | } |
@@ -11,72 +11,72 @@ |
||
11 | 11 | */ |
12 | 12 | class TelematicsVendors extends Common |
13 | 13 | { |
14 | - /** |
|
15 | - * Unique ID of a telematics vendor. |
|
16 | - * @var type string |
|
17 | - */ |
|
18 | - public $id; |
|
14 | + /** |
|
15 | + * Unique ID of a telematics vendor. |
|
16 | + * @var type string |
|
17 | + */ |
|
18 | + public $id; |
|
19 | 19 | |
20 | - /** |
|
21 | - * Vendor name |
|
22 | - * @var type string |
|
23 | - */ |
|
24 | - public $name; |
|
20 | + /** |
|
21 | + * Vendor name |
|
22 | + * @var type string |
|
23 | + */ |
|
24 | + public $name; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Vendor slug |
|
28 | - * @var type string |
|
29 | - */ |
|
30 | - public $slug; |
|
26 | + /** |
|
27 | + * Vendor slug |
|
28 | + * @var type string |
|
29 | + */ |
|
30 | + public $slug; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Vendor description |
|
34 | - * @var type string |
|
35 | - */ |
|
36 | - public $description; |
|
32 | + /** |
|
33 | + * Vendor description |
|
34 | + * @var type string |
|
35 | + */ |
|
36 | + public $description; |
|
37 | 37 | |
38 | - /** |
|
39 | - * URL to the telematics vendor's logo. |
|
40 | - * @var type string |
|
41 | - */ |
|
42 | - public $logo_url; |
|
38 | + /** |
|
39 | + * URL to the telematics vendor's logo. |
|
40 | + * @var type string |
|
41 | + */ |
|
42 | + public $logo_url; |
|
43 | 43 | |
44 | - /** |
|
45 | - * Website URL of a telematics vendor. |
|
46 | - * @var type string |
|
47 | - */ |
|
48 | - public $website_url; |
|
44 | + /** |
|
45 | + * Website URL of a telematics vendor. |
|
46 | + * @var type string |
|
47 | + */ |
|
48 | + public $website_url; |
|
49 | 49 | |
50 | - /** |
|
51 | - * API URL of a telematics vendor. |
|
52 | - * @var type string |
|
53 | - */ |
|
54 | - public $api_docs_url; |
|
50 | + /** |
|
51 | + * API URL of a telematics vendor. |
|
52 | + * @var type string |
|
53 | + */ |
|
54 | + public $api_docs_url; |
|
55 | 55 | |
56 | - /** |
|
57 | - * If 1, the vendor is integrated in Route4Me |
|
58 | - * @var type string |
|
59 | - */ |
|
60 | - public $is_integrated; |
|
56 | + /** |
|
57 | + * If 1, the vendor is integrated in Route4Me |
|
58 | + * @var type string |
|
59 | + */ |
|
60 | + public $is_integrated; |
|
61 | 61 | |
62 | - /** |
|
63 | - * Vendors size. |
|
64 | - * <para>Accepted values:</para> |
|
65 | - * <para>global, regional, local. </para> |
|
66 | - * @var type string |
|
67 | - */ |
|
68 | - public $size; |
|
62 | + /** |
|
63 | + * Vendors size. |
|
64 | + * <para>Accepted values:</para> |
|
65 | + * <para>global, regional, local. </para> |
|
66 | + * @var type string |
|
67 | + */ |
|
68 | + public $size; |
|
69 | 69 | |
70 | - public static function fromArray(array $params) |
|
71 | - { |
|
72 | - $vendorsParameters = new self(); |
|
70 | + public static function fromArray(array $params) |
|
71 | + { |
|
72 | + $vendorsParameters = new self(); |
|
73 | 73 | |
74 | - foreach ($params as $key => $value) { |
|
75 | - if (property_exists($vendorsParameters, $key)) { |
|
76 | - $vendorsParameters->{$key} = $value; |
|
77 | - } |
|
78 | - } |
|
74 | + foreach ($params as $key => $value) { |
|
75 | + if (property_exists($vendorsParameters, $key)) { |
|
76 | + $vendorsParameters->{$key} = $value; |
|
77 | + } |
|
78 | + } |
|
79 | 79 | |
80 | - return $vendorsParameters; |
|
81 | - } |
|
80 | + return $vendorsParameters; |
|
81 | + } |
|
82 | 82 | } |