@@ -26,24 +26,24 @@ discard block |
||
26 | 26 | |
27 | 27 | $addresses = array(); |
28 | 28 | foreach ($json as $address) { |
29 | - $addresses[] = Address::fromArray($address); |
|
29 | + $addresses[] = Address::fromArray($address); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | $parameters = RouteParameters::fromArray(array( |
33 | - "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
34 | - "route_name" => "Single Depot, Multiple Driver, No Time Window", |
|
35 | - "route_date" => time() + 24 * 60 * 60, |
|
36 | - "route_time" => 60 * 60 * 7, |
|
37 | - "rt" => TRUE, |
|
38 | - "distance_unit" => DistanceUnit::MILES, |
|
39 | - "device_type" => DeviceType::WEB, |
|
40 | - "optimize" => OptimizationType::TIME, |
|
41 | - "metric" => Metric::GEODESIC, |
|
42 | - "route_max_duration" => 86400, |
|
43 | - "travel_mode" => TravelMode::DRIVING, |
|
44 | - "vehicle_capacity" => 20, |
|
45 | - "vehicle_max_distance_mi" => 99999, |
|
46 | - "parts" => 4 |
|
33 | + "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
34 | + "route_name" => "Single Depot, Multiple Driver, No Time Window", |
|
35 | + "route_date" => time() + 24 * 60 * 60, |
|
36 | + "route_time" => 60 * 60 * 7, |
|
37 | + "rt" => TRUE, |
|
38 | + "distance_unit" => DistanceUnit::MILES, |
|
39 | + "device_type" => DeviceType::WEB, |
|
40 | + "optimize" => OptimizationType::TIME, |
|
41 | + "metric" => Metric::GEODESIC, |
|
42 | + "route_max_duration" => 86400, |
|
43 | + "travel_mode" => TravelMode::DRIVING, |
|
44 | + "vehicle_capacity" => 20, |
|
45 | + "vehicle_max_distance_mi" => 99999, |
|
46 | + "parts" => 4 |
|
47 | 47 | )); |
48 | 48 | |
49 | 49 | $optimizationParams = new OptimizationProblemParams; |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | $problem = OptimizationProblem::optimize($optimizationParams); |
54 | 54 | |
55 | 55 | foreach ((array)$problem as $key => $value) { |
56 | - if (is_string($value)) { |
|
57 | - echo $key." --> ".$value."<br>"; |
|
58 | - } else { |
|
59 | - echo "************ $key ************* <br>"; |
|
60 | - Route4Me::simplePrint((array)$value, true); |
|
61 | - echo "******************************* <br>"; |
|
62 | - } |
|
56 | + if (is_string($value)) { |
|
57 | + echo $key." --> ".$value."<br>"; |
|
58 | + } else { |
|
59 | + echo "************ $key ************* <br>"; |
|
60 | + Route4Me::simplePrint((array)$value, true); |
|
61 | + echo "******************************* <br>"; |
|
62 | + } |
|
63 | 63 | } |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | $addresses = array(); |
28 | 28 | |
29 | 29 | foreach ($json as $address) { |
30 | - $addresses[] = Address::fromArray($address); |
|
30 | + $addresses[] = Address::fromArray($address); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | $parameters = RouteParameters::fromArray(array( |
34 | - "algorithm_type" => AlgorithmType::TSP, |
|
35 | - "distance_unit" => DistanceUnit::MILES, |
|
36 | - "device_type" => DeviceType::WEB, |
|
37 | - "optimize" => OptimizationType::DISTANCE, |
|
38 | - "travel_mode" => TravelMode::DRIVING, |
|
39 | - "route_max_duration" => 86400, |
|
40 | - "vehicle_capacity" => 1, |
|
41 | - "vehicle_max_distance_mi" => 10000, |
|
42 | - "rt" => true |
|
34 | + "algorithm_type" => AlgorithmType::TSP, |
|
35 | + "distance_unit" => DistanceUnit::MILES, |
|
36 | + "device_type" => DeviceType::WEB, |
|
37 | + "optimize" => OptimizationType::DISTANCE, |
|
38 | + "travel_mode" => TravelMode::DRIVING, |
|
39 | + "route_max_duration" => 86400, |
|
40 | + "vehicle_capacity" => 1, |
|
41 | + "vehicle_max_distance_mi" => 10000, |
|
42 | + "rt" => true |
|
43 | 43 | )); |
44 | 44 | |
45 | 45 | $optimizationParams = new OptimizationProblemParams; |
@@ -49,11 +49,11 @@ discard block |
||
49 | 49 | $problems = OptimizationProblem::optimize($optimizationParams); |
50 | 50 | |
51 | 51 | foreach ($problems as $problem) { |
52 | - if (is_array($problem) || is_object($problem)) { |
|
53 | - foreach ($problem as $key => $value) { |
|
54 | - if (!is_object($value)) { |
|
55 | - echo $key." --> ".$value."<br>"; |
|
56 | - } |
|
57 | - } |
|
58 | - } |
|
52 | + if (is_array($problem) || is_object($problem)) { |
|
53 | + foreach ($problem as $key => $value) { |
|
54 | + if (!is_object($value)) { |
|
55 | + echo $key." --> ".$value."<br>"; |
|
56 | + } |
|
57 | + } |
|
58 | + } |
|
59 | 59 | } |
@@ -13,9 +13,9 @@ |
||
13 | 13 | Route4Me::setApiKey('11111111111111111111111111111111'); |
14 | 14 | |
15 | 15 | $recordParameters = Member::fromArray(array( |
16 | - 'device_id' => '546546516', |
|
17 | - 'device_type' => 'IPAD', |
|
18 | - 'format' => 'json', |
|
16 | + 'device_id' => '546546516', |
|
17 | + 'device_type' => 'IPAD', |
|
18 | + 'format' => 'json', |
|
19 | 19 | )); |
20 | 20 | |
21 | 21 | $member = new Member(); |
@@ -13,14 +13,14 @@ |
||
13 | 13 | Route4Me::setApiKey('11111111111111111111111111111111'); |
14 | 14 | |
15 | 15 | $recordParameters = Member::fromArray(array( |
16 | - 'member_id' => 77777, |
|
17 | - 'session_guid' => '454563', |
|
18 | - 'device_id' => '54564', |
|
19 | - 'device_type' =>'ipad', |
|
20 | - 'subscription_name' =>'IPAD_MONTHLY', |
|
21 | - 'token' =>'4/P7q7W91a-oMsCeLvIaQm6bTrgtp7', |
|
22 | - 'payload' =>'APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx', |
|
23 | - 'format' =>'json' |
|
16 | + 'member_id' => 77777, |
|
17 | + 'session_guid' => '454563', |
|
18 | + 'device_id' => '54564', |
|
19 | + 'device_type' =>'ipad', |
|
20 | + 'subscription_name' =>'IPAD_MONTHLY', |
|
21 | + 'token' =>'4/P7q7W91a-oMsCeLvIaQm6bTrgtp7', |
|
22 | + 'payload' =>'APA91bHun4MxP5egoKMwt2KZFBaFUH-1RYqx', |
|
23 | + 'format' =>'json' |
|
24 | 24 | )); |
25 | 25 | |
26 | 26 | $member = new Member(); |
@@ -7,284 +7,284 @@ |
||
7 | 7 | |
8 | 8 | class Address extends Common |
9 | 9 | { |
10 | - public $route_destination_id; |
|
11 | - public $alias; |
|
12 | - public $member_id; |
|
13 | - public $address; |
|
14 | - public $addressUpdate; |
|
15 | - public $is_depot = false; |
|
16 | - public $lat; |
|
17 | - public $lng; |
|
18 | - public $route_id; |
|
19 | - public $original_route_id; |
|
20 | - public $optimization_problem_id; |
|
21 | - public $sequence_no; |
|
22 | - public $geocoded; |
|
23 | - public $preferred_geocoding; |
|
24 | - public $failed_geocoding; |
|
25 | - public $geocodings = array(); |
|
26 | - public $contact_id; |
|
27 | - public $is_visited; |
|
28 | - public $customer_po; |
|
29 | - public $invoice_no; |
|
30 | - public $reference_no; |
|
31 | - public $order_no; |
|
32 | - public $weight; |
|
33 | - public $cost; |
|
34 | - public $revenue; |
|
35 | - public $cube; |
|
36 | - public $pieces; |
|
37 | - public $email; |
|
38 | - public $phone; |
|
39 | - public $tracking_number; |
|
40 | - public $destination_note_count; |
|
41 | - public $drive_time_to_next_destination; |
|
42 | - public $distance_to_next_destination; |
|
43 | - public $generated_time_window_start; |
|
44 | - public $generated_time_window_end; |
|
45 | - public $time_window_start; |
|
46 | - public $time_window_end; |
|
47 | - public $time; |
|
48 | - public $notes; |
|
49 | - public $timestamp_last_visited; |
|
50 | - public $custom_fields = array(); |
|
51 | - public $manifest = array(); |
|
10 | + public $route_destination_id; |
|
11 | + public $alias; |
|
12 | + public $member_id; |
|
13 | + public $address; |
|
14 | + public $addressUpdate; |
|
15 | + public $is_depot = false; |
|
16 | + public $lat; |
|
17 | + public $lng; |
|
18 | + public $route_id; |
|
19 | + public $original_route_id; |
|
20 | + public $optimization_problem_id; |
|
21 | + public $sequence_no; |
|
22 | + public $geocoded; |
|
23 | + public $preferred_geocoding; |
|
24 | + public $failed_geocoding; |
|
25 | + public $geocodings = array(); |
|
26 | + public $contact_id; |
|
27 | + public $is_visited; |
|
28 | + public $customer_po; |
|
29 | + public $invoice_no; |
|
30 | + public $reference_no; |
|
31 | + public $order_no; |
|
32 | + public $weight; |
|
33 | + public $cost; |
|
34 | + public $revenue; |
|
35 | + public $cube; |
|
36 | + public $pieces; |
|
37 | + public $email; |
|
38 | + public $phone; |
|
39 | + public $tracking_number; |
|
40 | + public $destination_note_count; |
|
41 | + public $drive_time_to_next_destination; |
|
42 | + public $distance_to_next_destination; |
|
43 | + public $generated_time_window_start; |
|
44 | + public $generated_time_window_end; |
|
45 | + public $time_window_start; |
|
46 | + public $time_window_end; |
|
47 | + public $time; |
|
48 | + public $notes; |
|
49 | + public $timestamp_last_visited; |
|
50 | + public $custom_fields = array(); |
|
51 | + public $manifest = array(); |
|
52 | 52 | |
53 | - public $first_name; |
|
54 | - public $last_name; |
|
55 | - public $is_departed; |
|
56 | - public $timestamp_last_departed; |
|
57 | - public $order_id; |
|
58 | - public $priority; |
|
59 | - public $curbside_lat; |
|
60 | - public $curbside_lng; |
|
61 | - public $time_window_start_2; |
|
62 | - public $time_window_end_2; |
|
53 | + public $first_name; |
|
54 | + public $last_name; |
|
55 | + public $is_departed; |
|
56 | + public $timestamp_last_departed; |
|
57 | + public $order_id; |
|
58 | + public $priority; |
|
59 | + public $curbside_lat; |
|
60 | + public $curbside_lng; |
|
61 | + public $time_window_start_2; |
|
62 | + public $time_window_end_2; |
|
63 | 63 | |
64 | - public static function fromArray(array $params) |
|
65 | - { |
|
66 | - $address = new Address(); |
|
67 | - foreach ($params as $key => $value) { |
|
68 | - if (property_exists($address, $key)) { |
|
69 | - $address->{$key} = $value; |
|
70 | - } |
|
71 | - } |
|
64 | + public static function fromArray(array $params) |
|
65 | + { |
|
66 | + $address = new Address(); |
|
67 | + foreach ($params as $key => $value) { |
|
68 | + if (property_exists($address, $key)) { |
|
69 | + $address->{$key} = $value; |
|
70 | + } |
|
71 | + } |
|
72 | 72 | |
73 | - return $address; |
|
74 | - } |
|
73 | + return $address; |
|
74 | + } |
|
75 | 75 | |
76 | - public static function getAddress($routeId, $addressId) |
|
77 | - { |
|
78 | - $address = Route4Me::makeRequst(array( |
|
79 | - 'url' => Endpoint::ADDRESS_V4, |
|
80 | - 'method' => 'GET', |
|
81 | - 'query' => array( |
|
82 | - 'route_id' => $routeId, |
|
83 | - 'route_destination_id' => $addressId, |
|
84 | - ) |
|
85 | - )); |
|
76 | + public static function getAddress($routeId, $addressId) |
|
77 | + { |
|
78 | + $address = Route4Me::makeRequst(array( |
|
79 | + 'url' => Endpoint::ADDRESS_V4, |
|
80 | + 'method' => 'GET', |
|
81 | + 'query' => array( |
|
82 | + 'route_id' => $routeId, |
|
83 | + 'route_destination_id' => $addressId, |
|
84 | + ) |
|
85 | + )); |
|
86 | 86 | |
87 | - return Address::fromArray($address); |
|
88 | - } |
|
87 | + return Address::fromArray($address); |
|
88 | + } |
|
89 | 89 | |
90 | - /*Get notes from the specified route destination |
|
90 | + /*Get notes from the specified route destination |
|
91 | 91 | * Returns an address object with notes, if an address exists, otherwise - return null. |
92 | 92 | */ |
93 | - public static function GetAddressesNotes($noteParams) |
|
94 | - { |
|
95 | - $address = Route4Me::makeRequst(array( |
|
96 | - 'url' => Endpoint::ADDRESS_V4, |
|
97 | - 'method' => 'GET', |
|
98 | - 'query' => array( |
|
99 | - 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
100 | - 'route_destination_id' => isset($noteParams['route_destination_id']) |
|
101 | - ? $noteParams['route_destination_id'] : null, |
|
102 | - 'notes' => 1, |
|
103 | - ) |
|
104 | - )); |
|
93 | + public static function GetAddressesNotes($noteParams) |
|
94 | + { |
|
95 | + $address = Route4Me::makeRequst(array( |
|
96 | + 'url' => Endpoint::ADDRESS_V4, |
|
97 | + 'method' => 'GET', |
|
98 | + 'query' => array( |
|
99 | + 'route_id' => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, |
|
100 | + 'route_destination_id' => isset($noteParams['route_destination_id']) |
|
101 | + ? $noteParams['route_destination_id'] : null, |
|
102 | + 'notes' => 1, |
|
103 | + ) |
|
104 | + )); |
|
105 | 105 | |
106 | - return $address; |
|
107 | - } |
|
106 | + return $address; |
|
107 | + } |
|
108 | 108 | |
109 | - public function update() |
|
110 | - { |
|
111 | - $addressUpdate = Route4Me::makeRequst(array( |
|
112 | - 'url' => Endpoint::ADDRESS_V4, |
|
113 | - 'method' => 'PUT', |
|
114 | - 'body' => $this->toArray(), |
|
115 | - 'query' => array( |
|
116 | - 'route_id' => $this->route_id, |
|
117 | - 'route_destination_id' => $this->route_destination_id, |
|
118 | - ), |
|
119 | - )); |
|
109 | + public function update() |
|
110 | + { |
|
111 | + $addressUpdate = Route4Me::makeRequst(array( |
|
112 | + 'url' => Endpoint::ADDRESS_V4, |
|
113 | + 'method' => 'PUT', |
|
114 | + 'body' => $this->toArray(), |
|
115 | + 'query' => array( |
|
116 | + 'route_id' => $this->route_id, |
|
117 | + 'route_destination_id' => $this->route_destination_id, |
|
118 | + ), |
|
119 | + )); |
|
120 | 120 | |
121 | - return Address::fromArray($addressUpdate); |
|
122 | - } |
|
121 | + return Address::fromArray($addressUpdate); |
|
122 | + } |
|
123 | 123 | |
124 | - public function markAddress($params) |
|
125 | - { |
|
126 | - $allQueryFields = array('route_id', 'route_destination_id'); |
|
127 | - $allBodyFields = array('is_visited', 'is_departed'); |
|
124 | + public function markAddress($params) |
|
125 | + { |
|
126 | + $allQueryFields = array('route_id', 'route_destination_id'); |
|
127 | + $allBodyFields = array('is_visited', 'is_departed'); |
|
128 | 128 | |
129 | - $result = Route4Me::makeRequst(array( |
|
130 | - 'url' => Endpoint::ADDRESS_V4, |
|
131 | - 'method' => 'PUT', |
|
132 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
133 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
134 | - )); |
|
129 | + $result = Route4Me::makeRequst(array( |
|
130 | + 'url' => Endpoint::ADDRESS_V4, |
|
131 | + 'method' => 'PUT', |
|
132 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
133 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
134 | + )); |
|
135 | 135 | |
136 | - return $result; |
|
137 | - } |
|
136 | + return $result; |
|
137 | + } |
|
138 | 138 | |
139 | - public function markAsDeparted($params) |
|
140 | - { |
|
141 | - $allQueryFields = array('route_id', 'address_id', 'is_departed', 'member_id'); |
|
139 | + public function markAsDeparted($params) |
|
140 | + { |
|
141 | + $allQueryFields = array('route_id', 'address_id', 'is_departed', 'member_id'); |
|
142 | 142 | |
143 | - $address = Route4Me::makeRequst(array( |
|
144 | - 'url' => Endpoint::MARK_ADDRESS_DEPARTED, |
|
145 | - 'method' => 'PUT', |
|
146 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
147 | - )); |
|
143 | + $address = Route4Me::makeRequst(array( |
|
144 | + 'url' => Endpoint::MARK_ADDRESS_DEPARTED, |
|
145 | + 'method' => 'PUT', |
|
146 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
147 | + )); |
|
148 | 148 | |
149 | - return $address; |
|
150 | - } |
|
149 | + return $address; |
|
150 | + } |
|
151 | 151 | |
152 | - public function markAsVisited($params) |
|
153 | - { |
|
154 | - $allQueryFields = array('route_id', 'address_id', 'is_visited', 'member_id'); |
|
152 | + public function markAsVisited($params) |
|
153 | + { |
|
154 | + $allQueryFields = array('route_id', 'address_id', 'is_visited', 'member_id'); |
|
155 | 155 | |
156 | - $address = Route4Me::makeRequst(array( |
|
157 | - 'url' => Endpoint::UPDATE_ADDRESS_VISITED, |
|
158 | - 'method' => 'PUT', |
|
159 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
160 | - )); |
|
156 | + $address = Route4Me::makeRequst(array( |
|
157 | + 'url' => Endpoint::UPDATE_ADDRESS_VISITED, |
|
158 | + 'method' => 'PUT', |
|
159 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
160 | + )); |
|
161 | 161 | |
162 | - return $address; |
|
163 | - } |
|
162 | + return $address; |
|
163 | + } |
|
164 | 164 | |
165 | - public function deleteAddress() |
|
166 | - { |
|
167 | - $address = Route4Me::makeRequst(array( |
|
168 | - 'url' => Endpoint::ADDRESS_V4, |
|
169 | - 'method' => 'DELETE', |
|
170 | - 'query' => array( |
|
171 | - 'route_id' => $this->route_id, |
|
172 | - 'route_destination_id' => $this->route_destination_id, |
|
173 | - ) |
|
174 | - )); |
|
165 | + public function deleteAddress() |
|
166 | + { |
|
167 | + $address = Route4Me::makeRequst(array( |
|
168 | + 'url' => Endpoint::ADDRESS_V4, |
|
169 | + 'method' => 'DELETE', |
|
170 | + 'query' => array( |
|
171 | + 'route_id' => $this->route_id, |
|
172 | + 'route_destination_id' => $this->route_destination_id, |
|
173 | + ) |
|
174 | + )); |
|
175 | 175 | |
176 | - return (bool)$address['deleted']; |
|
177 | - } |
|
176 | + return (bool)$address['deleted']; |
|
177 | + } |
|
178 | 178 | |
179 | - public function moveDestinationToRoute($params) |
|
180 | - { |
|
181 | - $allBodyFields = array('to_route_id', 'route_destination_id', 'after_destination_id'); |
|
179 | + public function moveDestinationToRoute($params) |
|
180 | + { |
|
181 | + $allBodyFields = array('to_route_id', 'route_destination_id', 'after_destination_id'); |
|
182 | 182 | |
183 | - $result = Route4Me::makeRequst(array( |
|
184 | - 'url' => Endpoint::MOVE_ROUTE_DESTINATION, |
|
185 | - 'method' => 'POST', |
|
186 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
187 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
188 | - )); |
|
183 | + $result = Route4Me::makeRequst(array( |
|
184 | + 'url' => Endpoint::MOVE_ROUTE_DESTINATION, |
|
185 | + 'method' => 'POST', |
|
186 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
187 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
188 | + )); |
|
189 | 189 | |
190 | - return $result; |
|
191 | - } |
|
190 | + return $result; |
|
191 | + } |
|
192 | 192 | |
193 | - public function AddAddressNote($params) |
|
194 | - { |
|
195 | - $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
196 | - $allBodyFields = array('strNoteContents', 'strUpdateType'); |
|
193 | + public function AddAddressNote($params) |
|
194 | + { |
|
195 | + $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type'); |
|
196 | + $allBodyFields = array('strNoteContents', 'strUpdateType'); |
|
197 | 197 | |
198 | - $result = Route4Me::makeRequst(array( |
|
199 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
200 | - 'method' => 'POST', |
|
201 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
202 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
203 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
204 | - )); |
|
198 | + $result = Route4Me::makeRequst(array( |
|
199 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
200 | + 'method' => 'POST', |
|
201 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
202 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params), |
|
203 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
204 | + )); |
|
205 | 205 | |
206 | - return $result; |
|
207 | - } |
|
206 | + return $result; |
|
207 | + } |
|
208 | 208 | |
209 | - public function AddNoteFile($params) |
|
210 | - { |
|
211 | - $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type', 'strUpdateType'); |
|
209 | + public function AddNoteFile($params) |
|
210 | + { |
|
211 | + $allQueryFields = array('route_id', 'address_id', 'dev_lat', 'dev_lng', 'device_type', 'strUpdateType'); |
|
212 | 212 | |
213 | - $result = Route4Me::makeRequst(array( |
|
214 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
215 | - 'method' => 'POST', |
|
216 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
217 | - 'body' => array( |
|
218 | - 'strFilename' => isset($params['strFilename']) ? Route4Me::getFileRealPath($params['strFilename']) : "" |
|
219 | - ), |
|
220 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
221 | - )); |
|
213 | + $result = Route4Me::makeRequst(array( |
|
214 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
215 | + 'method' => 'POST', |
|
216 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
217 | + 'body' => array( |
|
218 | + 'strFilename' => isset($params['strFilename']) ? Route4Me::getFileRealPath($params['strFilename']) : "" |
|
219 | + ), |
|
220 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
221 | + )); |
|
222 | 222 | |
223 | - return $result; |
|
224 | - } |
|
223 | + return $result; |
|
224 | + } |
|
225 | 225 | |
226 | - public function createCustomNoteType($params) |
|
227 | - { |
|
228 | - $allBodyFields = array('type', 'values'); |
|
226 | + public function createCustomNoteType($params) |
|
227 | + { |
|
228 | + $allBodyFields = array('type', 'values'); |
|
229 | 229 | |
230 | - $result = Route4Me::makeRequst(array( |
|
231 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
232 | - 'method' => 'POST', |
|
233 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
234 | - )); |
|
230 | + $result = Route4Me::makeRequst(array( |
|
231 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
232 | + 'method' => 'POST', |
|
233 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
234 | + )); |
|
235 | 235 | |
236 | - return $result; |
|
237 | - } |
|
236 | + return $result; |
|
237 | + } |
|
238 | 238 | |
239 | - public function removeCustomNoteType($params) |
|
240 | - { |
|
241 | - $result = Route4Me::makeRequst(array( |
|
242 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
243 | - 'method' => 'DELETE', |
|
244 | - 'body' => array( |
|
245 | - 'id' => isset($params['id']) ? $params['id'] : null |
|
246 | - ) |
|
247 | - )); |
|
239 | + public function removeCustomNoteType($params) |
|
240 | + { |
|
241 | + $result = Route4Me::makeRequst(array( |
|
242 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
243 | + 'method' => 'DELETE', |
|
244 | + 'body' => array( |
|
245 | + 'id' => isset($params['id']) ? $params['id'] : null |
|
246 | + ) |
|
247 | + )); |
|
248 | 248 | |
249 | - return $result; |
|
250 | - } |
|
249 | + return $result; |
|
250 | + } |
|
251 | 251 | |
252 | - public function getAllCustomNoteTypes() |
|
253 | - { |
|
254 | - $result = Route4Me::makeRequst(array( |
|
255 | - 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
256 | - 'method' => 'GET' |
|
257 | - )); |
|
252 | + public function getAllCustomNoteTypes() |
|
253 | + { |
|
254 | + $result = Route4Me::makeRequst(array( |
|
255 | + 'url' => Endpoint::NOTE_CUSTOM_TYPES_V4, |
|
256 | + 'method' => 'GET' |
|
257 | + )); |
|
258 | 258 | |
259 | - return $result; |
|
260 | - } |
|
259 | + return $result; |
|
260 | + } |
|
261 | 261 | |
262 | - public function addCustomNoteToRoute($params) |
|
263 | - { |
|
264 | - $customArray = array(); |
|
262 | + public function addCustomNoteToRoute($params) |
|
263 | + { |
|
264 | + $customArray = array(); |
|
265 | 265 | |
266 | - foreach ($params as $key => $value) { |
|
267 | - if (strpos($key, "custom_note_type")!==false) { |
|
268 | - $customArray[$key] = $value; |
|
269 | - } |
|
270 | - } |
|
266 | + foreach ($params as $key => $value) { |
|
267 | + if (strpos($key, "custom_note_type")!==false) { |
|
268 | + $customArray[$key] = $value; |
|
269 | + } |
|
270 | + } |
|
271 | 271 | |
272 | - $allQueryFields = array('route_id', 'address_id', 'format', 'dev_lat', 'dev_lng'); |
|
273 | - $allBodyFields = array('strUpdateType', 'strUpdateType', 'strNoteContents'); |
|
272 | + $allQueryFields = array('route_id', 'address_id', 'format', 'dev_lat', 'dev_lng'); |
|
273 | + $allBodyFields = array('strUpdateType', 'strUpdateType', 'strNoteContents'); |
|
274 | 274 | |
275 | - $result = Route4Me::makeRequst(array( |
|
276 | - 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
277 | - 'method' => 'POST', |
|
278 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
279 | - 'body' => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray), |
|
280 | - 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
281 | - )); |
|
275 | + $result = Route4Me::makeRequst(array( |
|
276 | + 'url' => Endpoint::ROUTE_NOTES_ADD, |
|
277 | + 'method' => 'POST', |
|
278 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params), |
|
279 | + 'body' => array_merge(Route4Me::generateRequestParameters($allBodyFields, $params), $customArray), |
|
280 | + 'HTTPHEADER' => 'Content-Type: multipart/form-data' |
|
281 | + )); |
|
282 | 282 | |
283 | - return $result; |
|
284 | - } |
|
283 | + return $result; |
|
284 | + } |
|
285 | 285 | |
286 | - function getAddressId() |
|
287 | - { |
|
288 | - return $this->route_destination_id; |
|
289 | - } |
|
286 | + function getAddressId() |
|
287 | + { |
|
288 | + return $this->route_destination_id; |
|
289 | + } |
|
290 | 290 | } |
@@ -27,23 +27,23 @@ discard block |
||
27 | 27 | $addresses = array(); |
28 | 28 | |
29 | 29 | foreach ($json as $address) { |
30 | - $addresses[] = Address::fromArray($address); |
|
30 | + $addresses[] = Address::fromArray($address); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | $parameters = RouteParameters::fromArray(array( |
34 | - "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
35 | - "route_name" => "Multiple Depot, Multiple Driver, Time Window", |
|
36 | - "route_date" => time() + 24 * 60 * 60, |
|
37 | - "route_time" => 60 * 60 * 7, |
|
38 | - "rt" => TRUE, |
|
39 | - "distance_unit" => DistanceUnit::MILES, |
|
40 | - "device_type" => DeviceType::WEB, |
|
41 | - "optimize" => OptimizationType::TIME, |
|
42 | - "metric" => Metric::GEODESIC, |
|
43 | - "route_max_duration" => 86400 * 3, |
|
44 | - "travel_mode" => TravelMode::DRIVING, |
|
45 | - "vehicle_capacity" => 99, |
|
46 | - "vehicle_max_distance_mi" => 99999 |
|
34 | + "algorithm_type" => Algorithmtype::CVRP_TW_SD, |
|
35 | + "route_name" => "Multiple Depot, Multiple Driver, Time Window", |
|
36 | + "route_date" => time() + 24 * 60 * 60, |
|
37 | + "route_time" => 60 * 60 * 7, |
|
38 | + "rt" => TRUE, |
|
39 | + "distance_unit" => DistanceUnit::MILES, |
|
40 | + "device_type" => DeviceType::WEB, |
|
41 | + "optimize" => OptimizationType::TIME, |
|
42 | + "metric" => Metric::GEODESIC, |
|
43 | + "route_max_duration" => 86400 * 3, |
|
44 | + "travel_mode" => TravelMode::DRIVING, |
|
45 | + "vehicle_capacity" => 99, |
|
46 | + "vehicle_max_distance_mi" => 99999 |
|
47 | 47 | )); |
48 | 48 | |
49 | 49 | $optimizationParams = new OptimizationProblemParams; |
@@ -53,11 +53,11 @@ discard block |
||
53 | 53 | $problem = OptimizationProblem::optimize($optimizationParams); |
54 | 54 | |
55 | 55 | foreach ((array)$problem as $key => $value) { |
56 | - if (is_string($value)) { |
|
57 | - echo $key." --> ".$value."<br>"; |
|
58 | - } else { |
|
59 | - echo "************ $key ************* <br>"; |
|
60 | - Route4Me::simplePrint((array)$value, true); |
|
61 | - echo "******************************* <br>"; |
|
62 | - } |
|
56 | + if (is_string($value)) { |
|
57 | + echo $key." --> ".$value."<br>"; |
|
58 | + } else { |
|
59 | + echo "************ $key ************* <br>"; |
|
60 | + Route4Me::simplePrint((array)$value, true); |
|
61 | + echo "******************************* <br>"; |
|
62 | + } |
|
63 | 63 | } |
@@ -6,78 +6,78 @@ |
||
6 | 6 | |
7 | 7 | class ActivityParameters extends Common |
8 | 8 | { |
9 | - public $route_id; |
|
10 | - public $device_id; |
|
11 | - public $member_id; |
|
12 | - public $team; |
|
13 | - public $limit; |
|
14 | - public $offset; |
|
15 | - public $start; |
|
16 | - public $end; |
|
17 | - public $activity_type; |
|
18 | - public $activity_message; |
|
9 | + public $route_id; |
|
10 | + public $device_id; |
|
11 | + public $member_id; |
|
12 | + public $team; |
|
13 | + public $limit; |
|
14 | + public $offset; |
|
15 | + public $start; |
|
16 | + public $end; |
|
17 | + public $activity_type; |
|
18 | + public $activity_message; |
|
19 | 19 | |
20 | - public $activity_id; |
|
21 | - public $activity_timestamp; |
|
22 | - public $route_destination_id; |
|
23 | - public $note_id; |
|
24 | - public $member; |
|
25 | - public $note_type; |
|
26 | - public $note_contents; |
|
27 | - public $route_name; |
|
28 | - public $note_file; |
|
29 | - public $destination_name; |
|
30 | - public $destination_alias; |
|
20 | + public $activity_id; |
|
21 | + public $activity_timestamp; |
|
22 | + public $route_destination_id; |
|
23 | + public $note_id; |
|
24 | + public $member; |
|
25 | + public $note_type; |
|
26 | + public $note_contents; |
|
27 | + public $route_name; |
|
28 | + public $note_file; |
|
29 | + public $destination_name; |
|
30 | + public $destination_alias; |
|
31 | 31 | |
32 | - public static function fromArray(array $params) |
|
33 | - { |
|
34 | - $activityparameters = new ActivityParameters(); |
|
32 | + public static function fromArray(array $params) |
|
33 | + { |
|
34 | + $activityparameters = new ActivityParameters(); |
|
35 | 35 | |
36 | - foreach ($params as $key => $value) { |
|
37 | - if (property_exists($activityparameters, $key)) { |
|
38 | - $activityparameters->{$key} = $value; |
|
39 | - } |
|
40 | - } |
|
36 | + foreach ($params as $key => $value) { |
|
37 | + if (property_exists($activityparameters, $key)) { |
|
38 | + $activityparameters->{$key} = $value; |
|
39 | + } |
|
40 | + } |
|
41 | 41 | |
42 | - return $activityparameters; |
|
43 | - } |
|
42 | + return $activityparameters; |
|
43 | + } |
|
44 | 44 | |
45 | - public static function getActivities($params) |
|
46 | - { |
|
47 | - $allQueryFields = array('route_id', 'team', 'limit', 'offset', 'start'); |
|
45 | + public static function getActivities($params) |
|
46 | + { |
|
47 | + $allQueryFields = array('route_id', 'team', 'limit', 'offset', 'start'); |
|
48 | 48 | |
49 | - $activity = Route4Me::makeRequst(array( |
|
50 | - 'url' => Endpoint::GET_ACTIVITIES, |
|
51 | - 'method' => 'GET', |
|
52 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
53 | - )); |
|
49 | + $activity = Route4Me::makeRequst(array( |
|
50 | + 'url' => Endpoint::GET_ACTIVITIES, |
|
51 | + 'method' => 'GET', |
|
52 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
53 | + )); |
|
54 | 54 | |
55 | - return $activity; |
|
56 | - } |
|
55 | + return $activity; |
|
56 | + } |
|
57 | 57 | |
58 | - public static function searcActivities($params) |
|
59 | - { |
|
60 | - $allQueryFields = array('route_id', 'limit', 'offset', 'activity_type'); |
|
58 | + public static function searcActivities($params) |
|
59 | + { |
|
60 | + $allQueryFields = array('route_id', 'limit', 'offset', 'activity_type'); |
|
61 | 61 | |
62 | - $activity = Route4Me::makeRequst(array( |
|
63 | - 'url' => Endpoint::GET_ACTIVITIES, |
|
64 | - 'method' => 'GET', |
|
65 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
66 | - )); |
|
62 | + $activity = Route4Me::makeRequst(array( |
|
63 | + 'url' => Endpoint::GET_ACTIVITIES, |
|
64 | + 'method' => 'GET', |
|
65 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
66 | + )); |
|
67 | 67 | |
68 | - return $activity; |
|
69 | - } |
|
68 | + return $activity; |
|
69 | + } |
|
70 | 70 | |
71 | - public static function sendUserMessage($params) |
|
72 | - { |
|
73 | - $allBodyFields = array('activity_type', 'activity_message', 'route_id'); |
|
71 | + public static function sendUserMessage($params) |
|
72 | + { |
|
73 | + $allBodyFields = array('activity_type', 'activity_message', 'route_id'); |
|
74 | 74 | |
75 | - $result = Route4Me::makeRequst(array( |
|
76 | - 'url' => Endpoint::ACTIVITY_FEED, |
|
77 | - 'method' => 'POST', |
|
78 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
79 | - )); |
|
75 | + $result = Route4Me::makeRequst(array( |
|
76 | + 'url' => Endpoint::ACTIVITY_FEED, |
|
77 | + 'method' => 'POST', |
|
78 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
79 | + )); |
|
80 | 80 | |
81 | - return $result; |
|
82 | - } |
|
81 | + return $result; |
|
82 | + } |
|
83 | 83 | } |
@@ -7,93 +7,93 @@ |
||
7 | 7 | |
8 | 8 | class OptimizationProblemParams extends Common |
9 | 9 | { |
10 | - public $optimization_problem_id; |
|
11 | - public $reoptimize; |
|
12 | - public $addresses = array(); |
|
13 | - public $parameters; |
|
14 | - public $directions; |
|
15 | - public $format; |
|
16 | - public $route_path_output; |
|
17 | - public $optimized_callback_url; |
|
18 | - public $redirect = true; |
|
10 | + public $optimization_problem_id; |
|
11 | + public $reoptimize; |
|
12 | + public $addresses = array(); |
|
13 | + public $parameters; |
|
14 | + public $directions; |
|
15 | + public $format; |
|
16 | + public $route_path_output; |
|
17 | + public $optimized_callback_url; |
|
18 | + public $redirect = true; |
|
19 | 19 | |
20 | - public static function fromArray($params) |
|
21 | - { |
|
22 | - $param = new OptimizationProblemParams; |
|
23 | - if (!isset($params['addresses'])) { |
|
24 | - throw new BadParam('addresses must be provided.'); |
|
25 | - } |
|
20 | + public static function fromArray($params) |
|
21 | + { |
|
22 | + $param = new OptimizationProblemParams; |
|
23 | + if (!isset($params['addresses'])) { |
|
24 | + throw new BadParam('addresses must be provided.'); |
|
25 | + } |
|
26 | 26 | |
27 | - if (!isset($params['parameters'])) { |
|
28 | - throw new BadParam('parameters must be provided.'); |
|
29 | - } |
|
27 | + if (!isset($params['parameters'])) { |
|
28 | + throw new BadParam('parameters must be provided.'); |
|
29 | + } |
|
30 | 30 | |
31 | - if ($params['parameters'] instanceof RouteParameters) { |
|
32 | - $param->setParameters($params['parameters']); |
|
33 | - } else { |
|
34 | - $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
|
35 | - } |
|
31 | + if ($params['parameters'] instanceof RouteParameters) { |
|
32 | + $param->setParameters($params['parameters']); |
|
33 | + } else { |
|
34 | + $param->setParameters(RouteParameters::fromArray($params['parameters'])); |
|
35 | + } |
|
36 | 36 | |
37 | - foreach ($params['addresses'] as $address) { |
|
38 | - if (!($address instanceof Address)) { |
|
39 | - $address = Address::fromArray($address); |
|
40 | - } |
|
37 | + foreach ($params['addresses'] as $address) { |
|
38 | + if (!($address instanceof Address)) { |
|
39 | + $address = Address::fromArray($address); |
|
40 | + } |
|
41 | 41 | |
42 | - $param->addAddress($address); |
|
43 | - } |
|
42 | + $param->addAddress($address); |
|
43 | + } |
|
44 | 44 | |
45 | - $param->directions = self::getValue($params, 'directions'); |
|
46 | - $param->format = self::getValue($params, 'format'); |
|
47 | - $param->route_path_output = self::getValue($params, 'route_path_output'); |
|
48 | - $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url'); |
|
49 | - $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id'); |
|
50 | - $param->reoptimize = self::getValue($params, 'reoptimize'); |
|
51 | - $param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN); |
|
45 | + $param->directions = self::getValue($params, 'directions'); |
|
46 | + $param->format = self::getValue($params, 'format'); |
|
47 | + $param->route_path_output = self::getValue($params, 'route_path_output'); |
|
48 | + $param->optimized_callback_url = self::getValue($params, 'optimized_callback_url'); |
|
49 | + $param->optimization_problem_id = self::getValue($params, 'optimization_problem_id'); |
|
50 | + $param->reoptimize = self::getValue($params, 'reoptimize'); |
|
51 | + $param->redirect = filter_var(self::getValue($params, 'redirect', true), FILTER_VALIDATE_BOOLEAN); |
|
52 | 52 | |
53 | - return $param; |
|
54 | - } |
|
53 | + return $param; |
|
54 | + } |
|
55 | 55 | |
56 | - public function __construct() |
|
57 | - { |
|
58 | - $this->parameters = new RouteParameters; |
|
59 | - } |
|
56 | + public function __construct() |
|
57 | + { |
|
58 | + $this->parameters = new RouteParameters; |
|
59 | + } |
|
60 | 60 | |
61 | - public function setParameters(RouteParameters $params) |
|
62 | - { |
|
63 | - $this->parameters = $params; |
|
61 | + public function setParameters(RouteParameters $params) |
|
62 | + { |
|
63 | + $this->parameters = $params; |
|
64 | 64 | |
65 | - return $this; |
|
66 | - } |
|
65 | + return $this; |
|
66 | + } |
|
67 | 67 | |
68 | - public function addAddress(Address $address) |
|
69 | - { |
|
70 | - $this->addresses[] = $address; |
|
68 | + public function addAddress(Address $address) |
|
69 | + { |
|
70 | + $this->addresses[] = $address; |
|
71 | 71 | |
72 | - return $this; |
|
73 | - } |
|
72 | + return $this; |
|
73 | + } |
|
74 | 74 | |
75 | - public function getAddressesArray() |
|
76 | - { |
|
77 | - $addresses = array(); |
|
75 | + public function getAddressesArray() |
|
76 | + { |
|
77 | + $addresses = array(); |
|
78 | 78 | |
79 | - foreach ($this->addresses as $address) { |
|
80 | - $addresses[] = $address->toArray(); |
|
81 | - } |
|
79 | + foreach ($this->addresses as $address) { |
|
80 | + $addresses[] = $address->toArray(); |
|
81 | + } |
|
82 | 82 | |
83 | - return $addresses; |
|
84 | - } |
|
83 | + return $addresses; |
|
84 | + } |
|
85 | 85 | |
86 | - public function getParametersArray() |
|
87 | - { |
|
88 | - return $this->parameters->toArray(); |
|
89 | - } |
|
86 | + public function getParametersArray() |
|
87 | + { |
|
88 | + return $this->parameters->toArray(); |
|
89 | + } |
|
90 | 90 | |
91 | - public function setAddresses(array $addresses) |
|
92 | - { |
|
93 | - foreach ($addresses as $address) { |
|
94 | - $this->addAddress($address); |
|
95 | - } |
|
91 | + public function setAddresses(array $addresses) |
|
92 | + { |
|
93 | + foreach ($addresses as $address) { |
|
94 | + $this->addAddress($address); |
|
95 | + } |
|
96 | 96 | |
97 | - return $this; |
|
98 | - } |
|
97 | + return $this; |
|
98 | + } |
|
99 | 99 | } |
@@ -3,13 +3,13 @@ |
||
3 | 3 | |
4 | 4 | class AlgorithmType |
5 | 5 | { |
6 | - const TSP = 1; |
|
7 | - const VRP = 2; |
|
8 | - const CVRP_TW_SD = 3; |
|
9 | - const CVRP_TW_MD = 4; |
|
10 | - const TSP_TW = 5; |
|
11 | - const TSP_TW_CR = 6; |
|
12 | - const BBCVRP = 7; |
|
13 | - const ALG_NONE = 100; |
|
14 | - const ALG_LEGACY_DISTRIBUTED = 101; |
|
6 | + const TSP = 1; |
|
7 | + const VRP = 2; |
|
8 | + const CVRP_TW_SD = 3; |
|
9 | + const CVRP_TW_MD = 4; |
|
10 | + const TSP_TW = 5; |
|
11 | + const TSP_TW_CR = 6; |
|
12 | + const BBCVRP = 7; |
|
13 | + const ALG_NONE = 100; |
|
14 | + const ALG_LEGACY_DISTRIBUTED = 101; |
|
15 | 15 | } |