@@ -21,7 +21,7 @@ |
||
| 21 | 21 | $json = json_decode(file_get_contents('./addresses.json'), true); |
| 22 | 22 | |
| 23 | 23 | $addresses = array(); |
| 24 | -foreach($json as $address) { |
|
| 24 | +foreach ($json as $address) { |
|
| 25 | 25 | $addresses[] = Address::fromArray($address); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -6,324 +6,324 @@ |
||
| 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) || !isset($randomOrder)) { |
|
| 156 | - return null; |
|
| 157 | - } |
|
| 155 | + if (is_null($randomOrder) || !isset($randomOrder)) { |
|
| 156 | + return null; |
|
| 157 | + } |
|
| 158 | 158 | |
| 159 | - return $randomOrder['order_id']; |
|
| 160 | - } |
|
| 159 | + return $randomOrder['order_id']; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - public function getRandomOrder($offset, $limit) |
|
| 163 | - { |
|
| 164 | - $params = array('offset' => $offset, 'limit' => $limit); |
|
| 162 | + public function getRandomOrder($offset, $limit) |
|
| 163 | + { |
|
| 164 | + $params = array('offset' => $offset, 'limit' => $limit); |
|
| 165 | 165 | |
| 166 | - $orders = self::getOrders($params); |
|
| 166 | + $orders = self::getOrders($params); |
|
| 167 | 167 | |
| 168 | - if (is_null($orders) || !isset($orders['results'])) { |
|
| 169 | - return null; |
|
| 170 | - } |
|
| 168 | + if (is_null($orders) || !isset($orders['results'])) { |
|
| 169 | + return null; |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
| 172 | + $randomIndex = rand(0, sizeof($orders['results']) - 1); |
|
| 173 | 173 | |
| 174 | - $order = $orders['results'][$randomIndex]; |
|
| 174 | + $order = $orders['results'][$randomIndex]; |
|
| 175 | 175 | |
| 176 | - return $order; |
|
| 177 | - } |
|
| 176 | + return $order; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - public static function removeOrder($params) |
|
| 180 | - { |
|
| 181 | - $allBodyFields = array('order_ids'); |
|
| 179 | + public static function removeOrder($params) |
|
| 180 | + { |
|
| 181 | + $allBodyFields = array('order_ids'); |
|
| 182 | 182 | |
| 183 | - $response = Route4Me::makeRequst(array( |
|
| 184 | - 'url' => Endpoint::ORDER_V4, |
|
| 185 | - 'method' => 'DELETE', |
|
| 186 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 187 | - )); |
|
| 183 | + $response = Route4Me::makeRequst(array( |
|
| 184 | + 'url' => Endpoint::ORDER_V4, |
|
| 185 | + 'method' => 'DELETE', |
|
| 186 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 187 | + )); |
|
| 188 | 188 | |
| 189 | - return $response; |
|
| 190 | - } |
|
| 189 | + return $response; |
|
| 190 | + } |
|
| 191 | 191 | |
| 192 | - public static function updateOrder($params) |
|
| 193 | - { |
|
| 194 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', |
|
| 195 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 192 | + public static function updateOrder($params) |
|
| 193 | + { |
|
| 194 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', |
|
| 195 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 196 | 196 | |
| 197 | - $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 197 | + $allBodyFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 198 | 198 | |
| 199 | - $response = Route4Me::makeRequst(array( |
|
| 200 | - 'url' => Endpoint::ORDER_V4, |
|
| 201 | - 'method' => 'PUT', |
|
| 202 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 203 | - )); |
|
| 199 | + $response = Route4Me::makeRequst(array( |
|
| 200 | + 'url' => Endpoint::ORDER_V4, |
|
| 201 | + 'method' => 'PUT', |
|
| 202 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 203 | + )); |
|
| 204 | 204 | |
| 205 | - return $response; |
|
| 206 | - } |
|
| 205 | + return $response; |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - public static function searchOrder($params) |
|
| 209 | - { |
|
| 210 | - $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
| 208 | + public static function searchOrder($params) |
|
| 209 | + { |
|
| 210 | + $allQueryFields = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' ); |
|
| 211 | 211 | |
| 212 | - $response = Route4Me::makeRequst(array( |
|
| 213 | - 'url' => Endpoint::ORDER_V4, |
|
| 214 | - 'method' => 'GET', |
|
| 215 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 216 | - )); |
|
| 212 | + $response = Route4Me::makeRequst(array( |
|
| 213 | + 'url' => Endpoint::ORDER_V4, |
|
| 214 | + 'method' => 'GET', |
|
| 215 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 216 | + )); |
|
| 217 | 217 | |
| 218 | - return $response; |
|
| 219 | - } |
|
| 218 | + return $response; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | - public static function validateCoordinate($coord) |
|
| 222 | - { |
|
| 223 | - $key = key($coord); |
|
| 221 | + public static function validateCoordinate($coord) |
|
| 222 | + { |
|
| 223 | + $key = key($coord); |
|
| 224 | 224 | |
| 225 | - if (!is_numeric($coord[$key])) { |
|
| 226 | - return false; |
|
| 227 | - } |
|
| 225 | + if (!is_numeric($coord[$key])) { |
|
| 226 | + return false; |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | - switch ($key) { |
|
| 230 | - case 'cached_lat': |
|
| 231 | - case 'curbside_lat': |
|
| 232 | - if ($coord[$key]>90 || $coord[$key]<-90) { |
|
| 233 | - return false; |
|
| 234 | - } |
|
| 235 | - break; |
|
| 236 | - case 'cached_lng': |
|
| 237 | - case 'curbside_lng': |
|
| 238 | - if ($coord[$key]>180 || $coord[$key]<-180) { |
|
| 239 | - return false; |
|
| 240 | - } |
|
| 241 | - break; |
|
| 242 | - } |
|
| 229 | + switch ($key) { |
|
| 230 | + case 'cached_lat': |
|
| 231 | + case 'curbside_lat': |
|
| 232 | + if ($coord[$key]>90 || $coord[$key]<-90) { |
|
| 233 | + return false; |
|
| 234 | + } |
|
| 235 | + break; |
|
| 236 | + case 'cached_lng': |
|
| 237 | + case 'curbside_lng': |
|
| 238 | + if ($coord[$key]>180 || $coord[$key]<-180) { |
|
| 239 | + return false; |
|
| 240 | + } |
|
| 241 | + break; |
|
| 242 | + } |
|
| 243 | 243 | |
| 244 | - return true; |
|
| 245 | - } |
|
| 244 | + return true; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
| 248 | - { |
|
| 249 | - $max_line_length = 512; |
|
| 250 | - $delemietr = ','; |
|
| 247 | + public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping) |
|
| 248 | + { |
|
| 249 | + $max_line_length = 512; |
|
| 250 | + $delemietr = ','; |
|
| 251 | 251 | |
| 252 | - $results = array(); |
|
| 253 | - $results['fail'] = array(); |
|
| 254 | - $results['success'] = array(); |
|
| 252 | + $results = array(); |
|
| 253 | + $results['fail'] = array(); |
|
| 254 | + $results['success'] = array(); |
|
| 255 | 255 | |
| 256 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 256 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 257 | 257 | |
| 258 | - $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
| 259 | - 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 258 | + $excludeFields = array('route_id', 'redirect', 'optimization_problem_id', 'order_id', |
|
| 259 | + 'order_ids', 'fields', 'offset', 'limit', 'query', 'created_timestamp'); |
|
| 260 | 260 | |
| 261 | - $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 261 | + $allOrderFields = Route4Me::getObjectProperties(new Order(), $excludeFields); |
|
| 262 | 262 | |
| 263 | - if (!empty($columns)) { |
|
| 264 | - array_push($results['fail'],'Empty CSV table'); |
|
| 265 | - return ($results); |
|
| 266 | - } |
|
| 263 | + if (!empty($columns)) { |
|
| 264 | + array_push($results['fail'],'Empty CSV table'); |
|
| 265 | + return ($results); |
|
| 266 | + } |
|
| 267 | 267 | |
| 268 | - $iRow=1; |
|
| 268 | + $iRow=1; |
|
| 269 | 269 | |
| 270 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 271 | - if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
| 270 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 271 | + if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) { |
|
| 272 | 272 | |
| 273 | - $cached_lat = 0.000; |
|
| 274 | - $cached_lng = 0.000; |
|
| 273 | + $cached_lat = 0.000; |
|
| 274 | + $cached_lng = 0.000; |
|
| 275 | 275 | |
| 276 | - foreach (array('cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng') as $coord) { |
|
| 277 | - if (!$this->validateCoordinate(array($coord => $rows[$ordersFieldsMapping[$coord]]))) { |
|
| 278 | - array_push($results['fail'], "$iRow --> Wrong "+$coord); |
|
| 279 | - $iRow++; |
|
| 280 | - continue; |
|
| 281 | - } else { |
|
| 282 | - switch ($coord) { |
|
| 283 | - case 'cached_lat': |
|
| 284 | - $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
| 285 | - break; |
|
| 286 | - case 'cached_lng': |
|
| 287 | - $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
| 288 | - break; |
|
| 289 | - } |
|
| 290 | - } |
|
| 291 | - } |
|
| 276 | + foreach (array('cached_lat', 'cached_lng', 'curbside_lat', 'curbside_lng') as $coord) { |
|
| 277 | + if (!$this->validateCoordinate(array($coord => $rows[$ordersFieldsMapping[$coord]]))) { |
|
| 278 | + array_push($results['fail'], "$iRow --> Wrong "+$coord); |
|
| 279 | + $iRow++; |
|
| 280 | + continue; |
|
| 281 | + } else { |
|
| 282 | + switch ($coord) { |
|
| 283 | + case 'cached_lat': |
|
| 284 | + $cached_lat = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
| 285 | + break; |
|
| 286 | + case 'cached_lng': |
|
| 287 | + $cached_lng = doubleval($rows[$ordersFieldsMapping[$coord]]); |
|
| 288 | + break; |
|
| 289 | + } |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | - $address = $rows[$ordersFieldsMapping['address_1']]; |
|
| 293 | + $address = $rows[$ordersFieldsMapping['address_1']]; |
|
| 294 | 294 | |
| 295 | - foreach (array('order_city', 'order_state_id', 'order_zip_code', 'order_country_id') as $addressPart) { |
|
| 296 | - if (isset($ordersFieldsMapping[$addressPart])) { |
|
| 297 | - $address .= ', '.$rows[$ordersFieldsMapping[$addressPart]]; |
|
| 298 | - } |
|
| 299 | - } |
|
| 295 | + foreach (array('order_city', 'order_state_id', 'order_zip_code', 'order_country_id') as $addressPart) { |
|
| 296 | + if (isset($ordersFieldsMapping[$addressPart])) { |
|
| 297 | + $address .= ', '.$rows[$ordersFieldsMapping[$addressPart]]; |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
| 301 | + echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>"; |
|
| 302 | 302 | |
| 303 | - $parametersArray = array(); |
|
| 303 | + $parametersArray = array(); |
|
| 304 | 304 | |
| 305 | - $parametersArray["cached_lat"] = $cached_lat; |
|
| 306 | - $parametersArray["cached_lng"] = $cached_lng; |
|
| 305 | + $parametersArray["cached_lat"] = $cached_lat; |
|
| 306 | + $parametersArray["cached_lng"] = $cached_lng; |
|
| 307 | 307 | |
| 308 | 308 | |
| 309 | - foreach ($allOrderFields as $orderField) { |
|
| 310 | - if (isset($ordersFieldsMapping[$orderField])) { |
|
| 311 | - $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
| 312 | - } |
|
| 313 | - } |
|
| 309 | + foreach ($allOrderFields as $orderField) { |
|
| 310 | + if (isset($ordersFieldsMapping[$orderField])) { |
|
| 311 | + $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]]; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - $orderParameters = Order::fromArray($parametersArray); |
|
| 315 | + $orderParameters = Order::fromArray($parametersArray); |
|
| 316 | 316 | |
| 317 | - $order = new Order(); |
|
| 317 | + $order = new Order(); |
|
| 318 | 318 | |
| 319 | - $orderResults = $order->addOrder($orderParameters); |
|
| 319 | + $orderResults = $order->addOrder($orderParameters); |
|
| 320 | 320 | |
| 321 | - array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
| 322 | - } else { |
|
| 323 | - array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
| 324 | - } |
|
| 321 | + array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly."); |
|
| 322 | + } else { |
|
| 323 | + array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - $iRow++; |
|
| 327 | - } |
|
| 328 | - } |
|
| 326 | + $iRow++; |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | 329 | } |
@@ -11,236 +11,236 @@ |
||
| 11 | 11 | |
| 12 | 12 | class OptimizationProblem extends Common |
| 13 | 13 | { |
| 14 | - public $optimization_problem_id; |
|
| 15 | - public $user_errors = array(); |
|
| 16 | - public $state; |
|
| 17 | - public $optimization_errors = array(); |
|
| 18 | - public $parameters; |
|
| 19 | - public $sent_to_background; |
|
| 20 | - public $created_timestamp; |
|
| 21 | - public $scheduled_for; |
|
| 22 | - public $optimization_completed_timestamp; |
|
| 23 | - public $addresses = array(); |
|
| 24 | - public $routes = array(); |
|
| 25 | - public $links = array(); |
|
| 26 | - |
|
| 27 | - function __construct() |
|
| 28 | - { |
|
| 29 | - $this->parameters = new RouteParameters; |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - public static function fromArray(array $params) |
|
| 33 | - { |
|
| 34 | - $problem = new OptimizationProblem; |
|
| 35 | - $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
| 36 | - $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
| 37 | - $problem->state = Common::getValue($params, 'state', array()); |
|
| 38 | - $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
| 39 | - $problem->links = Common::getValue($params, 'links', array()); |
|
| 40 | - |
|
| 41 | - if (isset($params['parameters'])) { |
|
| 42 | - $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - if (isset($params['addresses'])) { |
|
| 46 | - $addresses = array(); |
|
| 14 | + public $optimization_problem_id; |
|
| 15 | + public $user_errors = array(); |
|
| 16 | + public $state; |
|
| 17 | + public $optimization_errors = array(); |
|
| 18 | + public $parameters; |
|
| 19 | + public $sent_to_background; |
|
| 20 | + public $created_timestamp; |
|
| 21 | + public $scheduled_for; |
|
| 22 | + public $optimization_completed_timestamp; |
|
| 23 | + public $addresses = array(); |
|
| 24 | + public $routes = array(); |
|
| 25 | + public $links = array(); |
|
| 26 | + |
|
| 27 | + function __construct() |
|
| 28 | + { |
|
| 29 | + $this->parameters = new RouteParameters; |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + public static function fromArray(array $params) |
|
| 33 | + { |
|
| 34 | + $problem = new OptimizationProblem; |
|
| 35 | + $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id'); |
|
| 36 | + $problem->user_errors = Common::getValue($params, 'user_errors', array()); |
|
| 37 | + $problem->state = Common::getValue($params, 'state', array()); |
|
| 38 | + $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array()); |
|
| 39 | + $problem->links = Common::getValue($params, 'links', array()); |
|
| 40 | + |
|
| 41 | + if (isset($params['parameters'])) { |
|
| 42 | + $problem->parameters = RouteParameters::fromArray($params['parameters']); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + if (isset($params['addresses'])) { |
|
| 46 | + $addresses = array(); |
|
| 47 | 47 | |
| 48 | - foreach ($params['addresses'] as $address) { |
|
| 49 | - $addresses[] = Address::fromArray($address); |
|
| 50 | - } |
|
| 48 | + foreach ($params['addresses'] as $address) { |
|
| 49 | + $addresses[] = Address::fromArray($address); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - $problem->addresses = $addresses; |
|
| 53 | - } |
|
| 52 | + $problem->addresses = $addresses; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - if (isset($params['routes'])) { |
|
| 56 | - $routes = array(); |
|
| 55 | + if (isset($params['routes'])) { |
|
| 56 | + $routes = array(); |
|
| 57 | 57 | |
| 58 | - foreach ($params['routes'] as $route) { |
|
| 59 | - $routes[] = Route::fromArray($route); |
|
| 60 | - } |
|
| 58 | + foreach ($params['routes'] as $route) { |
|
| 59 | + $routes[] = Route::fromArray($route); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $problem->routes = $routes; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - return $problem; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - public static function optimize(OptimizationProblemParams $params) |
|
| 69 | - { |
|
| 70 | - $allQueryFields = array('redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url'); |
|
| 71 | - |
|
| 72 | - $optimize = Route4Me::makeRequst(array( |
|
| 73 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 74 | - 'method' => 'POST', |
|
| 75 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 76 | - 'body' => array( |
|
| 77 | - 'addresses' => $params->getAddressesArray(), |
|
| 78 | - 'parameters' => $params->getParametersArray() |
|
| 79 | - ) |
|
| 80 | - )); |
|
| 81 | - |
|
| 82 | - return OptimizationProblem::fromArray($optimize); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - public static function get($params) |
|
| 86 | - { |
|
| 87 | - $allQueryFields = array('state', 'limit', 'format', 'offset', |
|
| 88 | - 'optimization_problem_id', 'wait_for_final_state'); |
|
| 89 | - |
|
| 90 | - $optimize = Route4Me::makeRequst(array( |
|
| 91 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 92 | - 'method' => 'GET', |
|
| 93 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 94 | - )); |
|
| 95 | - |
|
| 96 | - if (isset($optimize['optimizations'])) { |
|
| 97 | - $problems = array(); |
|
| 62 | + $problem->routes = $routes; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + return $problem; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + public static function optimize(OptimizationProblemParams $params) |
|
| 69 | + { |
|
| 70 | + $allQueryFields = array('redirect', 'directions', 'format', 'route_path_output', 'optimized_callback_url'); |
|
| 71 | + |
|
| 72 | + $optimize = Route4Me::makeRequst(array( |
|
| 73 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 74 | + 'method' => 'POST', |
|
| 75 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 76 | + 'body' => array( |
|
| 77 | + 'addresses' => $params->getAddressesArray(), |
|
| 78 | + 'parameters' => $params->getParametersArray() |
|
| 79 | + ) |
|
| 80 | + )); |
|
| 81 | + |
|
| 82 | + return OptimizationProblem::fromArray($optimize); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + public static function get($params) |
|
| 86 | + { |
|
| 87 | + $allQueryFields = array('state', 'limit', 'format', 'offset', |
|
| 88 | + 'optimization_problem_id', 'wait_for_final_state'); |
|
| 89 | + |
|
| 90 | + $optimize = Route4Me::makeRequst(array( |
|
| 91 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 92 | + 'method' => 'GET', |
|
| 93 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 94 | + )); |
|
| 95 | + |
|
| 96 | + if (isset($optimize['optimizations'])) { |
|
| 97 | + $problems = array(); |
|
| 98 | 98 | |
| 99 | - foreach ($optimize['optimizations'] as $problem) { |
|
| 100 | - $problems[] = OptimizationProblem::fromArray($problem); |
|
| 101 | - } |
|
| 99 | + foreach ($optimize['optimizations'] as $problem) { |
|
| 100 | + $problems[] = OptimizationProblem::fromArray($problem); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | - return $problems; |
|
| 104 | - } else { |
|
| 105 | - return OptimizationProblem::fromArray($optimize); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - public static function reoptimize($params) |
|
| 110 | - { |
|
| 111 | - $param = new OptimizationProblemParams; |
|
| 112 | - $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
| 113 | - $param->reoptimize = 1; |
|
| 114 | - |
|
| 115 | - return self::update((array)$param); |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - public static function update($params) |
|
| 119 | - { |
|
| 120 | - $allQueryFields = array('optimization_problem_id', 'reoptimize'); |
|
| 121 | - $allBodyFields = array('addresses'); |
|
| 122 | - |
|
| 123 | - $optimize = Route4Me::makeRequst(array( |
|
| 124 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 125 | - 'method' => 'PUT', |
|
| 126 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 127 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 128 | - )); |
|
| 129 | - |
|
| 130 | - return $optimize; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - public function getOptimizationId() |
|
| 134 | - { |
|
| 135 | - return $this->optimization_problem_id; |
|
| 136 | - } |
|
| 137 | - |
|
| 138 | - public function getRoutes() |
|
| 139 | - { |
|
| 140 | - return $this->routes; |
|
| 141 | - } |
|
| 103 | + return $problems; |
|
| 104 | + } else { |
|
| 105 | + return OptimizationProblem::fromArray($optimize); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + public static function reoptimize($params) |
|
| 110 | + { |
|
| 111 | + $param = new OptimizationProblemParams; |
|
| 112 | + $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null; |
|
| 113 | + $param->reoptimize = 1; |
|
| 114 | + |
|
| 115 | + return self::update((array)$param); |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + public static function update($params) |
|
| 119 | + { |
|
| 120 | + $allQueryFields = array('optimization_problem_id', 'reoptimize'); |
|
| 121 | + $allBodyFields = array('addresses'); |
|
| 122 | + |
|
| 123 | + $optimize = Route4Me::makeRequst(array( |
|
| 124 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 125 | + 'method' => 'PUT', |
|
| 126 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 127 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 128 | + )); |
|
| 129 | + |
|
| 130 | + return $optimize; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + public function getOptimizationId() |
|
| 134 | + { |
|
| 135 | + return $this->optimization_problem_id; |
|
| 136 | + } |
|
| 137 | + |
|
| 138 | + public function getRoutes() |
|
| 139 | + { |
|
| 140 | + return $this->routes; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - public function getRandomOptimizationId($offset, $limit) |
|
| 144 | - { |
|
| 145 | - $optimizations = self::get(array('offset' => $offset, 'limit' => $limit)); |
|
| 143 | + public function getRandomOptimizationId($offset, $limit) |
|
| 144 | + { |
|
| 145 | + $optimizations = self::get(array('offset' => $offset, 'limit' => $limit)); |
|
| 146 | 146 | |
| 147 | - $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
| 148 | - |
|
| 149 | - if(!isset($rOptimization->optimization_problem_id)) { |
|
| 150 | - if (sizeof($optimizations)>9) { |
|
| 151 | - $this->getRandomOptimizationId($offset, $limit); |
|
| 152 | - } else { |
|
| 153 | - return null; |
|
| 154 | - } |
|
| 155 | - } |
|
| 147 | + $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
|
| 148 | + |
|
| 149 | + if(!isset($rOptimization->optimization_problem_id)) { |
|
| 150 | + if (sizeof($optimizations)>9) { |
|
| 151 | + $this->getRandomOptimizationId($offset, $limit); |
|
| 152 | + } else { |
|
| 153 | + return null; |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | 156 | |
| 157 | - return $rOptimization->optimization_problem_id; |
|
| 158 | - } |
|
| 157 | + return $rOptimization->optimization_problem_id; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - public function getAddresses($opt_id) |
|
| 161 | - { |
|
| 162 | - if ($opt_id==null) { |
|
| 163 | - return null; |
|
| 164 | - } |
|
| 160 | + public function getAddresses($opt_id) |
|
| 161 | + { |
|
| 162 | + if ($opt_id==null) { |
|
| 163 | + return null; |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | - $params = array("optimization_problem_id" => $opt_id); |
|
| 166 | + $params = array("optimization_problem_id" => $opt_id); |
|
| 167 | 167 | |
| 168 | - $optimization = (array)$this->get($params); |
|
| 168 | + $optimization = (array)$this->get($params); |
|
| 169 | 169 | |
| 170 | - $addresses = $optimization["addresses"]; |
|
| 170 | + $addresses = $optimization["addresses"]; |
|
| 171 | 171 | |
| 172 | - return $addresses; |
|
| 173 | - } |
|
| 172 | + return $addresses; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - public function getRandomAddressFromOptimization($opt_id) |
|
| 176 | - { |
|
| 177 | - $addresses = (array)$this->getAddresses($opt_id); |
|
| 175 | + public function getRandomAddressFromOptimization($opt_id) |
|
| 176 | + { |
|
| 177 | + $addresses = (array)$this->getAddresses($opt_id); |
|
| 178 | 178 | |
| 179 | - if ($addresses==null) { |
|
| 180 | - echo "There are no addresses in this optimization!.. Try again."; |
|
| 181 | - return null; |
|
| 182 | - } |
|
| 179 | + if ($addresses==null) { |
|
| 180 | + echo "There are no addresses in this optimization!.. Try again."; |
|
| 181 | + return null; |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - $num = rand(0, sizeof($addresses) - 1); |
|
| 184 | + $num = rand(0, sizeof($addresses) - 1); |
|
| 185 | 185 | |
| 186 | - $rAddress = $addresses[$num]; |
|
| 186 | + $rAddress = $addresses[$num]; |
|
| 187 | 187 | |
| 188 | - return $rAddress; |
|
| 189 | - } |
|
| 188 | + return $rAddress; |
|
| 189 | + } |
|
| 190 | 190 | |
| 191 | - public function removeAddress($params) |
|
| 192 | - { |
|
| 193 | - $allQueryFields = array('optimization_problem_id', 'route_destination_id'); |
|
| 194 | - |
|
| 195 | - $response = Route4Me::makeRequst(array( |
|
| 196 | - 'url' => Endpoint::ADDRESS_V4, |
|
| 197 | - 'method' => 'DELETE', |
|
| 198 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 199 | - )); |
|
| 200 | - |
|
| 201 | - return $response; |
|
| 202 | - } |
|
| 191 | + public function removeAddress($params) |
|
| 192 | + { |
|
| 193 | + $allQueryFields = array('optimization_problem_id', 'route_destination_id'); |
|
| 194 | + |
|
| 195 | + $response = Route4Me::makeRequst(array( |
|
| 196 | + 'url' => Endpoint::ADDRESS_V4, |
|
| 197 | + 'method' => 'DELETE', |
|
| 198 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 199 | + )); |
|
| 200 | + |
|
| 201 | + return $response; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - public function removeOptimization($params) |
|
| 205 | - { |
|
| 206 | - $allQueryFields = array('redirect'); |
|
| 207 | - $allBodyFields = array('optimization_problem_ids'); |
|
| 208 | - |
|
| 209 | - $response = Route4Me::makeRequst(array( |
|
| 210 | - 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 211 | - 'method' => 'DELETE', |
|
| 212 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 213 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 214 | - )); |
|
| 215 | - |
|
| 216 | - return $response; |
|
| 217 | - } |
|
| 204 | + public function removeOptimization($params) |
|
| 205 | + { |
|
| 206 | + $allQueryFields = array('redirect'); |
|
| 207 | + $allBodyFields = array('optimization_problem_ids'); |
|
| 208 | + |
|
| 209 | + $response = Route4Me::makeRequst(array( |
|
| 210 | + 'url' => Endpoint::OPTIMIZATION_PROBLEM, |
|
| 211 | + 'method' => 'DELETE', |
|
| 212 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 213 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 214 | + )); |
|
| 215 | + |
|
| 216 | + return $response; |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - public function getHybridOptimization($params) |
|
| 220 | - { |
|
| 221 | - $allQueryFields = array('target_date_string', 'timezone_offset_minutes'); |
|
| 222 | - |
|
| 223 | - $optimize = Route4Me::makeRequst(array( |
|
| 224 | - 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
| 225 | - 'method' => 'GET', |
|
| 226 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 227 | - )); |
|
| 228 | - |
|
| 229 | - return $optimize; |
|
| 230 | - } |
|
| 219 | + public function getHybridOptimization($params) |
|
| 220 | + { |
|
| 221 | + $allQueryFields = array('target_date_string', 'timezone_offset_minutes'); |
|
| 222 | + |
|
| 223 | + $optimize = Route4Me::makeRequst(array( |
|
| 224 | + 'url' => Endpoint::HYBRID_DATE_OPTIMIZATION, |
|
| 225 | + 'method' => 'GET', |
|
| 226 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 227 | + )); |
|
| 228 | + |
|
| 229 | + return $optimize; |
|
| 230 | + } |
|
| 231 | 231 | |
| 232 | - Public function addDepotsToHybrid($params) |
|
| 233 | - { |
|
| 234 | - $allQueryFields = array('optimization_problem_id'); |
|
| 235 | - $allBodyFields = array('optimization_problem_id', 'delete_old_depots', 'new_depots'); |
|
| 236 | - |
|
| 237 | - $depots = Route4Me::makeRequst(array( |
|
| 238 | - 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
| 239 | - 'method' => 'POST', |
|
| 240 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 241 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 242 | - )); |
|
| 243 | - |
|
| 244 | - return $depots; |
|
| 245 | - } |
|
| 232 | + Public function addDepotsToHybrid($params) |
|
| 233 | + { |
|
| 234 | + $allQueryFields = array('optimization_problem_id'); |
|
| 235 | + $allBodyFields = array('optimization_problem_id', 'delete_old_depots', 'new_depots'); |
|
| 236 | + |
|
| 237 | + $depots = Route4Me::makeRequst(array( |
|
| 238 | + 'url' => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT, |
|
| 239 | + 'method' => 'POST', |
|
| 240 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 241 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 242 | + )); |
|
| 243 | + |
|
| 244 | + return $depots; |
|
| 245 | + } |
|
| 246 | 246 | } |
@@ -146,7 +146,7 @@ |
||
| 146 | 146 | |
| 147 | 147 | $rOptimization = $optimizations[rand(0, sizeof($optimizations) - 1)]; |
| 148 | 148 | |
| 149 | - if(!isset($rOptimization->optimization_problem_id)) { |
|
| 149 | + if (!isset($rOptimization->optimization_problem_id)) { |
|
| 150 | 150 | if (sizeof($optimizations)>9) { |
| 151 | 151 | $this->getRandomOptimizationId($offset, $limit); |
| 152 | 152 | } else { |
@@ -6,325 +6,325 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Member extends Common |
| 8 | 8 | { |
| 9 | - public $device_id; |
|
| 10 | - public $device_type; |
|
| 11 | - public $format; |
|
| 9 | + public $device_id; |
|
| 10 | + public $device_type; |
|
| 11 | + public $format; |
|
| 12 | 12 | |
| 13 | - public $strEmail; |
|
| 14 | - public $strPassword; |
|
| 15 | - public $strPassword_1; |
|
| 16 | - public $strPassword_2; |
|
| 17 | - public $strFirstName; |
|
| 18 | - public $strLastName; |
|
| 19 | - public $strIndustry; |
|
| 20 | - public $chkTerms; |
|
| 21 | - public $plan; |
|
| 13 | + public $strEmail; |
|
| 14 | + public $strPassword; |
|
| 15 | + public $strPassword_1; |
|
| 16 | + public $strPassword_2; |
|
| 17 | + public $strFirstName; |
|
| 18 | + public $strLastName; |
|
| 19 | + public $strIndustry; |
|
| 20 | + public $chkTerms; |
|
| 21 | + public $plan; |
|
| 22 | 22 | |
| 23 | - public $session_guid; |
|
| 24 | - public $member_id; |
|
| 23 | + public $session_guid; |
|
| 24 | + public $member_id; |
|
| 25 | 25 | |
| 26 | - public $email_address; |
|
| 27 | - public $first_name; |
|
| 28 | - public $last_name; |
|
| 29 | - public $phone_number; |
|
| 30 | - public $company_name; |
|
| 31 | - public $webinar_date; |
|
| 26 | + public $email_address; |
|
| 27 | + public $first_name; |
|
| 28 | + public $last_name; |
|
| 29 | + public $phone_number; |
|
| 30 | + public $company_name; |
|
| 31 | + public $webinar_date; |
|
| 32 | 32 | |
| 33 | - public $subscription_name; |
|
| 34 | - public $token; |
|
| 35 | - public $payload; |
|
| 33 | + public $subscription_name; |
|
| 34 | + public $token; |
|
| 35 | + public $payload; |
|
| 36 | 36 | |
| 37 | - public $HIDE_ROUTED_ADDRESSES; |
|
| 38 | - public $member_phone; |
|
| 39 | - public $member_zipcode; |
|
| 40 | - public $route_count; |
|
| 41 | - public $member_email; |
|
| 42 | - public $HIDE_VISITED_ADDRESSES; |
|
| 43 | - public $READONLY_USER; |
|
| 44 | - public $member_type; |
|
| 45 | - public $date_of_birth; |
|
| 46 | - public $member_first_name; |
|
| 47 | - public $member_password; |
|
| 48 | - public $HIDE_NONFUTURE_ROUTES; |
|
| 49 | - public $member_last_name; |
|
| 50 | - public $SHOW_ALL_VEHICLES; |
|
| 51 | - public $SHOW_ALL_DRIVERS; |
|
| 37 | + public $HIDE_ROUTED_ADDRESSES; |
|
| 38 | + public $member_phone; |
|
| 39 | + public $member_zipcode; |
|
| 40 | + public $route_count; |
|
| 41 | + public $member_email; |
|
| 42 | + public $HIDE_VISITED_ADDRESSES; |
|
| 43 | + public $READONLY_USER; |
|
| 44 | + public $member_type; |
|
| 45 | + public $date_of_birth; |
|
| 46 | + public $member_first_name; |
|
| 47 | + public $member_password; |
|
| 48 | + public $HIDE_NONFUTURE_ROUTES; |
|
| 49 | + public $member_last_name; |
|
| 50 | + public $SHOW_ALL_VEHICLES; |
|
| 51 | + public $SHOW_ALL_DRIVERS; |
|
| 52 | 52 | |
| 53 | - public $config_key; |
|
| 54 | - public $config_value; |
|
| 53 | + public $config_key; |
|
| 54 | + public $config_value; |
|
| 55 | 55 | |
| 56 | - public $preferred_units; |
|
| 57 | - public $preferred_language; |
|
| 58 | - public $timezone; |
|
| 59 | - public $OWNER_MEMBER_ID; |
|
| 60 | - public $user_reg_state_id; |
|
| 61 | - public $user_reg_country_id; |
|
| 62 | - public $member_picture; |
|
| 63 | - public $api_key; |
|
| 64 | - public $custom_data; |
|
| 56 | + public $preferred_units; |
|
| 57 | + public $preferred_language; |
|
| 58 | + public $timezone; |
|
| 59 | + public $OWNER_MEMBER_ID; |
|
| 60 | + public $user_reg_state_id; |
|
| 61 | + public $user_reg_country_id; |
|
| 62 | + public $member_picture; |
|
| 63 | + public $api_key; |
|
| 64 | + public $custom_data; |
|
| 65 | 65 | |
| 66 | - public static function fromArray(array $params) |
|
| 67 | - { |
|
| 68 | - $member= new Member(); |
|
| 69 | - |
|
| 70 | - foreach($params as $key => $value) { |
|
| 71 | - if (property_exists($member, $key)) { |
|
| 72 | - $member->{$key} = $value; |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - return $member; |
|
| 77 | - } |
|
| 66 | + public static function fromArray(array $params) |
|
| 67 | + { |
|
| 68 | + $member= new Member(); |
|
| 69 | + |
|
| 70 | + foreach($params as $key => $value) { |
|
| 71 | + if (property_exists($member, $key)) { |
|
| 72 | + $member->{$key} = $value; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + return $member; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - public static function getUsers() |
|
| 80 | - { |
|
| 81 | - $response = Route4Me::makeRequst(array( |
|
| 82 | - 'url' => Endpoint::USER_V4, |
|
| 83 | - 'method' => 'GET' |
|
| 84 | - )); |
|
| 79 | + public static function getUsers() |
|
| 80 | + { |
|
| 81 | + $response = Route4Me::makeRequst(array( |
|
| 82 | + 'url' => Endpoint::USER_V4, |
|
| 83 | + 'method' => 'GET' |
|
| 84 | + )); |
|
| 85 | 85 | |
| 86 | - return $response; |
|
| 87 | - } |
|
| 86 | + return $response; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - public static function getUser($params) |
|
| 90 | - { |
|
| 91 | - $response = Route4Me::makeRequst(array( |
|
| 92 | - 'url' => Endpoint::USER_V4, |
|
| 93 | - 'method' => 'GET', |
|
| 94 | - 'query' => array( |
|
| 95 | - 'member_id' => isset($params['member_id']) ? $params['member_id'] : null |
|
| 96 | - ) |
|
| 97 | - )); |
|
| 89 | + public static function getUser($params) |
|
| 90 | + { |
|
| 91 | + $response = Route4Me::makeRequst(array( |
|
| 92 | + 'url' => Endpoint::USER_V4, |
|
| 93 | + 'method' => 'GET', |
|
| 94 | + 'query' => array( |
|
| 95 | + 'member_id' => isset($params['member_id']) ? $params['member_id'] : null |
|
| 96 | + ) |
|
| 97 | + )); |
|
| 98 | 98 | |
| 99 | - return $response; |
|
| 100 | - } |
|
| 99 | + return $response; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | - public static function getUserLocations($param) |
|
| 103 | - { |
|
| 104 | - $response = Route4Me::makeRequst(array( |
|
| 105 | - 'url' => Endpoint::VIEW_USER_LOCATIONS, |
|
| 106 | - 'method' => 'GET', |
|
| 107 | - 'query' => array( |
|
| 108 | - 'query' => $param |
|
| 109 | - ) |
|
| 110 | - )); |
|
| 102 | + public static function getUserLocations($param) |
|
| 103 | + { |
|
| 104 | + $response = Route4Me::makeRequst(array( |
|
| 105 | + 'url' => Endpoint::VIEW_USER_LOCATIONS, |
|
| 106 | + 'method' => 'GET', |
|
| 107 | + 'query' => array( |
|
| 108 | + 'query' => $param |
|
| 109 | + ) |
|
| 110 | + )); |
|
| 111 | 111 | |
| 112 | - return $response; |
|
| 113 | - } |
|
| 112 | + return $response; |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - public static function addDeviceRecord($params) |
|
| 116 | - { |
|
| 117 | - $allQueryFields = array('device_id', 'device_type'); |
|
| 118 | - $allBodyFields = array('device_id', 'device_type', 'format'); |
|
| 119 | - |
|
| 120 | - $response = Route4Me::makeRequst(array( |
|
| 121 | - 'url' => Endpoint::VERIFY_DEVICE_LICENSE, |
|
| 122 | - 'method' => 'POST', |
|
| 123 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 124 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 125 | - )); |
|
| 126 | - |
|
| 127 | - return $response; |
|
| 128 | - } |
|
| 115 | + public static function addDeviceRecord($params) |
|
| 116 | + { |
|
| 117 | + $allQueryFields = array('device_id', 'device_type'); |
|
| 118 | + $allBodyFields = array('device_id', 'device_type', 'format'); |
|
| 119 | + |
|
| 120 | + $response = Route4Me::makeRequst(array( |
|
| 121 | + 'url' => Endpoint::VERIFY_DEVICE_LICENSE, |
|
| 122 | + 'method' => 'POST', |
|
| 123 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 124 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 125 | + )); |
|
| 126 | + |
|
| 127 | + return $response; |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - public static function createMember($params) |
|
| 131 | - { |
|
| 132 | - $excludeFields = array('session_guid', 'member_id', 'token', 'payload', 'webinar_date', |
|
| 133 | - 'company_name', 'config_key', 'config_value', 'api_key'); |
|
| 130 | + public static function createMember($params) |
|
| 131 | + { |
|
| 132 | + $excludeFields = array('session_guid', 'member_id', 'token', 'payload', 'webinar_date', |
|
| 133 | + 'company_name', 'config_key', 'config_value', 'api_key'); |
|
| 134 | 134 | |
| 135 | - $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields); |
|
| 135 | + $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields); |
|
| 136 | 136 | |
| 137 | - $response = Route4Me::makeRequst(array( |
|
| 138 | - 'url' => Endpoint::USER_V4, |
|
| 139 | - 'method' => 'POST', |
|
| 140 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 141 | - )); |
|
| 142 | - |
|
| 143 | - return $response; |
|
| 144 | - } |
|
| 137 | + $response = Route4Me::makeRequst(array( |
|
| 138 | + 'url' => Endpoint::USER_V4, |
|
| 139 | + 'method' => 'POST', |
|
| 140 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 141 | + )); |
|
| 142 | + |
|
| 143 | + return $response; |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | - public static function getRandomMemberByType($memberType) |
|
| 147 | - { |
|
| 148 | - $members = self::getUsers(); |
|
| 146 | + public static function getRandomMemberByType($memberType) |
|
| 147 | + { |
|
| 148 | + $members = self::getUsers(); |
|
| 149 | 149 | |
| 150 | - if (is_null($members) || !isset($members['results'])) { |
|
| 151 | - return null; |
|
| 152 | - } |
|
| 150 | + if (is_null($members) || !isset($members['results'])) { |
|
| 151 | + return null; |
|
| 152 | + } |
|
| 153 | 153 | |
| 154 | - $memberIDs = array(); |
|
| 154 | + $memberIDs = array(); |
|
| 155 | 155 | |
| 156 | - foreach ($members['results'] as $memb) { |
|
| 157 | - if (isset($memb['member_id']) && isset($memb['member_type'])) { |
|
| 158 | - if ($memberType==$memb['member_type']) { |
|
| 159 | - $memberIDs[]=$memb['member_id']; |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - } |
|
| 156 | + foreach ($members['results'] as $memb) { |
|
| 157 | + if (isset($memb['member_id']) && isset($memb['member_type'])) { |
|
| 158 | + if ($memberType==$memb['member_type']) { |
|
| 159 | + $memberIDs[]=$memb['member_id']; |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - if (sizeof($memberIDs)<1) { |
|
| 165 | - return null; |
|
| 166 | - } |
|
| 164 | + if (sizeof($memberIDs)<1) { |
|
| 165 | + return null; |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - $randomIndex = rand(0, sizeof($memberIDs) - 1); |
|
| 168 | + $randomIndex = rand(0, sizeof($memberIDs) - 1); |
|
| 169 | 169 | |
| 170 | - return $memberIDs[$randomIndex]; |
|
| 171 | - } |
|
| 170 | + return $memberIDs[$randomIndex]; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | 173 | |
| 174 | - public static function updateMember($body) |
|
| 175 | - { |
|
| 176 | - $excludeFields = array('session_guid', 'token', 'payload', 'webinar_date', |
|
| 177 | - 'company_name', 'config_key', 'config_value', 'api_key'); |
|
| 174 | + public static function updateMember($body) |
|
| 175 | + { |
|
| 176 | + $excludeFields = array('session_guid', 'token', 'payload', 'webinar_date', |
|
| 177 | + 'company_name', 'config_key', 'config_value', 'api_key'); |
|
| 178 | 178 | |
| 179 | - $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields); |
|
| 179 | + $allBodyFields = Route4Me::getObjectProperties(new Member(), $excludeFields); |
|
| 180 | 180 | |
| 181 | - $response = Route4Me::makeRequst(array( |
|
| 182 | - 'url' => Endpoint::USER_V4, |
|
| 183 | - 'method' => 'PUT', |
|
| 184 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $body) |
|
| 185 | - )); |
|
| 181 | + $response = Route4Me::makeRequst(array( |
|
| 182 | + 'url' => Endpoint::USER_V4, |
|
| 183 | + 'method' => 'PUT', |
|
| 184 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $body) |
|
| 185 | + )); |
|
| 186 | 186 | |
| 187 | - return $response; |
|
| 188 | - } |
|
| 187 | + return $response; |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - public static function deleteMember($body) |
|
| 191 | - { |
|
| 192 | - $response = Route4Me::makeRequst(array( |
|
| 193 | - 'url' => Endpoint::USER_V4, |
|
| 194 | - 'method' => 'DELETE', |
|
| 195 | - 'body' => array( |
|
| 196 | - 'member_id' => isset($body->member_id) ? $body->member_id : null |
|
| 197 | - ) |
|
| 190 | + public static function deleteMember($body) |
|
| 191 | + { |
|
| 192 | + $response = Route4Me::makeRequst(array( |
|
| 193 | + 'url' => Endpoint::USER_V4, |
|
| 194 | + 'method' => 'DELETE', |
|
| 195 | + 'body' => array( |
|
| 196 | + 'member_id' => isset($body->member_id) ? $body->member_id : null |
|
| 197 | + ) |
|
| 198 | 198 | |
| 199 | - )); |
|
| 199 | + )); |
|
| 200 | 200 | |
| 201 | - return $response; |
|
| 202 | - } |
|
| 201 | + return $response; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - public static function newAccountRegistration($params) |
|
| 205 | - { |
|
| 206 | - $allQueryFields = array('plan'); |
|
| 207 | - $allBodyFields = array('strEmail', 'strPassword_1', 'strPassword_2', 'strFirstName', |
|
| 208 | - 'strLastName', 'format', 'strIndustry', 'chkTerms', 'device_type', 'strSubAccountType', |
|
| 209 | - 'blDisableMarketing', 'blDisableAccountActivationEmail'); |
|
| 210 | - |
|
| 211 | - $response = Route4Me::makeRequst(array( |
|
| 212 | - 'url' => Endpoint::REGISTER_ACTION, |
|
| 213 | - 'method' => 'POST', |
|
| 214 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 215 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 216 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 217 | - )); |
|
| 218 | - |
|
| 219 | - return $response; |
|
| 220 | - } |
|
| 204 | + public static function newAccountRegistration($params) |
|
| 205 | + { |
|
| 206 | + $allQueryFields = array('plan'); |
|
| 207 | + $allBodyFields = array('strEmail', 'strPassword_1', 'strPassword_2', 'strFirstName', |
|
| 208 | + 'strLastName', 'format', 'strIndustry', 'chkTerms', 'device_type', 'strSubAccountType', |
|
| 209 | + 'blDisableMarketing', 'blDisableAccountActivationEmail'); |
|
| 210 | + |
|
| 211 | + $response = Route4Me::makeRequst(array( |
|
| 212 | + 'url' => Endpoint::REGISTER_ACTION, |
|
| 213 | + 'method' => 'POST', |
|
| 214 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 215 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 216 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 217 | + )); |
|
| 218 | + |
|
| 219 | + return $response; |
|
| 220 | + } |
|
| 221 | 221 | |
| 222 | - public static function validateSession($params) |
|
| 223 | - { |
|
| 224 | - $allQueryFields = array('session_guid', 'member_id', 'format'); |
|
| 225 | - |
|
| 226 | - $response = Route4Me::makeRequst(array( |
|
| 227 | - 'url' => Endpoint::VALIDATE_SESSION, |
|
| 228 | - 'method' => 'GET', |
|
| 229 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 230 | - )); |
|
| 231 | - |
|
| 232 | - return $response; |
|
| 233 | - } |
|
| 222 | + public static function validateSession($params) |
|
| 223 | + { |
|
| 224 | + $allQueryFields = array('session_guid', 'member_id', 'format'); |
|
| 225 | + |
|
| 226 | + $response = Route4Me::makeRequst(array( |
|
| 227 | + 'url' => Endpoint::VALIDATE_SESSION, |
|
| 228 | + 'method' => 'GET', |
|
| 229 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 230 | + )); |
|
| 231 | + |
|
| 232 | + return $response; |
|
| 233 | + } |
|
| 234 | 234 | |
| 235 | - public static function memberAuthentication($params) |
|
| 236 | - { |
|
| 237 | - $allBodyFields = array('strEmail', 'strPassword', 'format'); |
|
| 238 | - |
|
| 239 | - $response = Route4Me::makeRequst(array( |
|
| 240 | - 'url' => Endpoint::AUTHENTICATE, |
|
| 241 | - 'method' => 'POST', |
|
| 242 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 243 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 244 | - )); |
|
| 245 | - |
|
| 246 | - return $response; |
|
| 247 | - } |
|
| 235 | + public static function memberAuthentication($params) |
|
| 236 | + { |
|
| 237 | + $allBodyFields = array('strEmail', 'strPassword', 'format'); |
|
| 238 | + |
|
| 239 | + $response = Route4Me::makeRequst(array( |
|
| 240 | + 'url' => Endpoint::AUTHENTICATE, |
|
| 241 | + 'method' => 'POST', |
|
| 242 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 243 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 244 | + )); |
|
| 245 | + |
|
| 246 | + return $response; |
|
| 247 | + } |
|
| 248 | 248 | |
| 249 | - public static function webinarRegistration($params) |
|
| 250 | - { |
|
| 251 | - $allBodyFields = array('email_address', 'first_name', 'last_name', 'phone_number', |
|
| 252 | - 'company_name', 'member_id', 'webinar_date'); |
|
| 253 | - |
|
| 254 | - $response = Route4Me::makeRequst(array( |
|
| 255 | - 'url' => Endpoint::WEBINAR_REGISTER, |
|
| 256 | - 'method' => 'POST', |
|
| 257 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 258 | - )); |
|
| 259 | - |
|
| 260 | - return $response; |
|
| 261 | - } |
|
| 249 | + public static function webinarRegistration($params) |
|
| 250 | + { |
|
| 251 | + $allBodyFields = array('email_address', 'first_name', 'last_name', 'phone_number', |
|
| 252 | + 'company_name', 'member_id', 'webinar_date'); |
|
| 253 | + |
|
| 254 | + $response = Route4Me::makeRequst(array( |
|
| 255 | + 'url' => Endpoint::WEBINAR_REGISTER, |
|
| 256 | + 'method' => 'POST', |
|
| 257 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 258 | + )); |
|
| 259 | + |
|
| 260 | + return $response; |
|
| 261 | + } |
|
| 262 | 262 | |
| 263 | - public static function purchaseUserLicense($params) |
|
| 264 | - { |
|
| 265 | - $allQueryFields = array('device_id'); |
|
| 266 | - $allBodyFields = array('member_id', 'session_guid', 'device_id', 'device_type', |
|
| 267 | - 'subscription_name', 'token', 'payload', 'format'); |
|
| 268 | - |
|
| 269 | - $response = Route4Me::makeRequst(array( |
|
| 270 | - 'url' => Endpoint::USER_LICENSE, |
|
| 271 | - 'method' => 'POST', |
|
| 272 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 273 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 274 | - )); |
|
| 275 | - |
|
| 276 | - return $response; |
|
| 277 | - } |
|
| 263 | + public static function purchaseUserLicense($params) |
|
| 264 | + { |
|
| 265 | + $allQueryFields = array('device_id'); |
|
| 266 | + $allBodyFields = array('member_id', 'session_guid', 'device_id', 'device_type', |
|
| 267 | + 'subscription_name', 'token', 'payload', 'format'); |
|
| 268 | + |
|
| 269 | + $response = Route4Me::makeRequst(array( |
|
| 270 | + 'url' => Endpoint::USER_LICENSE, |
|
| 271 | + 'method' => 'POST', |
|
| 272 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 273 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 274 | + )); |
|
| 275 | + |
|
| 276 | + return $response; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - public static function newMemberConfigKey($params) |
|
| 280 | - { |
|
| 281 | - $allBodyFields = array('config_key', 'config_value'); |
|
| 282 | - |
|
| 283 | - $response = Route4Me::makeRequst(array( |
|
| 284 | - 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
| 285 | - 'method' => 'POST', |
|
| 286 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 287 | - )); |
|
| 288 | - |
|
| 289 | - return $response; |
|
| 290 | - } |
|
| 279 | + public static function newMemberConfigKey($params) |
|
| 280 | + { |
|
| 281 | + $allBodyFields = array('config_key', 'config_value'); |
|
| 282 | + |
|
| 283 | + $response = Route4Me::makeRequst(array( |
|
| 284 | + 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
| 285 | + 'method' => 'POST', |
|
| 286 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 287 | + )); |
|
| 288 | + |
|
| 289 | + return $response; |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - public static function removeMemberConfigKey($params) |
|
| 293 | - { |
|
| 294 | - $allBodyFields = array('config_key'); |
|
| 295 | - |
|
| 296 | - $response = Route4Me::makeRequst(array( |
|
| 297 | - 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
| 298 | - 'method' => 'DELETE', |
|
| 299 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 300 | - )); |
|
| 301 | - |
|
| 302 | - return $response; |
|
| 303 | - } |
|
| 292 | + public static function removeMemberConfigKey($params) |
|
| 293 | + { |
|
| 294 | + $allBodyFields = array('config_key'); |
|
| 295 | + |
|
| 296 | + $response = Route4Me::makeRequst(array( |
|
| 297 | + 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
| 298 | + 'method' => 'DELETE', |
|
| 299 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 300 | + )); |
|
| 301 | + |
|
| 302 | + return $response; |
|
| 303 | + } |
|
| 304 | 304 | |
| 305 | - public static function getMemberConfigData($params) |
|
| 306 | - { |
|
| 307 | - $allQueryFields = array('config_key'); |
|
| 308 | - |
|
| 309 | - $response = Route4Me::makeRequst(array( |
|
| 310 | - 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
| 311 | - 'method' => 'GET', |
|
| 312 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 313 | - )); |
|
| 314 | - |
|
| 315 | - return $response; |
|
| 316 | - } |
|
| 305 | + public static function getMemberConfigData($params) |
|
| 306 | + { |
|
| 307 | + $allQueryFields = array('config_key'); |
|
| 308 | + |
|
| 309 | + $response = Route4Me::makeRequst(array( |
|
| 310 | + 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
| 311 | + 'method' => 'GET', |
|
| 312 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 313 | + )); |
|
| 314 | + |
|
| 315 | + return $response; |
|
| 316 | + } |
|
| 317 | 317 | |
| 318 | - public static function updateMemberConfigKey($params) |
|
| 319 | - { |
|
| 320 | - $allBodyFields = array('config_key', 'config_value'); |
|
| 321 | - |
|
| 322 | - $response = Route4Me::makeRequst(array( |
|
| 323 | - 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
| 324 | - 'method' => 'PUT', |
|
| 325 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 326 | - )); |
|
| 327 | - |
|
| 328 | - return $response; |
|
| 329 | - } |
|
| 318 | + public static function updateMemberConfigKey($params) |
|
| 319 | + { |
|
| 320 | + $allBodyFields = array('config_key', 'config_value'); |
|
| 321 | + |
|
| 322 | + $response = Route4Me::makeRequst(array( |
|
| 323 | + 'url' => Endpoint::CONFIGURATION_SETTINGS, |
|
| 324 | + 'method' => 'PUT', |
|
| 325 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 326 | + )); |
|
| 327 | + |
|
| 328 | + return $response; |
|
| 329 | + } |
|
| 330 | 330 | } |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public static function fromArray(array $params) |
| 67 | 67 | { |
| 68 | - $member= new Member(); |
|
| 68 | + $member = new Member(); |
|
| 69 | 69 | |
| 70 | - foreach($params as $key => $value) { |
|
| 70 | + foreach ($params as $key => $value) { |
|
| 71 | 71 | if (property_exists($member, $key)) { |
| 72 | 72 | $member->{$key} = $value; |
| 73 | 73 | } |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | foreach ($members['results'] as $memb) { |
| 157 | 157 | if (isset($memb['member_id']) && isset($memb['member_type'])) { |
| 158 | 158 | if ($memberType==$memb['member_type']) { |
| 159 | - $memberIDs[]=$memb['member_id']; |
|
| 159 | + $memberIDs[] = $memb['member_id']; |
|
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | } |
@@ -6,450 +6,450 @@ |
||
| 6 | 6 | |
| 7 | 7 | class AddressBookLocation extends Common |
| 8 | 8 | { |
| 9 | - public $address_id; |
|
| 10 | - public $address_group; |
|
| 11 | - public $address_alias; |
|
| 12 | - public $address_1; |
|
| 13 | - public $address_2; |
|
| 14 | - public $first_name; |
|
| 15 | - public $last_name; |
|
| 16 | - public $address_email; |
|
| 17 | - public $address_phone_number; |
|
| 18 | - public $address_city; |
|
| 19 | - public $address_state_id; |
|
| 20 | - public $address_country_id; |
|
| 21 | - public $address_zip; |
|
| 22 | - public $cached_lat; |
|
| 23 | - public $cached_lng; |
|
| 24 | - public $curbside_lat; |
|
| 25 | - public $curbside_lng; |
|
| 26 | - public $color; |
|
| 27 | - public $address_custom_data; |
|
| 28 | - public $schedule; |
|
| 9 | + public $address_id; |
|
| 10 | + public $address_group; |
|
| 11 | + public $address_alias; |
|
| 12 | + public $address_1; |
|
| 13 | + public $address_2; |
|
| 14 | + public $first_name; |
|
| 15 | + public $last_name; |
|
| 16 | + public $address_email; |
|
| 17 | + public $address_phone_number; |
|
| 18 | + public $address_city; |
|
| 19 | + public $address_state_id; |
|
| 20 | + public $address_country_id; |
|
| 21 | + public $address_zip; |
|
| 22 | + public $cached_lat; |
|
| 23 | + public $cached_lng; |
|
| 24 | + public $curbside_lat; |
|
| 25 | + public $curbside_lng; |
|
| 26 | + public $color; |
|
| 27 | + public $address_custom_data; |
|
| 28 | + public $schedule; |
|
| 29 | 29 | |
| 30 | - public $created_timestamp; |
|
| 31 | - public $member_id; |
|
| 32 | - public $schedule_blacklist; |
|
| 33 | - public $in_route_count; |
|
| 34 | - public $last_visited_timestamp; |
|
| 35 | - public $last_routed_timestamp; |
|
| 36 | - public $local_time_window_start; |
|
| 37 | - public $local_time_window_end; |
|
| 38 | - public $local_time_window_start_2; |
|
| 39 | - public $local_time_window_end_2; |
|
| 40 | - public $service_time; |
|
| 41 | - public $local_timezone_string; |
|
| 42 | - public $address_icon; |
|
| 43 | - public $address_stop_type; |
|
| 44 | - public $address_cube; |
|
| 45 | - public $address_pieces; |
|
| 46 | - public $address_reference_no; |
|
| 47 | - public $address_revenue; |
|
| 48 | - public $address_weight; |
|
| 49 | - public $address_priority; |
|
| 50 | - public $address_customer_po; |
|
| 30 | + public $created_timestamp; |
|
| 31 | + public $member_id; |
|
| 32 | + public $schedule_blacklist; |
|
| 33 | + public $in_route_count; |
|
| 34 | + public $last_visited_timestamp; |
|
| 35 | + public $last_routed_timestamp; |
|
| 36 | + public $local_time_window_start; |
|
| 37 | + public $local_time_window_end; |
|
| 38 | + public $local_time_window_start_2; |
|
| 39 | + public $local_time_window_end_2; |
|
| 40 | + public $service_time; |
|
| 41 | + public $local_timezone_string; |
|
| 42 | + public $address_icon; |
|
| 43 | + public $address_stop_type; |
|
| 44 | + public $address_cube; |
|
| 45 | + public $address_pieces; |
|
| 46 | + public $address_reference_no; |
|
| 47 | + public $address_revenue; |
|
| 48 | + public $address_weight; |
|
| 49 | + public $address_priority; |
|
| 50 | + public $address_customer_po; |
|
| 51 | 51 | |
| 52 | - public static function fromArray(array $params) |
|
| 53 | - { |
|
| 54 | - $addressbooklocation = new AddressBookLocation(); |
|
| 52 | + public static function fromArray(array $params) |
|
| 53 | + { |
|
| 54 | + $addressbooklocation = new AddressBookLocation(); |
|
| 55 | 55 | |
| 56 | - foreach ($params as $key => $value) { |
|
| 57 | - if (property_exists($addressbooklocation, $key)) { |
|
| 58 | - $addressbooklocation->{$key} = $value; |
|
| 59 | - } |
|
| 60 | - } |
|
| 56 | + foreach ($params as $key => $value) { |
|
| 57 | + if (property_exists($addressbooklocation, $key)) { |
|
| 58 | + $addressbooklocation->{$key} = $value; |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return $addressbooklocation; |
|
| 63 | - } |
|
| 62 | + return $addressbooklocation; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | |
| 67 | - public static function getAddressBookLocation($addressId) |
|
| 68 | - { |
|
| 69 | - $ablocations = Route4Me::makeRequst(array( |
|
| 70 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 71 | - 'method' => 'GET', |
|
| 72 | - 'query' => array( |
|
| 73 | - 'query' => $addressId, |
|
| 74 | - 'limit' => 30 |
|
| 75 | - ) |
|
| 76 | - )); |
|
| 67 | + public static function getAddressBookLocation($addressId) |
|
| 68 | + { |
|
| 69 | + $ablocations = Route4Me::makeRequst(array( |
|
| 70 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 71 | + 'method' => 'GET', |
|
| 72 | + 'query' => array( |
|
| 73 | + 'query' => $addressId, |
|
| 74 | + 'limit' => 30 |
|
| 75 | + ) |
|
| 76 | + )); |
|
| 77 | 77 | |
| 78 | - return $ablocations; |
|
| 79 | - } |
|
| 78 | + return $ablocations; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - public static function searchAddressBookLocations($params) |
|
| 82 | - { |
|
| 83 | - $allQueryFields = array('display', 'query', 'fields', 'limit', 'offset'); |
|
| 81 | + public static function searchAddressBookLocations($params) |
|
| 82 | + { |
|
| 83 | + $allQueryFields = array('display', 'query', 'fields', 'limit', 'offset'); |
|
| 84 | 84 | |
| 85 | - $result = Route4Me::makeRequst(array( |
|
| 86 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 87 | - 'method' => 'GET', |
|
| 88 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 89 | - )); |
|
| 85 | + $result = Route4Me::makeRequst(array( |
|
| 86 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 87 | + 'method' => 'GET', |
|
| 88 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 89 | + )); |
|
| 90 | 90 | |
| 91 | - return $result; |
|
| 92 | - } |
|
| 91 | + return $result; |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - public static function getAddressBookLocations($params) |
|
| 95 | - { |
|
| 96 | - $allQueryFields = array('limit', 'offset', 'address_id'); |
|
| 94 | + public static function getAddressBookLocations($params) |
|
| 95 | + { |
|
| 96 | + $allQueryFields = array('limit', 'offset', 'address_id'); |
|
| 97 | 97 | |
| 98 | - $ablocations = Route4Me::makeRequst(array( |
|
| 99 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 100 | - 'method' => 'GET', |
|
| 101 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 102 | - )); |
|
| 98 | + $ablocations = Route4Me::makeRequst(array( |
|
| 99 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 100 | + 'method' => 'GET', |
|
| 101 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 102 | + )); |
|
| 103 | 103 | |
| 104 | - return $ablocations; |
|
| 105 | - } |
|
| 104 | + return $ablocations; |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | - public static function getRandomAddressBookLocation($params) |
|
| 108 | - { |
|
| 109 | - $ablocations = self::getAddressBookLocations($params); |
|
| 107 | + public static function getRandomAddressBookLocation($params) |
|
| 108 | + { |
|
| 109 | + $ablocations = self::getAddressBookLocations($params); |
|
| 110 | 110 | |
| 111 | - if (isset($ablocations["results"])) { |
|
| 112 | - $locationsSize = sizeof($ablocations["results"]); |
|
| 111 | + if (isset($ablocations["results"])) { |
|
| 112 | + $locationsSize = sizeof($ablocations["results"]); |
|
| 113 | 113 | |
| 114 | - if ($locationsSize>0) { |
|
| 115 | - $randomLocationIndex = rand(0, $locationsSize - 1); |
|
| 116 | - return $ablocations["results"][$randomLocationIndex]; |
|
| 117 | - } |
|
| 118 | - } |
|
| 114 | + if ($locationsSize>0) { |
|
| 115 | + $randomLocationIndex = rand(0, $locationsSize - 1); |
|
| 116 | + return $ablocations["results"][$randomLocationIndex]; |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - return null; |
|
| 121 | - } |
|
| 120 | + return null; |
|
| 121 | + } |
|
| 122 | 122 | |
| 123 | - /** |
|
| 124 | - * @param AddressBookLocation $params |
|
| 125 | - */ |
|
| 126 | - public static function addAdressBookLocation($params) |
|
| 127 | - { |
|
| 128 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
| 123 | + /** |
|
| 124 | + * @param AddressBookLocation $params |
|
| 125 | + */ |
|
| 126 | + public static function addAdressBookLocation($params) |
|
| 127 | + { |
|
| 128 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
| 129 | 129 | |
| 130 | - $response = Route4Me::makeRequst(array( |
|
| 131 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 132 | - 'method' => 'POST', |
|
| 133 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 134 | - )); |
|
| 130 | + $response = Route4Me::makeRequst(array( |
|
| 131 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 132 | + 'method' => 'POST', |
|
| 133 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 134 | + )); |
|
| 135 | 135 | |
| 136 | - return $response; |
|
| 137 | - } |
|
| 136 | + return $response; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - public function deleteAdressBookLocation($address_ids) |
|
| 140 | - { |
|
| 141 | - $result = Route4Me::makeRequst(array( |
|
| 142 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 143 | - 'method' => 'DELETEARRAY', |
|
| 144 | - 'query' => array( |
|
| 145 | - 'address_ids' => $address_ids |
|
| 146 | - ) |
|
| 147 | - )); |
|
| 139 | + public function deleteAdressBookLocation($address_ids) |
|
| 140 | + { |
|
| 141 | + $result = Route4Me::makeRequst(array( |
|
| 142 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 143 | + 'method' => 'DELETEARRAY', |
|
| 144 | + 'query' => array( |
|
| 145 | + 'address_ids' => $address_ids |
|
| 146 | + ) |
|
| 147 | + )); |
|
| 148 | 148 | |
| 149 | - return $result; |
|
| 150 | - } |
|
| 149 | + return $result; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - public function updateAdressBookLocation($params) |
|
| 153 | - { |
|
| 154 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
| 152 | + public function updateAdressBookLocation($params) |
|
| 153 | + { |
|
| 154 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
| 155 | 155 | |
| 156 | - $response = Route4Me::makeRequst(array( |
|
| 157 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 158 | - 'method' => 'PUT', |
|
| 159 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 160 | - )); |
|
| 156 | + $response = Route4Me::makeRequst(array( |
|
| 157 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
| 158 | + 'method' => 'PUT', |
|
| 159 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 160 | + )); |
|
| 161 | 161 | |
| 162 | - return $response; |
|
| 163 | - } |
|
| 162 | + return $response; |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | - public static function validateScheduleMode($scheduleMode) |
|
| 166 | - { |
|
| 167 | - $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
| 165 | + public static function validateScheduleMode($scheduleMode) |
|
| 166 | + { |
|
| 167 | + $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
| 168 | 168 | |
| 169 | - if (in_array($scheduleMode, $schedMmodes)) { |
|
| 170 | - return TRUE; |
|
| 171 | - } else { |
|
| 172 | - return FALSE; |
|
| 173 | - } |
|
| 174 | - } |
|
| 169 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
| 170 | + return TRUE; |
|
| 171 | + } else { |
|
| 172 | + return FALSE; |
|
| 173 | + } |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - public static function validateScheduleEnable($scheduleEnabled) |
|
| 177 | - { |
|
| 178 | - $schedEnables = array(TRUE, FALSE); |
|
| 176 | + public static function validateScheduleEnable($scheduleEnabled) |
|
| 177 | + { |
|
| 178 | + $schedEnables = array(TRUE, FALSE); |
|
| 179 | 179 | |
| 180 | - if (in_array($scheduleEnabled, $schedEnables)) { |
|
| 181 | - return TRUE; |
|
| 182 | - } else { |
|
| 183 | - return FALSE; |
|
| 184 | - } |
|
| 185 | - } |
|
| 180 | + if (in_array($scheduleEnabled, $schedEnables)) { |
|
| 181 | + return TRUE; |
|
| 182 | + } else { |
|
| 183 | + return FALSE; |
|
| 184 | + } |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - public static function validateScheduleEvery($scheduleEvery) |
|
| 188 | - { |
|
| 189 | - if (is_numeric($scheduleEvery)) { |
|
| 190 | - return TRUE; |
|
| 191 | - } else { |
|
| 192 | - return FALSE; |
|
| 193 | - } |
|
| 194 | - } |
|
| 187 | + public static function validateScheduleEvery($scheduleEvery) |
|
| 188 | + { |
|
| 189 | + if (is_numeric($scheduleEvery)) { |
|
| 190 | + return TRUE; |
|
| 191 | + } else { |
|
| 192 | + return FALSE; |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - public static function validateScheduleWeekDays($scheduleWeekDays) |
|
| 197 | - { |
|
| 198 | - $weekdays = explode(',', $scheduleWeekDays); |
|
| 196 | + public static function validateScheduleWeekDays($scheduleWeekDays) |
|
| 197 | + { |
|
| 198 | + $weekdays = explode(',', $scheduleWeekDays); |
|
| 199 | 199 | |
| 200 | - if (sizeof($weekdays)<1) { |
|
| 201 | - return FALSE; |
|
| 202 | - } |
|
| 200 | + if (sizeof($weekdays)<1) { |
|
| 201 | + return FALSE; |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - $isValid = TRUE; |
|
| 204 | + $isValid = TRUE; |
|
| 205 | 205 | |
| 206 | - for ($i=0; $i<sizeof($weekdays); $i++) { |
|
| 207 | - if (is_numeric($weekdays[$i])) { |
|
| 208 | - $wday = intval($weekdays[$i]); |
|
| 209 | - if ($wday<1 || $wday>7) { |
|
| 210 | - $isValid = FALSE; |
|
| 211 | - } |
|
| 212 | - } else { |
|
| 213 | - $isValid = FALSE; |
|
| 214 | - } |
|
| 215 | - } |
|
| 206 | + for ($i=0; $i<sizeof($weekdays); $i++) { |
|
| 207 | + if (is_numeric($weekdays[$i])) { |
|
| 208 | + $wday = intval($weekdays[$i]); |
|
| 209 | + if ($wday<1 || $wday>7) { |
|
| 210 | + $isValid = FALSE; |
|
| 211 | + } |
|
| 212 | + } else { |
|
| 213 | + $isValid = FALSE; |
|
| 214 | + } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - return $isValid; |
|
| 218 | - } |
|
| 217 | + return $isValid; |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | - public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
| 221 | - { |
|
| 222 | - $schedMonthlyMmodes = array("dates", "nth"); |
|
| 220 | + public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
| 221 | + { |
|
| 222 | + $schedMonthlyMmodes = array("dates", "nth"); |
|
| 223 | 223 | |
| 224 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
| 225 | - return TRUE; |
|
| 226 | - } else { |
|
| 227 | - return FALSE; |
|
| 228 | - } |
|
| 229 | - } |
|
| 224 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
| 225 | + return TRUE; |
|
| 226 | + } else { |
|
| 227 | + return FALSE; |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | 230 | |
| 231 | - public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
| 232 | - { |
|
| 233 | - $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
| 231 | + public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
| 232 | + { |
|
| 233 | + $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
| 234 | 234 | |
| 235 | - if (sizeof($monthlyDates)<1) { |
|
| 236 | - return FALSE; |
|
| 237 | - } |
|
| 235 | + if (sizeof($monthlyDates)<1) { |
|
| 236 | + return FALSE; |
|
| 237 | + } |
|
| 238 | 238 | |
| 239 | - $isValid = TRUE; |
|
| 239 | + $isValid = TRUE; |
|
| 240 | 240 | |
| 241 | - for ($i=0; $i<sizeof($monthlyDates); $i++) { |
|
| 242 | - if (is_numeric($monthlyDates[$i])) { |
|
| 243 | - $mday = intval($monthlyDates[$i]); |
|
| 244 | - if ($mday <1 || $mday > 31) { |
|
| 245 | - $isValid = FALSE; |
|
| 246 | - } |
|
| 247 | - } else { |
|
| 248 | - $isValid = FALSE; |
|
| 249 | - } |
|
| 250 | - } |
|
| 241 | + for ($i=0; $i<sizeof($monthlyDates); $i++) { |
|
| 242 | + if (is_numeric($monthlyDates[$i])) { |
|
| 243 | + $mday = intval($monthlyDates[$i]); |
|
| 244 | + if ($mday <1 || $mday > 31) { |
|
| 245 | + $isValid = FALSE; |
|
| 246 | + } |
|
| 247 | + } else { |
|
| 248 | + $isValid = FALSE; |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | 251 | |
| 252 | - return $isValid; |
|
| 253 | - } |
|
| 252 | + return $isValid; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - public static function validateScheduleNthN($scheduleNthN) |
|
| 256 | - { |
|
| 257 | - if (!is_numeric($scheduleNthN)) { |
|
| 258 | - return FALSE; |
|
| 259 | - } |
|
| 255 | + public static function validateScheduleNthN($scheduleNthN) |
|
| 256 | + { |
|
| 257 | + if (!is_numeric($scheduleNthN)) { |
|
| 258 | + return FALSE; |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
| 261 | + $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
| 262 | 262 | |
| 263 | - if (in_array($scheduleNthN, $schedNthNs)) { |
|
| 264 | - return TRUE; |
|
| 265 | - } else { |
|
| 266 | - return FALSE; |
|
| 267 | - } |
|
| 268 | - } |
|
| 263 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
| 264 | + return TRUE; |
|
| 265 | + } else { |
|
| 266 | + return FALSE; |
|
| 267 | + } |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | - public static function validateScheduleNthWhat($scheduleNthWhat) |
|
| 271 | - { |
|
| 272 | - if (!is_numeric($scheduleNthWhat)) { |
|
| 273 | - return FALSE; |
|
| 274 | - } |
|
| 270 | + public static function validateScheduleNthWhat($scheduleNthWhat) |
|
| 271 | + { |
|
| 272 | + if (!is_numeric($scheduleNthWhat)) { |
|
| 273 | + return FALSE; |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
| 276 | + $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
| 277 | 277 | |
| 278 | - if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
| 279 | - return TRUE; |
|
| 280 | - } else { |
|
| 281 | - return FALSE; |
|
| 282 | - } |
|
| 283 | - } |
|
| 278 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
| 279 | + return TRUE; |
|
| 280 | + } else { |
|
| 281 | + return FALSE; |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - /** Function adds the locations (with/without schedule) from the CSV file. |
|
| 286 | - * $csvFileHandle - a file handler. |
|
| 287 | - * Returns array $results which contains two arrays: fail and succes. |
|
| 288 | - */ |
|
| 289 | - public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
| 290 | - { |
|
| 291 | - $max_line_length = 512; |
|
| 292 | - $delemietr = ','; |
|
| 285 | + /** Function adds the locations (with/without schedule) from the CSV file. |
|
| 286 | + * $csvFileHandle - a file handler. |
|
| 287 | + * Returns array $results which contains two arrays: fail and succes. |
|
| 288 | + */ |
|
| 289 | + public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
| 290 | + { |
|
| 291 | + $max_line_length = 512; |
|
| 292 | + $delemietr = ','; |
|
| 293 | 293 | |
| 294 | - $results = array(); |
|
| 295 | - $results['fail'] = array(); |
|
| 296 | - $results['success'] = array(); |
|
| 294 | + $results = array(); |
|
| 295 | + $results['fail'] = array(); |
|
| 296 | + $results['success'] = array(); |
|
| 297 | 297 | |
| 298 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 298 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
| 299 | 299 | |
| 300 | - $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
| 300 | + $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
| 301 | 301 | |
| 302 | - if (empty($columns)) { |
|
| 303 | - array_push($results['fail'], 'Empty CSV table'); |
|
| 304 | - return ($results); |
|
| 305 | - } |
|
| 302 | + if (empty($columns)) { |
|
| 303 | + array_push($results['fail'], 'Empty CSV table'); |
|
| 304 | + return ($results); |
|
| 305 | + } |
|
| 306 | 306 | |
| 307 | - $iRow = 1; |
|
| 307 | + $iRow = 1; |
|
| 308 | 308 | |
| 309 | - while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 310 | - if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
| 311 | - || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
| 312 | - continue; |
|
| 313 | - } |
|
| 309 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
| 310 | + if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
| 311 | + || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
| 312 | + continue; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | - $curSchedule = ""; |
|
| 316 | - $mode = ""; |
|
| 315 | + $curSchedule = ""; |
|
| 316 | + $mode = ""; |
|
| 317 | 317 | |
| 318 | - $failCount = sizeof($results['fail']); |
|
| 318 | + $failCount = sizeof($results['fail']); |
|
| 319 | 319 | |
| 320 | - if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
| 321 | - if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
| 322 | - $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
| 323 | - $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
| 324 | - } else { |
|
| 325 | - array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
| 326 | - } |
|
| 327 | - } else { |
|
| 328 | - array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
| 329 | - } |
|
| 320 | + if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
| 321 | + if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
| 322 | + $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
| 323 | + $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
| 324 | + } else { |
|
| 325 | + array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
| 326 | + } |
|
| 327 | + } else { |
|
| 328 | + array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
| 332 | - if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
| 333 | - $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
| 334 | - } else { |
|
| 335 | - array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
| 336 | - } |
|
| 337 | - } |
|
| 331 | + if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
| 332 | + if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
| 333 | + $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
| 334 | + } else { |
|
| 335 | + array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | - if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
| 340 | - if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
| 341 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
| 342 | - if ($mode=='daily') { |
|
| 343 | - $curSchedule = trim($curSchedule,','); |
|
| 344 | - $curSchedule.='}'; |
|
| 345 | - } |
|
| 346 | - } else { |
|
| 347 | - array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
| 348 | - } |
|
| 349 | - } |
|
| 339 | + if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
| 340 | + if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
| 341 | + $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
| 342 | + if ($mode=='daily') { |
|
| 343 | + $curSchedule = trim($curSchedule,','); |
|
| 344 | + $curSchedule.='}'; |
|
| 345 | + } |
|
| 346 | + } else { |
|
| 347 | + array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
| 348 | + } |
|
| 349 | + } |
|
| 350 | 350 | |
| 351 | - if ($mode!='daily') { |
|
| 352 | - switch ($mode) { |
|
| 353 | - case 'weekly': |
|
| 354 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 355 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 356 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
| 357 | - } else { |
|
| 358 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
| 359 | - } |
|
| 360 | - } else { |
|
| 361 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
| 362 | - } |
|
| 363 | - break; |
|
| 364 | - case 'monthly': |
|
| 365 | - $monthlyMode = ""; |
|
| 366 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 367 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 368 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
| 369 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
| 370 | - } else { |
|
| 371 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
| 372 | - } |
|
| 373 | - } else { |
|
| 374 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
| 375 | - } |
|
| 351 | + if ($mode!='daily') { |
|
| 352 | + switch ($mode) { |
|
| 353 | + case 'weekly': |
|
| 354 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 355 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
| 356 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
| 357 | + } else { |
|
| 358 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
| 359 | + } |
|
| 360 | + } else { |
|
| 361 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
| 362 | + } |
|
| 363 | + break; |
|
| 364 | + case 'monthly': |
|
| 365 | + $monthlyMode = ""; |
|
| 366 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 367 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
| 368 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
| 369 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
| 370 | + } else { |
|
| 371 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
| 372 | + } |
|
| 373 | + } else { |
|
| 374 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
| 375 | + } |
|
| 376 | 376 | |
| 377 | - if ($monthlyMode!="") { |
|
| 378 | - switch ($monthlyMode) { |
|
| 379 | - case 'dates': |
|
| 380 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 381 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 382 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
| 383 | - } else { |
|
| 384 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
| 385 | - } |
|
| 386 | - } |
|
| 387 | - break; |
|
| 388 | - case 'nth': |
|
| 389 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 390 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 391 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
| 392 | - } else { |
|
| 393 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
| 394 | - } |
|
| 395 | - } else { |
|
| 396 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
| 397 | - } |
|
| 377 | + if ($monthlyMode!="") { |
|
| 378 | + switch ($monthlyMode) { |
|
| 379 | + case 'dates': |
|
| 380 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 381 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
| 382 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
| 383 | + } else { |
|
| 384 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
| 385 | + } |
|
| 386 | + } |
|
| 387 | + break; |
|
| 388 | + case 'nth': |
|
| 389 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 390 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
| 391 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
| 392 | + } else { |
|
| 393 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
| 394 | + } |
|
| 395 | + } else { |
|
| 396 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
| 397 | + } |
|
| 398 | 398 | |
| 399 | - if ($curSchedule!="") { |
|
| 400 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 401 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 402 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
| 403 | - } else { |
|
| 404 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
| 405 | - } |
|
| 406 | - } else { |
|
| 407 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - break; |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - break; |
|
| 414 | - default: |
|
| 415 | - $curSchedule = ""; |
|
| 416 | - break; |
|
| 417 | - } |
|
| 418 | - } |
|
| 399 | + if ($curSchedule!="") { |
|
| 400 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 401 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
| 402 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
| 403 | + } else { |
|
| 404 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
| 405 | + } |
|
| 406 | + } else { |
|
| 407 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + break; |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + break; |
|
| 414 | + default: |
|
| 415 | + $curSchedule = ""; |
|
| 416 | + break; |
|
| 417 | + } |
|
| 418 | + } |
|
| 419 | 419 | |
| 420 | - if (sizeof($results['fail'])>$failCount) { |
|
| 421 | - $curSchedule = ""; |
|
| 422 | - } |
|
| 420 | + if (sizeof($results['fail'])>$failCount) { |
|
| 421 | + $curSchedule = ""; |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | - if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
| 425 | - $iRow++; |
|
| 426 | - continue; |
|
| 427 | - } |
|
| 424 | + if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
| 425 | + $iRow++; |
|
| 426 | + continue; |
|
| 427 | + } |
|
| 428 | 428 | |
| 429 | - $curSchedule = strtolower($curSchedule); |
|
| 429 | + $curSchedule = strtolower($curSchedule); |
|
| 430 | 430 | |
| 431 | - $curSchedule = '[{'.$curSchedule.'}]'; |
|
| 431 | + $curSchedule = '[{'.$curSchedule.'}]'; |
|
| 432 | 432 | |
| 433 | - $oSchedule = json_decode($curSchedule,TRUE); |
|
| 433 | + $oSchedule = json_decode($curSchedule,TRUE); |
|
| 434 | 434 | |
| 435 | - $parametersArray = array(); |
|
| 435 | + $parametersArray = array(); |
|
| 436 | 436 | |
| 437 | - foreach ($addressBookFields as $addressBookField) { |
|
| 438 | - if (isset($locationsFieldsMapping[$addressBookField])) { |
|
| 439 | - $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
| 440 | - } |
|
| 441 | - } |
|
| 437 | + foreach ($addressBookFields as $addressBookField) { |
|
| 438 | + if (isset($locationsFieldsMapping[$addressBookField])) { |
|
| 439 | + $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
| 440 | + } |
|
| 441 | + } |
|
| 442 | 442 | |
| 443 | - $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
| 443 | + $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
| 444 | 444 | |
| 445 | - $abContacts = new AddressBookLocation(); |
|
| 445 | + $abContacts = new AddressBookLocation(); |
|
| 446 | 446 | |
| 447 | - $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
| 447 | + $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
| 448 | 448 | |
| 449 | - array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
| 450 | - } |
|
| 449 | + array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
| 450 | + } |
|
| 451 | 451 | |
| 452 | - return $results; |
|
| 453 | - } |
|
| 452 | + return $results; |
|
| 453 | + } |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | \ No newline at end of file |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | $isValid = TRUE; |
| 205 | 205 | |
| 206 | - for ($i=0; $i<sizeof($weekdays); $i++) { |
|
| 206 | + for ($i = 0; $i<sizeof($weekdays); $i++) { |
|
| 207 | 207 | if (is_numeric($weekdays[$i])) { |
| 208 | 208 | $wday = intval($weekdays[$i]); |
| 209 | 209 | if ($wday<1 || $wday>7) { |
@@ -238,10 +238,10 @@ discard block |
||
| 238 | 238 | |
| 239 | 239 | $isValid = TRUE; |
| 240 | 240 | |
| 241 | - for ($i=0; $i<sizeof($monthlyDates); $i++) { |
|
| 241 | + for ($i = 0; $i<sizeof($monthlyDates); $i++) { |
|
| 242 | 242 | if (is_numeric($monthlyDates[$i])) { |
| 243 | 243 | $mday = intval($monthlyDates[$i]); |
| 244 | - if ($mday <1 || $mday > 31) { |
|
| 244 | + if ($mday<1 || $mday>31) { |
|
| 245 | 245 | $isValid = FALSE; |
| 246 | 246 | } |
| 247 | 247 | } else { |
@@ -338,10 +338,10 @@ discard block |
||
| 338 | 338 | |
| 339 | 339 | if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
| 340 | 340 | if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
| 341 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
| 341 | + $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
| 342 | 342 | if ($mode=='daily') { |
| 343 | - $curSchedule = trim($curSchedule,','); |
|
| 344 | - $curSchedule.='}'; |
|
| 343 | + $curSchedule = trim($curSchedule, ','); |
|
| 344 | + $curSchedule .= '}'; |
|
| 345 | 345 | } |
| 346 | 346 | } else { |
| 347 | 347 | array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | |
| 431 | 431 | $curSchedule = '[{'.$curSchedule.'}]'; |
| 432 | 432 | |
| 433 | - $oSchedule = json_decode($curSchedule,TRUE); |
|
| 433 | + $oSchedule = json_decode($curSchedule, TRUE); |
|
| 434 | 434 | |
| 435 | 435 | $parametersArray = array(); |
| 436 | 436 | |
@@ -9,410 +9,410 @@ |
||
| 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(); |
|
| 79 | + if (isset($params['addresses'])) { |
|
| 80 | + $addresses = array(); |
|
| 81 | 81 | |
| 82 | - foreach ($params['addresses'] as $address) { |
|
| 83 | - $addresses[] = Address::fromArray($address); |
|
| 84 | - } |
|
| 82 | + foreach ($params['addresses'] as $address) { |
|
| 83 | + $addresses[] = Address::fromArray($address); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - $route->addresses = $addresses; |
|
| 87 | - } |
|
| 86 | + $route->addresses = $addresses; |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - $route->links = Common::getValue($params, 'links', array()); |
|
| 90 | - $route->directions = Common::getValue($params, 'directions', array()); |
|
| 91 | - $route->path = Common::getValue($params, 'path', array()); |
|
| 92 | - $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
| 89 | + $route->links = Common::getValue($params, 'links', array()); |
|
| 90 | + $route->directions = Common::getValue($params, 'directions', array()); |
|
| 91 | + $route->path = Common::getValue($params, 'path', array()); |
|
| 92 | + $route->tracking_history = Common::getValue($params, 'tracking_history', array()); |
|
| 93 | 93 | |
| 94 | - return $route; |
|
| 95 | - } |
|
| 94 | + return $route; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - public static function getRoutes($params = null) |
|
| 98 | - { |
|
| 99 | - $allQueryFields = array('route_id', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset'); |
|
| 97 | + public static function getRoutes($params = null) |
|
| 98 | + { |
|
| 99 | + $allQueryFields = array('route_id', 'route_path_output', 'query', 'directions', 'device_tracking_history', 'limit', 'offset'); |
|
| 100 | 100 | |
| 101 | - $result = Route4Me::makeRequst(array( |
|
| 102 | - 'url' => Endpoint::ROUTE_V4, |
|
| 103 | - 'method' => 'GET', |
|
| 104 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 105 | - )); |
|
| 101 | + $result = Route4Me::makeRequst(array( |
|
| 102 | + 'url' => Endpoint::ROUTE_V4, |
|
| 103 | + 'method' => 'GET', |
|
| 104 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 105 | + )); |
|
| 106 | 106 | |
| 107 | - if (isset($params['route_id'])) { |
|
| 108 | - return Route::fromArray($result); |
|
| 109 | - } else { |
|
| 110 | - $routes = array(); |
|
| 111 | - foreach ($result as $route) { |
|
| 112 | - $routes[] = Route::fromArray($route); |
|
| 113 | - } |
|
| 114 | - return $routes; |
|
| 115 | - } |
|
| 116 | - } |
|
| 107 | + if (isset($params['route_id'])) { |
|
| 108 | + return Route::fromArray($result); |
|
| 109 | + } else { |
|
| 110 | + $routes = array(); |
|
| 111 | + foreach ($result as $route) { |
|
| 112 | + $routes[] = Route::fromArray($route); |
|
| 113 | + } |
|
| 114 | + return $routes; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - public function getRoutePoints($params) |
|
| 119 | - { |
|
| 120 | - $allQueryFields = array('route_id', 'route_path_output', 'compress_path_points', 'directions'); |
|
| 118 | + public function getRoutePoints($params) |
|
| 119 | + { |
|
| 120 | + $allQueryFields = array('route_id', 'route_path_output', 'compress_path_points', 'directions'); |
|
| 121 | 121 | |
| 122 | - $result = Route4Me::makeRequst(array( |
|
| 123 | - 'url' => Endpoint::ROUTE_V4, |
|
| 124 | - 'method' => 'GET', |
|
| 125 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 126 | - )); |
|
| 122 | + $result = Route4Me::makeRequst(array( |
|
| 123 | + 'url' => Endpoint::ROUTE_V4, |
|
| 124 | + 'method' => 'GET', |
|
| 125 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 126 | + )); |
|
| 127 | 127 | |
| 128 | - return $result; |
|
| 129 | - } |
|
| 128 | + return $result; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - public function duplicateRoute($route_id) |
|
| 132 | - { |
|
| 133 | - $result = Route4Me::makeRequst(array( |
|
| 134 | - 'url' => Endpoint::ROUTE_DUPLICATE, |
|
| 135 | - 'method' => 'GET', |
|
| 136 | - 'query' => array( |
|
| 137 | - 'route_id' => $route_id, |
|
| 138 | - 'to' => 'none', |
|
| 139 | - ) |
|
| 140 | - )); |
|
| 131 | + public function duplicateRoute($route_id) |
|
| 132 | + { |
|
| 133 | + $result = Route4Me::makeRequst(array( |
|
| 134 | + 'url' => Endpoint::ROUTE_DUPLICATE, |
|
| 135 | + 'method' => 'GET', |
|
| 136 | + 'query' => array( |
|
| 137 | + 'route_id' => $route_id, |
|
| 138 | + 'to' => 'none', |
|
| 139 | + ) |
|
| 140 | + )); |
|
| 141 | 141 | |
| 142 | - return $result; |
|
| 143 | - } |
|
| 142 | + return $result; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - public function resequenceRoute($params) |
|
| 146 | - { |
|
| 147 | - $allQueryFields = array('route_id', 'route_destination_id'); |
|
| 148 | - $allBodyFields = array('addresses'); |
|
| 145 | + public function resequenceRoute($params) |
|
| 146 | + { |
|
| 147 | + $allQueryFields = array('route_id', 'route_destination_id'); |
|
| 148 | + $allBodyFields = array('addresses'); |
|
| 149 | 149 | |
| 150 | - $result = Route4Me::makeRequst(array( |
|
| 151 | - 'url' => Endpoint::ROUTE_V4, |
|
| 152 | - 'method' => 'PUT', |
|
| 153 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 154 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 155 | - )); |
|
| 150 | + $result = Route4Me::makeRequst(array( |
|
| 151 | + 'url' => Endpoint::ROUTE_V4, |
|
| 152 | + 'method' => 'PUT', |
|
| 153 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 154 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 155 | + )); |
|
| 156 | 156 | |
| 157 | - return $result; |
|
| 158 | - } |
|
| 157 | + return $result; |
|
| 158 | + } |
|
| 159 | 159 | |
| 160 | - public function resequenceAllAddresses($params) |
|
| 161 | - { |
|
| 162 | - $allQueryFields = array('route_id', 'disable_optimization', 'optimize'); |
|
| 160 | + public function resequenceAllAddresses($params) |
|
| 161 | + { |
|
| 162 | + $allQueryFields = array('route_id', 'disable_optimization', 'optimize'); |
|
| 163 | 163 | |
| 164 | - $result = Route4Me::makeRequst(array( |
|
| 165 | - 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
| 166 | - 'method' => 'GET', |
|
| 167 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 168 | - )); |
|
| 164 | + $result = Route4Me::makeRequst(array( |
|
| 165 | + 'url' => Endpoint::REOPTIMIZE_V3_2, |
|
| 166 | + 'method' => 'GET', |
|
| 167 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 168 | + )); |
|
| 169 | 169 | |
| 170 | - return $result; |
|
| 171 | - } |
|
| 170 | + return $result; |
|
| 171 | + } |
|
| 172 | 172 | |
| 173 | - public function mergeRoutes($params) |
|
| 174 | - { |
|
| 175 | - $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
| 173 | + public function mergeRoutes($params) |
|
| 174 | + { |
|
| 175 | + $allBodyFields = array('route_ids', 'depot_address', 'remove_origin', 'depot_lat', 'depot_lng'); |
|
| 176 | 176 | |
| 177 | - $result = Route4Me::makeRequst(array( |
|
| 178 | - 'url' => Endpoint::ROUTES_MERGE, |
|
| 179 | - 'method' => 'POST', |
|
| 180 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 181 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 182 | - )); |
|
| 177 | + $result = Route4Me::makeRequst(array( |
|
| 178 | + 'url' => Endpoint::ROUTES_MERGE, |
|
| 179 | + 'method' => 'POST', |
|
| 180 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 181 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 182 | + )); |
|
| 183 | 183 | |
| 184 | - return $result; |
|
| 185 | - } |
|
| 184 | + return $result; |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - public function shareRoute($params) |
|
| 188 | - { |
|
| 189 | - $allQueryFields = array('route_id', 'response_format'); |
|
| 190 | - $allBodyFields = array('recipient_email'); |
|
| 187 | + public function shareRoute($params) |
|
| 188 | + { |
|
| 189 | + $allQueryFields = array('route_id', 'response_format'); |
|
| 190 | + $allBodyFields = array('recipient_email'); |
|
| 191 | 191 | |
| 192 | - $result = Route4Me::makeRequst(array( |
|
| 193 | - 'url' => Endpoint::ROUTE_SHARE, |
|
| 194 | - 'method' => 'POST', |
|
| 195 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 196 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 197 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 198 | - )); |
|
| 192 | + $result = Route4Me::makeRequst(array( |
|
| 193 | + 'url' => Endpoint::ROUTE_SHARE, |
|
| 194 | + 'method' => 'POST', |
|
| 195 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 196 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 197 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
| 198 | + )); |
|
| 199 | 199 | |
| 200 | - return $result; |
|
| 201 | - } |
|
| 200 | + return $result; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - // Returns random route_id from existing routes between $offset and $offset+$limit |
|
| 204 | - public function getRandomRouteId($offset, $limit) |
|
| 205 | - { |
|
| 206 | - $params = array( |
|
| 207 | - 'offset' => !is_null($offset) ? $offset : 0, |
|
| 208 | - 'limit' => !is_null($limit) ? $limit : 30 |
|
| 209 | - ); |
|
| 203 | + // Returns random route_id from existing routes between $offset and $offset+$limit |
|
| 204 | + public function getRandomRouteId($offset, $limit) |
|
| 205 | + { |
|
| 206 | + $params = array( |
|
| 207 | + 'offset' => !is_null($offset) ? $offset : 0, |
|
| 208 | + 'limit' => !is_null($limit) ? $limit : 30 |
|
| 209 | + ); |
|
| 210 | 210 | |
| 211 | - $routes = $this->getRoutes($params); |
|
| 211 | + $routes = $this->getRoutes($params); |
|
| 212 | 212 | |
| 213 | - if (is_null($routes) || sizeof($routes)<1) { |
|
| 214 | - echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
| 215 | - return null; |
|
| 216 | - } |
|
| 213 | + if (is_null($routes) || sizeof($routes)<1) { |
|
| 214 | + echo "<br> There are no routes in the account. Please, create the routes first. <br>"; |
|
| 215 | + return null; |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - $randomIndex = rand(0, sizeof($routes) - 1); |
|
| 218 | + $randomIndex = rand(0, sizeof($routes) - 1); |
|
| 219 | 219 | |
| 220 | - return $routes[$randomIndex]->route_id; |
|
| 221 | - } |
|
| 220 | + return $routes[$randomIndex]->route_id; |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - public function update() |
|
| 224 | - { |
|
| 225 | - $route = Route4Me::makeRequst(array( |
|
| 226 | - 'url' => Endpoint::ROUTE_V4, |
|
| 227 | - 'method' => 'PUT', |
|
| 228 | - 'query' => array( |
|
| 229 | - 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
| 230 | - ), |
|
| 231 | - 'body' => array( |
|
| 232 | - 'parameters' => $this->parameters, |
|
| 233 | - ), |
|
| 234 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 235 | - )); |
|
| 223 | + public function update() |
|
| 224 | + { |
|
| 225 | + $route = Route4Me::makeRequst(array( |
|
| 226 | + 'url' => Endpoint::ROUTE_V4, |
|
| 227 | + 'method' => 'PUT', |
|
| 228 | + 'query' => array( |
|
| 229 | + 'route_id' => isset($this->route_id) ? $this->route_id : null |
|
| 230 | + ), |
|
| 231 | + 'body' => array( |
|
| 232 | + 'parameters' => $this->parameters, |
|
| 233 | + ), |
|
| 234 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 235 | + )); |
|
| 236 | 236 | |
| 237 | - return Route::fromArray($route); |
|
| 238 | - } |
|
| 237 | + return Route::fromArray($route); |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - public function updateAddress($address = null) |
|
| 241 | - { |
|
| 242 | - $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
| 243 | - : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
| 240 | + public function updateAddress($address = null) |
|
| 241 | + { |
|
| 242 | + $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) |
|
| 243 | + : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters)); |
|
| 244 | 244 | |
| 245 | - $result = Route4Me::makeRequst(array( |
|
| 246 | - 'url' => Endpoint::ADDRESS_V4, |
|
| 247 | - 'method' => 'PUT', |
|
| 248 | - 'query' => array( |
|
| 249 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 250 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 251 | - ), |
|
| 252 | - 'body' => $body, |
|
| 253 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 254 | - )); |
|
| 245 | + $result = Route4Me::makeRequst(array( |
|
| 246 | + 'url' => Endpoint::ADDRESS_V4, |
|
| 247 | + 'method' => 'PUT', |
|
| 248 | + 'query' => array( |
|
| 249 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 250 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 251 | + ), |
|
| 252 | + 'body' => $body, |
|
| 253 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 254 | + )); |
|
| 255 | 255 | |
| 256 | - return $result; |
|
| 257 | - } |
|
| 256 | + return $result; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - public function updateRouteAddress() |
|
| 260 | - { |
|
| 261 | - $result = Route4Me::makeRequst(array( |
|
| 262 | - 'url' => Endpoint::ADDRESS_V4, |
|
| 263 | - 'method' => 'PUT', |
|
| 264 | - 'query' => array( |
|
| 265 | - 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 266 | - 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 267 | - ), |
|
| 268 | - 'body' => array( |
|
| 269 | - "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
| 270 | - "addresses" => isset($this->addresses) ? $this->addresses : null |
|
| 271 | - ), |
|
| 272 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 273 | - )); |
|
| 259 | + public function updateRouteAddress() |
|
| 260 | + { |
|
| 261 | + $result = Route4Me::makeRequst(array( |
|
| 262 | + 'url' => Endpoint::ADDRESS_V4, |
|
| 263 | + 'method' => 'PUT', |
|
| 264 | + 'query' => array( |
|
| 265 | + 'route_id' => isset($this->route_id) ? $this->route_id : null, |
|
| 266 | + 'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null, |
|
| 267 | + ), |
|
| 268 | + 'body' => array( |
|
| 269 | + "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null, |
|
| 270 | + "addresses" => isset($this->addresses) ? $this->addresses : null |
|
| 271 | + ), |
|
| 272 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 273 | + )); |
|
| 274 | 274 | |
| 275 | - return $result; |
|
| 276 | - } |
|
| 275 | + return $result; |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - public function addAddresses($params) |
|
| 279 | - { |
|
| 280 | - $allQueryFields = array('route_id'); |
|
| 281 | - $allBodyFields = array('addresses'); |
|
| 278 | + public function addAddresses($params) |
|
| 279 | + { |
|
| 280 | + $allQueryFields = array('route_id'); |
|
| 281 | + $allBodyFields = array('addresses'); |
|
| 282 | 282 | |
| 283 | - $route = Route4Me::makeRequst(array( |
|
| 284 | - 'url' => Endpoint::ROUTE_V4, |
|
| 285 | - 'method' => 'PUT', |
|
| 286 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 287 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 288 | - 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 289 | - )); |
|
| 283 | + $route = Route4Me::makeRequst(array( |
|
| 284 | + 'url' => Endpoint::ROUTE_V4, |
|
| 285 | + 'method' => 'PUT', |
|
| 286 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 287 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 288 | + 'HTTPHEADER' => isset($this->httpheaders) ? $this->httpheaders : null, |
|
| 289 | + )); |
|
| 290 | 290 | |
| 291 | - return Route::fromArray($route); |
|
| 292 | - } |
|
| 291 | + return Route::fromArray($route); |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - public function insertAddressOptimalPosition(array $params) |
|
| 295 | - { |
|
| 296 | - $allQueryFields = array('route_id'); |
|
| 297 | - $allBodyFields = array('addresses', 'optimal_position'); |
|
| 294 | + public function insertAddressOptimalPosition(array $params) |
|
| 295 | + { |
|
| 296 | + $allQueryFields = array('route_id'); |
|
| 297 | + $allBodyFields = array('addresses', 'optimal_position'); |
|
| 298 | 298 | |
| 299 | - $route = Route4Me::makeRequst(array( |
|
| 300 | - 'url' => Endpoint::ROUTE_V4, |
|
| 301 | - 'method' => 'PUT', |
|
| 302 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 303 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 304 | - )); |
|
| 299 | + $route = Route4Me::makeRequst(array( |
|
| 300 | + 'url' => Endpoint::ROUTE_V4, |
|
| 301 | + 'method' => 'PUT', |
|
| 302 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 303 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
| 304 | + )); |
|
| 305 | 305 | |
| 306 | - return Route::fromArray($route); |
|
| 307 | - } |
|
| 306 | + return Route::fromArray($route); |
|
| 307 | + } |
|
| 308 | 308 | |
| 309 | - public function addNoteFile($params) |
|
| 310 | - { |
|
| 311 | - $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
| 312 | - $rpath = realpath($fname); |
|
| 309 | + public function addNoteFile($params) |
|
| 310 | + { |
|
| 311 | + $fname = isset($params['strFilename']) ? $params['strFilename'] : null; |
|
| 312 | + $rpath = realpath($fname); |
|
| 313 | 313 | |
| 314 | - $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
| 315 | - $allBodyFields = array('strUpdateType', 'strFilename', 'strNoteContents'); |
|
| 314 | + $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
| 315 | + $allBodyFields = array('strUpdateType', 'strFilename', 'strNoteContents'); |
|
| 316 | 316 | |
| 317 | - $result = Route4Me::makeRequst(array( |
|
| 318 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 319 | - 'method' => 'POST', |
|
| 320 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 321 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 322 | - 'FILE' => $rpath, |
|
| 323 | - 'HTTPHEADER' => array( |
|
| 324 | - 'Content-Type: application/x-www-form-urlencoded' |
|
| 325 | - ) |
|
| 326 | - )); |
|
| 317 | + $result = Route4Me::makeRequst(array( |
|
| 318 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
| 319 | + 'method' => 'POST', |
|
| 320 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
| 321 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
| 322 | + 'FILE' => $rpath, |
|
| 323 | + 'HTTPHEADER' => array( |
|
| 324 | + 'Content-Type: application/x-www-form-urlencoded' |
|
| 325 | + ) |
|
| 326 | + )); |
|
| 327 | 327 | |
| 328 | - return $result; |
|
| 329 | - } |
|
| 328 | + return $result; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - public function deleteRoutes($route_id) |
|
| 332 | - { |
|
| 333 | - $result = Route4Me::makeRequst(array( |
|
| 334 | - 'url' => Endpoint::ROUTES_DELETE, |
|
| 335 | - 'method' => 'DELETE', |
|
| 336 | - 'query' => array( |
|
| 337 | - 'route_id' => $route_id, |
|
| 338 | - ) |
|
| 339 | - )); |
|
| 331 | + public function deleteRoutes($route_id) |
|
| 332 | + { |
|
| 333 | + $result = Route4Me::makeRequst(array( |
|
| 334 | + 'url' => Endpoint::ROUTES_DELETE, |
|
| 335 | + 'method' => 'DELETE', |
|
| 336 | + 'query' => array( |
|
| 337 | + 'route_id' => $route_id, |
|
| 338 | + ) |
|
| 339 | + )); |
|
| 340 | 340 | |
| 341 | - return $result; |
|
| 342 | - } |
|
| 341 | + return $result; |
|
| 342 | + } |
|
| 343 | 343 | |
| 344 | - public function GetAddressesFromRoute($route_id) |
|
| 345 | - { |
|
| 346 | - $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
| 344 | + public function GetAddressesFromRoute($route_id) |
|
| 345 | + { |
|
| 346 | + $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
| 347 | 347 | |
| 348 | - if (isset($route1)) { |
|
| 349 | - return $route1->addresses; |
|
| 350 | - } else { |
|
| 351 | - return null; |
|
| 352 | - } |
|
| 353 | - } |
|
| 348 | + if (isset($route1)) { |
|
| 349 | + return $route1->addresses; |
|
| 350 | + } else { |
|
| 351 | + return null; |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | - public function GetRandomAddressFromRoute($route_id) |
|
| 356 | - { |
|
| 357 | - $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
| 355 | + public function GetRandomAddressFromRoute($route_id) |
|
| 356 | + { |
|
| 357 | + $route1 = Route::getRoutes(array('route_id' => $route_id)); |
|
| 358 | 358 | |
| 359 | - if (isset($route1)) { |
|
| 360 | - $addresses = $route1->addresses; |
|
| 359 | + if (isset($route1)) { |
|
| 360 | + $addresses = $route1->addresses; |
|
| 361 | 361 | |
| 362 | - $rnd = rand(0, sizeof($addresses) - 1); |
|
| 362 | + $rnd = rand(0, sizeof($addresses) - 1); |
|
| 363 | 363 | |
| 364 | - return $addresses[$rnd]; |
|
| 365 | - } else { |
|
| 366 | - return null; |
|
| 367 | - } |
|
| 368 | - } |
|
| 364 | + return $addresses[$rnd]; |
|
| 365 | + } else { |
|
| 366 | + return null; |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | 369 | |
| 370 | - public function getRouteId() |
|
| 371 | - { |
|
| 372 | - return $this->route_id; |
|
| 373 | - } |
|
| 370 | + public function getRouteId() |
|
| 371 | + { |
|
| 372 | + return $this->route_id; |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | - public function getOptimizationId() |
|
| 376 | - { |
|
| 377 | - return $this->optimization_problem_id; |
|
| 378 | - } |
|
| 375 | + public function getOptimizationId() |
|
| 376 | + { |
|
| 377 | + return $this->optimization_problem_id; |
|
| 378 | + } |
|
| 379 | 379 | |
| 380 | - public function GetLastLocation(array $params) |
|
| 381 | - { |
|
| 382 | - $allQueryFields = array('route_id', 'device_tracking_history'); |
|
| 380 | + public function GetLastLocation(array $params) |
|
| 381 | + { |
|
| 382 | + $allQueryFields = array('route_id', 'device_tracking_history'); |
|
| 383 | 383 | |
| 384 | - $route = Route4Me::makeRequst(array( |
|
| 385 | - 'url' => Endpoint::ROUTE_V4, |
|
| 386 | - 'method' => 'GET', |
|
| 387 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 388 | - )); |
|
| 384 | + $route = Route4Me::makeRequst(array( |
|
| 385 | + 'url' => Endpoint::ROUTE_V4, |
|
| 386 | + 'method' => 'GET', |
|
| 387 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 388 | + )); |
|
| 389 | 389 | |
| 390 | - return Route::fromArray($route); |
|
| 391 | - } |
|
| 390 | + return Route::fromArray($route); |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - public function GetTrackingHistoryFromTimeRange(array $params) |
|
| 394 | - { |
|
| 395 | - $allQueryFields = array('route_id', 'format', 'time_period', 'start_date', 'end_date'); |
|
| 393 | + public function GetTrackingHistoryFromTimeRange(array $params) |
|
| 394 | + { |
|
| 395 | + $allQueryFields = array('route_id', 'format', 'time_period', 'start_date', 'end_date'); |
|
| 396 | 396 | |
| 397 | - $route = Route4Me::makeRequst(array( |
|
| 398 | - 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
| 399 | - 'method' => 'GET', |
|
| 400 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 401 | - )); |
|
| 397 | + $route = Route4Me::makeRequst(array( |
|
| 398 | + 'url' => Endpoint::GET_DEVICE_LOCATION, |
|
| 399 | + 'method' => 'GET', |
|
| 400 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 401 | + )); |
|
| 402 | 402 | |
| 403 | - return $route; |
|
| 404 | - } |
|
| 403 | + return $route; |
|
| 404 | + } |
|
| 405 | 405 | |
| 406 | - public function GetAssetTracking(array $params) |
|
| 407 | - { |
|
| 408 | - $allQueryFields = array('tracking'); |
|
| 406 | + public function GetAssetTracking(array $params) |
|
| 407 | + { |
|
| 408 | + $allQueryFields = array('tracking'); |
|
| 409 | 409 | |
| 410 | - $route = Route4Me::makeRequst(array( |
|
| 411 | - 'url' => Endpoint::STATUS_V4, |
|
| 412 | - 'method' => 'GET', |
|
| 413 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 414 | - )); |
|
| 410 | + $route = Route4Me::makeRequst(array( |
|
| 411 | + 'url' => Endpoint::STATUS_V4, |
|
| 412 | + 'method' => 'GET', |
|
| 413 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
| 414 | + )); |
|
| 415 | 415 | |
| 416 | - return $route; |
|
| 417 | - } |
|
| 416 | + return $route; |
|
| 417 | + } |
|
| 418 | 418 | } |
@@ -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) || !isset($vehicles['data']) || sizeof($vehicles['data'])<1) { |
|
| 102 | - return null; |
|
| 103 | - } |
|
| 101 | + if (is_null($vehicles) || !isset($vehicles['data']) || sizeof($vehicles['data'])<1) { |
|
| 102 | + return null; |
|
| 103 | + } |
|
| 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,13 +59,13 @@ 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(); |
|
| 68 | + $vehicle = new Vehicle(); |
|
| 69 | 69 | foreach ($params as $key => $value) { |
| 70 | 70 | if (property_exists($vehicle, $key)) { |
| 71 | 71 | $vehicle->{$key} = $value; |
@@ -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, |
@@ -5,74 +5,74 @@ |
||
| 5 | 5 | |
| 6 | 6 | class RouteParameters extends Common |
| 7 | 7 | { |
| 8 | - public $is_upload; |
|
| 9 | - public $rt; |
|
| 10 | - public $route_name; |
|
| 11 | - public $route_date; |
|
| 12 | - public $route_time; |
|
| 13 | - public $shared_publicly; |
|
| 14 | - public $disable_optimization; |
|
| 15 | - public $optimize; |
|
| 16 | - public $lock_last; |
|
| 17 | - public $vehicle_capacity; |
|
| 18 | - public $vehicle_max_distance_mi; |
|
| 19 | - public $distance_unit; |
|
| 20 | - public $travel_mode; |
|
| 21 | - public $avoid; |
|
| 22 | - public $vehicle_id; |
|
| 23 | - public $dev_lat; |
|
| 24 | - public $dev_lng; |
|
| 25 | - public $route_max_duration; |
|
| 26 | - public $route_email; |
|
| 27 | - public $route_type = "api"; |
|
| 28 | - public $store_route = true; |
|
| 29 | - public $metric; |
|
| 30 | - public $algorithm_type; |
|
| 31 | - public $member_id; |
|
| 32 | - public $ip; |
|
| 33 | - public $dm; |
|
| 34 | - public $dirm; |
|
| 35 | - public $parts; |
|
| 36 | - public $device_id; |
|
| 37 | - public $device_type; |
|
| 38 | - public $has_trailer; |
|
| 39 | - public $trailer_weight_t; |
|
| 40 | - public $limited_weight_t; |
|
| 41 | - public $weight_per_axle_t; |
|
| 42 | - public $truck_height_meters; |
|
| 43 | - public $truck_width_meters; |
|
| 44 | - public $truck_length_meters; |
|
| 45 | - public $truck_hazardous_goods; |
|
| 8 | + public $is_upload; |
|
| 9 | + public $rt; |
|
| 10 | + public $route_name; |
|
| 11 | + public $route_date; |
|
| 12 | + public $route_time; |
|
| 13 | + public $shared_publicly; |
|
| 14 | + public $disable_optimization; |
|
| 15 | + public $optimize; |
|
| 16 | + public $lock_last; |
|
| 17 | + public $vehicle_capacity; |
|
| 18 | + public $vehicle_max_distance_mi; |
|
| 19 | + public $distance_unit; |
|
| 20 | + public $travel_mode; |
|
| 21 | + public $avoid; |
|
| 22 | + public $vehicle_id; |
|
| 23 | + public $dev_lat; |
|
| 24 | + public $dev_lng; |
|
| 25 | + public $route_max_duration; |
|
| 26 | + public $route_email; |
|
| 27 | + public $route_type = "api"; |
|
| 28 | + public $store_route = true; |
|
| 29 | + public $metric; |
|
| 30 | + public $algorithm_type; |
|
| 31 | + public $member_id; |
|
| 32 | + public $ip; |
|
| 33 | + public $dm; |
|
| 34 | + public $dirm; |
|
| 35 | + public $parts; |
|
| 36 | + public $device_id; |
|
| 37 | + public $device_type; |
|
| 38 | + public $has_trailer; |
|
| 39 | + public $trailer_weight_t; |
|
| 40 | + public $limited_weight_t; |
|
| 41 | + public $weight_per_axle_t; |
|
| 42 | + public $truck_height_meters; |
|
| 43 | + public $truck_width_meters; |
|
| 44 | + public $truck_length_meters; |
|
| 45 | + public $truck_hazardous_goods; |
|
| 46 | 46 | |
| 47 | - public $vehicle_max_cargo_weight; |
|
| 48 | - public $vehicle_max_cargo_volume; |
|
| 49 | - public $subtour_max_revenue; |
|
| 50 | - public $avoidance_zones; |
|
| 51 | - public $driver_id; |
|
| 52 | - public $parts_min; |
|
| 53 | - public $first_drive_then_wait_between_stops; |
|
| 54 | - public $truck_height; |
|
| 55 | - public $truck_width; |
|
| 56 | - public $truck_length; |
|
| 57 | - public $optimization_quality; |
|
| 58 | - public $override_addresses; |
|
| 59 | - public $max_tour_size; |
|
| 60 | - public $min_tour_size; |
|
| 61 | - public $uturn; |
|
| 62 | - public $leftturn; |
|
| 63 | - public $rightturn; |
|
| 47 | + public $vehicle_max_cargo_weight; |
|
| 48 | + public $vehicle_max_cargo_volume; |
|
| 49 | + public $subtour_max_revenue; |
|
| 50 | + public $avoidance_zones; |
|
| 51 | + public $driver_id; |
|
| 52 | + public $parts_min; |
|
| 53 | + public $first_drive_then_wait_between_stops; |
|
| 54 | + public $truck_height; |
|
| 55 | + public $truck_width; |
|
| 56 | + public $truck_length; |
|
| 57 | + public $optimization_quality; |
|
| 58 | + public $override_addresses; |
|
| 59 | + public $max_tour_size; |
|
| 60 | + public $min_tour_size; |
|
| 61 | + public $uturn; |
|
| 62 | + public $leftturn; |
|
| 63 | + public $rightturn; |
|
| 64 | 64 | |
| 65 | - public $optimized_callback_url; |
|
| 65 | + public $optimized_callback_url; |
|
| 66 | 66 | |
| 67 | - public static function fromArray(array $params) |
|
| 68 | - { |
|
| 69 | - $routeParams = new RouteParameters(); |
|
| 70 | - foreach ($params as $key => $value) { |
|
| 71 | - if (property_exists($routeParams, $key)) { |
|
| 72 | - $routeParams->{$key} = $value; |
|
| 73 | - } |
|
| 74 | - } |
|
| 67 | + public static function fromArray(array $params) |
|
| 68 | + { |
|
| 69 | + $routeParams = new RouteParameters(); |
|
| 70 | + foreach ($params as $key => $value) { |
|
| 71 | + if (property_exists($routeParams, $key)) { |
|
| 72 | + $routeParams->{$key} = $value; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - return $routeParams; |
|
| 77 | - } |
|
| 76 | + return $routeParams; |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -7,415 +7,415 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Route4Me |
| 9 | 9 | { |
| 10 | - static public $apiKey; |
|
| 11 | - static public $baseUrl = Endpoint::BASE_URL; |
|
| 10 | + static public $apiKey; |
|
| 11 | + static public $baseUrl = Endpoint::BASE_URL; |
|
| 12 | 12 | |
| 13 | - public static function setApiKey($apiKey) |
|
| 14 | - { |
|
| 15 | - self::$apiKey = $apiKey; |
|
| 16 | - } |
|
| 13 | + public static function setApiKey($apiKey) |
|
| 14 | + { |
|
| 15 | + self::$apiKey = $apiKey; |
|
| 16 | + } |
|
| 17 | 17 | |
| 18 | - public static function getApiKey() |
|
| 19 | - { |
|
| 20 | - return self::$apiKey; |
|
| 21 | - } |
|
| 18 | + public static function getApiKey() |
|
| 19 | + { |
|
| 20 | + return self::$apiKey; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - public static function setBaseUrl($baseUrl) |
|
| 24 | - { |
|
| 25 | - self::$baseUrl = $baseUrl; |
|
| 26 | - } |
|
| 23 | + public static function setBaseUrl($baseUrl) |
|
| 24 | + { |
|
| 25 | + self::$baseUrl = $baseUrl; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public static function getBaseUrl() |
|
| 29 | - { |
|
| 30 | - return self::$baseUrl; |
|
| 31 | - } |
|
| 28 | + public static function getBaseUrl() |
|
| 29 | + { |
|
| 30 | + return self::$baseUrl; |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public static function fileUploadRequest($options) { |
|
| 34 | - $query = isset($options['query']) ? array_filter($options['query']) : array(); |
|
| 33 | + public static function fileUploadRequest($options) { |
|
| 34 | + $query = isset($options['query']) ? array_filter($options['query']) : array(); |
|
| 35 | 35 | |
| 36 | - if (sizeof($query)==0) { |
|
| 37 | - return null; |
|
| 36 | + if (sizeof($query)==0) { |
|
| 37 | + return null; |
|
| 38 | 38 | |
| 39 | - } |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $body = isset($options['body']) ? array_filter($options['body']) : null; |
|
| 41 | + $body = isset($options['body']) ? array_filter($options['body']) : null; |
|
| 42 | 42 | |
| 43 | - $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
|
| 43 | + $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
|
| 44 | 44 | |
| 45 | - if ($fname=='') { |
|
| 46 | - return null; |
|
| 47 | - } |
|
| 45 | + if ($fname=='') { |
|
| 46 | + return null; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname); |
|
| 49 | + $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname); |
|
| 50 | 50 | |
| 51 | - $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(array('api_key' => self::getApiKey()), $query)); |
|
| 51 | + $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(array('api_key' => self::getApiKey()), $query)); |
|
| 52 | 52 | |
| 53 | - $ch = curl_init($url); |
|
| 53 | + $ch = curl_init($url); |
|
| 54 | 54 | |
| 55 | - $curlOpts = array( |
|
| 56 | - CURLOPT_POST => true, |
|
| 57 | - CURLOPT_RETURNTRANSFER => false, |
|
| 58 | - CURLOPT_TIMEOUT => 60, |
|
| 59 | - CURLOPT_FOLLOWLOCATION => true, |
|
| 60 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 61 | - CURLOPT_SSL_VERIFYPEER => FALSE |
|
| 62 | - ); |
|
| 55 | + $curlOpts = array( |
|
| 56 | + CURLOPT_POST => true, |
|
| 57 | + CURLOPT_RETURNTRANSFER => false, |
|
| 58 | + CURLOPT_TIMEOUT => 60, |
|
| 59 | + CURLOPT_FOLLOWLOCATION => true, |
|
| 60 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 61 | + CURLOPT_SSL_VERIFYPEER => FALSE |
|
| 62 | + ); |
|
| 63 | 63 | |
| 64 | - curl_setopt_array($ch, $curlOpts); |
|
| 64 | + curl_setopt_array($ch, $curlOpts); |
|
| 65 | 65 | |
| 66 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
| 66 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
| 67 | 67 | |
| 68 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
| 69 | - "Content-Type: multipart/form-data", |
|
| 70 | - 'Content-Disposition: form-data; name="strFilename"' |
|
| 71 | - )); |
|
| 72 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
| 73 | - curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); |
|
| 68 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
| 69 | + "Content-Type: multipart/form-data", |
|
| 70 | + 'Content-Disposition: form-data; name="strFilename"' |
|
| 71 | + )); |
|
| 72 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
| 73 | + curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); |
|
| 74 | 74 | |
| 75 | - $result = curl_exec($ch); |
|
| 75 | + $result = curl_exec($ch); |
|
| 76 | 76 | |
| 77 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 78 | - curl_close($ch); |
|
| 77 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 78 | + curl_close($ch); |
|
| 79 | 79 | |
| 80 | - $json = json_decode($result, true); |
|
| 80 | + $json = json_decode($result, true); |
|
| 81 | 81 | |
| 82 | - if (200==$code) { |
|
| 83 | - return $json; |
|
| 84 | - } elseif (isset($json['errors'])) { |
|
| 85 | - throw new ApiError(implode(', ', $json['errors'])); |
|
| 86 | - } else { |
|
| 87 | - throw new ApiError('Something wrong'); |
|
| 88 | - } |
|
| 89 | - } |
|
| 82 | + if (200==$code) { |
|
| 83 | + return $json; |
|
| 84 | + } elseif (isset($json['errors'])) { |
|
| 85 | + throw new ApiError(implode(', ', $json['errors'])); |
|
| 86 | + } else { |
|
| 87 | + throw new ApiError('Something wrong'); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | 90 | |
| 91 | - public static function makeRequst($options) { |
|
| 92 | - $errorHandler = new myErrorHandler(); |
|
| 91 | + public static function makeRequst($options) { |
|
| 92 | + $errorHandler = new myErrorHandler(); |
|
| 93 | 93 | |
| 94 | - $old_error_handler = set_error_handler(array($errorHandler, "proc_error")); |
|
| 94 | + $old_error_handler = set_error_handler(array($errorHandler, "proc_error")); |
|
| 95 | 95 | |
| 96 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 97 | - $query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
| 96 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 97 | + $query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
| 98 | 98 | |
| 99 | - $body = isset($options['body']) ? $options['body'] : null; |
|
| 100 | - $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
| 101 | - $headers = array( |
|
| 102 | - "User-Agent: Route4Me php-sdk" |
|
| 103 | - ); |
|
| 99 | + $body = isset($options['body']) ? $options['body'] : null; |
|
| 100 | + $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
| 101 | + $headers = array( |
|
| 102 | + "User-Agent: Route4Me php-sdk" |
|
| 103 | + ); |
|
| 104 | 104 | |
| 105 | - if (isset($options['HTTPHEADER'])) { |
|
| 106 | - $headers[] = $options['HTTPHEADER']; |
|
| 107 | - } |
|
| 105 | + if (isset($options['HTTPHEADER'])) { |
|
| 106 | + $headers[] = $options['HTTPHEADER']; |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if (isset($options['HTTPHEADERS'])) { |
|
| 110 | - foreach ($options['HTTPHEADERS'] As $header) { |
|
| 111 | - $headers[] = $header; |
|
| 112 | - } |
|
| 113 | - } |
|
| 109 | + if (isset($options['HTTPHEADERS'])) { |
|
| 110 | + foreach ($options['HTTPHEADERS'] As $header) { |
|
| 111 | + $headers[] = $header; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - $ch = curl_init(); |
|
| 115 | + $ch = curl_init(); |
|
| 116 | 116 | |
| 117 | - $url = $options['url'].'?'.http_build_query(array_merge( |
|
| 118 | - $query, array('api_key' => self::getApiKey()) |
|
| 119 | - )); |
|
| 117 | + $url = $options['url'].'?'.http_build_query(array_merge( |
|
| 118 | + $query, array('api_key' => self::getApiKey()) |
|
| 119 | + )); |
|
| 120 | 120 | |
| 121 | - $baseUrl = self::getBaseUrl(); |
|
| 121 | + $baseUrl = self::getBaseUrl(); |
|
| 122 | 122 | |
| 123 | - $curlOpts = arraY( |
|
| 124 | - CURLOPT_URL => $baseUrl.$url, |
|
| 125 | - CURLOPT_RETURNTRANSFER => true, |
|
| 126 | - CURLOPT_TIMEOUT => 80, |
|
| 127 | - CURLOPT_FOLLOWLOCATION => true, |
|
| 128 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 129 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
| 130 | - CURLOPT_HTTPHEADER => $headers |
|
| 131 | - ); |
|
| 123 | + $curlOpts = arraY( |
|
| 124 | + CURLOPT_URL => $baseUrl.$url, |
|
| 125 | + CURLOPT_RETURNTRANSFER => true, |
|
| 126 | + CURLOPT_TIMEOUT => 80, |
|
| 127 | + CURLOPT_FOLLOWLOCATION => true, |
|
| 128 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 129 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
| 130 | + CURLOPT_HTTPHEADER => $headers |
|
| 131 | + ); |
|
| 132 | 132 | |
| 133 | - curl_setopt_array($ch, $curlOpts); |
|
| 133 | + curl_setopt_array($ch, $curlOpts); |
|
| 134 | 134 | |
| 135 | - if ($file!=null) { |
|
| 136 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
|
| 137 | - $fp=fopen($file, 'r'); |
|
| 138 | - curl_setopt($ch, CURLOPT_INFILE, $fp); |
|
| 139 | - curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
|
| 140 | - } |
|
| 135 | + if ($file!=null) { |
|
| 136 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
|
| 137 | + $fp=fopen($file, 'r'); |
|
| 138 | + curl_setopt($ch, CURLOPT_INFILE, $fp); |
|
| 139 | + curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - switch ($method) { |
|
| 143 | - case 'DELETE': |
|
| 144 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 145 | - break; |
|
| 146 | - case 'DELETEARRAY': |
|
| 147 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 148 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 149 | - break; |
|
| 150 | - case 'PUT': |
|
| 151 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
| 152 | - break; |
|
| 153 | - case 'POST': |
|
| 154 | - if (isset($body)) { |
|
| 155 | - $bodyData = json_encode($body); |
|
| 156 | - if (isset($options['HTTPHEADER'])) { |
|
| 157 | - if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) { |
|
| 158 | - $bodyData = $body; |
|
| 159 | - } |
|
| 160 | - } |
|
| 142 | + switch ($method) { |
|
| 143 | + case 'DELETE': |
|
| 144 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 145 | + break; |
|
| 146 | + case 'DELETEARRAY': |
|
| 147 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 148 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 149 | + break; |
|
| 150 | + case 'PUT': |
|
| 151 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
| 152 | + break; |
|
| 153 | + case 'POST': |
|
| 154 | + if (isset($body)) { |
|
| 155 | + $bodyData = json_encode($body); |
|
| 156 | + if (isset($options['HTTPHEADER'])) { |
|
| 157 | + if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) { |
|
| 158 | + $bodyData = $body; |
|
| 159 | + } |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 163 | - } |
|
| 164 | - break; |
|
| 165 | - case 'ADD': |
|
| 166 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
| 167 | - } |
|
| 162 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
| 163 | + } |
|
| 164 | + break; |
|
| 165 | + case 'ADD': |
|
| 166 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - if (is_numeric(array_search($method, array('DELETE', 'PUT')))) { |
|
| 170 | - if (isset($body)) { |
|
| 171 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 172 | - } |
|
| 173 | - } |
|
| 169 | + if (is_numeric(array_search($method, array('DELETE', 'PUT')))) { |
|
| 170 | + if (isset($body)) { |
|
| 171 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - $result = curl_exec($ch); |
|
| 175 | + $result = curl_exec($ch); |
|
| 176 | 176 | |
| 177 | - $isxml = FALSE; |
|
| 178 | - $jxml = ""; |
|
| 179 | - if (strpos($result, '<?xml')>-1) { |
|
| 180 | - $xml = simplexml_load_string($result); |
|
| 181 | - //$jxml = json_encode($xml); |
|
| 182 | - $jxml = self::object2array($xml); |
|
| 183 | - $isxml = TRUE; |
|
| 184 | - } |
|
| 177 | + $isxml = FALSE; |
|
| 178 | + $jxml = ""; |
|
| 179 | + if (strpos($result, '<?xml')>-1) { |
|
| 180 | + $xml = simplexml_load_string($result); |
|
| 181 | + //$jxml = json_encode($xml); |
|
| 182 | + $jxml = self::object2array($xml); |
|
| 183 | + $isxml = TRUE; |
|
| 184 | + } |
|
| 185 | 185 | |
| 186 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 187 | - curl_close($ch); |
|
| 186 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 187 | + curl_close($ch); |
|
| 188 | 188 | |
| 189 | - if (200==$code) { |
|
| 190 | - if ($isxml) { |
|
| 191 | - $json = $jxml; |
|
| 192 | - } else { |
|
| 193 | - $json = json_decode($result, true); |
|
| 194 | - } |
|
| 189 | + if (200==$code) { |
|
| 190 | + if ($isxml) { |
|
| 191 | + $json = $jxml; |
|
| 192 | + } else { |
|
| 193 | + $json = json_decode($result, true); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - if (isset($json['errors'])) { |
|
| 197 | - throw new ApiError(implode(', ', $json['errors'])); |
|
| 198 | - } else { |
|
| 199 | - return $json; |
|
| 200 | - } |
|
| 201 | - } elseif (409==$code) { |
|
| 202 | - throw new ApiError('Wrong API key'); |
|
| 203 | - } else { |
|
| 204 | - throw new ApiError('Something wrong'); |
|
| 205 | - } |
|
| 206 | - } |
|
| 196 | + if (isset($json['errors'])) { |
|
| 197 | + throw new ApiError(implode(', ', $json['errors'])); |
|
| 198 | + } else { |
|
| 199 | + return $json; |
|
| 200 | + } |
|
| 201 | + } elseif (409==$code) { |
|
| 202 | + throw new ApiError('Wrong API key'); |
|
| 203 | + } else { |
|
| 204 | + throw new ApiError('Something wrong'); |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - /** |
|
| 209 | - * @param $object: JSON object |
|
| 210 | - */ |
|
| 211 | - public static function object2array($object) |
|
| 212 | - { |
|
| 213 | - return @json_decode(@json_encode($object), 1); |
|
| 214 | - } |
|
| 208 | + /** |
|
| 209 | + * @param $object: JSON object |
|
| 210 | + */ |
|
| 211 | + public static function object2array($object) |
|
| 212 | + { |
|
| 213 | + return @json_decode(@json_encode($object), 1); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - public static function makeUrlRequst($url, $options) { |
|
| 217 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 218 | - $query = isset($options['query']) ? |
|
| 219 | - array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
| 220 | - $body = isset($options['body']) ? $options['body'] : null; |
|
| 221 | - $ch = curl_init(); |
|
| 216 | + public static function makeUrlRequst($url, $options) { |
|
| 217 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
| 218 | + $query = isset($options['query']) ? |
|
| 219 | + array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
| 220 | + $body = isset($options['body']) ? $options['body'] : null; |
|
| 221 | + $ch = curl_init(); |
|
| 222 | 222 | |
| 223 | - $curlOpts = arraY( |
|
| 224 | - CURLOPT_URL => $url, |
|
| 225 | - CURLOPT_RETURNTRANSFER => true, |
|
| 226 | - CURLOPT_TIMEOUT => 60, |
|
| 227 | - CURLOPT_FOLLOWLOCATION => true, |
|
| 228 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 229 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
| 230 | - CURLOPT_HTTPHEADER => array( |
|
| 231 | - 'User-Agent' => 'Route4Me php-sdk' |
|
| 232 | - ) |
|
| 233 | - ); |
|
| 223 | + $curlOpts = arraY( |
|
| 224 | + CURLOPT_URL => $url, |
|
| 225 | + CURLOPT_RETURNTRANSFER => true, |
|
| 226 | + CURLOPT_TIMEOUT => 60, |
|
| 227 | + CURLOPT_FOLLOWLOCATION => true, |
|
| 228 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
| 229 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
| 230 | + CURLOPT_HTTPHEADER => array( |
|
| 231 | + 'User-Agent' => 'Route4Me php-sdk' |
|
| 232 | + ) |
|
| 233 | + ); |
|
| 234 | 234 | |
| 235 | - curl_setopt_array($ch, $curlOpts); |
|
| 235 | + curl_setopt_array($ch, $curlOpts); |
|
| 236 | 236 | |
| 237 | - switch ($method) { |
|
| 238 | - case 'DELETE': |
|
| 239 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 240 | - break; |
|
| 241 | - case 'DELETEARRAY': |
|
| 242 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 243 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 244 | - break; |
|
| 245 | - case 'PUT': |
|
| 246 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
| 247 | - break; |
|
| 248 | - case 'POST': |
|
| 249 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
| 250 | - break; |
|
| 251 | - case 'ADD': |
|
| 252 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
| 253 | - } |
|
| 237 | + switch ($method) { |
|
| 238 | + case 'DELETE': |
|
| 239 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 240 | + break; |
|
| 241 | + case 'DELETEARRAY': |
|
| 242 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
| 243 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
| 244 | + break; |
|
| 245 | + case 'PUT': |
|
| 246 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
| 247 | + break; |
|
| 248 | + case 'POST': |
|
| 249 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
| 250 | + break; |
|
| 251 | + case 'ADD': |
|
| 252 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - if (is_numeric(array_search($method, array('DELETE', 'PUT', 'POST')))) { |
|
| 256 | - if (isset($body)) { |
|
| 257 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 258 | - } |
|
| 259 | - } |
|
| 255 | + if (is_numeric(array_search($method, array('DELETE', 'PUT', 'POST')))) { |
|
| 256 | + if (isset($body)) { |
|
| 257 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - $result = curl_exec($ch); |
|
| 261 | + $result = curl_exec($ch); |
|
| 262 | 262 | |
| 263 | - $isxml = FALSE; |
|
| 264 | - $jxml = ""; |
|
| 263 | + $isxml = FALSE; |
|
| 264 | + $jxml = ""; |
|
| 265 | 265 | |
| 266 | - if (strpos($result, '<?xml')>-1) { |
|
| 267 | - $xml = simplexml_load_string($result); |
|
| 268 | - $jxml = json_encode($xml); |
|
| 269 | - $isxml = TRUE; |
|
| 270 | - } |
|
| 266 | + if (strpos($result, '<?xml')>-1) { |
|
| 267 | + $xml = simplexml_load_string($result); |
|
| 268 | + $jxml = json_encode($xml); |
|
| 269 | + $isxml = TRUE; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 273 | - curl_close($ch); |
|
| 272 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
| 273 | + curl_close($ch); |
|
| 274 | 274 | |
| 275 | - if ($isxml) { |
|
| 276 | - $json = $jxml; |
|
| 277 | - } else { |
|
| 278 | - $json = json_decode($result, true); |
|
| 279 | - } |
|
| 275 | + if ($isxml) { |
|
| 276 | + $json = $jxml; |
|
| 277 | + } else { |
|
| 278 | + $json = json_decode($result, true); |
|
| 279 | + } |
|
| 280 | 280 | |
| 281 | - if (200==$code) { |
|
| 282 | - return $json; |
|
| 283 | - } elseif (isset($json['errors'])) { |
|
| 284 | - throw new ApiError(implode(', ', $json['errors'])); |
|
| 285 | - } else { |
|
| 286 | - throw new ApiError('Something wrong'); |
|
| 287 | - } |
|
| 288 | - } |
|
| 281 | + if (200==$code) { |
|
| 282 | + return $json; |
|
| 283 | + } elseif (isset($json['errors'])) { |
|
| 284 | + throw new ApiError(implode(', ', $json['errors'])); |
|
| 285 | + } else { |
|
| 286 | + throw new ApiError('Something wrong'); |
|
| 287 | + } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - /** |
|
| 291 | - * Prints on the screen main keys and values of the array |
|
| 292 | - * @param $results: object to be printed on the screen. |
|
| 293 | - * @param $deepPrinting: if true, object will be printed recursively. |
|
| 294 | - */ |
|
| 295 | - public static function simplePrint($results, $deepPrinting = null) |
|
| 296 | - { |
|
| 297 | - if (isset($results)) { |
|
| 298 | - if (is_array($results)) { |
|
| 299 | - foreach ($results as $key=>$result) { |
|
| 300 | - if (is_array($result)) { |
|
| 301 | - foreach ($result as $key1=>$result1) { |
|
| 302 | - if (is_array($result1)) { |
|
| 303 | - if ($deepPrinting) { |
|
| 304 | - echo "<br>$key1 ------><br>"; |
|
| 305 | - Route4Me::simplePrint($result1, true); |
|
| 306 | - echo "------<br>"; |
|
| 307 | - } else { |
|
| 308 | - echo $key1." --> "."Array() <br>"; |
|
| 309 | - } |
|
| 310 | - } else { |
|
| 311 | - if (is_object($result1)) { |
|
| 312 | - if ($deepPrinting) { |
|
| 313 | - echo "<br>$key1 ------><br>"; |
|
| 314 | - $oarray = (array)$result1; |
|
| 315 | - Route4Me::simplePrint($oarray, true); |
|
| 316 | - echo "------<br>"; |
|
| 317 | - } else { |
|
| 318 | - echo $key1." --> "."Object <br>"; |
|
| 319 | - } |
|
| 320 | - } else { |
|
| 321 | - if (!is_null($result1)) { |
|
| 322 | - echo $key1." --> ".$result1."<br>"; |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - } else { |
|
| 328 | - if (is_object($result)) { |
|
| 329 | - if ($deepPrinting) { |
|
| 330 | - echo "<br>$key ------><br>"; |
|
| 331 | - $oarray = (array)$result; |
|
| 332 | - Route4Me::simplePrint($oarray, true); |
|
| 333 | - echo "------<br>"; |
|
| 334 | - } else { |
|
| 335 | - echo $key." --> "."Object <br>"; |
|
| 336 | - } |
|
| 337 | - } else { |
|
| 338 | - if (!is_null($result)) { |
|
| 339 | - echo $key." --> ".$result."<br>"; |
|
| 340 | - } |
|
| 341 | - } |
|
| 290 | + /** |
|
| 291 | + * Prints on the screen main keys and values of the array |
|
| 292 | + * @param $results: object to be printed on the screen. |
|
| 293 | + * @param $deepPrinting: if true, object will be printed recursively. |
|
| 294 | + */ |
|
| 295 | + public static function simplePrint($results, $deepPrinting = null) |
|
| 296 | + { |
|
| 297 | + if (isset($results)) { |
|
| 298 | + if (is_array($results)) { |
|
| 299 | + foreach ($results as $key=>$result) { |
|
| 300 | + if (is_array($result)) { |
|
| 301 | + foreach ($result as $key1=>$result1) { |
|
| 302 | + if (is_array($result1)) { |
|
| 303 | + if ($deepPrinting) { |
|
| 304 | + echo "<br>$key1 ------><br>"; |
|
| 305 | + Route4Me::simplePrint($result1, true); |
|
| 306 | + echo "------<br>"; |
|
| 307 | + } else { |
|
| 308 | + echo $key1." --> "."Array() <br>"; |
|
| 309 | + } |
|
| 310 | + } else { |
|
| 311 | + if (is_object($result1)) { |
|
| 312 | + if ($deepPrinting) { |
|
| 313 | + echo "<br>$key1 ------><br>"; |
|
| 314 | + $oarray = (array)$result1; |
|
| 315 | + Route4Me::simplePrint($oarray, true); |
|
| 316 | + echo "------<br>"; |
|
| 317 | + } else { |
|
| 318 | + echo $key1." --> "."Object <br>"; |
|
| 319 | + } |
|
| 320 | + } else { |
|
| 321 | + if (!is_null($result1)) { |
|
| 322 | + echo $key1." --> ".$result1."<br>"; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + } else { |
|
| 328 | + if (is_object($result)) { |
|
| 329 | + if ($deepPrinting) { |
|
| 330 | + echo "<br>$key ------><br>"; |
|
| 331 | + $oarray = (array)$result; |
|
| 332 | + Route4Me::simplePrint($oarray, true); |
|
| 333 | + echo "------<br>"; |
|
| 334 | + } else { |
|
| 335 | + echo $key." --> "."Object <br>"; |
|
| 336 | + } |
|
| 337 | + } else { |
|
| 338 | + if (!is_null($result)) { |
|
| 339 | + echo $key." --> ".$result."<br>"; |
|
| 340 | + } |
|
| 341 | + } |
|
| 342 | 342 | |
| 343 | - } |
|
| 344 | - //echo "<br>"; |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - } |
|
| 343 | + } |
|
| 344 | + //echo "<br>"; |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + } |
|
| 349 | 349 | |
| 350 | - /** |
|
| 351 | - * Generates query or body parameters. |
|
| 352 | - * @param $allFields: all known fields could be used for parameters generation. |
|
| 353 | - * @param $params: input parameters (array or object) |
|
| 354 | - */ |
|
| 355 | - public static function generateRequestParameters($allFields, $params) |
|
| 356 | - { |
|
| 357 | - $generatedParams = array(); |
|
| 350 | + /** |
|
| 351 | + * Generates query or body parameters. |
|
| 352 | + * @param $allFields: all known fields could be used for parameters generation. |
|
| 353 | + * @param $params: input parameters (array or object) |
|
| 354 | + */ |
|
| 355 | + public static function generateRequestParameters($allFields, $params) |
|
| 356 | + { |
|
| 357 | + $generatedParams = array(); |
|
| 358 | 358 | |
| 359 | - if (is_array($params)) { |
|
| 360 | - foreach ($allFields as $field) { |
|
| 361 | - if (isset($params[$field])) { |
|
| 362 | - $generatedParams[$field] = $params[$field]; |
|
| 363 | - } |
|
| 364 | - } |
|
| 365 | - } elseif (is_object($params)) { |
|
| 366 | - foreach ($allFields as $field) { |
|
| 367 | - if (isset($params->{$field})) { |
|
| 368 | - $generatedParams[$field] = $params->{$field}; |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - } |
|
| 359 | + if (is_array($params)) { |
|
| 360 | + foreach ($allFields as $field) { |
|
| 361 | + if (isset($params[$field])) { |
|
| 362 | + $generatedParams[$field] = $params[$field]; |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + } elseif (is_object($params)) { |
|
| 366 | + foreach ($allFields as $field) { |
|
| 367 | + if (isset($params->{$field})) { |
|
| 368 | + $generatedParams[$field] = $params->{$field}; |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - return $generatedParams; |
|
| 374 | - } |
|
| 373 | + return $generatedParams; |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - /** |
|
| 377 | - * Returns an array of the object properties |
|
| 378 | - * @param $object: An object. |
|
| 379 | - * @param $exclude: array of the object parameters to be excluded from the returned array. |
|
| 380 | - */ |
|
| 381 | - public static function getObjectProperties($object, $exclude) |
|
| 382 | - { |
|
| 383 | - $objectParameters = array(); |
|
| 376 | + /** |
|
| 377 | + * Returns an array of the object properties |
|
| 378 | + * @param $object: An object. |
|
| 379 | + * @param $exclude: array of the object parameters to be excluded from the returned array. |
|
| 380 | + */ |
|
| 381 | + public static function getObjectProperties($object, $exclude) |
|
| 382 | + { |
|
| 383 | + $objectParameters = array(); |
|
| 384 | 384 | |
| 385 | - foreach (get_object_vars($object) as $key => $value) { |
|
| 386 | - if (property_exists($object, $key)) { |
|
| 387 | - if (!is_numeric(array_search($key, $exclude))) { |
|
| 388 | - array_push($objectParameters, $key); |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - } |
|
| 385 | + foreach (get_object_vars($object) as $key => $value) { |
|
| 386 | + if (property_exists($object, $key)) { |
|
| 387 | + if (!is_numeric(array_search($key, $exclude))) { |
|
| 388 | + array_push($objectParameters, $key); |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + } |
|
| 392 | 392 | |
| 393 | - return $objectParameters; |
|
| 394 | - } |
|
| 393 | + return $objectParameters; |
|
| 394 | + } |
|
| 395 | 395 | |
| 396 | - /** |
|
| 397 | - * Returns url path generated from the array of the fields and parameters. |
|
| 398 | - * @param $allFields; array of the paossible fields (parameter names). |
|
| 399 | - * @param $params: input parameters (array or object). |
|
| 400 | - */ |
|
| 401 | - public static function generateUrlPath($allFields, $params) |
|
| 402 | - { |
|
| 403 | - $generatedPath = ""; |
|
| 396 | + /** |
|
| 397 | + * Returns url path generated from the array of the fields and parameters. |
|
| 398 | + * @param $allFields; array of the paossible fields (parameter names). |
|
| 399 | + * @param $params: input parameters (array or object). |
|
| 400 | + */ |
|
| 401 | + public static function generateUrlPath($allFields, $params) |
|
| 402 | + { |
|
| 403 | + $generatedPath = ""; |
|
| 404 | 404 | |
| 405 | - if (is_array($params)) { |
|
| 406 | - foreach ($allFields as $field) { |
|
| 407 | - if (isset($params[$field])) { |
|
| 408 | - $generatedPath .= $params[$field].'/'; |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - } elseif (is_object($params)) { |
|
| 412 | - foreach ($allFields as $field) { |
|
| 413 | - if (isset($params->{$field})) { |
|
| 414 | - $generatedPath .= $params->{$field}.'/'; |
|
| 415 | - } |
|
| 416 | - } |
|
| 417 | - } |
|
| 405 | + if (is_array($params)) { |
|
| 406 | + foreach ($allFields as $field) { |
|
| 407 | + if (isset($params[$field])) { |
|
| 408 | + $generatedPath .= $params[$field].'/'; |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | + } elseif (is_object($params)) { |
|
| 412 | + foreach ($allFields as $field) { |
|
| 413 | + if (isset($params->{$field})) { |
|
| 414 | + $generatedPath .= $params->{$field}.'/'; |
|
| 415 | + } |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - return $generatedPath; |
|
| 420 | - } |
|
| 419 | + return $generatedPath; |
|
| 420 | + } |
|
| 421 | 421 | } |