@@ -6,372 +6,372 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Order extends Common |
| 8 | 8 | { |
| 9 | - public $address_1; |
|
| 10 | - public $address_2; |
|
| 11 | - public $cached_lat; |
|
| 12 | - public $cached_lng; |
|
| 13 | - public $curbside_lat; |
|
| 14 | - public $curbside_lng; |
|
| 15 | - public $address_alias; |
|
| 16 | - public $address_city; |
|
| 17 | - public $EXT_FIELD_first_name; |
|
| 18 | - public $EXT_FIELD_last_name; |
|
| 19 | - public $EXT_FIELD_email; |
|
| 20 | - public $EXT_FIELD_phone; |
|
| 21 | - public $EXT_FIELD_custom_data; |
|
| 9 | + public $address_1; |
|
| 10 | + public $address_2; |
|
| 11 | + public $cached_lat; |
|
| 12 | + public $cached_lng; |
|
| 13 | + public $curbside_lat; |
|
| 14 | + public $curbside_lng; |
|
| 15 | + public $address_alias; |
|
| 16 | + public $address_city; |
|
| 17 | + public $EXT_FIELD_first_name; |
|
| 18 | + public $EXT_FIELD_last_name; |
|
| 19 | + public $EXT_FIELD_email; |
|
| 20 | + public $EXT_FIELD_phone; |
|
| 21 | + public $EXT_FIELD_custom_data; |
|
| 22 | 22 | |
| 23 | - public $color; |
|
| 24 | - public $order_icon; |
|
| 25 | - public $local_time_window_start; |
|
| 26 | - public $local_time_window_end; |
|
| 27 | - public $local_time_window_start_2; |
|
| 28 | - public $local_time_window_end_2; |
|
| 29 | - public $service_time; |
|
| 23 | + public $color; |
|
| 24 | + public $order_icon; |
|
| 25 | + public $local_time_window_start; |
|
| 26 | + public $local_time_window_end; |
|
| 27 | + public $local_time_window_start_2; |
|
| 28 | + public $local_time_window_end_2; |
|
| 29 | + public $service_time; |
|
| 30 | 30 | |
| 31 | - public $day_scheduled_for_YYMMDD; |
|
| 31 | + public $day_scheduled_for_YYMMDD; |
|
| 32 | 32 | |
| 33 | - public $route_id; |
|
| 34 | - public $redirect; |
|
| 35 | - public $optimization_problem_id; |
|
| 36 | - public $order_id; |
|
| 37 | - public $order_ids; |
|
| 33 | + public $route_id; |
|
| 34 | + public $redirect; |
|
| 35 | + public $optimization_problem_id; |
|
| 36 | + public $order_id; |
|
| 37 | + public $order_ids; |
|
| 38 | 38 | |
| 39 | - public $day_added_YYMMDD; |
|
| 40 | - public $scheduled_for_YYMMDD; |
|
| 41 | - public $fields; |
|
| 42 | - public $offset; |
|
| 43 | - public $limit; |
|
| 44 | - public $query; |
|
| 39 | + public $day_added_YYMMDD; |
|
| 40 | + public $scheduled_for_YYMMDD; |
|
| 41 | + public $fields; |
|
| 42 | + public $offset; |
|
| 43 | + public $limit; |
|
| 44 | + public $query; |
|
| 45 | 45 | |
| 46 | - public $created_timestamp; |
|
| 47 | - public $order_status_id; |
|
| 48 | - public $member_id; |
|
| 49 | - public $address_state_id; |
|
| 50 | - public $address_country_id; |
|
| 51 | - public $address_zip; |
|
| 52 | - public $in_route_count; |
|
| 53 | - public $last_visited_timestamp; |
|
| 54 | - public $last_routed_timestamp; |
|
| 55 | - public $local_timezone_string; |
|
| 56 | - public $is_validated; |
|
| 57 | - public $is_pending; |
|
| 58 | - public $is_accepted; |
|
| 59 | - public $is_started; |
|
| 60 | - public $is_completed; |
|
| 61 | - public $custom_user_fields; |
|
| 46 | + public $created_timestamp; |
|
| 47 | + public $order_status_id; |
|
| 48 | + public $member_id; |
|
| 49 | + public $address_state_id; |
|
| 50 | + public $address_country_id; |
|
| 51 | + public $address_zip; |
|
| 52 | + public $in_route_count; |
|
| 53 | + public $last_visited_timestamp; |
|
| 54 | + public $last_routed_timestamp; |
|
| 55 | + public $local_timezone_string; |
|
| 56 | + public $is_validated; |
|
| 57 | + public $is_pending; |
|
| 58 | + public $is_accepted; |
|
| 59 | + public $is_started; |
|
| 60 | + public $is_completed; |
|
| 61 | + public $custom_user_fields; |
|
| 62 | 62 | |
| 63 | - public static function fromArray(array $params) { |
|
| 64 | - $order = new Order(); |
|
| 65 | - foreach ($params as $key => $value) { |
|
| 66 | - if (property_exists($order, $key)) { |
|
| 67 | - $order->{$key} = $value; |
|
| 68 | - } |
|
| 69 | - } |
|
| 63 | + public static function fromArray(array $params) { |
|
| 64 | + $order = new Order(); |
|
| 65 | + foreach ($params as $key => $value) { |
|
| 66 | + if (property_exists($order, $key)) { |
|
| 67 | + $order->{$key} = $value; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - return $order; |
|
| 72 | - } |
|
| 71 | + return $order; |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - /** |
|
| 75 | - * @param Order $params |
|
| 76 | - */ |
|
| 77 | - public static function addOrder($params) |
|
| 78 | - { |
|
| 79 | - $body = array(); |
|
| 74 | + /** |
|
| 75 | + * @param Order $params |
|
| 76 | + */ |
|
| 77 | + public static function addOrder($params) |
|
| 78 | + { |
|
| 79 | + $body = array(); |
|
| 80 | 80 | |
| 81 | - $allAddOrderParameters = array('address_1', 'address_2', 'member_id', 'cached_lat', 'cached_lng', 'curbside_lat', |
|
| 82 | - 'curbside_lng', 'color', 'order_icon', 'day_scheduled_for_YYMMDD', 'address_alias', 'address_city', 'address_state_id', |
|
| 83 | - 'address_country_id', 'address_zip', 'local_time_window_start', 'local_time_window_end', 'local_time_window_start_2', |
|
| 84 | - 'local_time_window_end_2', 'service_time', 'local_timezone_string', 'EXT_FIELD_first_name', 'EXT_FIELD_last_name', |
|
| 85 | - 'EXT_FIELD_email', 'EXT_FIELD_phone', 'EXT_FIELD_custom_data', 'is_validated', 'is_pending', 'is_accepted', 'is_started', |
|
| 86 | - 'is_completed', 'custom_user_fields'); |
|
| 81 | + $allAddOrderParameters = array('address_1', 'address_2', 'member_id', 'cached_lat', 'cached_lng', 'curbside_lat', |
|
| 82 | + 'curbside_lng', 'color', 'order_icon', 'day_scheduled_for_YYMMDD', 'address_alias', 'address_city', 'address_state_id', |
|
| 83 | + 'address_country_id', 'address_zip', 'local_time_window_start', 'local_time_window_end', 'local_time_window_start_2', |
|
| 84 | + 'local_time_window_end_2', 'service_time', 'local_timezone_string', 'EXT_FIELD_first_name', 'EXT_FIELD_last_name', |
|
| 85 | + 'EXT_FIELD_email', 'EXT_FIELD_phone', 'EXT_FIELD_custom_data', 'is_validated', 'is_pending', 'is_accepted', 'is_started', |
|
| 86 | + 'is_completed', 'custom_user_fields'); |
|
| 87 | 87 | |
| 88 | - foreach ($allAddOrderParameters as $addOrderParameter) { |
|
| 89 | - if (isset($params->{$addOrderParameter})) $body[$addOrderParameter] = $params->{$addOrderParameter}; |
|
| 90 | - } |
|
| 88 | + foreach ($allAddOrderParameters as $addOrderParameter) { |
|
| 89 | + if (isset($params->{$addOrderParameter})) $body[$addOrderParameter] = $params->{$addOrderParameter}; |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - $response = Route4Me::makeRequst(array( |
|
| 93 | - 'url' => Endpoint::ORDER_V4, |
|
| 94 | - 'method' => 'POST', |
|
| 95 | - 'body' => $body |
|
| 96 | - )); |
|
| 92 | + $response = Route4Me::makeRequst(array( |
|
| 93 | + 'url' => Endpoint::ORDER_V4, |
|
| 94 | + 'method' => 'POST', |
|
| 95 | + 'body' => $body |
|
| 96 | + )); |
|
| 97 | 97 | |
| 98 | - return $response; |
|
| 99 | - } |
|
| 98 | + return $response; |
|
| 99 | + } |
|
| 100 | 100 | |
| 101 | - public static function addOrder2Route($params, $body) |
|
| 102 | - { |
|
| 103 | - $response = Route4Me::makeRequst(array( |
|
| 104 | - 'url' => Endpoint::ROUTE_V4, |
|
| 105 | - 'method' => 'PUT', |
|
| 106 | - 'query' => array( |
|
| 107 | - 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
| 108 | - 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
| 109 | - ), |
|
| 110 | - 'body' => (array)$body |
|
| 111 | - )); |
|
| 101 | + public static function addOrder2Route($params, $body) |
|
| 102 | + { |
|
| 103 | + $response = Route4Me::makeRequst(array( |
|
| 104 | + 'url' => Endpoint::ROUTE_V4, |
|
| 105 | + 'method' => 'PUT', |
|
| 106 | + 'query' => array( |
|
| 107 | + 'route_id' => isset($params->route_id) ? $params->route_id : null, |
|
| 108 | + 'redirect' => isset($params->redirect) ? $params->redirect : null |
|
| 109 | + ), |
|
| 110 | + 'body' => (array)$body |
|
| 111 | + )); |
|
| 112 | 112 | |
| 113 | - return $response; |
|
| 114 | - } |
|
| 113 | + return $response; |
|
| 114 | + } |
|
| 115 | 115 | |
| 116 | - public static function addOrder2Optimization($params, $body) |
|
| 117 | - { |
|
| 118 | - $response = Route4Me::makeRequst(array( |
|
| 119 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 120 | - 'method' => 'PUT', |
|
| 121 | - 'query' => array( |
|
| 122 | - 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
| 123 | - 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
| 124 | - 'device_type' => isset($params['device_type']) ? $params['device_type'] : null |
|
| 125 | - ), |
|
| 126 | - 'body' => (array)$body |
|
| 127 | - )); |
|
| 116 | + public static function addOrder2Optimization($params, $body) |
|
| 117 | + { |
|
| 118 | + $response = Route4Me::makeRequst(array( |
|
| 119 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 120 | + 'method' => 'PUT', |
|
| 121 | + 'query' => array( |
|
| 122 | + 'optimization_problem_id' => isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null, |
|
| 123 | + 'redirect' => isset($params['redirect']) ? $params['redirect'] : null, |
|
| 124 | + 'device_type' => isset($params['device_type']) ? $params['device_type'] : null |
|
| 125 | + ), |
|
| 126 | + 'body' => (array)$body |
|
| 127 | + )); |
|
| 128 | 128 | |
| 129 | - return $response; |
|
| 130 | - } |
|
| 129 | + return $response; |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - public static function getOrder($params) |
|
| 133 | - { |
|
| 134 | - $query = array(); |
|
| 135 | - $allGetParameters = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
| 132 | + public static function getOrder($params) |
|
| 133 | + { |
|
| 134 | + $query = array(); |
|
| 135 | + $allGetParameters = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
| 136 | 136 | |
| 137 | - foreach ($allGetParameters as $getParameter) { |
|
| 138 | - if (isset($params->{$getParameter})) $query[$getParameter] = $params->{$getParameter}; |
|
| 139 | - } |
|
| 137 | + foreach ($allGetParameters as $getParameter) { |
|
| 138 | + if (isset($params->{$getParameter})) $query[$getParameter] = $params->{$getParameter}; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | - $response = Route4Me::makeRequst(array( |
|
| 142 | - 'url' => Endpoint::ORDER_V4, |
|
| 143 | - 'method' => 'GET', |
|
| 144 | - 'query' => $query |
|
| 145 | - )); |
|
| 141 | + $response = Route4Me::makeRequst(array( |
|
| 142 | + 'url' => Endpoint::ORDER_V4, |
|
| 143 | + 'method' => 'GET', |
|
| 144 | + 'query' => $query |
|
| 145 | + )); |
|
| 146 | 146 | |
| 147 | - return $response; |
|
| 148 | - } |
|
| 147 | + return $response; |
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - public static function getOrders($params) |
|
| 151 | - { |
|
| 152 | - $response = Route4Me::makeRequst(array( |
|
| 153 | - 'url' => Endpoint::ORDER_V4, |
|
| 154 | - 'method' => 'GET', |
|
| 155 | - 'query' => array( |
|
| 156 | - 'offset' => isset($params->offset) ? $params->offset : null, |
|
| 157 | - 'limit' => isset($params->limit) ? $params->limit : null |
|
| 158 | - ) |
|
| 159 | - )); |
|
| 150 | + public static function getOrders($params) |
|
| 151 | + { |
|
| 152 | + $response = Route4Me::makeRequst(array( |
|
| 153 | + 'url' => Endpoint::ORDER_V4, |
|
| 154 | + 'method' => 'GET', |
|
| 155 | + 'query' => array( |
|
| 156 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
| 157 | + 'limit' => isset($params->limit) ? $params->limit : null |
|
| 158 | + ) |
|
| 159 | + )); |
|
| 160 | 160 | |
| 161 | - return $response; |
|
| 162 | - } |
|
| 161 | + return $response; |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - public function getRandomOrderId($offset, $limit) |
|
| 165 | - { |
|
| 166 | - $randomOrder = $this->getRandomOrder($offset, $limit); |
|
| 164 | + public function getRandomOrderId($offset, $limit) |
|
| 165 | + { |
|
| 166 | + $randomOrder = $this->getRandomOrder($offset, $limit); |
|
| 167 | 167 | |
| 168 | - if (is_null($randomOrder)) { |
|
| 169 | - return null; |
|
| 170 | - } |
|
| 168 | + if (is_null($randomOrder)) { |
|
| 169 | + return null; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - if (!isset($randomOrder)) { |
|
| 173 | - return null; |
|
| 174 | - } |
|
| 172 | + if (!isset($randomOrder)) { |
|
| 173 | + return null; |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - return $randomOrder['order_id']; |
|
| 177 | - } |
|
| 176 | + return $randomOrder['order_id']; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - public function getRandomOrder($offset, $limit) |
|
| 180 | - { |
|
| 181 | - $params = array('offset' => $offset, 'limit' => $limit); |
|
| 179 | + public function getRandomOrder($offset, $limit) |
|
| 180 | + { |
|
| 181 | + $params = array('offset' => $offset, 'limit' => $limit); |
|
| 182 | 182 | |
| 183 | - $orders = self::getOrders($params); |
|
| 183 | + $orders = self::getOrders($params); |
|
| 184 | 184 | |
| 185 | - if (is_null($orders)) { |
|
| 186 | - return null; |
|
| 187 | - } |
|
| 185 | + if (is_null($orders)) { |
|
| 186 | + return null; |
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - if (!isset($orders['results'])) { |
|
| 190 | - return null; |
|
| 191 | - } |
|
| 189 | + if (!isset($orders['results'])) { |
|
| 190 | + return null; |
|
| 191 | + } |
|
| 192 | 192 | |
| 193 | - $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
| 193 | + $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
| 194 | 194 | |
| 195 | - $order = $orders['results'][$randomIndex]; |
|
| 195 | + $order = $orders['results'][$randomIndex]; |
|
| 196 | 196 | |
| 197 | - return $order; |
|
| 198 | - } |
|
| 197 | + return $order; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - public static function removeOrder($params) |
|
| 201 | - { |
|
| 202 | - $response = Route4Me::makeRequst(array( |
|
| 203 | - 'url' => Endpoint::ORDER_V4, |
|
| 204 | - 'method' => 'DELETE', |
|
| 205 | - 'body' => array( |
|
| 206 | - 'order_ids' => isset($params->order_ids) ? $params->order_ids : null |
|
| 207 | - ) |
|
| 208 | - )); |
|
| 200 | + public static function removeOrder($params) |
|
| 201 | + { |
|
| 202 | + $response = Route4Me::makeRequst(array( |
|
| 203 | + 'url' => Endpoint::ORDER_V4, |
|
| 204 | + 'method' => 'DELETE', |
|
| 205 | + 'body' => array( |
|
| 206 | + 'order_ids' => isset($params->order_ids) ? $params->order_ids : null |
|
| 207 | + ) |
|
| 208 | + )); |
|
| 209 | 209 | |
| 210 | - return $response; |
|
| 211 | - } |
|
| 210 | + return $response; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - public static function updateOrder($body) |
|
| 214 | - { |
|
| 215 | - $response = Route4Me::makeRequst(array( |
|
| 216 | - 'url' => Endpoint::ORDER_V4, |
|
| 217 | - 'method' => 'PUT', |
|
| 218 | - 'body' => (array)$body |
|
| 219 | - )); |
|
| 213 | + public static function updateOrder($body) |
|
| 214 | + { |
|
| 215 | + $response = Route4Me::makeRequst(array( |
|
| 216 | + 'url' => Endpoint::ORDER_V4, |
|
| 217 | + 'method' => 'PUT', |
|
| 218 | + 'body' => (array)$body |
|
| 219 | + )); |
|
| 220 | 220 | |
| 221 | - return $response; |
|
| 222 | - } |
|
| 221 | + return $response; |
|
| 222 | + } |
|
| 223 | 223 | |
| 224 | - public static function searchOrder($params) |
|
| 225 | - { |
|
| 226 | - $query = array(); |
|
| 227 | - $allSearchParameters = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
| 224 | + public static function searchOrder($params) |
|
| 225 | + { |
|
| 226 | + $query = array(); |
|
| 227 | + $allSearchParameters = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
| 228 | 228 | |
| 229 | - foreach ($allSearchParameters as $searchParameter) { |
|
| 230 | - if (isset($params->{$searchParameter})) $query[$searchParameter] = $params->{$searchParameter}; |
|
| 231 | - } |
|
| 229 | + foreach ($allSearchParameters as $searchParameter) { |
|
| 230 | + if (isset($params->{$searchParameter})) $query[$searchParameter] = $params->{$searchParameter}; |
|
| 231 | + } |
|
| 232 | 232 | |
| 233 | - $response = Route4Me::makeRequst(array( |
|
| 234 | - 'url' => Endpoint::ORDER_V4, |
|
| 235 | - 'method' => 'GET', |
|
| 236 | - 'query' => $query |
|
| 237 | - )); |
|
| 233 | + $response = Route4Me::makeRequst(array( |
|
| 234 | + 'url' => Endpoint::ORDER_V4, |
|
| 235 | + 'method' => 'GET', |
|
| 236 | + 'query' => $query |
|
| 237 | + )); |
|
| 238 | 238 | |
| 239 | - return $response; |
|
| 240 | - } |
|
| 239 | + return $response; |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - public static function validateLatitude($lat) |
|
| 243 | - { |
|
| 244 | - if (!is_numeric($lat)) { |
|
| 245 | - return false; |
|
| 246 | - } |
|
| 242 | + public static function validateLatitude($lat) |
|
| 243 | + { |
|
| 244 | + if (!is_numeric($lat)) { |
|
| 245 | + return false; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - if ($lat>90 || $lat<-90) { |
|
| 249 | - return false; |
|
| 250 | - } |
|
| 248 | + if ($lat>90 || $lat<-90) { |
|
| 249 | + return false; |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - return true; |
|
| 253 | - } |
|
| 252 | + return true; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - public static function validateLongitude($lng) |
|
| 256 | - { |
|
| 257 | - if (!is_numeric($lng)) { |
|
| 258 | - return false; |
|
| 259 | - } |
|
| 255 | + public static function validateLongitude($lng) |
|
| 256 | + { |
|
| 257 | + if (!is_numeric($lng)) { |
|
| 258 | + return false; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - if ($lng>180 || $lng<-180) { |
|
| 262 | - return false; |
|
| 263 | - } |
|
| 261 | + if ($lng>180 || $lng<-180) { |
|
| 262 | + return false; |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - return true; |
|
| 266 | - } |
|
| 265 | + return true; |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
| 269 | - { |
|
| 270 | - $max_line_length = 512; |
|
| 271 | - $delemietr = ','; |
|
| 268 | + public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
| 269 | + { |
|
| 270 | + $max_line_length = 512; |
|
| 271 | + $delemietr = ','; |
|
| 272 | 272 | |
| 273 | - $results = array(); |
|
| 274 | - $results['fail'] = array(); |
|
| 275 | - $results['success'] = array(); |
|
| 273 | + $results = array(); |
|
| 274 | + $results['fail'] = array(); |
|
| 275 | + $results['success'] = array(); |
|
| 276 | 276 | |
| 277 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 277 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 278 | 278 | |
| 279 | - $allOrderFields = array("curbside_lat","curbside_lng","color","day_scheduled_for_YYMMDD", |
|
| 280 | - "address_alias","address_1","address_2","local_time_window_start","local_time_window_end","local_time_window_start_2", |
|
| 281 | - "local_time_window_end_2","service_time","EXT_FIELD_first_name","EXT_FIELD_last_name","EXT_FIELD_email","EXT_FIELD_phone", |
|
| 282 | - "EXT_FIELD_custom_data","order_icon"); |
|
| 279 | + $allOrderFields = array("curbside_lat","curbside_lng","color","day_scheduled_for_YYMMDD", |
|
| 280 | + "address_alias","address_1","address_2","local_time_window_start","local_time_window_end","local_time_window_start_2", |
|
| 281 | + "local_time_window_end_2","service_time","EXT_FIELD_first_name","EXT_FIELD_last_name","EXT_FIELD_email","EXT_FIELD_phone", |
|
| 282 | + "EXT_FIELD_custom_data","order_icon"); |
|
| 283 | 283 | |
| 284 | - if (!empty($columns)) { |
|
| 285 | - array_push($results['fail'],'Empty CSV table'); |
|
| 286 | - return ($results); |
|
| 287 | - } |
|
| 284 | + if (!empty($columns)) { |
|
| 285 | + array_push($results['fail'],'Empty CSV table'); |
|
| 286 | + return ($results); |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - $iRow=1; |
|
| 289 | + $iRow=1; |
|
| 290 | 290 | |
| 291 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 292 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
| 291 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 292 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
| 293 | 293 | |
| 294 | - $cached_lat = 0.000; |
|
| 294 | + $cached_lat = 0.000; |
|
| 295 | 295 | |
| 296 | - if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) { |
|
| 297 | - array_push($results['fail'], "$iRow --> Wrong cached_lat"); |
|
| 298 | - $iRow++; |
|
| 299 | - continue; |
|
| 300 | - } else { |
|
| 301 | - $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
| 302 | - } |
|
| 296 | + if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) { |
|
| 297 | + array_push($results['fail'], "$iRow --> Wrong cached_lat"); |
|
| 298 | + $iRow++; |
|
| 299 | + continue; |
|
| 300 | + } else { |
|
| 301 | + $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]); |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - $cached_lng = 0.000; |
|
| 304 | + $cached_lng = 0.000; |
|
| 305 | 305 | |
| 306 | - if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) { |
|
| 307 | - array_push($results['fail'], "$iRow --> Wrong cached_lng"); |
|
| 308 | - $iRow++; |
|
| 309 | - continue; |
|
| 310 | - } else { |
|
| 311 | - $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
| 312 | - } |
|
| 306 | + if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) { |
|
| 307 | + array_push($results['fail'], "$iRow --> Wrong cached_lng"); |
|
| 308 | + $iRow++; |
|
| 309 | + continue; |
|
| 310 | + } else { |
|
| 311 | + $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]); |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - if (isset($ordersFieldsMapping['curbside_lat'])) { |
|
| 315 | - if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
|
| 316 | - array_push($results['fail'], "$iRow --> Wrong curbside_lat"); |
|
| 317 | - $iRow++; |
|
| 318 | - continue; |
|
| 319 | - } |
|
| 320 | - } |
|
| 314 | + if (isset($ordersFieldsMapping['curbside_lat'])) { |
|
| 315 | + if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) { |
|
| 316 | + array_push($results['fail'], "$iRow --> Wrong curbside_lat"); |
|
| 317 | + $iRow++; |
|
| 318 | + continue; |
|
| 319 | + } |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - if (isset($ordersFieldsMapping['curbside_lng'])) { |
|
| 323 | - if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) { |
|
| 324 | - array_push($results['fail'], "$iRow --> Wrong curbside_lng"); |
|
| 325 | - $iRow++; |
|
| 326 | - continue; |
|
| 327 | - } |
|
| 328 | - } |
|
| 322 | + if (isset($ordersFieldsMapping['curbside_lng'])) { |
|
| 323 | + if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) { |
|
| 324 | + array_push($results['fail'], "$iRow --> Wrong curbside_lng"); |
|
| 325 | + $iRow++; |
|
| 326 | + continue; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | 329 | |
| 330 | - $address = $rows[$ordersFieldsMapping['address_1']]; |
|
| 330 | + $address = $rows[$ordersFieldsMapping['address_1']]; |
|
| 331 | 331 | |
| 332 | - if (isset($ordersFieldsMapping['order_city'])) { |
|
| 333 | - $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
| 334 | - } |
|
| 332 | + if (isset($ordersFieldsMapping['order_city'])) { |
|
| 333 | + $address.=', '.$rows[$ordersFieldsMapping['order_city']]; |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | - if (isset($ordersFieldsMapping['order_state_id'])) { |
|
| 337 | - $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
| 338 | - } |
|
| 336 | + if (isset($ordersFieldsMapping['order_state_id'])) { |
|
| 337 | + $address.=', '.$rows[$ordersFieldsMapping['order_state_id']]; |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - if (isset($ordersFieldsMapping['order_zip_code'])) { |
|
| 341 | - $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
| 342 | - } |
|
| 340 | + if (isset($ordersFieldsMapping['order_zip_code'])) { |
|
| 341 | + $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']]; |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - if (isset($ordersFieldsMapping['order_country_id'])) { |
|
| 345 | - $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
| 346 | - } |
|
| 344 | + if (isset($ordersFieldsMapping['order_country_id'])) { |
|
| 345 | + $address.=', '.$rows[$ordersFieldsMapping['order_country_id']]; |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | - echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
| 348 | + echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
| 349 | 349 | |
| 350 | - $parametersArray = array(); |
|
| 350 | + $parametersArray = array(); |
|
| 351 | 351 | |
| 352 | - $parametersArray["cached_lat"] = $cached_lat; |
|
| 353 | - $parametersArray["cached_lng"] = $cached_lng; |
|
| 352 | + $parametersArray["cached_lat"] = $cached_lat; |
|
| 353 | + $parametersArray["cached_lng"] = $cached_lng; |
|
| 354 | 354 | |
| 355 | 355 | |
| 356 | - foreach ($allOrderFields as $orderField) { |
|
| 357 | - if (isset($ordersFieldsMapping[$orderField])) { |
|
| 358 | - $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
| 359 | - } |
|
| 360 | - } |
|
| 356 | + foreach ($allOrderFields as $orderField) { |
|
| 357 | + if (isset($ordersFieldsMapping[$orderField])) { |
|
| 358 | + $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | - $orderParameters = Order::fromArray($parametersArray); |
|
| 362 | + $orderParameters = Order::fromArray($parametersArray); |
|
| 363 | 363 | |
| 364 | - $order = new Order(); |
|
| 364 | + $order = new Order(); |
|
| 365 | 365 | |
| 366 | - $orderResults = $order->addOrder($orderParameters); |
|
| 366 | + $orderResults = $order->addOrder($orderParameters); |
|
| 367 | 367 | |
| 368 | - array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
| 369 | - } |
|
| 370 | - else { |
|
| 371 | - array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
| 372 | - } |
|
| 368 | + array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
| 369 | + } |
|
| 370 | + else { |
|
| 371 | + array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
| 372 | + } |
|
| 373 | 373 | |
| 374 | - $iRow++; |
|
| 375 | - } |
|
| 376 | - } |
|
| 374 | + $iRow++; |
|
| 375 | + } |
|
| 376 | + } |
|
| 377 | 377 | } |
@@ -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; |