@@ -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,157 +193,157 @@ 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 | - $query = null; |
|
201 | - $body = null; |
|
202 | - |
|
203 | - if (is_array($params)) { |
|
204 | - if (isset($params['optimization_problem_id']) || isset($params['parameters'])) { |
|
205 | - $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
|
206 | - } |
|
207 | - |
|
208 | - if ((isset($params['addresses']) && sizeof($params['addresses']) > 0) |
|
209 | - || (isset($params['parameters']) && sizeof($params['parameters']) > 0) |
|
210 | - ) { |
|
211 | - $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
|
212 | - } |
|
213 | - } else { |
|
214 | - if (isset($params->optimization_problem_id) || isset($params->parameters)) { |
|
215 | - $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
|
216 | - } |
|
217 | - |
|
218 | - if ((isset($params->addresses) && sizeof($params->addresses) > 0) |
|
219 | - || (isset($params->parameters) && sizeof($params->parameters) > 0) |
|
220 | - ) { |
|
221 | - $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
|
222 | - } |
|
223 | - } |
|
224 | - |
|
225 | - $optimize = Route4Me::makeRequst([ |
|
226 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
227 | - 'method' => 'PUT', |
|
228 | - 'query' => $query, |
|
229 | - 'body' => $body, |
|
230 | - ]); |
|
231 | - |
|
232 | - return $optimize; |
|
233 | - } |
|
234 | - |
|
235 | - public function getOptimizationId() |
|
236 | - { |
|
237 | - return $this->optimization_problem_id; |
|
238 | - } |
|
239 | - |
|
240 | - public function getRoutes() |
|
241 | - { |
|
242 | - return $this->routes; |
|
243 | - } |
|
244 | - |
|
245 | - public function getRandomOptimizationId($offset, $limit) |
|
246 | - { |
|
247 | - $optimizations = self::get(['offset' => $offset, 'limit' => $limit]); |
|
248 | - |
|
249 | - $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
250 | - |
|
251 | - if (!isset($rOptimization->optimization_problem_id)) { |
|
252 | - if (sizeof($optimizations) > 9) { |
|
253 | - $this->getRandomOptimizationId($offset, $limit); |
|
254 | - } else { |
|
255 | - return null; |
|
256 | - } |
|
257 | - } |
|
258 | - |
|
259 | - return $rOptimization->optimization_problem_id; |
|
260 | - } |
|
261 | - |
|
262 | - public function getAddresses($opt_id) |
|
263 | - { |
|
264 | - if (null == $opt_id) { |
|
265 | - return null; |
|
266 | - } |
|
267 | - |
|
268 | - $params = ['optimization_problem_id' => $opt_id]; |
|
269 | - |
|
270 | - $optimization = (array) $this->get($params); |
|
271 | - |
|
272 | - $addresses = $optimization['addresses']; |
|
273 | - |
|
274 | - return $addresses; |
|
275 | - } |
|
276 | - |
|
277 | - public function getRandomAddressFromOptimization($opt_id) |
|
278 | - { |
|
279 | - $addresses = (array) $this->getAddresses($opt_id); |
|
280 | - |
|
281 | - if (null == $addresses) { |
|
282 | - echo 'There are no addresses in this optimization!.. Try again.'; |
|
283 | - |
|
284 | - return null; |
|
285 | - } |
|
286 | - |
|
287 | - $num = rand(0, sizeof($addresses) - 1); |
|
288 | - |
|
289 | - $rAddress = $addresses[$num]; |
|
290 | - |
|
291 | - return $rAddress; |
|
292 | - } |
|
293 | - |
|
294 | - public function removeAddress($params) |
|
295 | - { |
|
296 | - $allQueryFields = ['optimization_problem_id', 'route_destination_id']; |
|
297 | - |
|
298 | - $response = Route4Me::makeRequst([ |
|
299 | - 'url' => Endpoint::ADDRESS_V4, |
|
300 | - 'method' => 'DELETE', |
|
301 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
302 | - ]); |
|
303 | - |
|
304 | - return $response; |
|
305 | - } |
|
306 | - |
|
307 | - public function removeOptimization($params) |
|
308 | - { |
|
309 | - $allQueryFields = ['redirect']; |
|
310 | - $allBodyFields = ['optimization_problem_ids']; |
|
311 | - |
|
312 | - $response = Route4Me::makeRequst([ |
|
313 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
314 | - 'method' => 'DELETE', |
|
315 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
316 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
317 | - ]); |
|
318 | - |
|
319 | - return $response; |
|
320 | - } |
|
321 | - |
|
322 | - public function getHybridOptimization($params) |
|
323 | - { |
|
324 | - $allQueryFields = ['target_date_string', 'timezone_offset_minutes']; |
|
325 | - |
|
326 | - $optimize = Route4Me::makeRequst([ |
|
327 | - 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
328 | - 'method' => 'GET', |
|
329 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
330 | - ]); |
|
196 | + public static function update($params) |
|
197 | + { |
|
198 | + $allQueryFields = ['optimization_problem_id', 'reoptimize']; |
|
199 | + $allBodyFields = ['addresses', 'parameters']; |
|
200 | + $query = null; |
|
201 | + $body = null; |
|
202 | + |
|
203 | + if (is_array($params)) { |
|
204 | + if (isset($params['optimization_problem_id']) || isset($params['parameters'])) { |
|
205 | + $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
|
206 | + } |
|
207 | + |
|
208 | + if ((isset($params['addresses']) && sizeof($params['addresses']) > 0) |
|
209 | + || (isset($params['parameters']) && sizeof($params['parameters']) > 0) |
|
210 | + ) { |
|
211 | + $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
|
212 | + } |
|
213 | + } else { |
|
214 | + if (isset($params->optimization_problem_id) || isset($params->parameters)) { |
|
215 | + $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
|
216 | + } |
|
217 | + |
|
218 | + if ((isset($params->addresses) && sizeof($params->addresses) > 0) |
|
219 | + || (isset($params->parameters) && sizeof($params->parameters) > 0) |
|
220 | + ) { |
|
221 | + $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
|
222 | + } |
|
223 | + } |
|
224 | + |
|
225 | + $optimize = Route4Me::makeRequst([ |
|
226 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
227 | + 'method' => 'PUT', |
|
228 | + 'query' => $query, |
|
229 | + 'body' => $body, |
|
230 | + ]); |
|
231 | + |
|
232 | + return $optimize; |
|
233 | + } |
|
234 | + |
|
235 | + public function getOptimizationId() |
|
236 | + { |
|
237 | + return $this->optimization_problem_id; |
|
238 | + } |
|
239 | + |
|
240 | + public function getRoutes() |
|
241 | + { |
|
242 | + return $this->routes; |
|
243 | + } |
|
244 | + |
|
245 | + public function getRandomOptimizationId($offset, $limit) |
|
246 | + { |
|
247 | + $optimizations = self::get(['offset' => $offset, 'limit' => $limit]); |
|
248 | + |
|
249 | + $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
250 | + |
|
251 | + if (!isset($rOptimization->optimization_problem_id)) { |
|
252 | + if (sizeof($optimizations) > 9) { |
|
253 | + $this->getRandomOptimizationId($offset, $limit); |
|
254 | + } else { |
|
255 | + return null; |
|
256 | + } |
|
257 | + } |
|
258 | + |
|
259 | + return $rOptimization->optimization_problem_id; |
|
260 | + } |
|
261 | + |
|
262 | + public function getAddresses($opt_id) |
|
263 | + { |
|
264 | + if (null == $opt_id) { |
|
265 | + return null; |
|
266 | + } |
|
267 | + |
|
268 | + $params = ['optimization_problem_id' => $opt_id]; |
|
269 | + |
|
270 | + $optimization = (array) $this->get($params); |
|
271 | + |
|
272 | + $addresses = $optimization['addresses']; |
|
273 | + |
|
274 | + return $addresses; |
|
275 | + } |
|
276 | + |
|
277 | + public function getRandomAddressFromOptimization($opt_id) |
|
278 | + { |
|
279 | + $addresses = (array) $this->getAddresses($opt_id); |
|
280 | + |
|
281 | + if (null == $addresses) { |
|
282 | + echo 'There are no addresses in this optimization!.. Try again.'; |
|
283 | + |
|
284 | + return null; |
|
285 | + } |
|
286 | + |
|
287 | + $num = rand(0, sizeof($addresses) - 1); |
|
288 | + |
|
289 | + $rAddress = $addresses[$num]; |
|
290 | + |
|
291 | + return $rAddress; |
|
292 | + } |
|
293 | + |
|
294 | + public function removeAddress($params) |
|
295 | + { |
|
296 | + $allQueryFields = ['optimization_problem_id', 'route_destination_id']; |
|
297 | + |
|
298 | + $response = Route4Me::makeRequst([ |
|
299 | + 'url' => Endpoint::ADDRESS_V4, |
|
300 | + 'method' => 'DELETE', |
|
301 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
302 | + ]); |
|
303 | + |
|
304 | + return $response; |
|
305 | + } |
|
306 | + |
|
307 | + public function removeOptimization($params) |
|
308 | + { |
|
309 | + $allQueryFields = ['redirect']; |
|
310 | + $allBodyFields = ['optimization_problem_ids']; |
|
311 | + |
|
312 | + $response = Route4Me::makeRequst([ |
|
313 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
314 | + 'method' => 'DELETE', |
|
315 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
316 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
317 | + ]); |
|
318 | + |
|
319 | + return $response; |
|
320 | + } |
|
321 | + |
|
322 | + public function getHybridOptimization($params) |
|
323 | + { |
|
324 | + $allQueryFields = ['target_date_string', 'timezone_offset_minutes']; |
|
325 | + |
|
326 | + $optimize = Route4Me::makeRequst([ |
|
327 | + 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
328 | + 'method' => 'GET', |
|
329 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
330 | + ]); |
|
331 | 331 | |
332 | - return $optimize; |
|
333 | - } |
|
332 | + return $optimize; |
|
333 | + } |
|
334 | 334 | |
335 | - public function addDepotsToHybrid($params) |
|
336 | - { |
|
337 | - $allQueryFields = ['optimization_problem_id']; |
|
338 | - $allBodyFields = ['optimization_problem_id', 'delete_old_depots', 'new_depots']; |
|
335 | + public function addDepotsToHybrid($params) |
|
336 | + { |
|
337 | + $allQueryFields = ['optimization_problem_id']; |
|
338 | + $allBodyFields = ['optimization_problem_id', 'delete_old_depots', 'new_depots']; |
|
339 | 339 | |
340 | - $depots = Route4Me::makeRequst([ |
|
341 | - 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
342 | - 'method' => 'POST', |
|
343 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
344 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
345 | - ]); |
|
340 | + $depots = Route4Me::makeRequst([ |
|
341 | + 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
342 | + 'method' => 'POST', |
|
343 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
344 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
345 | + ]); |
|
346 | 346 | |
347 | - return $depots; |
|
348 | - } |
|
347 | + return $depots; |
|
348 | + } |
|
349 | 349 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | public static function get($params) |
157 | 157 | { |
158 | 158 | $allQueryFields = ['state', 'limit', 'format', 'offset', |
159 | - 'optimization_problem_id', 'wait_for_final_state','start_date','end_date', ]; |
|
159 | + 'optimization_problem_id', 'wait_for_final_state', 'start_date', 'end_date', ]; |
|
160 | 160 | |
161 | 161 | $result = Route4Me::makeRequst([ |
162 | 162 | 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
@@ -205,8 +205,8 @@ discard block |
||
205 | 205 | $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
206 | 206 | } |
207 | 207 | |
208 | - if ((isset($params['addresses']) && sizeof($params['addresses']) > 0) |
|
209 | - || (isset($params['parameters']) && sizeof($params['parameters']) > 0) |
|
208 | + if ((isset($params['addresses']) && sizeof($params['addresses'])>0) |
|
209 | + || (isset($params['parameters']) && sizeof($params['parameters'])>0) |
|
210 | 210 | ) { |
211 | 211 | $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
212 | 212 | } |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | $query = Route4Me::generateRequestParameters($allQueryFields, $params); |
216 | 216 | } |
217 | 217 | |
218 | - if ((isset($params->addresses) && sizeof($params->addresses) > 0) |
|
219 | - || (isset($params->parameters) && sizeof($params->parameters) > 0) |
|
218 | + if ((isset($params->addresses) && sizeof($params->addresses)>0) |
|
219 | + || (isset($params->parameters) && sizeof($params->parameters)>0) |
|
220 | 220 | ) { |
221 | 221 | $body = Route4Me::generateRequestParameters($allBodyFields, $params); |
222 | 222 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
250 | 250 | |
251 | 251 | if (!isset($rOptimization->optimization_problem_id)) { |
252 | - if (sizeof($optimizations) > 9) { |
|
252 | + if (sizeof($optimizations)>9) { |
|
253 | 253 | $this->getRandomOptimizationId($offset, $limit); |
254 | 254 | } else { |
255 | 255 | return null; |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | |
262 | 262 | public function getAddresses($opt_id) |
263 | 263 | { |
264 | - if (null == $opt_id) { |
|
264 | + if (null==$opt_id) { |
|
265 | 265 | return null; |
266 | 266 | } |
267 | 267 | |
268 | 268 | $params = ['optimization_problem_id' => $opt_id]; |
269 | 269 | |
270 | - $optimization = (array) $this->get($params); |
|
270 | + $optimization = (array)$this->get($params); |
|
271 | 271 | |
272 | 272 | $addresses = $optimization['addresses']; |
273 | 273 | |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | |
277 | 277 | public function getRandomAddressFromOptimization($opt_id) |
278 | 278 | { |
279 | - $addresses = (array) $this->getAddresses($opt_id); |
|
279 | + $addresses = (array)$this->getAddresses($opt_id); |
|
280 | 280 | |
281 | - if (null == $addresses) { |
|
281 | + if (null==$addresses) { |
|
282 | 282 | echo 'There are no addresses in this optimization!.. Try again.'; |
283 | 283 | |
284 | 284 | return null; |
@@ -12,184 +12,184 @@ |
||
12 | 12 | |
13 | 13 | final class TeamManagementUnitTests extends \PHPUnit\Framework\TestCase |
14 | 14 | { |
15 | - public static ?int $member_id = null; |
|
16 | - public static ?int $owner_member_id = null; |
|
17 | - |
|
18 | - public static function setUpBeforeClass() : void |
|
19 | - { |
|
20 | - Route4Me::setApiKey(Constants::API_KEY); |
|
21 | - } |
|
22 | - |
|
23 | - public function testOwnerMemberMustExists() : void |
|
24 | - { |
|
25 | - $member = new Member(); |
|
26 | - $res_members = $member->getUsers(); |
|
15 | + public static ?int $member_id = null; |
|
16 | + public static ?int $owner_member_id = null; |
|
17 | + |
|
18 | + public static function setUpBeforeClass() : void |
|
19 | + { |
|
20 | + Route4Me::setApiKey(Constants::API_KEY); |
|
21 | + } |
|
22 | + |
|
23 | + public function testOwnerMemberMustExists() : void |
|
24 | + { |
|
25 | + $member = new Member(); |
|
26 | + $res_members = $member->getUsers(); |
|
27 | 27 | |
28 | - if (is_array($res_members) && isset($res_members['results'])) { |
|
29 | - foreach ($res_members['results'] as $key => $value) { |
|
30 | - if ($value['OWNER_MEMBER_ID'] == 0) { |
|
31 | - self::$owner_member_id = $value['member_id']; |
|
32 | - break; |
|
33 | - } |
|
34 | - } |
|
35 | - } |
|
36 | - $this->assertNotNull(self::$owner_member_id); |
|
37 | - } |
|
38 | - |
|
39 | - public function testOptionCanBeCreateEmpty() : void |
|
40 | - { |
|
41 | - $this->assertInstanceOf(Option::class, new Option()); |
|
42 | - } |
|
43 | - |
|
44 | - public function testOptionCanBeCreateFromArray() : void |
|
45 | - { |
|
46 | - $this->assertInstanceOf(Option::class, new Option([ |
|
47 | - 'value' => '1', |
|
48 | - 'title' => '2' |
|
49 | - ])); |
|
50 | - } |
|
51 | - |
|
52 | - public function testPermissionCanBeCreateEmpty() : void |
|
53 | - { |
|
54 | - $this->assertInstanceOf(Permission::class, new Permission()); |
|
55 | - } |
|
56 | - |
|
57 | - public function testPermissionCanBeCreateFromArray() : void |
|
58 | - { |
|
59 | - $this->assertInstanceOf(Permission::class, new Permission([ |
|
60 | - 'id' => '1', |
|
61 | - 'options' => [ |
|
62 | - [ |
|
63 | - 'value' => '2', |
|
64 | - 'title' => '3' |
|
65 | - ], [ |
|
66 | - 'value' => '4', |
|
67 | - 'title' => '5' |
|
68 | - ] |
|
69 | - ] |
|
70 | - ])); |
|
71 | - } |
|
72 | - |
|
73 | - public function testResponseTeamCanBeCreateEmpty() : void |
|
74 | - { |
|
75 | - $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam()); |
|
76 | - } |
|
77 | - |
|
78 | - public function testResponseTeamCanBeCreateFromArray() : void |
|
79 | - { |
|
80 | - $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam([ |
|
81 | - 'member_id' => '1', |
|
82 | - 'member_first_name' => '2' |
|
83 | - ])); |
|
84 | - } |
|
85 | - |
|
86 | - public function testTeamManagementCanBeCreateEmpty() : void |
|
87 | - { |
|
88 | - $this->assertInstanceOf(TeamManagement::class, new TeamManagement()); |
|
89 | - } |
|
90 | - |
|
91 | - public function testCreateMustReturnResponseTeam() : void |
|
92 | - { |
|
93 | - $team_mng = new TeamManagement(); |
|
94 | - $res_team = $team_mng->create([ |
|
95 | - 'new_password' => '12345&Qwerty', |
|
96 | - 'member_first_name' => 'Tusha I', |
|
97 | - 'member_last_name' => 'Pupkindzes', |
|
98 | - 'member_email' => '[email protected]', |
|
99 | - 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
100 | - 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
101 | - ]); |
|
102 | - |
|
103 | - $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
104 | - $this->assertNotNull($res_team->member_id); |
|
105 | - $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
28 | + if (is_array($res_members) && isset($res_members['results'])) { |
|
29 | + foreach ($res_members['results'] as $key => $value) { |
|
30 | + if ($value['OWNER_MEMBER_ID'] == 0) { |
|
31 | + self::$owner_member_id = $value['member_id']; |
|
32 | + break; |
|
33 | + } |
|
34 | + } |
|
35 | + } |
|
36 | + $this->assertNotNull(self::$owner_member_id); |
|
37 | + } |
|
38 | + |
|
39 | + public function testOptionCanBeCreateEmpty() : void |
|
40 | + { |
|
41 | + $this->assertInstanceOf(Option::class, new Option()); |
|
42 | + } |
|
43 | + |
|
44 | + public function testOptionCanBeCreateFromArray() : void |
|
45 | + { |
|
46 | + $this->assertInstanceOf(Option::class, new Option([ |
|
47 | + 'value' => '1', |
|
48 | + 'title' => '2' |
|
49 | + ])); |
|
50 | + } |
|
51 | + |
|
52 | + public function testPermissionCanBeCreateEmpty() : void |
|
53 | + { |
|
54 | + $this->assertInstanceOf(Permission::class, new Permission()); |
|
55 | + } |
|
56 | + |
|
57 | + public function testPermissionCanBeCreateFromArray() : void |
|
58 | + { |
|
59 | + $this->assertInstanceOf(Permission::class, new Permission([ |
|
60 | + 'id' => '1', |
|
61 | + 'options' => [ |
|
62 | + [ |
|
63 | + 'value' => '2', |
|
64 | + 'title' => '3' |
|
65 | + ], [ |
|
66 | + 'value' => '4', |
|
67 | + 'title' => '5' |
|
68 | + ] |
|
69 | + ] |
|
70 | + ])); |
|
71 | + } |
|
72 | + |
|
73 | + public function testResponseTeamCanBeCreateEmpty() : void |
|
74 | + { |
|
75 | + $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam()); |
|
76 | + } |
|
77 | + |
|
78 | + public function testResponseTeamCanBeCreateFromArray() : void |
|
79 | + { |
|
80 | + $this->assertInstanceOf(ResponseTeam::class, new ResponseTeam([ |
|
81 | + 'member_id' => '1', |
|
82 | + 'member_first_name' => '2' |
|
83 | + ])); |
|
84 | + } |
|
85 | + |
|
86 | + public function testTeamManagementCanBeCreateEmpty() : void |
|
87 | + { |
|
88 | + $this->assertInstanceOf(TeamManagement::class, new TeamManagement()); |
|
89 | + } |
|
90 | + |
|
91 | + public function testCreateMustReturnResponseTeam() : void |
|
92 | + { |
|
93 | + $team_mng = new TeamManagement(); |
|
94 | + $res_team = $team_mng->create([ |
|
95 | + 'new_password' => '12345&Qwerty', |
|
96 | + 'member_first_name' => 'Tusha I', |
|
97 | + 'member_last_name' => 'Pupkindzes', |
|
98 | + 'member_email' => '[email protected]', |
|
99 | + 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
100 | + 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
101 | + ]); |
|
102 | + |
|
103 | + $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
104 | + $this->assertNotNull($res_team->member_id); |
|
105 | + $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
106 | 106 | |
107 | - self::$member_id = $res_team->member_id; |
|
108 | - } |
|
109 | - |
|
110 | - public function testGetUserMustReturnResponseTeam() : void |
|
111 | - { |
|
112 | - $team_mng = new TeamManagement(); |
|
113 | - $res_team = $team_mng->getUser(self::$member_id); |
|
114 | - |
|
115 | - $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
116 | - $this->assertNotNull($res_team->member_id); |
|
117 | - $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
118 | - } |
|
119 | - |
|
120 | - public function testGetUsersMustReturnArrayOfResponseTeam() : void |
|
121 | - { |
|
122 | - $team_mng = new TeamManagement(); |
|
123 | - $result = $team_mng->getUsers(); |
|
124 | - |
|
125 | - $this->assertIsArray($result); |
|
126 | - if (count($result) > 0) { |
|
127 | - $this->assertInstanceOf(ResponseTeam::class, $result[0]); |
|
128 | - } |
|
129 | - } |
|
130 | - |
|
131 | - public function testUpdateMustReturnUpdatedResponseTeam() : void |
|
132 | - { |
|
133 | - $team_mng = new TeamManagement(); |
|
134 | - $res_team = $team_mng->update(self::$member_id, [ |
|
135 | - 'HIDE_ROUTED_ADDRESSES' => true, |
|
136 | - 'member_type' => 'SUB_ACCOUNT_DISPATCHER' |
|
137 | - ]); |
|
138 | - |
|
139 | - $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
140 | - $this->assertEquals($res_team->HIDE_ROUTED_ADDRESSES, 1); |
|
141 | - $this->assertEquals($res_team->member_type, 'SUB_ACCOUNT_DISPATCHER'); |
|
142 | - } |
|
143 | - |
|
144 | - public function testDeleteMustReturnDeletedResponseTeam() : void |
|
145 | - { |
|
146 | - $team_mng = new TeamManagement(); |
|
147 | - $res_team = $team_mng->delete(self::$member_id); |
|
148 | - |
|
149 | - $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
150 | - $this->assertNotNull($res_team->member_id); |
|
151 | - $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
152 | - } |
|
153 | - |
|
154 | - public function testBulkInsertMustAddNewMembers() : void |
|
155 | - { |
|
156 | - $team_mng = new TeamManagement(); |
|
157 | - $result = $team_mng->bulkInsert([ |
|
158 | - [ |
|
159 | - 'new_password' => '12345&Qwerty', |
|
160 | - 'member_first_name' => 'Tusha I', |
|
161 | - 'member_last_name' => 'Pupkindzes', |
|
162 | - 'member_email' => '[email protected]', |
|
163 | - 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
164 | - 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
165 | - ], [ |
|
166 | - 'new_password' => '12345&Qwerty', |
|
167 | - 'member_first_name' => 'Tusha II', |
|
168 | - 'member_last_name' => 'Pupkindzes', |
|
169 | - 'member_email' => '[email protected]', |
|
170 | - 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
171 | - 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
172 | - ] |
|
173 | - ], [ |
|
174 | - 'conflicts' => 'overwrite' |
|
175 | - ]); |
|
176 | - |
|
177 | - $this->assertIsArray($result); |
|
178 | - } |
|
107 | + self::$member_id = $res_team->member_id; |
|
108 | + } |
|
109 | + |
|
110 | + public function testGetUserMustReturnResponseTeam() : void |
|
111 | + { |
|
112 | + $team_mng = new TeamManagement(); |
|
113 | + $res_team = $team_mng->getUser(self::$member_id); |
|
114 | + |
|
115 | + $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
116 | + $this->assertNotNull($res_team->member_id); |
|
117 | + $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
118 | + } |
|
119 | + |
|
120 | + public function testGetUsersMustReturnArrayOfResponseTeam() : void |
|
121 | + { |
|
122 | + $team_mng = new TeamManagement(); |
|
123 | + $result = $team_mng->getUsers(); |
|
124 | + |
|
125 | + $this->assertIsArray($result); |
|
126 | + if (count($result) > 0) { |
|
127 | + $this->assertInstanceOf(ResponseTeam::class, $result[0]); |
|
128 | + } |
|
129 | + } |
|
130 | + |
|
131 | + public function testUpdateMustReturnUpdatedResponseTeam() : void |
|
132 | + { |
|
133 | + $team_mng = new TeamManagement(); |
|
134 | + $res_team = $team_mng->update(self::$member_id, [ |
|
135 | + 'HIDE_ROUTED_ADDRESSES' => true, |
|
136 | + 'member_type' => 'SUB_ACCOUNT_DISPATCHER' |
|
137 | + ]); |
|
138 | + |
|
139 | + $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
140 | + $this->assertEquals($res_team->HIDE_ROUTED_ADDRESSES, 1); |
|
141 | + $this->assertEquals($res_team->member_type, 'SUB_ACCOUNT_DISPATCHER'); |
|
142 | + } |
|
143 | + |
|
144 | + public function testDeleteMustReturnDeletedResponseTeam() : void |
|
145 | + { |
|
146 | + $team_mng = new TeamManagement(); |
|
147 | + $res_team = $team_mng->delete(self::$member_id); |
|
148 | + |
|
149 | + $this->assertInstanceOf(ResponseTeam::class, $res_team); |
|
150 | + $this->assertNotNull($res_team->member_id); |
|
151 | + $this->assertEquals($res_team->member_first_name, 'Tusha I'); |
|
152 | + } |
|
153 | + |
|
154 | + public function testBulkInsertMustAddNewMembers() : void |
|
155 | + { |
|
156 | + $team_mng = new TeamManagement(); |
|
157 | + $result = $team_mng->bulkInsert([ |
|
158 | + [ |
|
159 | + 'new_password' => '12345&Qwerty', |
|
160 | + 'member_first_name' => 'Tusha I', |
|
161 | + 'member_last_name' => 'Pupkindzes', |
|
162 | + 'member_email' => '[email protected]', |
|
163 | + 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
164 | + 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
165 | + ], [ |
|
166 | + 'new_password' => '12345&Qwerty', |
|
167 | + 'member_first_name' => 'Tusha II', |
|
168 | + 'member_last_name' => 'Pupkindzes', |
|
169 | + 'member_email' => '[email protected]', |
|
170 | + 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
171 | + 'OWNER_MEMBER_ID' => self::$owner_member_id |
|
172 | + ] |
|
173 | + ], [ |
|
174 | + 'conflicts' => 'overwrite' |
|
175 | + ]); |
|
176 | + |
|
177 | + $this->assertIsArray($result); |
|
178 | + } |
|
179 | 179 | |
180 | - public static function tearDownAfterClass() : void |
|
181 | - { |
|
182 | - sleep(5); |
|
183 | - |
|
184 | - $team_mng = new TeamManagement(); |
|
185 | - $result = $team_mng->getUsers(); |
|
186 | - |
|
187 | - if (is_array($result)) { |
|
188 | - foreach ($result as $key => $member) { |
|
189 | - if ($member->member_last_name == 'Pupkindzes') { |
|
190 | - $team_mng->delete($member->member_id); |
|
191 | - } |
|
192 | - } |
|
193 | - } |
|
194 | - } |
|
180 | + public static function tearDownAfterClass() : void |
|
181 | + { |
|
182 | + sleep(5); |
|
183 | + |
|
184 | + $team_mng = new TeamManagement(); |
|
185 | + $result = $team_mng->getUsers(); |
|
186 | + |
|
187 | + if (is_array($result)) { |
|
188 | + foreach ($result as $key => $member) { |
|
189 | + if ($member->member_last_name == 'Pupkindzes') { |
|
190 | + $team_mng->delete($member->member_id); |
|
191 | + } |
|
192 | + } |
|
193 | + } |
|
194 | + } |
|
195 | 195 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | |
28 | 28 | if (is_array($res_members) && isset($res_members['results'])) { |
29 | 29 | foreach ($res_members['results'] as $key => $value) { |
30 | - if ($value['OWNER_MEMBER_ID'] == 0) { |
|
30 | + if ($value['OWNER_MEMBER_ID']==0) { |
|
31 | 31 | self::$owner_member_id = $value['member_id']; |
32 | 32 | break; |
33 | 33 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $result = $team_mng->getUsers(); |
124 | 124 | |
125 | 125 | $this->assertIsArray($result); |
126 | - if (count($result) > 0) { |
|
126 | + if (count($result)>0) { |
|
127 | 127 | $this->assertInstanceOf(ResponseTeam::class, $result[0]); |
128 | 128 | } |
129 | 129 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | if (is_array($result)) { |
188 | 188 | foreach ($result as $key => $member) { |
189 | - if ($member->member_last_name == 'Pupkindzes') { |
|
189 | + if ($member->member_last_name=='Pupkindzes') { |
|
190 | 190 | $team_mng->delete($member->member_id); |
191 | 191 | } |
192 | 192 | } |
@@ -13,13 +13,13 @@ |
||
13 | 13 | */ |
14 | 14 | class Option extends Common |
15 | 15 | { |
16 | - public ?string $value = null; |
|
17 | - public ?string $title = null; |
|
16 | + public ?string $value = null; |
|
17 | + public ?string $title = null; |
|
18 | 18 | |
19 | - public function __construct(?array $params = null) |
|
20 | - { |
|
21 | - if ($params !== null) { |
|
22 | - $this->fillFromArray($params); |
|
23 | - } |
|
24 | - } |
|
19 | + public function __construct(?array $params = null) |
|
20 | + { |
|
21 | + if ($params !== null) { |
|
22 | + $this->fillFromArray($params); |
|
23 | + } |
|
24 | + } |
|
25 | 25 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | public function __construct(?array $params = null) |
37 | 37 | { |
38 | - if ($params !== null) { |
|
38 | + if ($params!==null) { |
|
39 | 39 | $this->fillFromArray($params); |
40 | 40 | } |
41 | 41 | } |
@@ -13,139 +13,139 @@ |
||
13 | 13 | */ |
14 | 14 | class ResponseTeam extends Common |
15 | 15 | { |
16 | - /** |
|
17 | - * The member ID |
|
18 | - */ |
|
19 | - public ?int $member_id = null; |
|
20 | - |
|
21 | - /** |
|
22 | - * The user's account owner ID |
|
23 | - */ |
|
24 | - public ?int $OWNER_MEMBER_ID = null; |
|
25 | - |
|
26 | - /** |
|
27 | - * User's first name |
|
28 | - */ |
|
29 | - public ?string $member_first_name = null; |
|
30 | - |
|
31 | - /** |
|
32 | - * User's last name |
|
33 | - */ |
|
34 | - public ?string $member_last_name = null; |
|
35 | - |
|
36 | - /** |
|
37 | - * User's email |
|
38 | - */ |
|
39 | - public ?string $member_email = null; |
|
40 | - |
|
41 | - /** |
|
42 | - * User's image |
|
43 | - * @example '/uploads/cc6aba1a0e68ea429c51e3f9cb12e1ac/profile_c96135b77f6fc42be64cd98e0c21d341.jpg' |
|
44 | - */ |
|
45 | - public ?string $member_picture = null; |
|
46 | - |
|
47 | - /** |
|
48 | - * Member type. |
|
49 | - * Available values: 'PRIMARY_ACCOUNT', 'SUB_ACCOUNT_ADMIN', 'SUB_ACCOUNT_REGIONAL_MANAGER', |
|
50 | - * 'SUB_ACCOUNT_DISPATCHER', 'SUB_ACCOUNT_PLANNER', "SUB_ACCOUNT_DRIVER' |
|
51 | - * @example 'SUB_ACCOUNT_DISPATCHER' |
|
52 | - */ |
|
53 | - public ?string $member_type = null; |
|
54 | - |
|
55 | - /** |
|
56 | - * If true, the routed addresses will be hidden. |
|
57 | - */ |
|
58 | - public ?bool $HIDE_ROUTED_ADDRESSES = null; |
|
59 | - |
|
60 | - /** |
|
61 | - * If true, the visited addresses will be hidden. |
|
62 | - */ |
|
63 | - public ?bool $HIDE_VISITED_ADDRESSES = null; |
|
64 | - |
|
65 | - /** |
|
66 | - * If true, the nonfuture routes will be hidden. |
|
67 | - */ |
|
68 | - public ?bool $HIDE_NONFUTURE_ROUTES = null; |
|
69 | - |
|
70 | - /** |
|
71 | - * If true, the user has read-only access type. |
|
72 | - */ |
|
73 | - public ?bool $READONLY_USER = null; |
|
74 | - |
|
75 | - /** |
|
76 | - * If true, the global address book contacts are visible in a user account. |
|
77 | - */ |
|
78 | - public ?bool $SHOW_SUSR_ADDR = null; |
|
79 | - |
|
80 | - /** |
|
81 | - * If true, the global orders are visible in a user account. |
|
82 | - */ |
|
83 | - public ?bool $SHOW_SUSR_ORDERS = null; |
|
84 | - |
|
85 | - /** |
|
86 | - * If true, all drivers are visible to the user. |
|
87 | - */ |
|
88 | - public ?bool $SHOW_ALL_DRIVERS = null; |
|
89 | - |
|
90 | - /** |
|
91 | - * If true, all vehicles are visible to the user. |
|
92 | - */ |
|
93 | - public ?bool $SHOW_ALL_VEHICLES = null; |
|
94 | - |
|
95 | - /** |
|
96 | - * Allowed sub-member types in the user's account. |
|
97 | - * String array, available types: 'SUB_ACCOUNT_DRIVER', 'SUB_ACCOUNT_DISPATCHER', |
|
98 | - * 'SUB_ACCOUNT_PLANNER', 'SUB_ACCOUNT_ANALYST', 'SUB_ACCOUNT_ADMIN', 'SUB_ACCOUNT_REGIONAL_MANAGER' |
|
99 | - */ |
|
100 | - public ?array $allowed_submember_types = null; |
|
101 | - |
|
102 | - /** |
|
103 | - * If true, the user can edit the account data. |
|
104 | - */ |
|
105 | - public ?bool $can_edit = null; |
|
106 | - |
|
107 | - /** |
|
108 | - * If true, the user can delete the account data. |
|
109 | - */ |
|
110 | - public ?bool $can_delete = null; |
|
111 | - |
|
112 | - /** |
|
113 | - * The user's custom data. |
|
114 | - * @example ['custom_data_key' => 'custom_data_value'] |
|
115 | - */ |
|
116 | - public ?array $custom_data = null; |
|
117 | - |
|
118 | - /** |
|
119 | - * Optimization profile ID |
|
120 | - * @example '18a6e1c5-0a02-4c58-a2d3-5c842ab550be' |
|
121 | - */ |
|
122 | - public ?string $optimization_profile_id = null; |
|
123 | - |
|
124 | - /** |
|
125 | - * Member type title |
|
126 | - */ |
|
127 | - public ?string $member_type_title = null; |
|
128 | - |
|
129 | - /** |
|
130 | - * User's permissions |
|
131 | - */ |
|
132 | - public ?array $permissions = null; |
|
133 | - |
|
134 | - public function __construct(?array $params = null) |
|
135 | - { |
|
136 | - if ($params !== null) { |
|
137 | - foreach ($this as $key => $value) { |
|
138 | - if (isset($params[$key])) { |
|
139 | - if ($key === 'permissions') { |
|
140 | - $this->{$key} = array(); |
|
141 | - foreach ($params[$key] as $perm_key => $perm_value) { |
|
142 | - array_push($this->{$key}, new Permission($perm_value)); |
|
143 | - } |
|
144 | - } else { |
|
145 | - $this->{$key} = $params[$key]; |
|
146 | - } |
|
147 | - } |
|
148 | - } |
|
149 | - } |
|
150 | - } |
|
16 | + /** |
|
17 | + * The member ID |
|
18 | + */ |
|
19 | + public ?int $member_id = null; |
|
20 | + |
|
21 | + /** |
|
22 | + * The user's account owner ID |
|
23 | + */ |
|
24 | + public ?int $OWNER_MEMBER_ID = null; |
|
25 | + |
|
26 | + /** |
|
27 | + * User's first name |
|
28 | + */ |
|
29 | + public ?string $member_first_name = null; |
|
30 | + |
|
31 | + /** |
|
32 | + * User's last name |
|
33 | + */ |
|
34 | + public ?string $member_last_name = null; |
|
35 | + |
|
36 | + /** |
|
37 | + * User's email |
|
38 | + */ |
|
39 | + public ?string $member_email = null; |
|
40 | + |
|
41 | + /** |
|
42 | + * User's image |
|
43 | + * @example '/uploads/cc6aba1a0e68ea429c51e3f9cb12e1ac/profile_c96135b77f6fc42be64cd98e0c21d341.jpg' |
|
44 | + */ |
|
45 | + public ?string $member_picture = null; |
|
46 | + |
|
47 | + /** |
|
48 | + * Member type. |
|
49 | + * Available values: 'PRIMARY_ACCOUNT', 'SUB_ACCOUNT_ADMIN', 'SUB_ACCOUNT_REGIONAL_MANAGER', |
|
50 | + * 'SUB_ACCOUNT_DISPATCHER', 'SUB_ACCOUNT_PLANNER', "SUB_ACCOUNT_DRIVER' |
|
51 | + * @example 'SUB_ACCOUNT_DISPATCHER' |
|
52 | + */ |
|
53 | + public ?string $member_type = null; |
|
54 | + |
|
55 | + /** |
|
56 | + * If true, the routed addresses will be hidden. |
|
57 | + */ |
|
58 | + public ?bool $HIDE_ROUTED_ADDRESSES = null; |
|
59 | + |
|
60 | + /** |
|
61 | + * If true, the visited addresses will be hidden. |
|
62 | + */ |
|
63 | + public ?bool $HIDE_VISITED_ADDRESSES = null; |
|
64 | + |
|
65 | + /** |
|
66 | + * If true, the nonfuture routes will be hidden. |
|
67 | + */ |
|
68 | + public ?bool $HIDE_NONFUTURE_ROUTES = null; |
|
69 | + |
|
70 | + /** |
|
71 | + * If true, the user has read-only access type. |
|
72 | + */ |
|
73 | + public ?bool $READONLY_USER = null; |
|
74 | + |
|
75 | + /** |
|
76 | + * If true, the global address book contacts are visible in a user account. |
|
77 | + */ |
|
78 | + public ?bool $SHOW_SUSR_ADDR = null; |
|
79 | + |
|
80 | + /** |
|
81 | + * If true, the global orders are visible in a user account. |
|
82 | + */ |
|
83 | + public ?bool $SHOW_SUSR_ORDERS = null; |
|
84 | + |
|
85 | + /** |
|
86 | + * If true, all drivers are visible to the user. |
|
87 | + */ |
|
88 | + public ?bool $SHOW_ALL_DRIVERS = null; |
|
89 | + |
|
90 | + /** |
|
91 | + * If true, all vehicles are visible to the user. |
|
92 | + */ |
|
93 | + public ?bool $SHOW_ALL_VEHICLES = null; |
|
94 | + |
|
95 | + /** |
|
96 | + * Allowed sub-member types in the user's account. |
|
97 | + * String array, available types: 'SUB_ACCOUNT_DRIVER', 'SUB_ACCOUNT_DISPATCHER', |
|
98 | + * 'SUB_ACCOUNT_PLANNER', 'SUB_ACCOUNT_ANALYST', 'SUB_ACCOUNT_ADMIN', 'SUB_ACCOUNT_REGIONAL_MANAGER' |
|
99 | + */ |
|
100 | + public ?array $allowed_submember_types = null; |
|
101 | + |
|
102 | + /** |
|
103 | + * If true, the user can edit the account data. |
|
104 | + */ |
|
105 | + public ?bool $can_edit = null; |
|
106 | + |
|
107 | + /** |
|
108 | + * If true, the user can delete the account data. |
|
109 | + */ |
|
110 | + public ?bool $can_delete = null; |
|
111 | + |
|
112 | + /** |
|
113 | + * The user's custom data. |
|
114 | + * @example ['custom_data_key' => 'custom_data_value'] |
|
115 | + */ |
|
116 | + public ?array $custom_data = null; |
|
117 | + |
|
118 | + /** |
|
119 | + * Optimization profile ID |
|
120 | + * @example '18a6e1c5-0a02-4c58-a2d3-5c842ab550be' |
|
121 | + */ |
|
122 | + public ?string $optimization_profile_id = null; |
|
123 | + |
|
124 | + /** |
|
125 | + * Member type title |
|
126 | + */ |
|
127 | + public ?string $member_type_title = null; |
|
128 | + |
|
129 | + /** |
|
130 | + * User's permissions |
|
131 | + */ |
|
132 | + public ?array $permissions = null; |
|
133 | + |
|
134 | + public function __construct(?array $params = null) |
|
135 | + { |
|
136 | + if ($params !== null) { |
|
137 | + foreach ($this as $key => $value) { |
|
138 | + if (isset($params[$key])) { |
|
139 | + if ($key === 'permissions') { |
|
140 | + $this->{$key} = array(); |
|
141 | + foreach ($params[$key] as $perm_key => $perm_value) { |
|
142 | + array_push($this->{$key}, new Permission($perm_value)); |
|
143 | + } |
|
144 | + } else { |
|
145 | + $this->{$key} = $params[$key]; |
|
146 | + } |
|
147 | + } |
|
148 | + } |
|
149 | + } |
|
150 | + } |
|
151 | 151 | } |
@@ -133,10 +133,10 @@ |
||
133 | 133 | |
134 | 134 | public function __construct(?array $params = null) |
135 | 135 | { |
136 | - if ($params !== null) { |
|
136 | + if ($params!==null) { |
|
137 | 137 | foreach ($this as $key => $value) { |
138 | 138 | if (isset($params[$key])) { |
139 | - if ($key === 'permissions') { |
|
139 | + if ($key==='permissions') { |
|
140 | 140 | $this->{$key} = array(); |
141 | 141 | foreach ($params[$key] as $perm_key => $perm_value) { |
142 | 142 | array_push($this->{$key}, new Permission($perm_value)); |
@@ -14,35 +14,35 @@ |
||
14 | 14 | */ |
15 | 15 | class Permission extends Common |
16 | 16 | { |
17 | - public ?string $id = null; |
|
18 | - public ?string $title = null; |
|
19 | - public ?string $type = null; |
|
17 | + public ?string $id = null; |
|
18 | + public ?string $title = null; |
|
19 | + public ?string $type = null; |
|
20 | 20 | |
21 | - /** |
|
22 | - * Array of Options |
|
23 | - */ |
|
24 | - public ?array $options = null; |
|
21 | + /** |
|
22 | + * Array of Options |
|
23 | + */ |
|
24 | + public ?array $options = null; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Array of strings |
|
28 | - */ |
|
29 | - public ?array $value = null; |
|
26 | + /** |
|
27 | + * Array of strings |
|
28 | + */ |
|
29 | + public ?array $value = null; |
|
30 | 30 | |
31 | - public function __construct(?array $params = null) |
|
32 | - { |
|
33 | - if ($params !== null) { |
|
34 | - foreach ($this as $key => $value) { |
|
35 | - if (isset($params[$key])) { |
|
36 | - if ($key === 'options') { |
|
37 | - $this->{$key} = array(); |
|
38 | - foreach ($params[$key] as $opt_key => $opt_value) { |
|
39 | - array_push($this->{$key}, new Option($opt_value)); |
|
40 | - } |
|
41 | - } else { |
|
42 | - $this->{$key} = $params[$key]; |
|
43 | - } |
|
44 | - } |
|
45 | - } |
|
46 | - } |
|
47 | - } |
|
31 | + public function __construct(?array $params = null) |
|
32 | + { |
|
33 | + if ($params !== null) { |
|
34 | + foreach ($this as $key => $value) { |
|
35 | + if (isset($params[$key])) { |
|
36 | + if ($key === 'options') { |
|
37 | + $this->{$key} = array(); |
|
38 | + foreach ($params[$key] as $opt_key => $opt_value) { |
|
39 | + array_push($this->{$key}, new Option($opt_value)); |
|
40 | + } |
|
41 | + } else { |
|
42 | + $this->{$key} = $params[$key]; |
|
43 | + } |
|
44 | + } |
|
45 | + } |
|
46 | + } |
|
47 | + } |
|
48 | 48 | } |
@@ -30,10 +30,10 @@ |
||
30 | 30 | |
31 | 31 | public function __construct(?array $params = null) |
32 | 32 | { |
33 | - if ($params !== null) { |
|
33 | + if ($params!==null) { |
|
34 | 34 | foreach ($this as $key => $value) { |
35 | 35 | if (isset($params[$key])) { |
36 | - if ($key === 'options') { |
|
36 | + if ($key==='options') { |
|
37 | 37 | $this->{$key} = array(); |
38 | 38 | foreach ($params[$key] as $opt_key => $opt_value) { |
39 | 39 | array_push($this->{$key}, new Option($opt_value)); |
@@ -17,277 +17,277 @@ |
||
17 | 17 | */ |
18 | 18 | class TeamManagement extends Common |
19 | 19 | { |
20 | - public function __construct() |
|
21 | - { |
|
22 | - Route4Me::setBaseUrl(''); |
|
23 | - } |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + Route4Me::setBaseUrl(''); |
|
23 | + } |
|
24 | 24 | |
25 | - /** |
|
26 | - * Add a new sub-user to the Member account by sending the corresponding |
|
27 | - * body payload with the sub-users' parameters. |
|
28 | - * |
|
29 | - * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
30 | - * |
|
31 | - * @param array $params - Sub-user properties. |
|
32 | - * string new_password - Password. |
|
33 | - * string new_member_picture - Member picture. |
|
34 | - * string member_first_name - First name. |
|
35 | - * string member_last_name - Last name. |
|
36 | - * string member_email - E-mail. |
|
37 | - * string member_company - Company. |
|
38 | - * string member_type - Member type. |
|
39 | - * int OWNER_MEMBER_ID - Owner member ID. |
|
40 | - * string member_phone - Phone. |
|
41 | - * string date_of_birth - Date of birth. |
|
42 | - * int user_reg_state_id - User state ID. |
|
43 | - * int user_reg_country_id - User country ID. |
|
44 | - * float DriverHourlyRate - Drive hourly rate. |
|
45 | - * bool HIDE_ROUTED_ADDRESSES - Hide routed addresses. |
|
46 | - * bool HIDE_VISITED_ADDRESSES - Hide visited addresses. |
|
47 | - * bool HIDE_NONFUTURE_ROUTES - Hide nonfuture routes. |
|
48 | - * bool READONLY_USER - Readonly user. |
|
49 | - * bool SHOW_SUSR_ADDR - Show sub-user addresses. |
|
50 | - * bool SHOW_SUSR_ORDERS - Show sub-user orders. |
|
51 | - * bool SHOW_ALL_DRIVERS - Show all drivers. |
|
52 | - * bool SHOW_ALL_VEHICLES - Show all vehicles. |
|
53 | - * bool display_max_routes_future_days - Display max routes. |
|
54 | - * int vendor_id - Vendoe ID. |
|
55 | - * float driving_rate - Driving rate. |
|
56 | - * float working_rate - Working rate. |
|
57 | - * float mile_rate - Mile rate. |
|
58 | - * float idling_rate - Idling rate. |
|
59 | - * string timezone - Timezone. |
|
60 | - * string optimization_profile_id - Optimization profile ID. |
|
61 | - * array permissions - Array of permissions |
|
62 | - * string id - ID of permission |
|
63 | - * array value - Array of string values |
|
64 | - * @return ResponseTeam |
|
65 | - * @throws Exception\ApiError |
|
66 | - */ |
|
67 | - public function create(array $params) : ResponseTeam |
|
68 | - { |
|
69 | - $allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name', |
|
70 | - 'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth', |
|
71 | - 'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES', |
|
72 | - 'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS', |
|
73 | - 'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate', |
|
74 | - 'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions' |
|
75 | - ]; |
|
25 | + /** |
|
26 | + * Add a new sub-user to the Member account by sending the corresponding |
|
27 | + * body payload with the sub-users' parameters. |
|
28 | + * |
|
29 | + * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
30 | + * |
|
31 | + * @param array $params - Sub-user properties. |
|
32 | + * string new_password - Password. |
|
33 | + * string new_member_picture - Member picture. |
|
34 | + * string member_first_name - First name. |
|
35 | + * string member_last_name - Last name. |
|
36 | + * string member_email - E-mail. |
|
37 | + * string member_company - Company. |
|
38 | + * string member_type - Member type. |
|
39 | + * int OWNER_MEMBER_ID - Owner member ID. |
|
40 | + * string member_phone - Phone. |
|
41 | + * string date_of_birth - Date of birth. |
|
42 | + * int user_reg_state_id - User state ID. |
|
43 | + * int user_reg_country_id - User country ID. |
|
44 | + * float DriverHourlyRate - Drive hourly rate. |
|
45 | + * bool HIDE_ROUTED_ADDRESSES - Hide routed addresses. |
|
46 | + * bool HIDE_VISITED_ADDRESSES - Hide visited addresses. |
|
47 | + * bool HIDE_NONFUTURE_ROUTES - Hide nonfuture routes. |
|
48 | + * bool READONLY_USER - Readonly user. |
|
49 | + * bool SHOW_SUSR_ADDR - Show sub-user addresses. |
|
50 | + * bool SHOW_SUSR_ORDERS - Show sub-user orders. |
|
51 | + * bool SHOW_ALL_DRIVERS - Show all drivers. |
|
52 | + * bool SHOW_ALL_VEHICLES - Show all vehicles. |
|
53 | + * bool display_max_routes_future_days - Display max routes. |
|
54 | + * int vendor_id - Vendoe ID. |
|
55 | + * float driving_rate - Driving rate. |
|
56 | + * float working_rate - Working rate. |
|
57 | + * float mile_rate - Mile rate. |
|
58 | + * float idling_rate - Idling rate. |
|
59 | + * string timezone - Timezone. |
|
60 | + * string optimization_profile_id - Optimization profile ID. |
|
61 | + * array permissions - Array of permissions |
|
62 | + * string id - ID of permission |
|
63 | + * array value - Array of string values |
|
64 | + * @return ResponseTeam |
|
65 | + * @throws Exception\ApiError |
|
66 | + */ |
|
67 | + public function create(array $params) : ResponseTeam |
|
68 | + { |
|
69 | + $allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name', |
|
70 | + 'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth', |
|
71 | + 'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES', |
|
72 | + 'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS', |
|
73 | + 'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate', |
|
74 | + 'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions' |
|
75 | + ]; |
|
76 | 76 | |
77 | - return $this->toResponseTeam(Route4Me::makeRequst([ |
|
78 | - 'url' => Endpoint::TEAM_USERS, |
|
79 | - 'method' => 'POST', |
|
80 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
81 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
82 | - ])); |
|
83 | - } |
|
77 | + return $this->toResponseTeam(Route4Me::makeRequst([ |
|
78 | + 'url' => Endpoint::TEAM_USERS, |
|
79 | + 'method' => 'POST', |
|
80 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
81 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
82 | + ])); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * View all existing sub-users associated with the Member’s account. |
|
87 | - * |
|
88 | - * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
89 | - * |
|
90 | - * @return ResponseTeam[] |
|
91 | - * @throws Exception\ApiError |
|
92 | - */ |
|
93 | - public function getUsers() : ?array |
|
94 | - { |
|
95 | - $result = Route4Me::makeRequst([ |
|
96 | - 'url' => Endpoint::TEAM_USERS, |
|
97 | - 'method' => 'GET' |
|
98 | - ]); |
|
85 | + /** |
|
86 | + * View all existing sub-users associated with the Member’s account. |
|
87 | + * |
|
88 | + * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
89 | + * |
|
90 | + * @return ResponseTeam[] |
|
91 | + * @throws Exception\ApiError |
|
92 | + */ |
|
93 | + public function getUsers() : ?array |
|
94 | + { |
|
95 | + $result = Route4Me::makeRequst([ |
|
96 | + 'url' => Endpoint::TEAM_USERS, |
|
97 | + 'method' => 'GET' |
|
98 | + ]); |
|
99 | 99 | |
100 | - if (is_array($result)) { |
|
101 | - $arr = []; |
|
102 | - foreach ($result as $key => $value) { |
|
103 | - array_push($arr, $this->toResponseTeam($value)); |
|
104 | - } |
|
105 | - return $arr; |
|
106 | - } |
|
107 | - return null; |
|
108 | - } |
|
100 | + if (is_array($result)) { |
|
101 | + $arr = []; |
|
102 | + foreach ($result as $key => $value) { |
|
103 | + array_push($arr, $this->toResponseTeam($value)); |
|
104 | + } |
|
105 | + return $arr; |
|
106 | + } |
|
107 | + return null; |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Get the sub-user by specifying the path parameter ID. |
|
112 | - * |
|
113 | - * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
114 | - * |
|
115 | - * @param int $userId - User ID. |
|
116 | - * @return ResponseTeam |
|
117 | - * @throws Exception\ApiError |
|
118 | - */ |
|
119 | - public function getUser(int $userId) : ResponseTeam |
|
120 | - { |
|
121 | - return $this->toResponseTeam(Route4Me::makeRequst([ |
|
122 | - 'url' => Endpoint::TEAM_USERS . '/' . $userId, |
|
123 | - 'method' => 'GET' |
|
124 | - ])); |
|
125 | - } |
|
110 | + /** |
|
111 | + * Get the sub-user by specifying the path parameter ID. |
|
112 | + * |
|
113 | + * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
114 | + * |
|
115 | + * @param int $userId - User ID. |
|
116 | + * @return ResponseTeam |
|
117 | + * @throws Exception\ApiError |
|
118 | + */ |
|
119 | + public function getUser(int $userId) : ResponseTeam |
|
120 | + { |
|
121 | + return $this->toResponseTeam(Route4Me::makeRequst([ |
|
122 | + 'url' => Endpoint::TEAM_USERS . '/' . $userId, |
|
123 | + 'method' => 'GET' |
|
124 | + ])); |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * Delete the sub-user by specifying the path parameter ID. |
|
129 | - * |
|
130 | - * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
131 | - * |
|
132 | - * @param int $userId - User ID. |
|
133 | - * @return ResponseTeam - Deleted object |
|
134 | - * @throws Exception\ApiError |
|
135 | - */ |
|
136 | - public function delete(int $userId) : ResponseTeam |
|
137 | - { |
|
138 | - return $this->toResponseTeam(Route4Me::makeRequst([ |
|
139 | - 'url' => Endpoint::TEAM_USERS . '/' . $userId, |
|
140 | - 'method' => 'DELETE' |
|
141 | - ])); |
|
142 | - } |
|
127 | + /** |
|
128 | + * Delete the sub-user by specifying the path parameter ID. |
|
129 | + * |
|
130 | + * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
131 | + * |
|
132 | + * @param int $userId - User ID. |
|
133 | + * @return ResponseTeam - Deleted object |
|
134 | + * @throws Exception\ApiError |
|
135 | + */ |
|
136 | + public function delete(int $userId) : ResponseTeam |
|
137 | + { |
|
138 | + return $this->toResponseTeam(Route4Me::makeRequst([ |
|
139 | + 'url' => Endpoint::TEAM_USERS . '/' . $userId, |
|
140 | + 'method' => 'DELETE' |
|
141 | + ])); |
|
142 | + } |
|
143 | 143 | |
144 | - /** |
|
145 | - * Update the sub-user by specifying the path parameter ID and by sending the |
|
146 | - * corresponding body payload with the sub-user's parameters.. |
|
147 | - * |
|
148 | - * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
149 | - * |
|
150 | - * @param int $userId - User ID. |
|
151 | - * @param array $params - Sub-user properties. |
|
152 | - * string new_password - Password. |
|
153 | - * string new_member_picture - Member picture. |
|
154 | - * string member_first_name - First name. |
|
155 | - * string member_last_name - Last name. |
|
156 | - * string member_email - E-mail. |
|
157 | - * string member_company - Company. |
|
158 | - * string member_type - Member type. |
|
159 | - * int OWNER_MEMBER_ID - Owner member ID. |
|
160 | - * string member_phone - Phone. |
|
161 | - * string date_of_birth - Date of birth. |
|
162 | - * int user_reg_state_id - User state ID. |
|
163 | - * int user_reg_country_id - User country ID. |
|
164 | - * float DriverHourlyRate - Drive hourly rate. |
|
165 | - * bool HIDE_ROUTED_ADDRESSES - Hide routed addresses. |
|
166 | - * bool HIDE_VISITED_ADDRESSES - Hide visited addresses. |
|
167 | - * bool HIDE_NONFUTURE_ROUTES - Hide nonfuture routes. |
|
168 | - * bool READONLY_USER - Readonly user. |
|
169 | - * bool SHOW_SUSR_ADDR - Show sub-user addresses. |
|
170 | - * bool SHOW_SUSR_ORDERS - Show sub-user orders. |
|
171 | - * bool SHOW_ALL_DRIVERS - Show all drivers. |
|
172 | - * bool SHOW_ALL_VEHICLES - Show all vehicles. |
|
173 | - * bool display_max_routes_future_days - Display max routes. |
|
174 | - * int vendor_id - Vendoe ID. |
|
175 | - * float driving_rate - Driving rate. |
|
176 | - * float working_rate - Working rate. |
|
177 | - * float mile_rate - Mile rate. |
|
178 | - * float idling_rate - Idling rate. |
|
179 | - * string timezone - Timezone. |
|
180 | - * string optimization_profile_id - Optimization profile ID. |
|
181 | - * array permissions - Array of permissions |
|
182 | - * string id - ID of permission |
|
183 | - * array value - Array of string values |
|
184 | - * @return ResponseTeam |
|
185 | - * @throws Exception\ApiError |
|
186 | - */ |
|
187 | - public function update(int $userId, array $params) : ResponseTeam |
|
188 | - { |
|
189 | - $allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name', |
|
190 | - 'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth', |
|
191 | - 'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES', |
|
192 | - 'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS', |
|
193 | - 'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate', |
|
194 | - 'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions' |
|
195 | - ]; |
|
144 | + /** |
|
145 | + * Update the sub-user by specifying the path parameter ID and by sending the |
|
146 | + * corresponding body payload with the sub-user's parameters.. |
|
147 | + * |
|
148 | + * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
149 | + * |
|
150 | + * @param int $userId - User ID. |
|
151 | + * @param array $params - Sub-user properties. |
|
152 | + * string new_password - Password. |
|
153 | + * string new_member_picture - Member picture. |
|
154 | + * string member_first_name - First name. |
|
155 | + * string member_last_name - Last name. |
|
156 | + * string member_email - E-mail. |
|
157 | + * string member_company - Company. |
|
158 | + * string member_type - Member type. |
|
159 | + * int OWNER_MEMBER_ID - Owner member ID. |
|
160 | + * string member_phone - Phone. |
|
161 | + * string date_of_birth - Date of birth. |
|
162 | + * int user_reg_state_id - User state ID. |
|
163 | + * int user_reg_country_id - User country ID. |
|
164 | + * float DriverHourlyRate - Drive hourly rate. |
|
165 | + * bool HIDE_ROUTED_ADDRESSES - Hide routed addresses. |
|
166 | + * bool HIDE_VISITED_ADDRESSES - Hide visited addresses. |
|
167 | + * bool HIDE_NONFUTURE_ROUTES - Hide nonfuture routes. |
|
168 | + * bool READONLY_USER - Readonly user. |
|
169 | + * bool SHOW_SUSR_ADDR - Show sub-user addresses. |
|
170 | + * bool SHOW_SUSR_ORDERS - Show sub-user orders. |
|
171 | + * bool SHOW_ALL_DRIVERS - Show all drivers. |
|
172 | + * bool SHOW_ALL_VEHICLES - Show all vehicles. |
|
173 | + * bool display_max_routes_future_days - Display max routes. |
|
174 | + * int vendor_id - Vendoe ID. |
|
175 | + * float driving_rate - Driving rate. |
|
176 | + * float working_rate - Working rate. |
|
177 | + * float mile_rate - Mile rate. |
|
178 | + * float idling_rate - Idling rate. |
|
179 | + * string timezone - Timezone. |
|
180 | + * string optimization_profile_id - Optimization profile ID. |
|
181 | + * array permissions - Array of permissions |
|
182 | + * string id - ID of permission |
|
183 | + * array value - Array of string values |
|
184 | + * @return ResponseTeam |
|
185 | + * @throws Exception\ApiError |
|
186 | + */ |
|
187 | + public function update(int $userId, array $params) : ResponseTeam |
|
188 | + { |
|
189 | + $allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name', |
|
190 | + 'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth', |
|
191 | + 'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES', |
|
192 | + 'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS', |
|
193 | + 'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate', |
|
194 | + 'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions' |
|
195 | + ]; |
|
196 | 196 | |
197 | - return $this->toResponseTeam(Route4Me::makeRequst([ |
|
198 | - 'url' => Endpoint::TEAM_USERS . '/' . $userId, |
|
199 | - 'method' => 'PATCH', |
|
200 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
201 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
202 | - ])); |
|
203 | - } |
|
197 | + return $this->toResponseTeam(Route4Me::makeRequst([ |
|
198 | + 'url' => Endpoint::TEAM_USERS . '/' . $userId, |
|
199 | + 'method' => 'PATCH', |
|
200 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
201 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
202 | + ])); |
|
203 | + } |
|
204 | 204 | |
205 | - /** |
|
206 | - * Add multiple sub-users to the User account by sending the corresponding |
|
207 | - * body payload with the array of the sub-users' parameters |
|
208 | - * |
|
209 | - * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
210 | - * |
|
211 | - * @param array $params - Array of array of Sub-user properties. |
|
212 | - * string new_password - Password. |
|
213 | - * string new_member_picture - Member picture. |
|
214 | - * string member_first_name - First name. |
|
215 | - * string member_last_name - Last name. |
|
216 | - * string member_email - E-mail. |
|
217 | - * string member_company - Company. |
|
218 | - * string member_type - Member type. |
|
219 | - * int OWNER_MEMBER_ID - Owner member ID. |
|
220 | - * string member_phone - Phone. |
|
221 | - * string date_of_birth - Date of birth. |
|
222 | - * int user_reg_state_id - User state ID. |
|
223 | - * int user_reg_country_id - User country ID. |
|
224 | - * float DriverHourlyRate - Drive hourly rate. |
|
225 | - * bool HIDE_ROUTED_ADDRESSES - Hide routed addresses. |
|
226 | - * bool HIDE_VISITED_ADDRESSES - Hide visited addresses. |
|
227 | - * bool HIDE_NONFUTURE_ROUTES - Hide nonfuture routes. |
|
228 | - * bool READONLY_USER - Readonly user. |
|
229 | - * bool SHOW_SUSR_ADDR - Show sub-user addresses. |
|
230 | - * bool SHOW_SUSR_ORDERS - Show sub-user orders. |
|
231 | - * bool SHOW_ALL_DRIVERS - Show all drivers. |
|
232 | - * bool SHOW_ALL_VEHICLES - Show all vehicles. |
|
233 | - * bool display_max_routes_future_days - Display max routes. |
|
234 | - * int vendor_id - Vendoe ID. |
|
235 | - * float driving_rate - Driving rate. |
|
236 | - * float working_rate - Working rate. |
|
237 | - * float mile_rate - Mile rate. |
|
238 | - * float idling_rate - Idling rate. |
|
239 | - * string timezone - Timezone. |
|
240 | - * string optimization_profile_id - Optimization profile ID. |
|
241 | - * array permissions - Array of permissions |
|
242 | - * string id - ID of permission |
|
243 | - * array value - Array of string values |
|
244 | - * @param array options - Array of insert options. |
|
245 | - * string [api_key] - User API key. |
|
246 | - * string [conflicts] - Conflict resolving rule. |
|
247 | - * Possible values: 'fail', 'overwrite' and 'skip'. |
|
248 | - * @return ResponseTeam |
|
249 | - * @throws Exception\ApiError |
|
250 | - */ |
|
251 | - public function bulkInsert(array $params, ?array $options = null) |
|
252 | - { |
|
253 | - $allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name', |
|
254 | - 'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth', |
|
255 | - 'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES', |
|
256 | - 'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS', |
|
257 | - 'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate', |
|
258 | - 'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions' |
|
259 | - ]; |
|
205 | + /** |
|
206 | + * Add multiple sub-users to the User account by sending the corresponding |
|
207 | + * body payload with the array of the sub-users' parameters |
|
208 | + * |
|
209 | + * @see {@link https://virtserver.swaggerhub.com/Route4Me} |
|
210 | + * |
|
211 | + * @param array $params - Array of array of Sub-user properties. |
|
212 | + * string new_password - Password. |
|
213 | + * string new_member_picture - Member picture. |
|
214 | + * string member_first_name - First name. |
|
215 | + * string member_last_name - Last name. |
|
216 | + * string member_email - E-mail. |
|
217 | + * string member_company - Company. |
|
218 | + * string member_type - Member type. |
|
219 | + * int OWNER_MEMBER_ID - Owner member ID. |
|
220 | + * string member_phone - Phone. |
|
221 | + * string date_of_birth - Date of birth. |
|
222 | + * int user_reg_state_id - User state ID. |
|
223 | + * int user_reg_country_id - User country ID. |
|
224 | + * float DriverHourlyRate - Drive hourly rate. |
|
225 | + * bool HIDE_ROUTED_ADDRESSES - Hide routed addresses. |
|
226 | + * bool HIDE_VISITED_ADDRESSES - Hide visited addresses. |
|
227 | + * bool HIDE_NONFUTURE_ROUTES - Hide nonfuture routes. |
|
228 | + * bool READONLY_USER - Readonly user. |
|
229 | + * bool SHOW_SUSR_ADDR - Show sub-user addresses. |
|
230 | + * bool SHOW_SUSR_ORDERS - Show sub-user orders. |
|
231 | + * bool SHOW_ALL_DRIVERS - Show all drivers. |
|
232 | + * bool SHOW_ALL_VEHICLES - Show all vehicles. |
|
233 | + * bool display_max_routes_future_days - Display max routes. |
|
234 | + * int vendor_id - Vendoe ID. |
|
235 | + * float driving_rate - Driving rate. |
|
236 | + * float working_rate - Working rate. |
|
237 | + * float mile_rate - Mile rate. |
|
238 | + * float idling_rate - Idling rate. |
|
239 | + * string timezone - Timezone. |
|
240 | + * string optimization_profile_id - Optimization profile ID. |
|
241 | + * array permissions - Array of permissions |
|
242 | + * string id - ID of permission |
|
243 | + * array value - Array of string values |
|
244 | + * @param array options - Array of insert options. |
|
245 | + * string [api_key] - User API key. |
|
246 | + * string [conflicts] - Conflict resolving rule. |
|
247 | + * Possible values: 'fail', 'overwrite' and 'skip'. |
|
248 | + * @return ResponseTeam |
|
249 | + * @throws Exception\ApiError |
|
250 | + */ |
|
251 | + public function bulkInsert(array $params, ?array $options = null) |
|
252 | + { |
|
253 | + $allBodyFields = ['new_password', 'new_member_picture', 'member_first_name', 'member_last_name', |
|
254 | + 'member_email', 'member_company', 'member_type', 'OWNER_MEMBER_ID', 'member_phone', 'date_of_birth', |
|
255 | + 'user_reg_state_id', 'user_reg_country_id', 'DriverHourlyRate', 'HIDE_ROUTED_ADDRESSES', |
|
256 | + 'HIDE_VISITED_ADDRESSES', 'HIDE_NONFUTURE_ROUTES', 'READONLY_USER', 'SHOW_SUSR_ADDR', 'SHOW_SUSR_ORDERS', |
|
257 | + 'SHOW_ALL_DRIVERS', 'SHOW_ALL_VEHICLES', 'display_max_routes_future_days', 'vendor_id', 'driving_rate', |
|
258 | + 'working_rate', 'mile_rate', 'idling_rate', 'timezone', 'optimization_profile_id', 'permissions' |
|
259 | + ]; |
|
260 | 260 | |
261 | - $allQueryFields = ['api_key', 'conflicts']; |
|
261 | + $allQueryFields = ['api_key', 'conflicts']; |
|
262 | 262 | |
263 | - $body = []; |
|
264 | - foreach ($params as $key => $value) { |
|
265 | - $body[] = Route4Me::generateRequestParameters($allBodyFields, $value); |
|
266 | - } |
|
263 | + $body = []; |
|
264 | + foreach ($params as $key => $value) { |
|
265 | + $body[] = Route4Me::generateRequestParameters($allBodyFields, $value); |
|
266 | + } |
|
267 | 267 | |
268 | - $result = Route4Me::makeRequst([ |
|
269 | - 'url' => Endpoint::TEAM_USERS_BULK_INSERT, |
|
270 | - 'method' => 'POST', |
|
271 | - 'HTTPHEADER' => 'Content-Type: application/json', |
|
272 | - 'body' => ['users' => $body], |
|
273 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $options) |
|
274 | - ]); |
|
268 | + $result = Route4Me::makeRequst([ |
|
269 | + 'url' => Endpoint::TEAM_USERS_BULK_INSERT, |
|
270 | + 'method' => 'POST', |
|
271 | + 'HTTPHEADER' => 'Content-Type: application/json', |
|
272 | + 'body' => ['users' => $body], |
|
273 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $options) |
|
274 | + ]); |
|
275 | 275 | |
276 | - if (is_array($result)) { |
|
277 | - $arr = []; |
|
278 | - foreach ($result as $key => $value) { |
|
279 | - array_push($arr, $this->toResponseTeam($value)); |
|
280 | - } |
|
281 | - return $arr; |
|
282 | - } |
|
283 | - return null; |
|
284 | - } |
|
276 | + if (is_array($result)) { |
|
277 | + $arr = []; |
|
278 | + foreach ($result as $key => $value) { |
|
279 | + array_push($arr, $this->toResponseTeam($value)); |
|
280 | + } |
|
281 | + return $arr; |
|
282 | + } |
|
283 | + return null; |
|
284 | + } |
|
285 | 285 | |
286 | - private function toResponseTeam($result) : ResponseTeam |
|
287 | - { |
|
288 | - if (is_array($result)) { |
|
289 | - return new ResponseTeam($result); |
|
290 | - } |
|
291 | - throw new ApiError('Can not convert result to ResponseTeam object.'); |
|
292 | - } |
|
286 | + private function toResponseTeam($result) : ResponseTeam |
|
287 | + { |
|
288 | + if (is_array($result)) { |
|
289 | + return new ResponseTeam($result); |
|
290 | + } |
|
291 | + throw new ApiError('Can not convert result to ResponseTeam object.'); |
|
292 | + } |
|
293 | 293 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | public function getUser(int $userId) : ResponseTeam |
120 | 120 | { |
121 | 121 | return $this->toResponseTeam(Route4Me::makeRequst([ |
122 | - 'url' => Endpoint::TEAM_USERS . '/' . $userId, |
|
122 | + 'url' => Endpoint::TEAM_USERS.'/'.$userId, |
|
123 | 123 | 'method' => 'GET' |
124 | 124 | ])); |
125 | 125 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | public function delete(int $userId) : ResponseTeam |
137 | 137 | { |
138 | 138 | return $this->toResponseTeam(Route4Me::makeRequst([ |
139 | - 'url' => Endpoint::TEAM_USERS . '/' . $userId, |
|
139 | + 'url' => Endpoint::TEAM_USERS.'/'.$userId, |
|
140 | 140 | 'method' => 'DELETE' |
141 | 141 | ])); |
142 | 142 | } |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | ]; |
196 | 196 | |
197 | 197 | return $this->toResponseTeam(Route4Me::makeRequst([ |
198 | - 'url' => Endpoint::TEAM_USERS . '/' . $userId, |
|
198 | + 'url' => Endpoint::TEAM_USERS.'/'.$userId, |
|
199 | 199 | 'method' => 'PATCH', |
200 | 200 | 'HTTPHEADER' => 'Content-Type: application/json', |
201 | 201 | 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
@@ -18,37 +18,37 @@ |
||
18 | 18 | Route4Me::setApiKey(Constants::API_KEY); |
19 | 19 | |
20 | 20 | try { |
21 | - // get OWNER_MEMBER_ID |
|
22 | - $owner_member_id = null; |
|
23 | - $member = new Member(); |
|
24 | - $res_members = $member->getUsers(); |
|
25 | - |
|
26 | - if (is_array($res_members) && isset($res_members['results'])) { |
|
27 | - foreach ($res_members['results'] as $key => $value) { |
|
28 | - if ($value['OWNER_MEMBER_ID'] == 0) { |
|
29 | - $owner_member_id = $value['member_id']; |
|
30 | - break; |
|
31 | - } |
|
32 | - } |
|
33 | - } |
|
34 | - |
|
35 | - if (!$owner_member_id) { |
|
36 | - throw new Exception("Cannot find OWNER_MEMBER_ID."); |
|
37 | - } |
|
38 | - |
|
39 | - // new sub-user |
|
40 | - $params = [ |
|
41 | - 'new_password' => '12345#Tusha', |
|
42 | - 'member_first_name' => 'Tusha I', |
|
43 | - 'member_last_name' => 'Pupkindzes', |
|
44 | - 'member_email' => '[email protected]', |
|
45 | - 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
46 | - 'OWNER_MEMBER_ID' => $owner_member_id |
|
47 | - ]; |
|
48 | - |
|
49 | - $tm = new TeamManagement(); |
|
50 | - $res = $tm->create($params); |
|
51 | - print_r($res); |
|
21 | + // get OWNER_MEMBER_ID |
|
22 | + $owner_member_id = null; |
|
23 | + $member = new Member(); |
|
24 | + $res_members = $member->getUsers(); |
|
25 | + |
|
26 | + if (is_array($res_members) && isset($res_members['results'])) { |
|
27 | + foreach ($res_members['results'] as $key => $value) { |
|
28 | + if ($value['OWNER_MEMBER_ID'] == 0) { |
|
29 | + $owner_member_id = $value['member_id']; |
|
30 | + break; |
|
31 | + } |
|
32 | + } |
|
33 | + } |
|
34 | + |
|
35 | + if (!$owner_member_id) { |
|
36 | + throw new Exception("Cannot find OWNER_MEMBER_ID."); |
|
37 | + } |
|
38 | + |
|
39 | + // new sub-user |
|
40 | + $params = [ |
|
41 | + 'new_password' => '12345#Tusha', |
|
42 | + 'member_first_name' => 'Tusha I', |
|
43 | + 'member_last_name' => 'Pupkindzes', |
|
44 | + 'member_email' => '[email protected]', |
|
45 | + 'member_type' => 'SUB_ACCOUNT_DRIVER', |
|
46 | + 'OWNER_MEMBER_ID' => $owner_member_id |
|
47 | + ]; |
|
48 | + |
|
49 | + $tm = new TeamManagement(); |
|
50 | + $res = $tm->create($params); |
|
51 | + print_r($res); |
|
52 | 52 | } catch (Exception | ApiError $e) { |
53 | - echo $e->getMessage() . PHP_EOL; |
|
53 | + echo $e->getMessage() . PHP_EOL; |
|
54 | 54 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | |
26 | 26 | if (is_array($res_members) && isset($res_members['results'])) { |
27 | 27 | foreach ($res_members['results'] as $key => $value) { |
28 | - if ($value['OWNER_MEMBER_ID'] == 0) { |
|
28 | + if ($value['OWNER_MEMBER_ID']==0) { |
|
29 | 29 | $owner_member_id = $value['member_id']; |
30 | 30 | break; |
31 | 31 | } |
@@ -50,5 +50,5 @@ discard block |
||
50 | 50 | $res = $tm->create($params); |
51 | 51 | print_r($res); |
52 | 52 | } catch (Exception | ApiError $e) { |
53 | - echo $e->getMessage() . PHP_EOL; |
|
53 | + echo $e->getMessage().PHP_EOL; |
|
54 | 54 | } |
@@ -18,9 +18,9 @@ |
||
18 | 18 | $userId = 2565363; |
19 | 19 | |
20 | 20 | try { |
21 | - $tm = new TeamManagement(); |
|
22 | - $res = $tm->getUser($userId); |
|
23 | - print_r($res); |
|
21 | + $tm = new TeamManagement(); |
|
22 | + $res = $tm->getUser($userId); |
|
23 | + print_r($res); |
|
24 | 24 | } catch (ApiError $e) { |
25 | - echo 'Cannot get user with ID: ' . $userId . PHP_EOL; |
|
25 | + echo 'Cannot get user with ID: ' . $userId . PHP_EOL; |
|
26 | 26 | } |
@@ -22,5 +22,5 @@ |
||
22 | 22 | $res = $tm->getUser($userId); |
23 | 23 | print_r($res); |
24 | 24 | } catch (ApiError $e) { |
25 | - echo 'Cannot get user with ID: ' . $userId . PHP_EOL; |
|
25 | + echo 'Cannot get user with ID: '.$userId.PHP_EOL; |
|
26 | 26 | } |
@@ -16,9 +16,9 @@ |
||
16 | 16 | Route4Me::setApiKey(Constants::API_KEY); |
17 | 17 | |
18 | 18 | try { |
19 | - $tm = new TeamManagement(); |
|
20 | - $res = $tm->getUsers(); |
|
21 | - print_r($res); |
|
19 | + $tm = new TeamManagement(); |
|
20 | + $res = $tm->getUsers(); |
|
21 | + print_r($res); |
|
22 | 22 | } catch (ApiError $e) { |
23 | - echo $e->getMessage() . PHP_EOL; |
|
23 | + echo $e->getMessage() . PHP_EOL; |
|
24 | 24 | } |
@@ -20,5 +20,5 @@ |
||
20 | 20 | $res = $tm->getUsers(); |
21 | 21 | print_r($res); |
22 | 22 | } catch (ApiError $e) { |
23 | - echo $e->getMessage() . PHP_EOL; |
|
23 | + echo $e->getMessage().PHP_EOL; |
|
24 | 24 | } |