@@ -1,7 +1,7 @@ |
||
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; |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | |
19 | 19 | // Select a route with more than 4 addresses. |
20 | 20 | $routesParams = array( |
21 | - "offset" => 0, |
|
22 | - "limit" => 20 |
|
21 | + "offset" => 0, |
|
22 | + "limit" => 20 |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $routes = $route->getRoutes($routesParams); |
@@ -27,12 +27,12 @@ discard block |
||
27 | 27 | $selectedRoute = null; |
28 | 28 | |
29 | 29 | foreach ($routes as $route1) { |
30 | - if (isset($route1->destination_count)) { |
|
31 | - if ($route1->destination_count>4) { |
|
32 | - $selectedRoute = $route->getRoutes(array('route_id' => $route1->route_id)); |
|
33 | - break; |
|
34 | - } |
|
35 | - } |
|
30 | + if (isset($route1->destination_count)) { |
|
31 | + if ($route1->destination_count>4) { |
|
32 | + $selectedRoute = $route->getRoutes(array('route_id' => $route1->route_id)); |
|
33 | + break; |
|
34 | + } |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | assert(!is_null($selectedRoute), "Can't select a route with more than 4 addresses"); |
@@ -44,19 +44,19 @@ discard block |
||
44 | 44 | echo "Route ID-> $routeID, Route destination ID -> $routeDestinationID <br>"; |
45 | 45 | |
46 | 46 | $params = array( |
47 | - "route_id" => $routeID, |
|
48 | - "route_destination_id" => $routeDestinationID, |
|
49 | - "addresses" => array( |
|
50 | - "0" => array( |
|
51 | - "route_destination_id" => $routeDestinationID, |
|
52 | - "sequence_no" => 3 |
|
53 | - ) |
|
54 | - ) |
|
47 | + "route_id" => $routeID, |
|
48 | + "route_destination_id" => $routeDestinationID, |
|
49 | + "addresses" => array( |
|
50 | + "0" => array( |
|
51 | + "route_destination_id" => $routeDestinationID, |
|
52 | + "sequence_no" => 3 |
|
53 | + ) |
|
54 | + ) |
|
55 | 55 | ); |
56 | 56 | |
57 | 57 | $response = $route->resequenceRoute($params); |
58 | 58 | |
59 | 59 | foreach ($response['addresses'] as $address) { |
60 | - Route4Me::simplePrint($address); |
|
61 | - echo "<br>"; |
|
60 | + Route4Me::simplePrint($address); |
|
61 | + echo "<br>"; |
|
62 | 62 | } |
@@ -1,7 +1,7 @@ |
||
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; |
@@ -1,7 +1,7 @@ |
||
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,25 +23,25 @@ |
||
23 | 23 | |
24 | 24 | // Get a route with the path points |
25 | 25 | $params = array( |
26 | - "route_path_output" => "Points", |
|
27 | - "route_id" => $route_id |
|
26 | + "route_path_output" => "Points", |
|
27 | + "route_id" => $route_id |
|
28 | 28 | ); |
29 | 29 | |
30 | 30 | $routeResults = (array)$route->getRoutePoints($params); |
31 | 31 | |
32 | 32 | if (isset($routeResults['addresses'])) { |
33 | - foreach ($routeResults['addresses'] as $key => $address) { |
|
34 | - $araddress = (array)$address; |
|
33 | + foreach ($routeResults['addresses'] as $key => $address) { |
|
34 | + $araddress = (array)$address; |
|
35 | 35 | |
36 | - if (isset($araddress['route_destination_id'])) { |
|
37 | - echo "route_destination_id=".$araddress['route_destination_id']."<br>"; |
|
38 | - } |
|
36 | + if (isset($araddress['route_destination_id'])) { |
|
37 | + echo "route_destination_id=".$araddress['route_destination_id']."<br>"; |
|
38 | + } |
|
39 | 39 | |
40 | - if (isset($araddress['path_to_next'])) { |
|
41 | - echo "path_to_next:<br>"; |
|
42 | - Route4Me::simplePrint($araddress['path_to_next']); |
|
43 | - } |
|
40 | + if (isset($araddress['path_to_next'])) { |
|
41 | + echo "path_to_next:<br>"; |
|
42 | + Route4Me::simplePrint($araddress['path_to_next']); |
|
43 | + } |
|
44 | 44 | |
45 | - echo "<br>"; |
|
46 | - } |
|
45 | + echo "<br>"; |
|
46 | + } |
|
47 | 47 | } |
@@ -1,7 +1,7 @@ |
||
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,26 +23,26 @@ |
||
23 | 23 | |
24 | 24 | // Get a route with the path points |
25 | 25 | $params = array( |
26 | - "route_path_output" => "Points", |
|
27 | - "compress_path_points" => TRUE, |
|
28 | - "route_id" => $route_id |
|
26 | + "route_path_output" => "Points", |
|
27 | + "compress_path_points" => TRUE, |
|
28 | + "route_id" => $route_id |
|
29 | 29 | ); |
30 | 30 | |
31 | 31 | $routeResults = (array)$route->getRoutePoints($params); |
32 | 32 | |
33 | 33 | if (isset($routeResults['addresses'])) { |
34 | - foreach ($routeResults['addresses'] as $key => $address) { |
|
35 | - $araddress = (array)$address; |
|
34 | + foreach ($routeResults['addresses'] as $key => $address) { |
|
35 | + $araddress = (array)$address; |
|
36 | 36 | |
37 | - if (isset($araddress['route_destination_id'])) { |
|
38 | - echo "route_destination_id=".$araddress['route_destination_id']."<br>"; |
|
39 | - } |
|
37 | + if (isset($araddress['route_destination_id'])) { |
|
38 | + echo "route_destination_id=".$araddress['route_destination_id']."<br>"; |
|
39 | + } |
|
40 | 40 | |
41 | - if (isset($araddress['path_to_next'])) { |
|
42 | - echo "path_to_next:<br>"; |
|
43 | - Route4Me::simplePrint((array)$araddress['path_to_next']); |
|
44 | - } |
|
41 | + if (isset($araddress['path_to_next'])) { |
|
42 | + echo "path_to_next:<br>"; |
|
43 | + Route4Me::simplePrint((array)$araddress['path_to_next']); |
|
44 | + } |
|
45 | 45 | |
46 | - echo "<br>"; |
|
47 | - } |
|
46 | + echo "<br>"; |
|
47 | + } |
|
48 | 48 | } |
@@ -23,8 +23,8 @@ |
||
23 | 23 | |
24 | 24 | // Get a route with the directions |
25 | 25 | $params = array( |
26 | - "directions" => 1, |
|
27 | - "route_id" => $route_id |
|
26 | + "directions" => 1, |
|
27 | + "route_id" => $route_id |
|
28 | 28 | ); |
29 | 29 | |
30 | 30 | $routeResults = (array)$route->getRoutePoints($params); |
@@ -1,7 +1,7 @@ |
||
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; |
@@ -7,16 +7,16 @@ |
||
7 | 7 | |
8 | 8 | class Track extends Common |
9 | 9 | { |
10 | - public static function set(TrackSetParams $params) |
|
11 | - { |
|
12 | - $allQueryFields = Route4Me::getObjectProperties(new TrackSetParams(), array('tx_id')); |
|
10 | + public static function set(TrackSetParams $params) |
|
11 | + { |
|
12 | + $allQueryFields = Route4Me::getObjectProperties(new TrackSetParams(), array('tx_id')); |
|
13 | 13 | |
14 | - $json = Route4Me::makeRequst(array( |
|
15 | - 'url' => Endpoint::TRACK_SET, |
|
16 | - 'method' => 'GET', |
|
17 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
18 | - )); |
|
14 | + $json = Route4Me::makeRequst(array( |
|
15 | + 'url' => Endpoint::TRACK_SET, |
|
16 | + 'method' => 'GET', |
|
17 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
18 | + )); |
|
19 | 19 | |
20 | - return $json; |
|
21 | - } |
|
20 | + return $json; |
|
21 | + } |
|
22 | 22 | } |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | |
216 | 216 | public static function searchOrder($params) |
217 | 217 | { |
218 | - $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
218 | + $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'); |
|
219 | 219 | |
220 | 220 | $response = Route4Me::makeRequst(array( |
221 | 221 | 'url' => Endpoint::ORDER_V4, |
@@ -269,11 +269,11 @@ discard block |
||
269 | 269 | $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
270 | 270 | |
271 | 271 | if (!empty($columns)) { |
272 | - array_push($results['fail'],'Empty CSV table'); |
|
272 | + array_push($results['fail'], 'Empty CSV table'); |
|
273 | 273 | return ($results); |
274 | 274 | } |
275 | 275 | |
276 | - $iRow=1; |
|
276 | + $iRow = 1; |
|
277 | 277 | |
278 | 278 | while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
279 | 279 | if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
@@ -327,8 +327,7 @@ |
||
327 | 327 | $orderResults = $order->addOrder($orderParameters); |
328 | 328 | |
329 | 329 | array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
330 | - } |
|
331 | - else { |
|
330 | + } else { |
|
332 | 331 | array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
333 | 332 | } |
334 | 333 |
@@ -6,333 +6,333 @@ |
||
6 | 6 | |
7 | 7 | class Order extends Common |
8 | 8 | { |
9 | - public $address_1; |
|
10 | - public $address_2; |
|
11 | - public $cached_lat; |
|
12 | - public $cached_lng; |
|
13 | - public $curbside_lat; |
|
14 | - public $curbside_lng; |
|
15 | - public $address_alias; |
|
16 | - public $address_city; |
|
17 | - public $EXT_FIELD_first_name; |
|
18 | - public $EXT_FIELD_last_name; |
|
19 | - public $EXT_FIELD_email; |
|
20 | - public $EXT_FIELD_phone; |
|
21 | - public $EXT_FIELD_custom_data; |
|
9 | + public $address_1; |
|
10 | + public $address_2; |
|
11 | + public $cached_lat; |
|
12 | + public $cached_lng; |
|
13 | + public $curbside_lat; |
|
14 | + public $curbside_lng; |
|
15 | + public $address_alias; |
|
16 | + public $address_city; |
|
17 | + public $EXT_FIELD_first_name; |
|
18 | + public $EXT_FIELD_last_name; |
|
19 | + public $EXT_FIELD_email; |
|
20 | + public $EXT_FIELD_phone; |
|
21 | + public $EXT_FIELD_custom_data; |
|
22 | 22 | |
23 | - public $color; |
|
24 | - public $order_icon; |
|
25 | - public $local_time_window_start; |
|
26 | - public $local_time_window_end; |
|
27 | - public $local_time_window_start_2; |
|
28 | - public $local_time_window_end_2; |
|
29 | - public $service_time; |
|
23 | + public $color; |
|
24 | + public $order_icon; |
|
25 | + public $local_time_window_start; |
|
26 | + public $local_time_window_end; |
|
27 | + public $local_time_window_start_2; |
|
28 | + public $local_time_window_end_2; |
|
29 | + public $service_time; |
|
30 | 30 | |
31 | - public $day_scheduled_for_YYMMDD; |
|
31 | + public $day_scheduled_for_YYMMDD; |
|
32 | 32 | |
33 | - public $route_id; |
|
34 | - public $redirect; |
|
35 | - public $optimization_problem_id; |
|
36 | - public $order_id; |
|
37 | - public $order_ids; |
|
33 | + public $route_id; |
|
34 | + public $redirect; |
|
35 | + public $optimization_problem_id; |
|
36 | + public $order_id; |
|
37 | + public $order_ids; |
|
38 | 38 | |
39 | - public $day_added_YYMMDD; |
|
40 | - public $scheduled_for_YYMMDD; |
|
41 | - public $fields; |
|
42 | - public $offset; |
|
43 | - public $limit; |
|
44 | - public $query; |
|
39 | + public $day_added_YYMMDD; |
|
40 | + public $scheduled_for_YYMMDD; |
|
41 | + public $fields; |
|
42 | + public $offset; |
|
43 | + public $limit; |
|
44 | + public $query; |
|
45 | 45 | |
46 | - public $created_timestamp; |
|
47 | - public $order_status_id; |
|
48 | - public $member_id; |
|
49 | - public $address_state_id; |
|
50 | - public $address_country_id; |
|
51 | - public $address_zip; |
|
52 | - public $in_route_count; |
|
53 | - public $last_visited_timestamp; |
|
54 | - public $last_routed_timestamp; |
|
55 | - public $local_timezone_string; |
|
56 | - public $is_validated; |
|
57 | - public $is_pending; |
|
58 | - public $is_accepted; |
|
59 | - public $is_started; |
|
60 | - public $is_completed; |
|
61 | - public $custom_user_fields; |
|
46 | + public $created_timestamp; |
|
47 | + public $order_status_id; |
|
48 | + public $member_id; |
|
49 | + public $address_state_id; |
|
50 | + public $address_country_id; |
|
51 | + public $address_zip; |
|
52 | + public $in_route_count; |
|
53 | + public $last_visited_timestamp; |
|
54 | + public $last_routed_timestamp; |
|
55 | + public $local_timezone_string; |
|
56 | + public $is_validated; |
|
57 | + public $is_pending; |
|
58 | + public $is_accepted; |
|
59 | + public $is_started; |
|
60 | + public $is_completed; |
|
61 | + public $custom_user_fields; |
|
62 | 62 | |
63 | - public $addresses = array(); |
|
63 | + public $addresses = array(); |
|
64 | 64 | |
65 | - public static function fromArray(array $params) { |
|
66 | - $order = new Order(); |
|
67 | - foreach ($params as $key => $value) { |
|
68 | - if (property_exists($order, $key)) { |
|
69 | - $order->{$key} = $value; |
|
70 | - } |
|
71 | - } |
|
65 | + public static function fromArray(array $params) { |
|
66 | + $order = new Order(); |
|
67 | + foreach ($params as $key => $value) { |
|
68 | + if (property_exists($order, $key)) { |
|
69 | + $order->{$key} = $value; |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - return $order; |
|
74 | - } |
|
73 | + return $order; |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param Order $params |
|
78 | - */ |
|
79 | - public static function addOrder($params) |
|
80 | - { |
|
81 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
82 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
76 | + /** |
|
77 | + * @param Order $params |
|
78 | + */ |
|
79 | + public static function addOrder($params) |
|
80 | + { |
|
81 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
82 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
83 | 83 | |
84 | - $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
84 | + $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
85 | 85 | |
86 | - $response = Route4Me::makeRequst(array( |
|
87 | - 'url' => Endpoint::ORDER_V4, |
|
88 | - 'method' => 'POST', |
|
89 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
90 | - )); |
|
86 | + $response = Route4Me::makeRequst(array( |
|
87 | + 'url' => Endpoint::ORDER_V4, |
|
88 | + 'method' => 'POST', |
|
89 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
90 | + )); |
|
91 | 91 | |
92 | - return $response; |
|
93 | - } |
|
92 | + return $response; |
|
93 | + } |
|
94 | 94 | |
95 | - public static function addOrder2Route($params) |
|
96 | - { |
|
97 | - $allQueryFields = array('route_id', 'redirect'); |
|
98 | - $allBodyFields = array('addresses'); |
|
95 | + public static function addOrder2Route($params) |
|
96 | + { |
|
97 | + $allQueryFields = array('route_id', 'redirect'); |
|
98 | + $allBodyFields = array('addresses'); |
|
99 | 99 | |
100 | - $response = Route4Me::makeRequst(array( |
|
101 | - 'url' => Endpoint::ROUTE_V4, |
|
102 | - 'method' => 'PUT', |
|
103 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
104 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
105 | - )); |
|
100 | + $response = Route4Me::makeRequst(array( |
|
101 | + 'url' => Endpoint::ROUTE_V4, |
|
102 | + 'method' => 'PUT', |
|
103 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
104 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
105 | + )); |
|
106 | 106 | |
107 | - return $response; |
|
108 | - } |
|
107 | + return $response; |
|
108 | + } |
|
109 | 109 | |
110 | - public static function addOrder2Optimization($params) |
|
111 | - { |
|
112 | - $allQueryFields = array('optimization_problem_id', 'redirect', 'device_type'); |
|
113 | - $allBodyFields = array('addresses'); |
|
110 | + public static function addOrder2Optimization($params) |
|
111 | + { |
|
112 | + $allQueryFields = array('optimization_problem_id', 'redirect', 'device_type'); |
|
113 | + $allBodyFields = array('addresses'); |
|
114 | 114 | |
115 | - $response = Route4Me::makeRequst(array( |
|
116 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
117 | - 'method' => 'PUT', |
|
118 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
119 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
120 | - )); |
|
115 | + $response = Route4Me::makeRequst(array( |
|
116 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
117 | + 'method' => 'PUT', |
|
118 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
119 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
120 | + )); |
|
121 | 121 | |
122 | - return $response; |
|
123 | - } |
|
122 | + return $response; |
|
123 | + } |
|
124 | 124 | |
125 | - public static function getOrder($params) |
|
126 | - { |
|
127 | - $allQueryFields = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'); |
|
125 | + public static function getOrder($params) |
|
126 | + { |
|
127 | + $allQueryFields = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit'); |
|
128 | 128 | |
129 | - $response = Route4Me::makeRequst(array( |
|
130 | - 'url' => Endpoint::ORDER_V4, |
|
131 | - 'method' => 'GET', |
|
132 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
133 | - )); |
|
129 | + $response = Route4Me::makeRequst(array( |
|
130 | + 'url' => Endpoint::ORDER_V4, |
|
131 | + 'method' => 'GET', |
|
132 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
133 | + )); |
|
134 | 134 | |
135 | - return $response; |
|
136 | - } |
|
135 | + return $response; |
|
136 | + } |
|
137 | 137 | |
138 | - public static function getOrders($params) |
|
139 | - { |
|
140 | - $allQueryFields = array('offset', 'limit'); |
|
138 | + public static function getOrders($params) |
|
139 | + { |
|
140 | + $allQueryFields = array('offset', 'limit'); |
|
141 | 141 | |
142 | - $response = Route4Me::makeRequst(array( |
|
143 | - 'url' => Endpoint::ORDER_V4, |
|
144 | - 'method' => 'GET', |
|
145 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
146 | - )); |
|
142 | + $response = Route4Me::makeRequst(array( |
|
143 | + 'url' => Endpoint::ORDER_V4, |
|
144 | + 'method' => 'GET', |
|
145 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
146 | + )); |
|
147 | 147 | |
148 | - return $response; |
|
149 | - } |
|
148 | + return $response; |
|
149 | + } |
|
150 | 150 | |
151 | - public function getRandomOrderId($offset, $limit) |
|
152 | - { |
|
153 | - $randomOrder = $this->getRandomOrder($offset, $limit); |
|
151 | + public function getRandomOrderId($offset, $limit) |
|
152 | + { |
|
153 | + $randomOrder = $this->getRandomOrder($offset, $limit); |
|
154 | 154 | |
155 | - if (is_null($randomOrder)) { |
|
156 | - return null; |
|
157 | - } |
|
155 | + if (is_null($randomOrder)) { |
|
156 | + return null; |
|
157 | + } |
|
158 | 158 | |
159 | - if (!isset($randomOrder)) { |
|
160 | - return null; |
|
161 | - } |
|
159 | + if (!isset($randomOrder)) { |
|
160 | + return null; |
|
161 | + } |
|
162 | 162 | |
163 | - return $randomOrder['order_id']; |
|
164 | - } |
|
163 | + return $randomOrder['order_id']; |
|
164 | + } |
|
165 | 165 | |
166 | - public function getRandomOrder($offset, $limit) |
|
167 | - { |
|
168 | - $params = array('offset' => $offset, 'limit' => $limit); |
|
166 | + public function getRandomOrder($offset, $limit) |
|
167 | + { |
|
168 | + $params = array('offset' => $offset, 'limit' => $limit); |
|
169 | 169 | |
170 | - $orders = self::getOrders($params); |
|
170 | + $orders = self::getOrders($params); |
|
171 | 171 | |
172 | - if (is_null($orders)) { |
|
173 | - return null; |
|
174 | - } |
|
172 | + if (is_null($orders)) { |
|
173 | + return null; |
|
174 | + } |
|
175 | 175 | |
176 | - if (!isset($orders['results'])) { |
|
177 | - return null; |
|
178 | - } |
|
176 | + if (!isset($orders['results'])) { |
|
177 | + return null; |
|
178 | + } |
|
179 | 179 | |
180 | - $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
180 | + $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
181 | 181 | |
182 | - $order = $orders['results'][$randomIndex]; |
|
182 | + $order = $orders['results'][$randomIndex]; |
|
183 | 183 | |
184 | - return $order; |
|
185 | - } |
|
184 | + return $order; |
|
185 | + } |
|
186 | 186 | |
187 | - public static function removeOrder($params) |
|
188 | - { |
|
189 | - $allBodyFields = array('order_ids'); |
|
187 | + public static function removeOrder($params) |
|
188 | + { |
|
189 | + $allBodyFields = array('order_ids'); |
|
190 | 190 | |
191 | - $response = Route4Me::makeRequst(array( |
|
192 | - 'url' => Endpoint::ORDER_V4, |
|
193 | - 'method' => 'DELETE', |
|
194 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
195 | - )); |
|
191 | + $response = Route4Me::makeRequst(array( |
|
192 | + 'url' => Endpoint::ORDER_V4, |
|
193 | + 'method' => 'DELETE', |
|
194 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
195 | + )); |
|
196 | 196 | |
197 | - return $response; |
|
198 | - } |
|
197 | + return $response; |
|
198 | + } |
|
199 | 199 | |
200 | - public static function updateOrder($params) |
|
201 | - { |
|
202 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', |
|
203 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
200 | + public static function updateOrder($params) |
|
201 | + { |
|
202 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', |
|
203 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
204 | 204 | |
205 | - $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
205 | + $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
206 | 206 | |
207 | - $response = Route4Me::makeRequst(array( |
|
208 | - 'url' => Endpoint::ORDER_V4, |
|
209 | - 'method' => 'PUT', |
|
210 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
211 | - )); |
|
207 | + $response = Route4Me::makeRequst(array( |
|
208 | + 'url' => Endpoint::ORDER_V4, |
|
209 | + 'method' => 'PUT', |
|
210 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
211 | + )); |
|
212 | 212 | |
213 | - return $response; |
|
214 | - } |
|
213 | + return $response; |
|
214 | + } |
|
215 | 215 | |
216 | - public static function searchOrder($params) |
|
217 | - { |
|
218 | - $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
216 | + public static function searchOrder($params) |
|
217 | + { |
|
218 | + $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
219 | 219 | |
220 | - $response = Route4Me::makeRequst(array( |
|
221 | - 'url' => Endpoint::ORDER_V4, |
|
222 | - 'method' => 'GET', |
|
223 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
224 | - )); |
|
220 | + $response = Route4Me::makeRequst(array( |
|
221 | + 'url' => Endpoint::ORDER_V4, |
|
222 | + 'method' => 'GET', |
|
223 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
224 | + )); |
|
225 | 225 | |
226 | - return $response; |
|
227 | - } |
|
226 | + return $response; |
|
227 | + } |
|
228 | 228 | |
229 | - public static function validateCoordinate($coord) |
|
230 | - { |
|
231 | - $key = key($coord); |
|
229 | + public static function validateCoordinate($coord) |
|
230 | + { |
|
231 | + $key = key($coord); |
|
232 | 232 | |
233 | - if (!is_numeric($coord[$key])) { |
|
234 | - return false; |
|
235 | - } |
|
233 | + if (!is_numeric($coord[$key])) { |
|
234 | + return false; |
|
235 | + } |
|
236 | 236 | |
237 | - switch ($key) { |
|
238 | - case 'cached_lat': |
|
239 | - case 'curbside_lat': |
|
240 | - if ($coord[$key]>90 || $coord[$key]<-90) { |
|
241 | - return false; |
|
242 | - } |
|
243 | - break; |
|
244 | - case 'cached_lng': |
|
245 | - case 'curbside_lng': |
|
246 | - if ($coord[$key]>180 || $coord[$key]<-180) { |
|
247 | - return false; |
|
248 | - } |
|
249 | - break; |
|
250 | - } |
|
237 | + switch ($key) { |
|
238 | + case 'cached_lat': |
|
239 | + case 'curbside_lat': |
|
240 | + if ($coord[$key]>90 || $coord[$key]<-90) { |
|
241 | + return false; |
|
242 | + } |
|
243 | + break; |
|
244 | + case 'cached_lng': |
|
245 | + case 'curbside_lng': |
|
246 | + if ($coord[$key]>180 || $coord[$key]<-180) { |
|
247 | + return false; |
|
248 | + } |
|
249 | + break; |
|
250 | + } |
|
251 | 251 | |
252 | - return true; |
|
253 | - } |
|
252 | + return true; |
|
253 | + } |
|
254 | 254 | |
255 | - public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
256 | - { |
|
257 | - $max_line_length = 512; |
|
258 | - $delemietr = ','; |
|
255 | + public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
256 | + { |
|
257 | + $max_line_length = 512; |
|
258 | + $delemietr = ','; |
|
259 | 259 | |
260 | - $results = array(); |
|
261 | - $results['fail'] = array(); |
|
262 | - $results['success'] = array(); |
|
260 | + $results = array(); |
|
261 | + $results['fail'] = array(); |
|
262 | + $results['success'] = array(); |
|
263 | 263 | |
264 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
264 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
265 | 265 | |
266 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
267 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
266 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
267 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
268 | 268 | |
269 | - $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
269 | + $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
270 | 270 | |
271 | - if (!empty($columns)) { |
|
272 | - array_push($results['fail'],'Empty CSV table'); |
|
273 | - return ($results); |
|
274 | - } |
|
271 | + if (!empty($columns)) { |
|
272 | + array_push($results['fail'],'Empty CSV table'); |
|
273 | + return ($results); |
|
274 | + } |
|
275 | 275 | |
276 | - $iRow=1; |
|
276 | + $iRow=1; |
|
277 | 277 | |
278 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
279 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
278 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
279 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
280 | 280 | |
281 | - $cached_lat = 0.000; |
|
282 | - $cached_lng = 0.000; |
|
281 | + $cached_lat = 0.000; |
|
282 | + $cached_lng = 0.000; |
|
283 | 283 | |
284 | - foreach (array('cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng') as $coord) { |
|
285 | - if (!$this->validateCoordinate(array($coord => $rows[$ordersFieldsMapping[$coord]]))) { |
|
286 | - array_push($results['fail'], "$iRow --> Wrong "+$coord); |
|
287 | - $iRow++; |
|
288 | - continue; |
|
289 | - } else { |
|
290 | - switch ($coord) { |
|
291 | - case 'cached_lat': |
|
292 | - $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
293 | - break; |
|
294 | - case 'cached_lng': |
|
295 | - $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
296 | - break; |
|
297 | - } |
|
298 | - } |
|
299 | - } |
|
284 | + foreach (array('cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng') as $coord) { |
|
285 | + if (!$this->validateCoordinate(array($coord => $rows[$ordersFieldsMapping[$coord]]))) { |
|
286 | + array_push($results['fail'], "$iRow --> Wrong "+$coord); |
|
287 | + $iRow++; |
|
288 | + continue; |
|
289 | + } else { |
|
290 | + switch ($coord) { |
|
291 | + case 'cached_lat': |
|
292 | + $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
293 | + break; |
|
294 | + case 'cached_lng': |
|
295 | + $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
296 | + break; |
|
297 | + } |
|
298 | + } |
|
299 | + } |
|
300 | 300 | |
301 | - $address = $rows[$ordersFieldsMapping['address_1']]; |
|
301 | + $address = $rows[$ordersFieldsMapping['address_1']]; |
|
302 | 302 | |
303 | - foreach (array('order_city', 'order_state_id', 'order_zip_code', 'order_country_id') as $addressPart) { |
|
304 | - if (isset($ordersFieldsMapping[$addressPart])) { |
|
305 | - $address .= ', '.$rows[$ordersFieldsMapping[$addressPart]]; |
|
306 | - } |
|
307 | - } |
|
303 | + foreach (array('order_city', 'order_state_id', 'order_zip_code', 'order_country_id') as $addressPart) { |
|
304 | + if (isset($ordersFieldsMapping[$addressPart])) { |
|
305 | + $address .= ', '.$rows[$ordersFieldsMapping[$addressPart]]; |
|
306 | + } |
|
307 | + } |
|
308 | 308 | |
309 | - echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
309 | + echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
310 | 310 | |
311 | - $parametersArray = array(); |
|
311 | + $parametersArray = array(); |
|
312 | 312 | |
313 | - $parametersArray["cached_lat"] = $cached_lat; |
|
314 | - $parametersArray["cached_lng"] = $cached_lng; |
|
313 | + $parametersArray["cached_lat"] = $cached_lat; |
|
314 | + $parametersArray["cached_lng"] = $cached_lng; |
|
315 | 315 | |
316 | 316 | |
317 | - foreach ($allOrderFields as $orderField) { |
|
318 | - if (isset($ordersFieldsMapping[$orderField])) { |
|
319 | - $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
320 | - } |
|
321 | - } |
|
317 | + foreach ($allOrderFields as $orderField) { |
|
318 | + if (isset($ordersFieldsMapping[$orderField])) { |
|
319 | + $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
320 | + } |
|
321 | + } |
|
322 | 322 | |
323 | - $orderParameters = Order::fromArray($parametersArray); |
|
323 | + $orderParameters = Order::fromArray($parametersArray); |
|
324 | 324 | |
325 | - $order = new Order(); |
|
325 | + $order = new Order(); |
|
326 | 326 | |
327 | - $orderResults = $order->addOrder($orderParameters); |
|
327 | + $orderResults = $order->addOrder($orderParameters); |
|
328 | 328 | |
329 | - array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
330 | - } |
|
331 | - else { |
|
332 | - array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
333 | - } |
|
329 | + array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
330 | + } |
|
331 | + else { |
|
332 | + array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
333 | + } |
|
334 | 334 | |
335 | - $iRow++; |
|
336 | - } |
|
337 | - } |
|
335 | + $iRow++; |
|
336 | + } |
|
337 | + } |
|
338 | 338 | } |
@@ -6,157 +6,157 @@ |
||
6 | 6 | |
7 | 7 | class Vehicle extends Common |
8 | 8 | { |
9 | - public $vehicle_id; |
|
10 | - public $member_id; |
|
11 | - public $is_deleted; |
|
12 | - public $vehicle_alias; |
|
13 | - public $vehicle_vin; |
|
14 | - public $vehicle_reg_state_id; |
|
15 | - public $vehicle_reg_country_id; |
|
16 | - public $vehicle_license_plate; |
|
17 | - public $vehicle_type_id; |
|
18 | - public $vehicle_make; |
|
19 | - public $vehicle_model_year; |
|
20 | - public $vehicle_model; |
|
21 | - public $vehicle_year_acquired; |
|
22 | - public $vehicle_cost_new; |
|
23 | - public $purchased_new; |
|
24 | - public $license_start_date; |
|
25 | - public $license_end_date; |
|
26 | - public $vehicle_axle_count; |
|
27 | - public $is_operational; |
|
28 | - public $mpg_city; |
|
29 | - public $mpg_highway; |
|
30 | - public $fuel_type; |
|
31 | - public $height_inches; |
|
32 | - public $weight_lb; |
|
33 | - public $external_telematics_vehicle_id; |
|
34 | - public $has_trailer; |
|
35 | - public $heightInInches; |
|
36 | - public $lengthInInches; |
|
37 | - public $widthInInches; |
|
38 | - public $maxWeightPerAxleGroupInPounds; |
|
39 | - public $numAxles; |
|
40 | - public $weightInPounds; |
|
41 | - public $HazmatType; |
|
42 | - public $LowEmissionZonePref; |
|
43 | - public $Use53FootTrailerRouting; |
|
44 | - public $UseNationalNetwork; |
|
45 | - public $UseTruckRestrictions; |
|
46 | - public $AvoidFerries; |
|
47 | - public $DividedHighwayAvoidPreference; |
|
48 | - public $FreewayAvoidPreference; |
|
49 | - public $InternationalBordersOpen; |
|
50 | - public $TollRoadUsage; |
|
51 | - public $hwy_only; |
|
52 | - public $long_combination_vehicle; |
|
53 | - public $avoid_highways; |
|
54 | - public $side_street_adherence; |
|
55 | - public $truck_config; |
|
56 | - public $height_metric; |
|
57 | - public $length_metric; |
|
58 | - public $width_metric; |
|
59 | - public $weight_metric; |
|
60 | - public $max_weight_per_axle_group_metric; |
|
9 | + public $vehicle_id; |
|
10 | + public $member_id; |
|
11 | + public $is_deleted; |
|
12 | + public $vehicle_alias; |
|
13 | + public $vehicle_vin; |
|
14 | + public $vehicle_reg_state_id; |
|
15 | + public $vehicle_reg_country_id; |
|
16 | + public $vehicle_license_plate; |
|
17 | + public $vehicle_type_id; |
|
18 | + public $vehicle_make; |
|
19 | + public $vehicle_model_year; |
|
20 | + public $vehicle_model; |
|
21 | + public $vehicle_year_acquired; |
|
22 | + public $vehicle_cost_new; |
|
23 | + public $purchased_new; |
|
24 | + public $license_start_date; |
|
25 | + public $license_end_date; |
|
26 | + public $vehicle_axle_count; |
|
27 | + public $is_operational; |
|
28 | + public $mpg_city; |
|
29 | + public $mpg_highway; |
|
30 | + public $fuel_type; |
|
31 | + public $height_inches; |
|
32 | + public $weight_lb; |
|
33 | + public $external_telematics_vehicle_id; |
|
34 | + public $has_trailer; |
|
35 | + public $heightInInches; |
|
36 | + public $lengthInInches; |
|
37 | + public $widthInInches; |
|
38 | + public $maxWeightPerAxleGroupInPounds; |
|
39 | + public $numAxles; |
|
40 | + public $weightInPounds; |
|
41 | + public $HazmatType; |
|
42 | + public $LowEmissionZonePref; |
|
43 | + public $Use53FootTrailerRouting; |
|
44 | + public $UseNationalNetwork; |
|
45 | + public $UseTruckRestrictions; |
|
46 | + public $AvoidFerries; |
|
47 | + public $DividedHighwayAvoidPreference; |
|
48 | + public $FreewayAvoidPreference; |
|
49 | + public $InternationalBordersOpen; |
|
50 | + public $TollRoadUsage; |
|
51 | + public $hwy_only; |
|
52 | + public $long_combination_vehicle; |
|
53 | + public $avoid_highways; |
|
54 | + public $side_street_adherence; |
|
55 | + public $truck_config; |
|
56 | + public $height_metric; |
|
57 | + public $length_metric; |
|
58 | + public $width_metric; |
|
59 | + public $weight_metric; |
|
60 | + public $max_weight_per_axle_group_metric; |
|
61 | 61 | |
62 | - public function __construct () |
|
63 | - { |
|
64 | - Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
|
65 | - } |
|
62 | + public function __construct () |
|
63 | + { |
|
64 | + Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
|
65 | + } |
|
66 | 66 | |
67 | - public static function fromArray(array $params) { |
|
68 | - $vehicle= new Vehicle(); |
|
69 | - foreach($params as $key => $value) { |
|
70 | - if (property_exists($vehicle, $key)) { |
|
71 | - $vehicle->{$key} = $value; |
|
72 | - } |
|
73 | - } |
|
67 | + public static function fromArray(array $params) { |
|
68 | + $vehicle= new Vehicle(); |
|
69 | + foreach($params as $key => $value) { |
|
70 | + if (property_exists($vehicle, $key)) { |
|
71 | + $vehicle->{$key} = $value; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - return $vehicle; |
|
76 | - } |
|
75 | + return $vehicle; |
|
76 | + } |
|
77 | 77 | |
78 | - public static function getVehicles($params) |
|
79 | - { |
|
80 | - $allQueryFields = array('with_pagination', 'page', 'perPage'); |
|
78 | + public static function getVehicles($params) |
|
79 | + { |
|
80 | + $allQueryFields = array('with_pagination', 'page', 'perPage'); |
|
81 | 81 | |
82 | - $response = Route4Me::makeRequst(array( |
|
83 | - 'url' => Endpoint::VEHICLE_V4, |
|
84 | - 'method' => 'GET', |
|
85 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
86 | - )); |
|
82 | + $response = Route4Me::makeRequst(array( |
|
83 | + 'url' => Endpoint::VEHICLE_V4, |
|
84 | + 'method' => 'GET', |
|
85 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
86 | + )); |
|
87 | 87 | |
88 | - return $response; |
|
89 | - } |
|
88 | + return $response; |
|
89 | + } |
|
90 | 90 | |
91 | - public function getRandomVehicleId($page,$perPage) |
|
92 | - { |
|
93 | - $params = array( |
|
94 | - 'page' => isset($page) ? $page : 1, |
|
95 | - 'perPage' => isset($perPage) ? $perPage : 10, |
|
96 | - 'with_pagination' => true |
|
97 | - ); |
|
91 | + public function getRandomVehicleId($page,$perPage) |
|
92 | + { |
|
93 | + $params = array( |
|
94 | + 'page' => isset($page) ? $page : 1, |
|
95 | + 'perPage' => isset($perPage) ? $perPage : 10, |
|
96 | + 'with_pagination' => true |
|
97 | + ); |
|
98 | 98 | |
99 | - $vehicles = $this->getVehicles($params); |
|
99 | + $vehicles = $this->getVehicles($params); |
|
100 | 100 | |
101 | - if (is_null($vehicles)) return null; |
|
102 | - if (!isset($vehicles['data'])) return null; |
|
103 | - if (sizeof($vehicles['data'])<1) return null; |
|
101 | + if (is_null($vehicles)) return null; |
|
102 | + if (!isset($vehicles['data'])) return null; |
|
103 | + if (sizeof($vehicles['data'])<1) return null; |
|
104 | 104 | |
105 | - $randomIndex = rand(0, sizeof($vehicles['data'])-1); |
|
105 | + $randomIndex = rand(0, sizeof($vehicles['data'])-1); |
|
106 | 106 | |
107 | - return $vehicles['data'][$randomIndex]['vehicle_id']; |
|
108 | - } |
|
107 | + return $vehicles['data'][$randomIndex]['vehicle_id']; |
|
108 | + } |
|
109 | 109 | |
110 | - public function getVehicleByID($vehicleID) |
|
111 | - { |
|
112 | - $response = Route4Me::makeRequst(array( |
|
113 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
114 | - 'method' => 'GET' |
|
115 | - )); |
|
110 | + public function getVehicleByID($vehicleID) |
|
111 | + { |
|
112 | + $response = Route4Me::makeRequst(array( |
|
113 | + 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
114 | + 'method' => 'GET' |
|
115 | + )); |
|
116 | 116 | |
117 | - return $response; |
|
118 | - } |
|
117 | + return $response; |
|
118 | + } |
|
119 | 119 | |
120 | - public function updateVehicle($params) |
|
121 | - { |
|
122 | - $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
120 | + public function updateVehicle($params) |
|
121 | + { |
|
122 | + $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
123 | 123 | |
124 | - $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
|
124 | + $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
|
125 | 125 | |
126 | - $response = Route4Me::makeRequst(array( |
|
127 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
128 | - 'method' => 'PUT', |
|
129 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
130 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
131 | - )); |
|
126 | + $response = Route4Me::makeRequst(array( |
|
127 | + 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
128 | + 'method' => 'PUT', |
|
129 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
130 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
131 | + )); |
|
132 | 132 | |
133 | - return $response; |
|
134 | - } |
|
133 | + return $response; |
|
134 | + } |
|
135 | 135 | |
136 | - public function createVehicle($params) |
|
137 | - { |
|
138 | - $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
|
136 | + public function createVehicle($params) |
|
137 | + { |
|
138 | + $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
|
139 | 139 | |
140 | - $response = Route4Me::makeRequst(array( |
|
141 | - 'url' => Endpoint::VEHICLE_V4, |
|
142 | - 'method' => 'POST', |
|
143 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
144 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
145 | - )); |
|
140 | + $response = Route4Me::makeRequst(array( |
|
141 | + 'url' => Endpoint::VEHICLE_V4, |
|
142 | + 'method' => 'POST', |
|
143 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
144 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
145 | + )); |
|
146 | 146 | |
147 | - return $response; |
|
148 | - } |
|
147 | + return $response; |
|
148 | + } |
|
149 | 149 | |
150 | - public function removeVehicle($params) |
|
151 | - { |
|
152 | - $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
150 | + public function removeVehicle($params) |
|
151 | + { |
|
152 | + $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
|
153 | 153 | |
154 | - $response = Route4Me::makeRequst(array( |
|
155 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
156 | - 'method' => 'DELETE', |
|
157 | - 'HTTPHEADER' => 'Content-Type: application/json' |
|
158 | - )); |
|
154 | + $response = Route4Me::makeRequst(array( |
|
155 | + 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
156 | + 'method' => 'DELETE', |
|
157 | + 'HTTPHEADER' => 'Content-Type: application/json' |
|
158 | + )); |
|
159 | 159 | |
160 | - return $response; |
|
161 | - } |
|
160 | + return $response; |
|
161 | + } |
|
162 | 162 | } |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | public $weight_metric; |
60 | 60 | public $max_weight_per_axle_group_metric; |
61 | 61 | |
62 | - public function __construct () |
|
62 | + public function __construct() |
|
63 | 63 | { |
64 | 64 | Route4Me::setBaseUrl(Endpoint::WH_BASE_URL); |
65 | 65 | } |
66 | 66 | |
67 | 67 | public static function fromArray(array $params) { |
68 | - $vehicle= new Vehicle(); |
|
69 | - foreach($params as $key => $value) { |
|
68 | + $vehicle = new Vehicle(); |
|
69 | + foreach ($params as $key => $value) { |
|
70 | 70 | if (property_exists($vehicle, $key)) { |
71 | 71 | $vehicle->{$key} = $value; |
72 | 72 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | return $response; |
89 | 89 | } |
90 | 90 | |
91 | - public function getRandomVehicleId($page,$perPage) |
|
91 | + public function getRandomVehicleId($page, $perPage) |
|
92 | 92 | { |
93 | 93 | $params = array( |
94 | 94 | 'page' => isset($page) ? $page : 1, |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | if (!isset($vehicles['data'])) return null; |
103 | 103 | if (sizeof($vehicles['data'])<1) return null; |
104 | 104 | |
105 | - $randomIndex = rand(0, sizeof($vehicles['data'])-1); |
|
105 | + $randomIndex = rand(0, sizeof($vehicles['data']) - 1); |
|
106 | 106 | |
107 | 107 | return $vehicles['data'][$randomIndex]['vehicle_id']; |
108 | 108 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | public function getVehicleByID($vehicleID) |
111 | 111 | { |
112 | 112 | $response = Route4Me::makeRequst(array( |
113 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
113 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
114 | 114 | 'method' => 'GET' |
115 | 115 | )); |
116 | 116 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $allBodyFields = Route4Me::getObjectProperties(new Vehicle(), array('vehicle_id')); |
125 | 125 | |
126 | 126 | $response = Route4Me::makeRequst(array( |
127 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
127 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
128 | 128 | 'method' => 'PUT', |
129 | 129 | 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
130 | 130 | 'HTTPHEADER' => 'Content-Type: application/json' |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $vehicleID = isset($params->vehicle_id) ? $params->vehicle_id : null; |
153 | 153 | |
154 | 154 | $response = Route4Me::makeRequst(array( |
155 | - 'url' => Endpoint::VEHICLE_V4 . '/' . $vehicleID, |
|
155 | + 'url' => Endpoint::VEHICLE_V4.'/'.$vehicleID, |
|
156 | 156 | 'method' => 'DELETE', |
157 | 157 | 'HTTPHEADER' => 'Content-Type: application/json' |
158 | 158 | )); |
@@ -98,9 +98,15 @@ |
||
98 | 98 | |
99 | 99 | $vehicles = $this->getVehicles($params); |
100 | 100 | |
101 | - if (is_null($vehicles)) return null; |
|
102 | - if (!isset($vehicles['data'])) return null; |
|
103 | - if (sizeof($vehicles['data'])<1) return null; |
|
101 | + if (is_null($vehicles)) { |
|
102 | + return null; |
|
103 | + } |
|
104 | + if (!isset($vehicles['data'])) { |
|
105 | + return null; |
|
106 | + } |
|
107 | + if (sizeof($vehicles['data'])<1) { |
|
108 | + return null; |
|
109 | + } |
|
104 | 110 | |
105 | 111 | $randomIndex = rand(0, sizeof($vehicles['data'])-1); |
106 | 112 |
@@ -6,106 +6,106 @@ |
||
6 | 6 | |
7 | 7 | class Geocoding extends Common |
8 | 8 | { |
9 | - public $strExportFormat; |
|
10 | - public $format; |
|
11 | - public $addresses; |
|
12 | - public $pk; |
|
13 | - public $offset; |
|
14 | - public $limit; |
|
15 | - public $housenumber; |
|
16 | - public $zipcode; |
|
9 | + public $strExportFormat; |
|
10 | + public $format; |
|
11 | + public $addresses; |
|
12 | + public $pk; |
|
13 | + public $offset; |
|
14 | + public $limit; |
|
15 | + public $housenumber; |
|
16 | + public $zipcode; |
|
17 | 17 | |
18 | - public static function fromArray(array $params) |
|
19 | - { |
|
20 | - $geocoding = new Geocoding(); |
|
18 | + public static function fromArray(array $params) |
|
19 | + { |
|
20 | + $geocoding = new Geocoding(); |
|
21 | 21 | |
22 | - foreach($params as $key => $value) { |
|
23 | - if (property_exists($geocoding, $key)) { |
|
24 | - $geocoding->{$key} = $value; |
|
25 | - } |
|
26 | - } |
|
22 | + foreach($params as $key => $value) { |
|
23 | + if (property_exists($geocoding, $key)) { |
|
24 | + $geocoding->{$key} = $value; |
|
25 | + } |
|
26 | + } |
|
27 | 27 | |
28 | - return $geocoding; |
|
29 | - } |
|
28 | + return $geocoding; |
|
29 | + } |
|
30 | 30 | |
31 | - public static function forwardGeocoding($params) |
|
32 | - { |
|
33 | - $allBodyFields = array('strExportFormat', 'addresses'); |
|
31 | + public static function forwardGeocoding($params) |
|
32 | + { |
|
33 | + $allBodyFields = array('strExportFormat', 'addresses'); |
|
34 | 34 | |
35 | - $fgCoding = Route4Me::makeRequst(array( |
|
36 | - 'url' => Endpoint::GEOCODER, |
|
37 | - 'method' => 'POST', |
|
38 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
39 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
40 | - )); |
|
35 | + $fgCoding = Route4Me::makeRequst(array( |
|
36 | + 'url' => Endpoint::GEOCODER, |
|
37 | + 'method' => 'POST', |
|
38 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
39 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
40 | + )); |
|
41 | 41 | |
42 | - return $fgCoding; |
|
43 | - } |
|
42 | + return $fgCoding; |
|
43 | + } |
|
44 | 44 | |
45 | - public static function reverseGeocoding($params) |
|
46 | - { |
|
47 | - $allQueryFields = array('format', 'addresses', 'detailed'); |
|
45 | + public static function reverseGeocoding($params) |
|
46 | + { |
|
47 | + $allQueryFields = array('format', 'addresses', 'detailed'); |
|
48 | 48 | |
49 | - $fgcoding = Route4Me::makeRequst(array( |
|
50 | - 'url' => Endpoint::GEOCODER, |
|
51 | - 'method' => 'POST', |
|
52 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
53 | - )); |
|
49 | + $fgcoding = Route4Me::makeRequst(array( |
|
50 | + 'url' => Endpoint::GEOCODER, |
|
51 | + 'method' => 'POST', |
|
52 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
53 | + )); |
|
54 | 54 | |
55 | - return $fgcoding; |
|
56 | - } |
|
55 | + return $fgcoding; |
|
56 | + } |
|
57 | 57 | |
58 | - public static function getStreetData($params) |
|
59 | - { |
|
60 | - $url_query = Endpoint::STREET_DATA; |
|
58 | + public static function getStreetData($params) |
|
59 | + { |
|
60 | + $url_query = Endpoint::STREET_DATA; |
|
61 | 61 | |
62 | - $allPathFields = array('pk', 'offset', 'limit'); |
|
62 | + $allPathFields = array('pk', 'offset', 'limit'); |
|
63 | 63 | |
64 | - $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
64 | + $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
65 | 65 | |
66 | - $query = array(); |
|
66 | + $query = array(); |
|
67 | 67 | |
68 | - $response = Route4Me::makeUrlRequst($url_query, array( |
|
69 | - 'method' => 'GET', |
|
70 | - 'query' => $query |
|
71 | - )); |
|
68 | + $response = Route4Me::makeUrlRequst($url_query, array( |
|
69 | + 'method' => 'GET', |
|
70 | + 'query' => $query |
|
71 | + )); |
|
72 | 72 | |
73 | - return $response; |
|
74 | - } |
|
73 | + return $response; |
|
74 | + } |
|
75 | 75 | |
76 | - public static function getZipCode($params) |
|
77 | - { |
|
78 | - $url_query = Endpoint::STREET_DATA_ZIPCODE; |
|
76 | + public static function getZipCode($params) |
|
77 | + { |
|
78 | + $url_query = Endpoint::STREET_DATA_ZIPCODE; |
|
79 | 79 | |
80 | - $allPathFields = array('zipcode', 'offset', 'limit'); |
|
80 | + $allPathFields = array('zipcode', 'offset', 'limit'); |
|
81 | 81 | |
82 | - $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
82 | + $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
83 | 83 | |
84 | - $query = array(); |
|
84 | + $query = array(); |
|
85 | 85 | |
86 | - $response = Route4Me::makeUrlRequst($url_query, array( |
|
87 | - 'method' => 'GET', |
|
88 | - 'query' => $query |
|
89 | - )); |
|
86 | + $response = Route4Me::makeUrlRequst($url_query, array( |
|
87 | + 'method' => 'GET', |
|
88 | + 'query' => $query |
|
89 | + )); |
|
90 | 90 | |
91 | - return $response; |
|
92 | - } |
|
91 | + return $response; |
|
92 | + } |
|
93 | 93 | |
94 | - public static function getService($params) |
|
95 | - { |
|
96 | - $url_query = Endpoint::STREET_DATA_SERVICE; |
|
94 | + public static function getService($params) |
|
95 | + { |
|
96 | + $url_query = Endpoint::STREET_DATA_SERVICE; |
|
97 | 97 | |
98 | - $allPathFields = array('zipcode', 'housenumber', 'offset', 'limit'); |
|
98 | + $allPathFields = array('zipcode', 'housenumber', 'offset', 'limit'); |
|
99 | 99 | |
100 | - $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
100 | + $url_query .= Route4Me::generateUrlPath($allPathFields, $params); |
|
101 | 101 | |
102 | - $query = array(); |
|
102 | + $query = array(); |
|
103 | 103 | |
104 | - $response = Route4Me::makeUrlRequst($url_query, array( |
|
105 | - 'method' => 'GET', |
|
106 | - 'query' => $query |
|
107 | - )); |
|
104 | + $response = Route4Me::makeUrlRequst($url_query, array( |
|
105 | + 'method' => 'GET', |
|
106 | + 'query' => $query |
|
107 | + )); |
|
108 | 108 | |
109 | - return $response; |
|
110 | - } |
|
109 | + return $response; |
|
110 | + } |
|
111 | 111 | } |
@@ -19,7 +19,7 @@ |
||
19 | 19 | { |
20 | 20 | $geocoding = new Geocoding(); |
21 | 21 | |
22 | - foreach($params as $key => $value) { |
|
22 | + foreach ($params as $key => $value) { |
|
23 | 23 | if (property_exists($geocoding, $key)) { |
24 | 24 | $geocoding->{$key} = $value; |
25 | 25 | } |