@@ -18,14 +18,14 @@ |
||
18 | 18 | |
19 | 19 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
20 | 20 | $territoryParams['data'] = array( |
21 | - "37.569752822786455,-77.47833251953125", |
|
22 | - "5000" |
|
21 | + "37.569752822786455,-77.47833251953125", |
|
22 | + "5000" |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | - "territory_color" => "ff7700", |
|
28 | - "territory" => $territoryParams |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | + "territory_color" => "ff7700", |
|
28 | + "territory" => $territoryParams |
|
29 | 29 | )); |
30 | 30 | |
31 | 31 | $territory = new Territory(); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
5 | 5 | require $root.'/vendor/autoload.php'; |
6 | 6 | |
7 | 7 | use Route4Me\Route4Me; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000, 99999)), |
|
27 | 27 | "territory_color" => "ff7700", |
28 | 28 | "territory" => $territoryParams |
29 | 29 | )); |
@@ -9,474 +9,474 @@ |
||
9 | 9 | |
10 | 10 | class Route extends Common |
11 | 11 | { |
12 | - public $route_id; |
|
13 | - public $member_id; |
|
14 | - public $route_destination_id; |
|
15 | - public $optimization_problem_id; |
|
16 | - public $vehicle_alias; |
|
17 | - public $driver_alias; |
|
18 | - public $trip_distance; |
|
19 | - public $mpg; |
|
20 | - public $gas_price; |
|
21 | - public $route_duration_sec; |
|
22 | - public $destination_count; |
|
23 | - public $parameters; |
|
24 | - public $addresses = array(); |
|
25 | - public $links = array(); |
|
26 | - public $directions = array(); |
|
27 | - public $path = array(); |
|
28 | - public $tracking_history = array(); |
|
29 | - public $recipient_email; |
|
30 | - public $httpheaders; |
|
31 | - public $is_unrouted; |
|
32 | - public $time; |
|
12 | + public $route_id; |
|
13 | + public $member_id; |
|
14 | + public $route_destination_id; |
|
15 | + public $optimization_problem_id; |
|
16 | + public $vehicle_alias; |
|
17 | + public $driver_alias; |
|
18 | + public $trip_distance; |
|
19 | + public $mpg; |
|
20 | + public $gas_price; |
|
21 | + public $route_duration_sec; |
|
22 | + public $destination_count; |
|
23 | + public $parameters; |
|
24 | + public $addresses = array(); |
|
25 | + public $links = array(); |
|
26 | + public $directions = array(); |
|
27 | + public $path = array(); |
|
28 | + public $tracking_history = array(); |
|
29 | + public $recipient_email; |
|
30 | + public $httpheaders; |
|
31 | + public $is_unrouted; |
|
32 | + public $time; |
|
33 | 33 | |
34 | - public $dev_lat; |
|
35 | - public $dev_lng; |
|
34 | + public $dev_lat; |
|
35 | + public $dev_lng; |
|
36 | 36 | |
37 | - public $user_route_rating; |
|
38 | - public $member_email; |
|
39 | - public $member_first_name; |
|
40 | - public $member_last_name; |
|
41 | - public $channel_name; |
|
42 | - public $route_cost; |
|
43 | - public $route_revenue; |
|
44 | - public $net_revenue_per_distance_unit; |
|
45 | - public $created_timestamp; |
|
46 | - public $planned_total_route_duration; |
|
47 | - public $actual_travel_distance; |
|
48 | - public $actual_travel_time; |
|
49 | - public $actual_footsteps; |
|
50 | - public $working_time; |
|
51 | - public $driving_time; |
|
52 | - public $idling_time; |
|
53 | - public $paying_miles; |
|
54 | - public $geofence_polygon_type; |
|
55 | - public $geofence_polygon_size; |
|
56 | - public $notes; |
|
57 | - public $member_config_storage; |
|
37 | + public $user_route_rating; |
|
38 | + public $member_email; |
|
39 | + public $member_first_name; |
|
40 | + public $member_last_name; |
|
41 | + public $channel_name; |
|
42 | + public $route_cost; |
|
43 | + public $route_revenue; |
|
44 | + public $net_revenue_per_distance_unit; |
|
45 | + public $created_timestamp; |
|
46 | + public $planned_total_route_duration; |
|
47 | + public $actual_travel_distance; |
|
48 | + public $actual_travel_time; |
|
49 | + public $actual_footsteps; |
|
50 | + public $working_time; |
|
51 | + public $driving_time; |
|
52 | + public $idling_time; |
|
53 | + public $paying_miles; |
|
54 | + public $geofence_polygon_type; |
|
55 | + public $geofence_polygon_size; |
|
56 | + public $notes; |
|
57 | + public $member_config_storage; |
|
58 | 58 | |
59 | - public static function fromArray(array $params) |
|
60 | - { |
|
61 | - $route = new Route(); |
|
62 | - $route->route_id = Common::getValue($params, 'route_id'); |
|
63 | - $route->member_id = Common::getValue($params, 'member_id'); |
|
64 | - $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
65 | - $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
66 | - $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
67 | - $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
68 | - $route->mpg = Common::getValue($params, 'mpg'); |
|
69 | - $route->gas_price = Common::getValue($params, 'gas_price'); |
|
70 | - $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
71 | - $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
72 | - $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
59 | + public static function fromArray(array $params) |
|
60 | + { |
|
61 | + $route = new Route(); |
|
62 | + $route->route_id = Common::getValue($params, 'route_id'); |
|
63 | + $route->member_id = Common::getValue($params, 'member_id'); |
|
64 | + $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
65 | + $route->vehicle_alias = Common::getValue($params, 'vehicle_alias'); |
|
66 | + $route->driver_alias = Common::getValue($params, 'driver_alias'); |
|
67 | + $route->trip_distance = Common::getValue($params, 'trip_distance'); |
|
68 | + $route->mpg = Common::getValue($params, 'mpg'); |
|
69 | + $route->gas_price = Common::getValue($params, 'gas_price'); |
|
70 | + $route->route_duration_sec = Common::getvalue($params, 'route_duration_sec'); |
|
71 | + $route->destination_count = Common::getvalue($params, 'destination_count'); |
|
72 | + $route->is_unrouted = Common::getvalue($params, 'is_unrouted'); |
|
73 | 73 | |
74 | - // Make RouteParameters |
|
75 | - if (isset($params['parameters'])) { |
|
76 | - $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
77 | - } |
|
74 | + // Make RouteParameters |
|
75 | + if (isset($params['parameters'])) { |
|
76 | + $route->parameters = RouteParameters::fromArray($params['parameters']); |
|
77 | + } |
|
78 | 78 | |
79 | - if (isset($params['addresses'])) { |
|
80 | - $addresses = array(); |
|
81 | - foreach ($params['addresses'] as $address) { |
|
82 | - $addresses[] = Address::fromArray($address); |
|
83 | - } |
|
79 | + if (isset($params['addresses'])) { |
|
80 | + $addresses = array(); |
|
81 | + foreach ($params['addresses'] as $address) { |
|
82 | + $addresses[] = Address::fromArray($address); |
|
83 | + } |
|
84 | 84 | |
85 | - $route->addresses = $addresses; |
|
86 | - } |
|
85 | + $route->addresses = $addresses; |
|
86 | + } |
|
87 | 87 | |
88 | - $route->links = Common::getValue($params, 'links', array()); |
|
89 | - $route->directions = Common::getValue($params, 'directions', array()); |
|
90 | - $route->path = Common::getValue($params, 'path', array()); |
|
91 | - $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
88 | + $route->links = Common::getValue($params, 'links', array()); |
|
89 | + $route->directions = Common::getValue($params, 'directions', array()); |
|
90 | + $route->path = Common::getValue($params, 'path', array()); |
|
91 | + $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
92 | 92 | |
93 | - return $route; |
|
94 | - } |
|
93 | + return $route; |
|
94 | + } |
|
95 | 95 | |
96 | - public static function getRoutes($routeId = null, $params = null) |
|
97 | - { |
|
98 | - $result = Route4Me::makeRequst(array( |
|
99 | - 'url' => Endpoint::ROUTE_V4, |
|
100 | - 'method' => 'GET', |
|
101 | - 'query' => array( |
|
102 | - 'api_key' => Route4Me::getApiKey(), |
|
103 | - 'route_id' => !is_null($routeId) ? implode(',', (array)$routeId) : null, |
|
104 | - 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
105 | - 'query' => isset($params['query']) ? $params['query'] : null, |
|
106 | - 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
107 | - 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null, |
|
108 | - 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
109 | - 'offset' => isset($params['offset']) ? $params['offset'] : null |
|
110 | - ) |
|
111 | - )); |
|
96 | + public static function getRoutes($routeId = null, $params = null) |
|
97 | + { |
|
98 | + $result = Route4Me::makeRequst(array( |
|
99 | + 'url' => Endpoint::ROUTE_V4, |
|
100 | + 'method' => 'GET', |
|
101 | + 'query' => array( |
|
102 | + 'api_key' => Route4Me::getApiKey(), |
|
103 | + 'route_id' => !is_null($routeId) ? implode(',', (array)$routeId) : null, |
|
104 | + 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
105 | + 'query' => isset($params['query']) ? $params['query'] : null, |
|
106 | + 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
107 | + 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null, |
|
108 | + 'limit' => isset($params['limit']) ? $params['limit'] : null, |
|
109 | + 'offset' => isset($params['offset']) ? $params['offset'] : null |
|
110 | + ) |
|
111 | + )); |
|
112 | 112 | |
113 | - if ($routeId) { |
|
114 | - return Route::fromArray($result); die(""); |
|
115 | - } else { |
|
116 | - $routes = array(); |
|
117 | - foreach ($result as $route) { |
|
118 | - $routes[] = Route::fromArray($route); |
|
119 | - } |
|
120 | - return $routes; |
|
121 | - } |
|
122 | - } |
|
113 | + if ($routeId) { |
|
114 | + return Route::fromArray($result); die(""); |
|
115 | + } else { |
|
116 | + $routes = array(); |
|
117 | + foreach ($result as $route) { |
|
118 | + $routes[] = Route::fromArray($route); |
|
119 | + } |
|
120 | + return $routes; |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - public function getRoutePoints($routeId, $params) |
|
125 | - { |
|
126 | - $result = Route4Me::makeRequst(array( |
|
127 | - 'url' => Endpoint::ROUTE_V4, |
|
128 | - 'method' => 'GET', |
|
129 | - 'query' => array( |
|
130 | - 'api_key' => Route4Me::getApiKey(), |
|
131 | - 'route_id' => $routeId, |
|
132 | - 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
133 | - 'compress_path_points' => isset($params['compress_path_points']) ? $params['compress_path_points'] : null, |
|
134 | - 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
135 | - ) |
|
136 | - )); |
|
124 | + public function getRoutePoints($routeId, $params) |
|
125 | + { |
|
126 | + $result = Route4Me::makeRequst(array( |
|
127 | + 'url' => Endpoint::ROUTE_V4, |
|
128 | + 'method' => 'GET', |
|
129 | + 'query' => array( |
|
130 | + 'api_key' => Route4Me::getApiKey(), |
|
131 | + 'route_id' => $routeId, |
|
132 | + 'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null, |
|
133 | + 'compress_path_points' => isset($params['compress_path_points']) ? $params['compress_path_points'] : null, |
|
134 | + 'directions' => isset($params['directions']) ? $params['directions'] : null, |
|
135 | + ) |
|
136 | + )); |
|
137 | 137 | |
138 | - return $result; |
|
139 | - } |
|
138 | + return $result; |
|
139 | + } |
|
140 | 140 | |
141 | - public function duplicateRoute($route_id) |
|
142 | - { |
|
143 | - $result = Route4Me::makeRequst(array( |
|
144 | - 'url' => Endpoint::ROUTE_DUPLICATE, |
|
145 | - 'method' => 'GET', |
|
146 | - 'query' => array( |
|
147 | - 'api_key' => Route4Me::getApiKey(), |
|
148 | - 'route_id' => $route_id, |
|
149 | - 'to' => 'none', |
|
150 | - ) |
|
151 | - )); |
|
141 | + public function duplicateRoute($route_id) |
|
142 | + { |
|
143 | + $result = Route4Me::makeRequst(array( |
|
144 | + 'url' => Endpoint::ROUTE_DUPLICATE, |
|
145 | + 'method' => 'GET', |
|
146 | + 'query' => array( |
|
147 | + 'api_key' => Route4Me::getApiKey(), |
|
148 | + 'route_id' => $route_id, |
|
149 | + 'to' => 'none', |
|
150 | + ) |
|
151 | + )); |
|
152 | 152 | |
153 | - return $result; |
|
154 | - } |
|
153 | + return $result; |
|
154 | + } |
|
155 | 155 | |
156 | - public function resequenceRoute($params) |
|
157 | - { |
|
158 | - $result = Route4Me::makeRequst(array( |
|
159 | - 'url' => Endpoint::ROUTE_V4, |
|
160 | - 'method' => 'PUT', |
|
161 | - 'query' => array( |
|
162 | - 'api_key' => Route4Me::getApiKey(), |
|
163 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
164 | - 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
165 | - ), |
|
166 | - 'body' => array( |
|
167 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
168 | - ) |
|
169 | - )); |
|
156 | + public function resequenceRoute($params) |
|
157 | + { |
|
158 | + $result = Route4Me::makeRequst(array( |
|
159 | + 'url' => Endpoint::ROUTE_V4, |
|
160 | + 'method' => 'PUT', |
|
161 | + 'query' => array( |
|
162 | + 'api_key' => Route4Me::getApiKey(), |
|
163 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
164 | + 'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null, |
|
165 | + ), |
|
166 | + 'body' => array( |
|
167 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
168 | + ) |
|
169 | + )); |
|
170 | 170 | |
171 | - return $result; |
|
172 | - } |
|
171 | + return $result; |
|
172 | + } |
|
173 | 173 | |
174 | - public function resequenceAllAddresses($params) |
|
175 | - { |
|
176 | - $result = Route4Me::makeRequst(array( |
|
177 | - 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
178 | - 'method' => 'GET', |
|
179 | - 'query' => array( |
|
180 | - 'api_key' => Route4Me::getApiKey(), |
|
181 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
182 | - 'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null, |
|
183 | - 'optimize' => isset($params['optimize']) ? $params['optimize'] : null, |
|
184 | - ) |
|
185 | - )); |
|
174 | + public function resequenceAllAddresses($params) |
|
175 | + { |
|
176 | + $result = Route4Me::makeRequst(array( |
|
177 | + 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
178 | + 'method' => 'GET', |
|
179 | + 'query' => array( |
|
180 | + 'api_key' => Route4Me::getApiKey(), |
|
181 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
182 | + 'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null, |
|
183 | + 'optimize' => isset($params['optimize']) ? $params['optimize'] : null, |
|
184 | + ) |
|
185 | + )); |
|
186 | 186 | |
187 | - return $result; |
|
188 | - } |
|
187 | + return $result; |
|
188 | + } |
|
189 | 189 | |
190 | - public function mergeRoutes($params) |
|
191 | - { |
|
192 | - $result = Route4Me::makeRequst(array( |
|
193 | - 'url' => Endpoint::ROUTES_MERGE, |
|
194 | - 'method' => 'POST', |
|
195 | - 'query' => array( |
|
196 | - 'api_key' => Route4Me::getApiKey(), |
|
197 | - ), |
|
198 | - 'body' => array( |
|
199 | - 'route_ids' => isset($params['route_ids']) ? $params['route_ids'] : null, |
|
200 | - 'depot_address' => isset($params['depot_address']) ? $params['depot_address'] : null, |
|
201 | - 'remove_origin' => isset($params['remove_origin']) ? $params['remove_origin'] : null, |
|
202 | - 'depot_lat' => isset($params['depot_lat']) ? $params['depot_lat'] : null, |
|
203 | - 'depot_lat' => isset($params['depot_lat']) ? $params['depot_lat'] : null |
|
204 | - ), |
|
205 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
206 | - )); |
|
190 | + public function mergeRoutes($params) |
|
191 | + { |
|
192 | + $result = Route4Me::makeRequst(array( |
|
193 | + 'url' => Endpoint::ROUTES_MERGE, |
|
194 | + 'method' => 'POST', |
|
195 | + 'query' => array( |
|
196 | + 'api_key' => Route4Me::getApiKey(), |
|
197 | + ), |
|
198 | + 'body' => array( |
|
199 | + 'route_ids' => isset($params['route_ids']) ? $params['route_ids'] : null, |
|
200 | + 'depot_address' => isset($params['depot_address']) ? $params['depot_address'] : null, |
|
201 | + 'remove_origin' => isset($params['remove_origin']) ? $params['remove_origin'] : null, |
|
202 | + 'depot_lat' => isset($params['depot_lat']) ? $params['depot_lat'] : null, |
|
203 | + 'depot_lat' => isset($params['depot_lat']) ? $params['depot_lat'] : null |
|
204 | + ), |
|
205 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
206 | + )); |
|
207 | 207 | |
208 | - return $result; |
|
209 | - } |
|
208 | + return $result; |
|
209 | + } |
|
210 | 210 | |
211 | - public function shareRoute($params) |
|
212 | - { |
|
213 | - $result = Route4Me::makeRequst(array( |
|
214 | - 'url' => Endpoint::ROUTE_SHARE, |
|
215 | - 'method' => 'POST', |
|
216 | - 'query' => array( |
|
217 | - 'api_key' => Route4Me::getApiKey(), |
|
218 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
219 | - 'response_format' => isset($params['response_format']) ? $params['response_format'] : null, |
|
220 | - ), |
|
221 | - 'body' => array( |
|
222 | - 'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null, |
|
223 | - ), |
|
224 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
225 | - )); |
|
211 | + public function shareRoute($params) |
|
212 | + { |
|
213 | + $result = Route4Me::makeRequst(array( |
|
214 | + 'url' => Endpoint::ROUTE_SHARE, |
|
215 | + 'method' => 'POST', |
|
216 | + 'query' => array( |
|
217 | + 'api_key' => Route4Me::getApiKey(), |
|
218 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
219 | + 'response_format' => isset($params['response_format']) ? $params['response_format'] : null, |
|
220 | + ), |
|
221 | + 'body' => array( |
|
222 | + 'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null, |
|
223 | + ), |
|
224 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
225 | + )); |
|
226 | 226 | |
227 | - return $result; |
|
228 | - } |
|
227 | + return $result; |
|
228 | + } |
|
229 | 229 | |
230 | - // Returns random route_id from existing routes between $offset and $offset+$limit |
|
231 | - public function getRandomRouteId($offset, $limit) |
|
232 | - { |
|
233 | - $query['limit'] = !is_null($limit) ? $limit : 30; |
|
234 | - $query['offset'] = !is_null($offset) ? $offset : 0; |
|
230 | + // Returns random route_id from existing routes between $offset and $offset+$limit |
|
231 | + public function getRandomRouteId($offset, $limit) |
|
232 | + { |
|
233 | + $query['limit'] = !is_null($limit) ? $limit : 30; |
|
234 | + $query['offset'] = !is_null($offset) ? $offset : 0; |
|
235 | 235 | |
236 | - $json = Route4Me::makeRequst(array( |
|
237 | - 'url' => Endpoint::ROUTE_V4, |
|
238 | - 'method' => 'GET', |
|
239 | - 'query' => $query |
|
240 | - )); |
|
236 | + $json = Route4Me::makeRequst(array( |
|
237 | + 'url' => Endpoint::ROUTE_V4, |
|
238 | + 'method' => 'GET', |
|
239 | + 'query' => $query |
|
240 | + )); |
|
241 | 241 | |
242 | - if (sizeof($json)>0) { |
|
243 | - $routes = array(); |
|
242 | + if (sizeof($json)>0) { |
|
243 | + $routes = array(); |
|
244 | 244 | |
245 | - foreach ($json as $route) { |
|
246 | - $routes[] = Route::fromArray($route); |
|
247 | - } |
|
245 | + foreach ($json as $route) { |
|
246 | + $routes[] = Route::fromArray($route); |
|
247 | + } |
|
248 | 248 | |
249 | - $num = rand(0, sizeof($routes) - 1); |
|
250 | - $rRoute = (array)$routes[$num]; |
|
249 | + $num = rand(0, sizeof($routes) - 1); |
|
250 | + $rRoute = (array)$routes[$num]; |
|
251 | 251 | |
252 | - if (is_array($rRoute)) { |
|
253 | - return $rRoute["route_id"]; |
|
254 | - } else { |
|
255 | - return null; |
|
256 | - } |
|
257 | - } else { |
|
258 | - echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
259 | - return null; |
|
260 | - } |
|
261 | - } |
|
252 | + if (is_array($rRoute)) { |
|
253 | + return $rRoute["route_id"]; |
|
254 | + } else { |
|
255 | + return null; |
|
256 | + } |
|
257 | + } else { |
|
258 | + echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
259 | + return null; |
|
260 | + } |
|
261 | + } |
|
262 | 262 | |
263 | - public function update() |
|
264 | - { |
|
265 | - $route = Route4Me::makeRequst(array( |
|
266 | - 'url' => Endpoint::ROUTE_V4, |
|
267 | - 'method' => 'PUT', |
|
268 | - 'query' => array( |
|
269 | - 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
270 | - ), |
|
271 | - 'body' => array( |
|
272 | - 'parameters' => $this->parameters, |
|
273 | - ), |
|
274 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
275 | - )); |
|
263 | + public function update() |
|
264 | + { |
|
265 | + $route = Route4Me::makeRequst(array( |
|
266 | + 'url' => Endpoint::ROUTE_V4, |
|
267 | + 'method' => 'PUT', |
|
268 | + 'query' => array( |
|
269 | + 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
270 | + ), |
|
271 | + 'body' => array( |
|
272 | + 'parameters' => $this->parameters, |
|
273 | + ), |
|
274 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
275 | + )); |
|
276 | 276 | |
277 | - return Route::fromArray($route); |
|
278 | - } |
|
277 | + return Route::fromArray($route); |
|
278 | + } |
|
279 | 279 | |
280 | - public function updateAddress($address = null) |
|
281 | - { |
|
282 | - $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
283 | - : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
280 | + public function updateAddress($address = null) |
|
281 | + { |
|
282 | + $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
283 | + : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
284 | 284 | |
285 | - $result = Route4Me::makeRequst(array( |
|
286 | - 'url' => Endpoint::ADDRESS_V4, |
|
287 | - 'method' => 'PUT', |
|
288 | - 'query' => array( |
|
289 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
290 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
291 | - ), |
|
292 | - 'body' => $body, |
|
293 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
294 | - )); |
|
285 | + $result = Route4Me::makeRequst(array( |
|
286 | + 'url' => Endpoint::ADDRESS_V4, |
|
287 | + 'method' => 'PUT', |
|
288 | + 'query' => array( |
|
289 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
290 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
291 | + ), |
|
292 | + 'body' => $body, |
|
293 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
294 | + )); |
|
295 | 295 | |
296 | - return $result; |
|
297 | - } |
|
296 | + return $result; |
|
297 | + } |
|
298 | 298 | |
299 | - public function updateRouteAddress() |
|
300 | - { |
|
301 | - $result = Route4Me::makeRequst(array( |
|
302 | - 'url' => Endpoint::ADDRESS_V4, |
|
303 | - 'method' => 'PUT', |
|
304 | - 'query' => array( |
|
305 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
306 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
307 | - ), |
|
308 | - 'body' => array( |
|
309 | - "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
310 | - "addresses" => isset($this->addresses) ? $this->addresses : null |
|
311 | - ), |
|
312 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
313 | - )); |
|
299 | + public function updateRouteAddress() |
|
300 | + { |
|
301 | + $result = Route4Me::makeRequst(array( |
|
302 | + 'url' => Endpoint::ADDRESS_V4, |
|
303 | + 'method' => 'PUT', |
|
304 | + 'query' => array( |
|
305 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
306 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
307 | + ), |
|
308 | + 'body' => array( |
|
309 | + "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
310 | + "addresses" => isset($this->addresses) ? $this->addresses : null |
|
311 | + ), |
|
312 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
313 | + )); |
|
314 | 314 | |
315 | - return $result; |
|
316 | - } |
|
315 | + return $result; |
|
316 | + } |
|
317 | 317 | |
318 | - public function addAddresses($params) |
|
319 | - { |
|
320 | - $route = Route4Me::makeRequst(array( |
|
321 | - 'url' => Endpoint::ROUTE_V4, |
|
322 | - 'method' => 'PUT', |
|
323 | - 'query' => array( |
|
324 | - 'api_key' => Route4Me::getApiKey(), |
|
325 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null |
|
326 | - ), |
|
327 | - 'body' => array( |
|
328 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null |
|
329 | - ), |
|
330 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
331 | - )); |
|
318 | + public function addAddresses($params) |
|
319 | + { |
|
320 | + $route = Route4Me::makeRequst(array( |
|
321 | + 'url' => Endpoint::ROUTE_V4, |
|
322 | + 'method' => 'PUT', |
|
323 | + 'query' => array( |
|
324 | + 'api_key' => Route4Me::getApiKey(), |
|
325 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null |
|
326 | + ), |
|
327 | + 'body' => array( |
|
328 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null |
|
329 | + ), |
|
330 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
331 | + )); |
|
332 | 332 | |
333 | - return Route::fromArray($route); |
|
334 | - } |
|
333 | + return Route::fromArray($route); |
|
334 | + } |
|
335 | 335 | |
336 | - public function insertAddressOptimalPosition(array $params) |
|
337 | - { |
|
338 | - $route = Route4Me::makeRequst(array( |
|
339 | - 'url' => Endpoint::ROUTE_V4, |
|
340 | - 'method' => 'PUT', |
|
341 | - 'query' => array( |
|
342 | - 'api_key' => Route4Me::getApiKey(), |
|
343 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
344 | - ), |
|
345 | - 'body' => array( |
|
346 | - 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
347 | - 'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null, |
|
348 | - ) |
|
349 | - )); |
|
336 | + public function insertAddressOptimalPosition(array $params) |
|
337 | + { |
|
338 | + $route = Route4Me::makeRequst(array( |
|
339 | + 'url' => Endpoint::ROUTE_V4, |
|
340 | + 'method' => 'PUT', |
|
341 | + 'query' => array( |
|
342 | + 'api_key' => Route4Me::getApiKey(), |
|
343 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
344 | + ), |
|
345 | + 'body' => array( |
|
346 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
347 | + 'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null, |
|
348 | + ) |
|
349 | + )); |
|
350 | 350 | |
351 | - return Route::fromArray($route); |
|
352 | - } |
|
351 | + return Route::fromArray($route); |
|
352 | + } |
|
353 | 353 | |
354 | - public function addNoteFile($params) |
|
355 | - { |
|
356 | - $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
357 | - $rpath = realpath($fname); |
|
354 | + public function addNoteFile($params) |
|
355 | + { |
|
356 | + $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
357 | + $rpath = realpath($fname); |
|
358 | 358 | |
359 | - $result = Route4Me::makeRequst(array( |
|
360 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
361 | - 'method' => 'POST', |
|
362 | - 'query' => array( |
|
363 | - 'api_key' => Route4Me::getApiKey(), |
|
364 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
365 | - 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
366 | - 'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null, |
|
367 | - 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
368 | - 'device_type' => isset($params['device_type']) ? $params['device_type'] : null, |
|
369 | - 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
370 | - ), |
|
371 | - 'body' => array( |
|
372 | - 'strUpdateType' => isset($params['strUpdateType']) ? $params['strUpdateType'] : null, |
|
373 | - 'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null, |
|
374 | - 'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null, |
|
375 | - ), |
|
376 | - 'FILE' => $rpath, |
|
359 | + $result = Route4Me::makeRequst(array( |
|
360 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
361 | + 'method' => 'POST', |
|
362 | + 'query' => array( |
|
363 | + 'api_key' => Route4Me::getApiKey(), |
|
364 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
365 | + 'address_id' => isset($params['address_id']) ? $params['address_id'] : null, |
|
366 | + 'dev_lat' => isset($params['dev_lat']) ? $params['dev_lat'] : null, |
|
367 | + 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
368 | + 'device_type' => isset($params['device_type']) ? $params['device_type'] : null, |
|
369 | + 'dev_lng' => isset($params['dev_lng']) ? $params['dev_lng'] : null, |
|
370 | + ), |
|
371 | + 'body' => array( |
|
372 | + 'strUpdateType' => isset($params['strUpdateType']) ? $params['strUpdateType'] : null, |
|
373 | + 'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null, |
|
374 | + 'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null, |
|
375 | + ), |
|
376 | + 'FILE' => $rpath, |
|
377 | 377 | |
378 | - 'HTTPHEADER' => array( |
|
379 | - 'Content-Type: application/x-www-form-urlencoded' |
|
380 | - ) |
|
381 | - )); |
|
378 | + 'HTTPHEADER' => array( |
|
379 | + 'Content-Type: application/x-www-form-urlencoded' |
|
380 | + ) |
|
381 | + )); |
|
382 | 382 | |
383 | - return $result; |
|
384 | - } |
|
383 | + return $result; |
|
384 | + } |
|
385 | 385 | |
386 | - public function delete($route_id) |
|
387 | - { |
|
388 | - $result = Route4Me::makeRequst(array( |
|
389 | - 'url' => Endpoint::ROUTES_DELETE, |
|
390 | - 'method' => 'DELETE', |
|
391 | - 'query' => array( |
|
392 | - 'api_key' => Route4Me::getApiKey(), |
|
393 | - 'route_id' => $route_id, |
|
394 | - ) |
|
395 | - )); |
|
386 | + public function delete($route_id) |
|
387 | + { |
|
388 | + $result = Route4Me::makeRequst(array( |
|
389 | + 'url' => Endpoint::ROUTES_DELETE, |
|
390 | + 'method' => 'DELETE', |
|
391 | + 'query' => array( |
|
392 | + 'api_key' => Route4Me::getApiKey(), |
|
393 | + 'route_id' => $route_id, |
|
394 | + ) |
|
395 | + )); |
|
396 | 396 | |
397 | - return $result; |
|
398 | - } |
|
397 | + return $result; |
|
398 | + } |
|
399 | 399 | |
400 | - public function GetAddressesFromRoute($route_id) |
|
401 | - { |
|
402 | - $route1 = Route::getRoutes($route_id,null); |
|
400 | + public function GetAddressesFromRoute($route_id) |
|
401 | + { |
|
402 | + $route1 = Route::getRoutes($route_id,null); |
|
403 | 403 | |
404 | - if (isset($route1)) { |
|
405 | - return $route1->addresses; |
|
406 | - } else { |
|
407 | - return null; |
|
408 | - } |
|
409 | - } |
|
404 | + if (isset($route1)) { |
|
405 | + return $route1->addresses; |
|
406 | + } else { |
|
407 | + return null; |
|
408 | + } |
|
409 | + } |
|
410 | 410 | |
411 | - public function GetRandomAddressFromRoute($route_id) |
|
412 | - { |
|
413 | - $route1 = Route::getRoutes($route_id, null); |
|
411 | + public function GetRandomAddressFromRoute($route_id) |
|
412 | + { |
|
413 | + $route1 = Route::getRoutes($route_id, null); |
|
414 | 414 | |
415 | - if (isset($route1)) { |
|
416 | - $addresses = $route1->addresses; |
|
415 | + if (isset($route1)) { |
|
416 | + $addresses = $route1->addresses; |
|
417 | 417 | |
418 | - $rnd = rand(0, sizeof($addresses) - 1); |
|
418 | + $rnd = rand(0, sizeof($addresses) - 1); |
|
419 | 419 | |
420 | - return $addresses[$rnd]; |
|
421 | - } else { |
|
422 | - return null; |
|
423 | - } |
|
424 | - } |
|
420 | + return $addresses[$rnd]; |
|
421 | + } else { |
|
422 | + return null; |
|
423 | + } |
|
424 | + } |
|
425 | 425 | |
426 | - public function getRouteId() |
|
427 | - { |
|
428 | - return $this->route_id; |
|
429 | - } |
|
426 | + public function getRouteId() |
|
427 | + { |
|
428 | + return $this->route_id; |
|
429 | + } |
|
430 | 430 | |
431 | - public function getOptimizationId() |
|
432 | - { |
|
433 | - return $this->optimization_problem_id; |
|
434 | - } |
|
431 | + public function getOptimizationId() |
|
432 | + { |
|
433 | + return $this->optimization_problem_id; |
|
434 | + } |
|
435 | 435 | |
436 | - public function GetLastLocation(array $params) |
|
437 | - { |
|
438 | - $route = Route4Me::makeRequst(array( |
|
439 | - 'url' => Endpoint::ROUTE_V4, |
|
440 | - 'method' => 'GET', |
|
441 | - 'query' => array( |
|
442 | - 'api_key' => Route4Me::getApiKey(), |
|
443 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
444 | - 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null |
|
445 | - ) |
|
446 | - )); |
|
436 | + public function GetLastLocation(array $params) |
|
437 | + { |
|
438 | + $route = Route4Me::makeRequst(array( |
|
439 | + 'url' => Endpoint::ROUTE_V4, |
|
440 | + 'method' => 'GET', |
|
441 | + 'query' => array( |
|
442 | + 'api_key' => Route4Me::getApiKey(), |
|
443 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
444 | + 'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null |
|
445 | + ) |
|
446 | + )); |
|
447 | 447 | |
448 | - return Route::fromArray($route); |
|
449 | - } |
|
448 | + return Route::fromArray($route); |
|
449 | + } |
|
450 | 450 | |
451 | - public function GetTrackingHistoryFromTimeRange(array $params) |
|
452 | - { |
|
453 | - $route = Route4Me::makeRequst(array( |
|
454 | - 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
455 | - 'method' => 'GET', |
|
456 | - 'query' => array( |
|
457 | - 'api_key' => Route4Me::getApiKey(), |
|
458 | - 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
459 | - 'format' => isset($params['format']) ? $params['format'] : null, |
|
460 | - 'time_period' => isset($params['time_period']) ? $params['time_period'] : null, |
|
461 | - 'start_date' => isset($params['start_date']) ? $params['start_date'] : null, |
|
462 | - 'end_date' => isset($params['end_date']) ? $params['end_date'] : null |
|
463 | - ) |
|
464 | - )); |
|
451 | + public function GetTrackingHistoryFromTimeRange(array $params) |
|
452 | + { |
|
453 | + $route = Route4Me::makeRequst(array( |
|
454 | + 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
455 | + 'method' => 'GET', |
|
456 | + 'query' => array( |
|
457 | + 'api_key' => Route4Me::getApiKey(), |
|
458 | + 'route_id' => isset($params['route_id']) ? $params['route_id'] : null, |
|
459 | + 'format' => isset($params['format']) ? $params['format'] : null, |
|
460 | + 'time_period' => isset($params['time_period']) ? $params['time_period'] : null, |
|
461 | + 'start_date' => isset($params['start_date']) ? $params['start_date'] : null, |
|
462 | + 'end_date' => isset($params['end_date']) ? $params['end_date'] : null |
|
463 | + ) |
|
464 | + )); |
|
465 | 465 | |
466 | - return $route; |
|
467 | - } |
|
466 | + return $route; |
|
467 | + } |
|
468 | 468 | |
469 | - public function GetAssetTracking(array $params) |
|
470 | - { |
|
471 | - $route = Route4Me::makeRequst(array( |
|
472 | - 'url' => Endpoint::STATUS_V4, |
|
473 | - 'method' => 'GET', |
|
474 | - 'query' => array( |
|
475 | - 'api_key' => Route4Me::getApiKey(), |
|
476 | - 'tracking' => isset($params['tracking']) ? $params['tracking'] : null |
|
477 | - ) |
|
478 | - )); |
|
469 | + public function GetAssetTracking(array $params) |
|
470 | + { |
|
471 | + $route = Route4Me::makeRequst(array( |
|
472 | + 'url' => Endpoint::STATUS_V4, |
|
473 | + 'method' => 'GET', |
|
474 | + 'query' => array( |
|
475 | + 'api_key' => Route4Me::getApiKey(), |
|
476 | + 'tracking' => isset($params['tracking']) ? $params['tracking'] : null |
|
477 | + ) |
|
478 | + )); |
|
479 | 479 | |
480 | - return $route; |
|
481 | - } |
|
480 | + return $route; |
|
481 | + } |
|
482 | 482 | } |
@@ -399,7 +399,7 @@ |
||
399 | 399 | |
400 | 400 | public function GetAddressesFromRoute($route_id) |
401 | 401 | { |
402 | - $route1 = Route::getRoutes($route_id,null); |
|
402 | + $route1 = Route::getRoutes($route_id, null); |
|
403 | 403 | |
404 | 404 | if (isset($route1)) { |
405 | 405 | return $route1->addresses; |