GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( ba89cf...799599 )
by Oleg
02:27
created
src/Route4Me/OptimizationProblem.php 1 patch
Indentation   +220 added lines, -220 removed lines patch added patch discarded remove patch
@@ -11,271 +11,271 @@
 block discarded – undo
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();
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 26
 
27
-    function __construct()
28
-    {
29
-        $this->parameters = new RouteParameters;
30
-    }
27
+	function __construct()
28
+	{
29
+		$this->parameters = new RouteParameters;
30
+	}
31 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());
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 40
 
41
-        if (isset($params['parameters'])) {
42
-            $problem->parameters = RouteParameters::fromArray($params['parameters']);
43
-        }
41
+		if (isset($params['parameters'])) {
42
+			$problem->parameters = RouteParameters::fromArray($params['parameters']);
43
+		}
44 44
 
45
-        if (isset($params['addresses'])) {
46
-            $addresses = array();
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
-        }
62
+			$problem->routes = $routes;
63
+		}
64 64
 
65
-        return $problem;
66
-    }
65
+		return $problem;
66
+	}
67 67
 
68
-    public static function optimize(OptimizationProblemParams $params)
69
-    {
70
-        $optimize = Route4Me::makeRequst(array(
71
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
72
-            'method' => 'POST',
73
-            'query'  => array(
74
-                'redirect'               => isset($params->redirect) ? $params->redirect : null,
75
-                'directions'             => isset($params->directions) ? $params->directions : null, 
76
-                'format'                 => isset($params->format) ? $params->format : null,
77
-                'route_path_output'      => isset($params->route_path_output) ? $params->route_path_output : null,
78
-                'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null
79
-            ),
80
-            'body'   => array(
81
-                'addresses'  => $params->getAddressesArray(),
82
-                'parameters' => $params->getParametersArray()
83
-            )
84
-        ));
68
+	public static function optimize(OptimizationProblemParams $params)
69
+	{
70
+		$optimize = Route4Me::makeRequst(array(
71
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
72
+			'method' => 'POST',
73
+			'query'  => array(
74
+				'redirect'               => isset($params->redirect) ? $params->redirect : null,
75
+				'directions'             => isset($params->directions) ? $params->directions : null, 
76
+				'format'                 => isset($params->format) ? $params->format : null,
77
+				'route_path_output'      => isset($params->route_path_output) ? $params->route_path_output : null,
78
+				'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null
79
+			),
80
+			'body'   => array(
81
+				'addresses'  => $params->getAddressesArray(),
82
+				'parameters' => $params->getParametersArray()
83
+			)
84
+		));
85 85
 
86
-        return OptimizationProblem::fromArray($optimize);
87
-    }
86
+		return OptimizationProblem::fromArray($optimize);
87
+	}
88 88
 
89
-    public static function get($params)
90
-    {
91
-        $optimize = Route4Me::makeRequst(array(
92
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
93
-            'method' => 'GET',
94
-            'query'  => array(
95
-                'state'  => isset($params['state']) ? $params['state'] : null,
96
-                'limit'  => isset($params['limit']) ? $params['limit'] : null,
97
-                'offset' => isset($params['offset']) ? $params['offset'] : null,
98
-                'optimization_problem_id' => isset($params['optimization_problem_id']) 
99
-                    ? $params['optimization_problem_id'] : null,
100
-                'wait_for_final_state' => isset($params['wait_for_final_state']) 
101
-                    ? $params['wait_for_final_state'] : null,
102
-            )
103
-        ));
89
+	public static function get($params)
90
+	{
91
+		$optimize = Route4Me::makeRequst(array(
92
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
93
+			'method' => 'GET',
94
+			'query'  => array(
95
+				'state'  => isset($params['state']) ? $params['state'] : null,
96
+				'limit'  => isset($params['limit']) ? $params['limit'] : null,
97
+				'offset' => isset($params['offset']) ? $params['offset'] : null,
98
+				'optimization_problem_id' => isset($params['optimization_problem_id']) 
99
+					? $params['optimization_problem_id'] : null,
100
+				'wait_for_final_state' => isset($params['wait_for_final_state']) 
101
+					? $params['wait_for_final_state'] : null,
102
+			)
103
+		));
104 104
 
105
-        if (isset($optimize['optimizations'])) {
106
-            $problems = array();
105
+		if (isset($optimize['optimizations'])) {
106
+			$problems = array();
107 107
             
108
-            foreach ($optimize['optimizations'] as $problem) {
109
-                $problems[] = OptimizationProblem::fromArray($problem);
110
-            }
108
+			foreach ($optimize['optimizations'] as $problem) {
109
+				$problems[] = OptimizationProblem::fromArray($problem);
110
+			}
111 111
             
112
-            return $problems;
113
-        } else {
114
-            return OptimizationProblem::fromArray($optimize);
115
-        }
116
-    }
112
+			return $problems;
113
+		} else {
114
+			return OptimizationProblem::fromArray($optimize);
115
+		}
116
+	}
117 117
 
118
-    public static function reoptimize($params)
119
-    {
120
-        $param = new OptimizationProblemParams;
121
-        $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null;
122
-        $param->reoptimize = 1;
118
+	public static function reoptimize($params)
119
+	{
120
+		$param = new OptimizationProblemParams;
121
+		$param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null;
122
+		$param->reoptimize = 1;
123 123
 
124
-        return self::update((array)$param);
125
-    }
124
+		return self::update((array)$param);
125
+	}
126 126
 
127
-    public static function update($params)
128
-    {
129
-        $optimize = Route4Me::makeRequst(array(
130
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
131
-            'method' => 'PUT',
132
-            'query'  => array(
133
-                'optimization_problem_id' => isset($params['optimization_problem_id'])
134
-                                               ? $params['optimization_problem_id'] : null,
135
-                'addresses'  => isset($params['addresses']) ? $params['addresses'] : null,
136
-                'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null,
137
-            )
138
-        ));
127
+	public static function update($params)
128
+	{
129
+		$optimize = Route4Me::makeRequst(array(
130
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
131
+			'method' => 'PUT',
132
+			'query'  => array(
133
+				'optimization_problem_id' => isset($params['optimization_problem_id'])
134
+											   ? $params['optimization_problem_id'] : null,
135
+				'addresses'  => isset($params['addresses']) ? $params['addresses'] : null,
136
+				'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null,
137
+			)
138
+		));
139 139
         
140
-        return $optimize;
141
-    }
140
+		return $optimize;
141
+	}
142 142
 
143
-    public function getOptimizationId()
144
-    {
145
-        return $this->optimization_problem_id;
146
-    }
143
+	public function getOptimizationId()
144
+	{
145
+		return $this->optimization_problem_id;
146
+	}
147 147
 
148
-    public function getRoutes()
149
-    {
150
-        return $this->routes;
151
-    }
148
+	public function getRoutes()
149
+	{
150
+		return $this->routes;
151
+	}
152 152
     
153
-    public function getRandomOptimizationId($offset, $limit)
154
-    {
155
-        $query['limit'] = !is_null($limit) ? $limit : 30;
156
-        $query['offset'] = !is_null($offset) ? $offset : 0;
153
+	public function getRandomOptimizationId($offset, $limit)
154
+	{
155
+		$query['limit'] = !is_null($limit) ? $limit : 30;
156
+		$query['offset'] = !is_null($offset) ? $offset : 0;
157 157
             
158
-        $json = Route4Me::makeRequst(array(
159
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
160
-            'method' => 'GET',
161
-            'query'  => $query
162
-        ));
158
+		$json = Route4Me::makeRequst(array(
159
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
160
+			'method' => 'GET',
161
+			'query'  => $query
162
+		));
163 163
         
164
-        $optimizations = array();
165
-            foreach ($json as $optimization) {
166
-                if (gettype($optimization)!="array") {
167
-                   continue; 
168
-                }
164
+		$optimizations = array();
165
+			foreach ($json as $optimization) {
166
+				if (gettype($optimization)!="array") {
167
+				   continue; 
168
+				}
169 169
                 
170
-                foreach ($optimization as $otp1) {
171
-                    $optimizations[] = $otp1;
172
-                }
173
-            }
170
+				foreach ($optimization as $otp1) {
171
+					$optimizations[] = $otp1;
172
+				}
173
+			}
174 174
             
175
-            $num = rand(0,sizeof($optimizations)-1);
175
+			$num = rand(0,sizeof($optimizations)-1);
176 176
             
177
-            $rOptimization = $optimizations[$num];
177
+			$rOptimization = $optimizations[$num];
178 178
             
179
-            return $rOptimization['optimization_problem_id'];
180
-    }
179
+			return $rOptimization['optimization_problem_id'];
180
+	}
181 181
     
182
-    public function getAddresses($opt_id)
183
-    {
184
-        if ($opt_id==null) {
185
-            return null;
186
-        }
182
+	public function getAddresses($opt_id)
183
+	{
184
+		if ($opt_id==null) {
185
+			return null;
186
+		}
187 187
         
188
-        $params = array("optimization_problem_id" => $opt_id );
188
+		$params = array("optimization_problem_id" => $opt_id );
189 189
         
190
-        $optimization = (array)$this->get($params);
190
+		$optimization = (array)$this->get($params);
191 191
         
192
-        $addresses = $optimization["addresses"];
192
+		$addresses = $optimization["addresses"];
193 193
         
194
-        return $addresses;
195
-    }
194
+		return $addresses;
195
+	}
196 196
     
197
-    public function getRandomAddressFromOptimization($opt_id)
198
-    {
199
-        $addresses = (array)$this->getAddresses($opt_id);
197
+	public function getRandomAddressFromOptimization($opt_id)
198
+	{
199
+		$addresses = (array)$this->getAddresses($opt_id);
200 200
         
201
-        if ($addresses==null) {
202
-            echo "There are no addresses in this optimization!.. Try again.";
203
-            return null;
204
-        }
201
+		if ($addresses==null) {
202
+			echo "There are no addresses in this optimization!.. Try again.";
203
+			return null;
204
+		}
205 205
         
206
-        $num = rand(0, sizeof($addresses)-1);
206
+		$num = rand(0, sizeof($addresses)-1);
207 207
         
208
-        $rAddress = $addresses[$num];
208
+		$rAddress = $addresses[$num];
209 209
         
210
-        return $rAddress;
211
-    }
210
+		return $rAddress;
211
+	}
212 212
     
213
-    public function removeAddress($params)
214
-    {
215
-        $response = Route4Me::makeRequst(array(
216
-            'url'    => Endpoint::ADDRESS_V4,
217
-            'method' => 'DELETE',
218
-            'query'  => array(
219
-                'optimization_problem_id' => isset($params['optimization_problem_id'])
220
-                                               ? $params['optimization_problem_id'] : null,
221
-                'route_destination_id'    => isset($params['route_destination_id'])
222
-                                               ? $params['route_destination_id'] : null,
223
-            )
224
-        ));
213
+	public function removeAddress($params)
214
+	{
215
+		$response = Route4Me::makeRequst(array(
216
+			'url'    => Endpoint::ADDRESS_V4,
217
+			'method' => 'DELETE',
218
+			'query'  => array(
219
+				'optimization_problem_id' => isset($params['optimization_problem_id'])
220
+											   ? $params['optimization_problem_id'] : null,
221
+				'route_destination_id'    => isset($params['route_destination_id'])
222
+											   ? $params['route_destination_id'] : null,
223
+			)
224
+		));
225 225
         
226
-        return $response;
227
-    }
226
+		return $response;
227
+	}
228 228
     
229
-    public function removeOptimization($params)
230
-    {
231
-        $response = Route4Me::makeRequst(array(
232
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
233
-            'method' => 'DELETE',
234
-            'query'  => array(
235
-                'redirect' => isset($params['redirect']) ? $params['redirect'] : null,
236
-            ),
237
-            'body'   => array(
238
-                'optimization_problem_ids' => isset($params['optimization_problem_ids'])
239
-                                                ? $params['optimization_problem_ids'] : null,
240
-            )
241
-        ));
229
+	public function removeOptimization($params)
230
+	{
231
+		$response = Route4Me::makeRequst(array(
232
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
233
+			'method' => 'DELETE',
234
+			'query'  => array(
235
+				'redirect' => isset($params['redirect']) ? $params['redirect'] : null,
236
+			),
237
+			'body'   => array(
238
+				'optimization_problem_ids' => isset($params['optimization_problem_ids'])
239
+												? $params['optimization_problem_ids'] : null,
240
+			)
241
+		));
242 242
         
243
-        return $response;
244
-    }
243
+		return $response;
244
+	}
245 245
     
246
-    public function getHybridOptimization($params)
247
-    {
248
-        $optimize = Route4Me::makeRequst(array(
249
-            'url'    => Endpoint::HYBRID_DATE_OPTIMIZATION,
250
-            'method' => 'GET',
251
-            'query'  => array(
252
-                'target_date_string'      => isset($params['target_date_string'])
253
-                                               ? $params['target_date_string'] : null,
254
-                'timezone_offset_minutes' => isset($params['timezone_offset_minutes'])
255
-                                               ? $params['timezone_offset_minutes'] : null
256
-            )
257
-        ));
246
+	public function getHybridOptimization($params)
247
+	{
248
+		$optimize = Route4Me::makeRequst(array(
249
+			'url'    => Endpoint::HYBRID_DATE_OPTIMIZATION,
250
+			'method' => 'GET',
251
+			'query'  => array(
252
+				'target_date_string'      => isset($params['target_date_string'])
253
+											   ? $params['target_date_string'] : null,
254
+				'timezone_offset_minutes' => isset($params['timezone_offset_minutes'])
255
+											   ? $params['timezone_offset_minutes'] : null
256
+			)
257
+		));
258 258
 
259
-        return $optimize;
260
-    }
259
+		return $optimize;
260
+	}
261 261
     
262
-    Public function addDepotsToHybrid($params)
263
-    {
264
-        $depots = Route4Me::makeRequst(array( 
265
-            'url'    => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT,
266
-            'method' => 'POST',
267
-            'query'  => array(
268
-                'optimization_problem_id' => isset($params['optimization_problem_id'])
269
-                                               ? $params['optimization_problem_id'] : null,
270
-                ),
271
-            'body'   => array(
272
-                'optimization_problem_id' => isset($params['optimization_problem_id'])
273
-                                               ? $params['optimization_problem_id'] : null,
274
-                'delete_old_depots'       => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null,
275
-                'new_depots'              => isset($params['new_depots']) ? $params['new_depots'] : null,
276
-            )
277
-        ));
262
+	Public function addDepotsToHybrid($params)
263
+	{
264
+		$depots = Route4Me::makeRequst(array( 
265
+			'url'    => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT,
266
+			'method' => 'POST',
267
+			'query'  => array(
268
+				'optimization_problem_id' => isset($params['optimization_problem_id'])
269
+											   ? $params['optimization_problem_id'] : null,
270
+				),
271
+			'body'   => array(
272
+				'optimization_problem_id' => isset($params['optimization_problem_id'])
273
+											   ? $params['optimization_problem_id'] : null,
274
+				'delete_old_depots'       => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null,
275
+				'new_depots'              => isset($params['new_depots']) ? $params['new_depots'] : null,
276
+			)
277
+		));
278 278
         
279
-        return $depots;
280
-    }
279
+		return $depots;
280
+	}
281 281
 }
Please login to merge, or discard this patch.
src/Route4Me/Order.php 1 patch
Indentation   +296 added lines, -296 removed lines patch added patch discarded remove patch
@@ -6,378 +6,378 @@
 block discarded – undo
6 6
 
7 7
 class Order extends Common
8 8
 {
9
-    public $address_1;
10
-    public $address_2;
11
-    public $cached_lat;
12
-    public $cached_lng;
13
-    public $curbside_lat;
14
-    public $curbside_lng;
15
-    public $address_alias;
16
-    public $address_city;
17
-    public $EXT_FIELD_first_name;
18
-    public $EXT_FIELD_last_name;
19
-    public $EXT_FIELD_email;
20
-    public $EXT_FIELD_phone;
21
-    public $EXT_FIELD_custom_data;
9
+	public $address_1;
10
+	public $address_2;
11
+	public $cached_lat;
12
+	public $cached_lng;
13
+	public $curbside_lat;
14
+	public $curbside_lng;
15
+	public $address_alias;
16
+	public $address_city;
17
+	public $EXT_FIELD_first_name;
18
+	public $EXT_FIELD_last_name;
19
+	public $EXT_FIELD_email;
20
+	public $EXT_FIELD_phone;
21
+	public $EXT_FIELD_custom_data;
22 22
     
23
-    public $color;
24
-    public $order_icon;
25
-    public $local_time_window_start;
26
-    public $local_time_window_end;
27
-    public $local_time_window_start_2;
28
-    public $local_time_window_end_2;
29
-    public $service_time;
23
+	public $color;
24
+	public $order_icon;
25
+	public $local_time_window_start;
26
+	public $local_time_window_end;
27
+	public $local_time_window_start_2;
28
+	public $local_time_window_end_2;
29
+	public $service_time;
30 30
     
31
-    public $day_scheduled_for_YYMMDD;
31
+	public $day_scheduled_for_YYMMDD;
32 32
     
33
-    public $route_id;
34
-    public $redirect;
35
-    public $optimization_problem_id;
36
-    public $order_id;
37
-    public $order_ids;
33
+	public $route_id;
34
+	public $redirect;
35
+	public $optimization_problem_id;
36
+	public $order_id;
37
+	public $order_ids;
38 38
     
39
-    public $day_added_YYMMDD;
40
-    public $scheduled_for_YYMMDD;
41
-    public $fields;
42
-    public $offset;
43
-    public $limit;
44
-    public $query;
39
+	public $day_added_YYMMDD;
40
+	public $scheduled_for_YYMMDD;
41
+	public $fields;
42
+	public $offset;
43
+	public $limit;
44
+	public $query;
45 45
     
46
-    public $created_timestamp;
47
-    public $order_status_id;
48
-    public $member_id;
49
-    public $address_state_id;
50
-    public $address_country_id;
51
-    public $address_zip;
52
-    public $in_route_count;
53
-    public $last_visited_timestamp;
54
-    public $last_routed_timestamp;
55
-    public $local_timezone_string;
56
-    public $is_validated;
57
-    public $is_pending;
58
-    public $is_accepted;
59
-    public $is_started;
60
-    public $is_completed;
61
-    public $custom_user_fields;
46
+	public $created_timestamp;
47
+	public $order_status_id;
48
+	public $member_id;
49
+	public $address_state_id;
50
+	public $address_country_id;
51
+	public $address_zip;
52
+	public $in_route_count;
53
+	public $last_visited_timestamp;
54
+	public $last_routed_timestamp;
55
+	public $local_timezone_string;
56
+	public $is_validated;
57
+	public $is_pending;
58
+	public $is_accepted;
59
+	public $is_started;
60
+	public $is_completed;
61
+	public $custom_user_fields;
62 62
     
63
-    public static function fromArray(array $params) {
64
-        $order = new Order();
65
-        foreach ($params as $key => $value) {
66
-            if (property_exists($order, $key)) {
67
-                $order->{$key} = $value;
68
-            }
69
-        }
63
+	public static function fromArray(array $params) {
64
+		$order = new Order();
65
+		foreach ($params as $key => $value) {
66
+			if (property_exists($order, $key)) {
67
+				$order->{$key} = $value;
68
+			}
69
+		}
70 70
         
71
-        return $order;
72
-    }
71
+		return $order;
72
+	}
73 73
     
74
-    /**
75
-     * @param Order $params
76
-     */
77
-    public static function addOrder($params)
78
-    {
79
-        $body = array();
74
+	/**
75
+	 * @param Order $params
76
+	 */
77
+	public static function addOrder($params)
78
+	{
79
+		$body = array();
80 80
         
81
-        $allAddOrderParameters = array('address_1', 'address_2', 'member_id', 'cached_lat', 'cached_lng', 'curbside_lat', 
82
-        'curbside_lng', 'color', 'order_icon', 'day_scheduled_for_YYMMDD', 'address_alias', 'address_city', 'address_state_id', 
83
-        'address_country_id', 'address_zip', 'local_time_window_start', 'local_time_window_end', 'local_time_window_start_2', 
84
-        'local_time_window_end_2', 'service_time', 'local_timezone_string', 'EXT_FIELD_first_name', 'EXT_FIELD_last_name', 
85
-        'EXT_FIELD_email', 'EXT_FIELD_phone', 'EXT_FIELD_custom_data', 'is_validated', 'is_pending', 'is_accepted', 'is_started', 
86
-        'is_completed', 'custom_user_fields');
81
+		$allAddOrderParameters = array('address_1', 'address_2', 'member_id', 'cached_lat', 'cached_lng', 'curbside_lat', 
82
+		'curbside_lng', 'color', 'order_icon', 'day_scheduled_for_YYMMDD', 'address_alias', 'address_city', 'address_state_id', 
83
+		'address_country_id', 'address_zip', 'local_time_window_start', 'local_time_window_end', 'local_time_window_start_2', 
84
+		'local_time_window_end_2', 'service_time', 'local_timezone_string', 'EXT_FIELD_first_name', 'EXT_FIELD_last_name', 
85
+		'EXT_FIELD_email', 'EXT_FIELD_phone', 'EXT_FIELD_custom_data', 'is_validated', 'is_pending', 'is_accepted', 'is_started', 
86
+		'is_completed', 'custom_user_fields');
87 87
         
88
-        foreach ($allAddOrderParameters as $addOrderParameter) {
89
-            if (isset($params->{$addOrderParameter})) $body[$addOrderParameter] = $params->{$addOrderParameter};
90
-        }
88
+		foreach ($allAddOrderParameters as $addOrderParameter) {
89
+			if (isset($params->{$addOrderParameter})) $body[$addOrderParameter] = $params->{$addOrderParameter};
90
+		}
91 91
        
92
-        $response = Route4Me::makeRequst(array(
93
-            'url'    => Endpoint::ORDER_V4,
94
-            'method' => 'POST',
95
-            'body'   => $body
96
-        ));
92
+		$response = Route4Me::makeRequst(array(
93
+			'url'    => Endpoint::ORDER_V4,
94
+			'method' => 'POST',
95
+			'body'   => $body
96
+		));
97 97
 
98
-        return $response;
99
-    }
98
+		return $response;
99
+	}
100 100
 
101
-    public static function addOrder2Route($params, $body)
102
-    {
103
-        $response = Route4Me::makeRequst(array(
104
-            'url'    => Endpoint::ROUTE_V4,
105
-            'method' => 'PUT',
106
-            'query'  => array(
107
-                'route_id' => isset($params->route_id) ? $params->route_id : null,
108
-                'redirect' => isset($params->redirect) ? $params->redirect : null
109
-            ),
110
-            'body' => (array)$body
111
-        ));
101
+	public static function addOrder2Route($params, $body)
102
+	{
103
+		$response = Route4Me::makeRequst(array(
104
+			'url'    => Endpoint::ROUTE_V4,
105
+			'method' => 'PUT',
106
+			'query'  => array(
107
+				'route_id' => isset($params->route_id) ? $params->route_id : null,
108
+				'redirect' => isset($params->redirect) ? $params->redirect : null
109
+			),
110
+			'body' => (array)$body
111
+		));
112 112
 
113
-        return $response;
114
-    }
113
+		return $response;
114
+	}
115 115
     
116
-    public static function addOrder2Optimization($params, $body)
117
-    {
118
-        $response = Route4Me::makeRequst(array(
119
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
120
-            'method' => 'PUT',
121
-            'query'  => array(
122
-                'optimization_problem_id' =>  isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null,
123
-                'redirect'                => isset($params['redirect']) ? $params['redirect'] : null,
124
-                'device_type'             => isset($params['device_type']) ? $params['device_type'] : null
125
-            ),
126
-            'body'  => (array)$body
127
-        ));
116
+	public static function addOrder2Optimization($params, $body)
117
+	{
118
+		$response = Route4Me::makeRequst(array(
119
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
120
+			'method' => 'PUT',
121
+			'query'  => array(
122
+				'optimization_problem_id' =>  isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null,
123
+				'redirect'                => isset($params['redirect']) ? $params['redirect'] : null,
124
+				'device_type'             => isset($params['device_type']) ? $params['device_type'] : null
125
+			),
126
+			'body'  => (array)$body
127
+		));
128 128
 
129
-        return $response;
130
-    }
129
+		return $response;
130
+	}
131 131
     
132
-    public static function getOrder($params)
133
-    {
134
-        $query = array();
135
-        $allGetParameters = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' );
132
+	public static function getOrder($params)
133
+	{
134
+		$query = array();
135
+		$allGetParameters = array('order_id', 'fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' );
136 136
         
137
-        foreach ($allGetParameters as $getParameter) {
138
-            if (isset($params->{$getParameter})) $query[$getParameter] = $params->{$getParameter};
139
-        }
137
+		foreach ($allGetParameters as $getParameter) {
138
+			if (isset($params->{$getParameter})) $query[$getParameter] = $params->{$getParameter};
139
+		}
140 140
 
141
-        $response = Route4Me::makeRequst(array(
142
-            'url'    => Endpoint::ORDER_V4,
143
-            'method' => 'GET',
144
-            'query'  => $query
145
-        ));
141
+		$response = Route4Me::makeRequst(array(
142
+			'url'    => Endpoint::ORDER_V4,
143
+			'method' => 'GET',
144
+			'query'  => $query
145
+		));
146 146
 
147
-        return $response;
148
-    }
147
+		return $response;
148
+	}
149 149
     
150
-    public static function getOrders($params)
151
-    {
152
-        $response = Route4Me::makeRequst(array(
153
-            'url'    => Endpoint::ORDER_V4,
154
-            'method' => 'GET',
155
-            'query'  => array(
156
-                'offset' => isset($params->offset) ? $params->offset : null,
157
-                'limit'  => isset($params->limit) ? $params->limit : null
158
-            )
159
-        ));
150
+	public static function getOrders($params)
151
+	{
152
+		$response = Route4Me::makeRequst(array(
153
+			'url'    => Endpoint::ORDER_V4,
154
+			'method' => 'GET',
155
+			'query'  => array(
156
+				'offset' => isset($params->offset) ? $params->offset : null,
157
+				'limit'  => isset($params->limit) ? $params->limit : null
158
+			)
159
+		));
160 160
 
161
-        return $response;
162
-    }
161
+		return $response;
162
+	}
163 163
     
164
-    public function getRandomOrderId($offset, $limit)
165
-    {
166
-        $params = array('offset' => $offset, 'limit' => $limit);
164
+	public function getRandomOrderId($offset, $limit)
165
+	{
166
+		$params = array('offset' => $offset, 'limit' => $limit);
167 167
         
168
-        $orders = self::getOrders($params);
168
+		$orders = self::getOrders($params);
169 169
         
170
-        if (is_null($orders)) {
171
-            return null;
172
-        }
170
+		if (is_null($orders)) {
171
+			return null;
172
+		}
173 173
         
174
-        if (!isset($orders['results'])) {
175
-            return null;
176
-        }
174
+		if (!isset($orders['results'])) {
175
+			return null;
176
+		}
177 177
         
178
-        $randomIndex = rand(0, sizeof($orders['results']) - 1);
178
+		$randomIndex = rand(0, sizeof($orders['results']) - 1);
179 179
         
180
-        $order = $orders['results'][$randomIndex];
180
+		$order = $orders['results'][$randomIndex];
181 181
         
182
-        return $order['order_id'];
183
-    }
182
+		return $order['order_id'];
183
+	}
184 184
     
185
-    public function getRandomOrder($offset, $limit)
186
-    {
187
-        $params = array('offset' => $offset, 'limit' => $limit);
185
+	public function getRandomOrder($offset, $limit)
186
+	{
187
+		$params = array('offset' => $offset, 'limit' => $limit);
188 188
         
189
-        $orders = self::getOrders($params);
189
+		$orders = self::getOrders($params);
190 190
         
191
-        if (is_null($orders)) {
192
-            return null;
193
-        }
191
+		if (is_null($orders)) {
192
+			return null;
193
+		}
194 194
         
195
-        if (!isset($orders['results'])) {
196
-            return null;
197
-        }
195
+		if (!isset($orders['results'])) {
196
+			return null;
197
+		}
198 198
         
199
-        $randomIndex = rand(0, sizeof($orders['results']) - 1);
199
+		$randomIndex = rand(0, sizeof($orders['results']) - 1);
200 200
         
201
-        $order = $orders['results'][$randomIndex];
201
+		$order = $orders['results'][$randomIndex];
202 202
         
203
-        return $order;
204
-    }
203
+		return $order;
204
+	}
205 205
     
206
-    public static function removeOrder($params)
207
-    {
208
-        $response = Route4Me::makeRequst(array(
209
-            'url'    => Endpoint::ORDER_V4,
210
-            'method' => 'DELETE',
211
-            'body'   => array(
212
-                'order_ids' =>  isset($params->order_ids) ? $params->order_ids : null
213
-            )
214
-        ));
206
+	public static function removeOrder($params)
207
+	{
208
+		$response = Route4Me::makeRequst(array(
209
+			'url'    => Endpoint::ORDER_V4,
210
+			'method' => 'DELETE',
211
+			'body'   => array(
212
+				'order_ids' =>  isset($params->order_ids) ? $params->order_ids : null
213
+			)
214
+		));
215 215
 
216
-        return $response;
217
-    }
216
+		return $response;
217
+	}
218 218
     
219
-    public static function updateOrder($body)
220
-    {
221
-        $response = Route4Me::makeRequst(array(
222
-            'url'    => Endpoint::ORDER_V4,
223
-            'method' => 'PUT',
224
-            'body'   => (array)$body
225
-        ));
219
+	public static function updateOrder($body)
220
+	{
221
+		$response = Route4Me::makeRequst(array(
222
+			'url'    => Endpoint::ORDER_V4,
223
+			'method' => 'PUT',
224
+			'body'   => (array)$body
225
+		));
226 226
 
227
-        return $response;
228
-    }
227
+		return $response;
228
+	}
229 229
     
230
-    public static function searchOrder($params)
231
-    {
232
-        $query = array();
233
-        $allSearchParameters = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' );
230
+	public static function searchOrder($params)
231
+	{
232
+		$query = array();
233
+		$allSearchParameters = array('fields', 'day_added_YYMMDD', 'scheduled_for_YYMMDD', 'query', 'offset', 'limit' );
234 234
         
235
-        foreach ($allSearchParameters as $searchParameter) {
236
-            if (isset($params->{$searchParameter})) $query[$searchParameter] = $params->{$searchParameter};
237
-        }
235
+		foreach ($allSearchParameters as $searchParameter) {
236
+			if (isset($params->{$searchParameter})) $query[$searchParameter] = $params->{$searchParameter};
237
+		}
238 238
         
239
-        $response = Route4Me::makeRequst(array(
240
-            'url'    => Endpoint::ORDER_V4,
241
-            'method' => 'GET',
242
-            'query'  => $query
243
-        ));
239
+		$response = Route4Me::makeRequst(array(
240
+			'url'    => Endpoint::ORDER_V4,
241
+			'method' => 'GET',
242
+			'query'  => $query
243
+		));
244 244
 
245
-        return $response;
246
-    }
245
+		return $response;
246
+	}
247 247
     
248
-    public static function validateLatitude($lat)
249
-    {
250
-        if (!is_numeric($lat)) {
251
-            return false;
252
-        }
248
+	public static function validateLatitude($lat)
249
+	{
250
+		if (!is_numeric($lat)) {
251
+			return false;
252
+		}
253 253
         
254
-        if ($lat>90 || $lat<-90) {
255
-            return false;
256
-        }
254
+		if ($lat>90 || $lat<-90) {
255
+			return false;
256
+		}
257 257
         
258
-        return true;
259
-    }
258
+		return true;
259
+	}
260 260
     
261
-    public static function validateLongitude($lng)
262
-    {
263
-        if (!is_numeric($lng)) {
264
-            return false;
265
-        }
261
+	public static function validateLongitude($lng)
262
+	{
263
+		if (!is_numeric($lng)) {
264
+			return false;
265
+		}
266 266
         
267
-        if ($lng>180 || $lng<-180) {
268
-            return false;
269
-        }
267
+		if ($lng>180 || $lng<-180) {
268
+			return false;
269
+		}
270 270
         
271
-        return true;
272
-    }
271
+		return true;
272
+	}
273 273
     
274
-    public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping)
275
-    {
276
-        $max_line_length = 512;
277
-        $delemietr = ',';
274
+	public function addOrdersFromCsvFile($csvFileHandle, $ordersFieldsMapping)
275
+	{
276
+		$max_line_length = 512;
277
+		$delemietr = ',';
278 278
         
279
-        $results = array();
280
-        $results['fail'] = array();
281
-        $results['success'] = array();
279
+		$results = array();
280
+		$results['fail'] = array();
281
+		$results['success'] = array();
282 282
         
283
-        $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
283
+		$columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
284 284
         
285
-        $allOrderFields = array("curbside_lat","curbside_lng","color","day_scheduled_for_YYMMDD",
286
-                "address_alias","address_1","address_2","local_time_window_start","local_time_window_end","local_time_window_start_2",
287
-                "local_time_window_end_2","service_time","EXT_FIELD_first_name","EXT_FIELD_last_name","EXT_FIELD_email","EXT_FIELD_phone",
288
-                "EXT_FIELD_custom_data","order_icon");
285
+		$allOrderFields = array("curbside_lat","curbside_lng","color","day_scheduled_for_YYMMDD",
286
+				"address_alias","address_1","address_2","local_time_window_start","local_time_window_end","local_time_window_start_2",
287
+				"local_time_window_end_2","service_time","EXT_FIELD_first_name","EXT_FIELD_last_name","EXT_FIELD_email","EXT_FIELD_phone",
288
+				"EXT_FIELD_custom_data","order_icon");
289 289
         
290
-        if (!empty($columns)) {
291
-             array_push($results['fail'],'Empty CSV table');
292
-             return ($results);
293
-        }
290
+		if (!empty($columns)) {
291
+			 array_push($results['fail'],'Empty CSV table');
292
+			 return ($results);
293
+		}
294 294
                  
295
-        $iRow=1;
295
+		$iRow=1;
296 296
         
297
-        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) {
298
-            if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) {
297
+		while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) {
298
+			if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) {
299 299
                 
300
-                $cached_lat = 0.000;
300
+				$cached_lat = 0.000;
301 301
                 
302
-                if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) {
303
-                    array_push($results['fail'], "$iRow --> Wrong cached_lat"); 
304
-                    $iRow++;
305
-                    continue;
306
-                } else {
307
-                    $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]);
308
-                }
302
+				if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) {
303
+					array_push($results['fail'], "$iRow --> Wrong cached_lat"); 
304
+					$iRow++;
305
+					continue;
306
+				} else {
307
+					$cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]);
308
+				}
309 309
                 
310
-                $cached_lng = 0.000;
310
+				$cached_lng = 0.000;
311 311
                 
312
-                if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) {
313
-                    array_push($results['fail'], "$iRow --> Wrong cached_lng"); 
314
-                    $iRow++;
315
-                    continue;
316
-                } else {
317
-                    $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]);
318
-                }
312
+				if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) {
313
+					array_push($results['fail'], "$iRow --> Wrong cached_lng"); 
314
+					$iRow++;
315
+					continue;
316
+				} else {
317
+					$cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]);
318
+				}
319 319
                 
320
-                if (isset($ordersFieldsMapping['curbside_lat'])) {
321
-                    if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) {
322
-                        array_push($results['fail'], "$iRow --> Wrong curbside_lat"); 
323
-                        $iRow++;
324
-                        continue;
325
-                    }
326
-                }
320
+				if (isset($ordersFieldsMapping['curbside_lat'])) {
321
+					if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) {
322
+						array_push($results['fail'], "$iRow --> Wrong curbside_lat"); 
323
+						$iRow++;
324
+						continue;
325
+					}
326
+				}
327 327
                 
328
-                if (isset($ordersFieldsMapping['curbside_lng'])) {
329
-                    if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) {
330
-                        array_push($results['fail'], "$iRow --> Wrong curbside_lng"); 
331
-                        $iRow++;
332
-                        continue;
333
-                    }
334
-                }
328
+				if (isset($ordersFieldsMapping['curbside_lng'])) {
329
+					if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) {
330
+						array_push($results['fail'], "$iRow --> Wrong curbside_lng"); 
331
+						$iRow++;
332
+						continue;
333
+					}
334
+				}
335 335
                 
336
-                $address = $rows[$ordersFieldsMapping['address_1']];
336
+				$address = $rows[$ordersFieldsMapping['address_1']];
337 337
                 
338
-                if (isset($ordersFieldsMapping['order_city'])) {
339
-                    $address.=', '.$rows[$ordersFieldsMapping['order_city']];
340
-                }
338
+				if (isset($ordersFieldsMapping['order_city'])) {
339
+					$address.=', '.$rows[$ordersFieldsMapping['order_city']];
340
+				}
341 341
                 
342
-                if (isset($ordersFieldsMapping['order_state_id'])) {
343
-                    $address.=', '.$rows[$ordersFieldsMapping['order_state_id']];
344
-                }
342
+				if (isset($ordersFieldsMapping['order_state_id'])) {
343
+					$address.=', '.$rows[$ordersFieldsMapping['order_state_id']];
344
+				}
345 345
                 
346
-                if (isset($ordersFieldsMapping['order_zip_code'])) {
347
-                    $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']];
348
-                }
346
+				if (isset($ordersFieldsMapping['order_zip_code'])) {
347
+					$address.=', '.$rows[$ordersFieldsMapping['order_zip_code']];
348
+				}
349 349
                 
350
-                if (isset($ordersFieldsMapping['order_country_id'])) {
351
-                    $address.=', '.$rows[$ordersFieldsMapping['order_country_id']];
352
-                }
350
+				if (isset($ordersFieldsMapping['order_country_id'])) {
351
+					$address.=', '.$rows[$ordersFieldsMapping['order_country_id']];
352
+				}
353 353
                 
354
-                echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>";
354
+				echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>";
355 355
                 
356
-                $parametersArray = array();
356
+				$parametersArray = array();
357 357
                 
358
-                $parametersArray["cached_lat"] = $cached_lat;
359
-                $parametersArray["cached_lng"] = $cached_lng;
358
+				$parametersArray["cached_lat"] = $cached_lat;
359
+				$parametersArray["cached_lng"] = $cached_lng;
360 360
                 
361 361
                 
362
-                foreach ($allOrderFields as $orderField) {
363
-                    if (isset($ordersFieldsMapping[$orderField])) {
364
-                        $parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]];
365
-                    }
366
-                }
362
+				foreach ($allOrderFields as $orderField) {
363
+					if (isset($ordersFieldsMapping[$orderField])) {
364
+						$parametersArray[$orderField] = $rows[$ordersFieldsMapping[$orderField]];
365
+					}
366
+				}
367 367
                 
368
-                $orderParameters = Order::fromArray($parametersArray);
368
+				$orderParameters = Order::fromArray($parametersArray);
369 369
 
370
-                $order = new Order();
370
+				$order = new Order();
371 371
                 
372
-                $orderResults = $order->addOrder($orderParameters);
372
+				$orderResults = $order->addOrder($orderParameters);
373 373
                 
374
-                array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
375
-            }
376
-            else {
377
-                array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
378
-            }
374
+				array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
375
+			}
376
+			else {
377
+				array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
378
+			}
379 379
             
380
-            $iRow++;
381
-        }
382
-    }
380
+			$iRow++;
381
+		}
382
+	}
383 383
 }
Please login to merge, or discard this patch.
src/Route4Me/Territory.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 
70 70
 	public static function addTerritory($params)
71 71
 	{
72
-	    $terParams = array();
72
+		$terParams = array();
73 73
 
74
-        if (isset($params->territory['type'])) $terParams['type'] = $params->territory['type'];
75
-        if (isset($params->territory['data'])) $terParams['data'] = $params->territory['data'];
74
+		if (isset($params->territory['type'])) $terParams['type'] = $params->territory['type'];
75
+		if (isset($params->territory['data'])) $terParams['data'] = $params->territory['data'];
76 76
         
77 77
 		$response = Route4Me::makeRequst(array(
78 78
 			'url'    => Endpoint::TERRITORY_V4,
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
 	
103 103
 	public function updateTerritory($params)
104 104
 	{
105
-	    //var_dump($params); die("");
105
+		//var_dump($params); die("");
106 106
 		$response = Route4Me::makeRequst(array(
107 107
 			'url'    => Endpoint::TERRITORY_V4,
108 108
 			'method' => 'PUT',
109 109
 			'query'  => array(
110
-                'territory_id'  => isset($params->territory_id) ? $params->territory_id : null
111
-            ),
112
-            'body'   => array(
113
-                'territory_name'   => isset($params->territory_name) ? $params->territory_name : null,
114
-                'member_id'        => isset($params->member_id) ? $params->member_id : null,
115
-                'territory_color'  => isset($params->territory_color) ? $params->territory_color : null,
116
-                'territory'        => isset($params->territory) ? $params->territory : null
117
-            ) 
110
+				'territory_id'  => isset($params->territory_id) ? $params->territory_id : null
111
+			),
112
+			'body'   => array(
113
+				'territory_name'   => isset($params->territory_name) ? $params->territory_name : null,
114
+				'member_id'        => isset($params->member_id) ? $params->member_id : null,
115
+				'territory_color'  => isset($params->territory_color) ? $params->territory_color : null,
116
+				'territory'        => isset($params->territory) ? $params->territory : null
117
+			) 
118 118
 
119 119
 		));
120 120
 
Please login to merge, or discard this patch.
src/Route4Me/Route4Me.php 1 patch
Indentation   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -7,343 +7,343 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Route4Me/Route.php 1 patch
Indentation   +416 added lines, -416 removed lines patch added patch discarded remove patch
@@ -9,480 +9,480 @@
 block discarded – undo
9 9
 
10 10
 class Route extends Common
11 11
 {
12
-    public $route_id;
13
-    public $member_id;
14
-    public $route_destination_id;
15
-    public $optimization_problem_id;
16
-    public $vehicle_alias;
17
-    public $driver_alias;
18
-    public $trip_distance;
19
-    public $mpg;
20
-    public $gas_price;
21
-    public $route_duration_sec;
22
-    public $destination_count;
23
-    public $parameters;
24
-    public $addresses = array();
25
-    public $links = array();
26
-    public $directions = array();
27
-    public $path = array();
28
-    public $tracking_history = array();
29
-    public $recipient_email;
30
-    public $httpheaders;
31
-    public $is_unrouted;
32
-    public $time;
12
+	public $route_id;
13
+	public $member_id;
14
+	public $route_destination_id;
15
+	public $optimization_problem_id;
16
+	public $vehicle_alias;
17
+	public $driver_alias;
18
+	public $trip_distance;
19
+	public $mpg;
20
+	public $gas_price;
21
+	public $route_duration_sec;
22
+	public $destination_count;
23
+	public $parameters;
24
+	public $addresses = array();
25
+	public $links = array();
26
+	public $directions = array();
27
+	public $path = array();
28
+	public $tracking_history = array();
29
+	public $recipient_email;
30
+	public $httpheaders;
31
+	public $is_unrouted;
32
+	public $time;
33 33
     
34
-    public $dev_lat;
35
-    public $dev_lng;
34
+	public $dev_lat;
35
+	public $dev_lng;
36 36
     
37
-    public $user_route_rating;
38
-    public $member_email;
39
-    public $member_first_name;
40
-    public $member_last_name;
41
-    public $channel_name;
42
-    public $route_cost;
43
-    public $route_revenue;
44
-    public $net_revenue_per_distance_unit;
45
-    public $created_timestamp;
46
-    public $planned_total_route_duration;
47
-    public $actual_travel_distance;
48
-    public $actual_travel_time;
49
-    public $actual_footsteps;
50
-    public $working_time;
51
-    public $driving_time;
52
-    public $idling_time;
53
-    public $paying_miles;
54
-    public $geofence_polygon_type;
55
-    public $geofence_polygon_size;
56
-    public $notes;
57
-    public $member_config_storage;
37
+	public $user_route_rating;
38
+	public $member_email;
39
+	public $member_first_name;
40
+	public $member_last_name;
41
+	public $channel_name;
42
+	public $route_cost;
43
+	public $route_revenue;
44
+	public $net_revenue_per_distance_unit;
45
+	public $created_timestamp;
46
+	public $planned_total_route_duration;
47
+	public $actual_travel_distance;
48
+	public $actual_travel_time;
49
+	public $actual_footsteps;
50
+	public $working_time;
51
+	public $driving_time;
52
+	public $idling_time;
53
+	public $paying_miles;
54
+	public $geofence_polygon_type;
55
+	public $geofence_polygon_size;
56
+	public $notes;
57
+	public $member_config_storage;
58 58
 
59
-    public static function fromArray(array $params) 
60
-    {
61
-        $route = new Route();
62
-        $route->route_id                = Common::getValue($params, 'route_id');
63
-        $route->member_id               = Common::getValue($params, 'member_id');
64
-        $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
65
-        $route->vehicle_alias           = Common::getValue($params, 'vehicle_alias');
66
-        $route->driver_alias            = Common::getValue($params, 'driver_alias');
67
-        $route->trip_distance           = Common::getValue($params, 'trip_distance');
68
-        $route->mpg                     = Common::getValue($params, 'mpg');
69
-        $route->gas_price               = Common::getValue($params, 'gas_price');
70
-        $route->route_duration_sec      = Common::getvalue($params, 'route_duration_sec');
71
-        $route->destination_count       = Common::getvalue($params, 'destination_count');
72
-        $route->is_unrouted             = Common::getvalue($params, 'is_unrouted');
59
+	public static function fromArray(array $params) 
60
+	{
61
+		$route = new Route();
62
+		$route->route_id                = Common::getValue($params, 'route_id');
63
+		$route->member_id               = Common::getValue($params, 'member_id');
64
+		$route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
65
+		$route->vehicle_alias           = Common::getValue($params, 'vehicle_alias');
66
+		$route->driver_alias            = Common::getValue($params, 'driver_alias');
67
+		$route->trip_distance           = Common::getValue($params, 'trip_distance');
68
+		$route->mpg                     = Common::getValue($params, 'mpg');
69
+		$route->gas_price               = Common::getValue($params, 'gas_price');
70
+		$route->route_duration_sec      = Common::getvalue($params, 'route_duration_sec');
71
+		$route->destination_count       = Common::getvalue($params, 'destination_count');
72
+		$route->is_unrouted             = Common::getvalue($params, 'is_unrouted');
73 73
 
74
-        // Make RouteParameters
75
-        if (isset($params['parameters'])) {
76
-            $route->parameters = RouteParameters::fromArray($params['parameters']);
77
-        }
74
+		// Make RouteParameters
75
+		if (isset($params['parameters'])) {
76
+			$route->parameters = RouteParameters::fromArray($params['parameters']);
77
+		}
78 78
 
79
-        if (isset($params['addresses'])) {
80
-            $addresses = array();
81
-            foreach ($params['addresses'] as $address) {
82
-                $addresses[] = Address::fromArray($address);
83
-            }
79
+		if (isset($params['addresses'])) {
80
+			$addresses = array();
81
+			foreach ($params['addresses'] as $address) {
82
+				$addresses[] = Address::fromArray($address);
83
+			}
84 84
 
85
-            $route->addresses = $addresses;
86
-        }
85
+			$route->addresses = $addresses;
86
+		}
87 87
 
88
-        $route->links            = Common::getValue($params, 'links', array());
89
-        $route->directions       = Common::getValue($params, 'directions', array());
90
-        $route->path             = Common::getValue($params, 'path', array());
91
-        $route->tracking_history = Common::getValue($params, 'tracking_history', array());
88
+		$route->links            = Common::getValue($params, 'links', array());
89
+		$route->directions       = Common::getValue($params, 'directions', array());
90
+		$route->path             = Common::getValue($params, 'path', array());
91
+		$route->tracking_history = Common::getValue($params, 'tracking_history', array());
92 92
 
93
-        return $route;
94
-    }
93
+		return $route;
94
+	}
95 95
 
96
-    public static function getRoutes($routeId = null, $params = null)
97
-    {
98
-        $result = Route4Me::makeRequst(array(
99
-            'url'    => Endpoint::ROUTE_V4,
100
-            'method' => 'GET',
101
-            'query'  => array(
102
-                'api_key'                  => Route4Me::getApiKey(),
103
-                'route_id'                 => !is_null($routeId) ? implode(',', (array)$routeId) : null,
104
-                'route_path_output'        => isset($params['route_path_output']) ? $params['route_path_output'] : null,
105
-                'query'                    => isset($params['query']) ? $params['query'] : null,
106
-                'directions'               => isset($params['directions']) ? $params['directions'] : null,
107
-                'device_tracking_history'  => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null,
108
-                'limit'                    => isset($params['limit']) ? $params['limit'] : null,
109
-                'offset'                   => isset($params['offset']) ? $params['offset'] : null
110
-            )
111
-        ));
96
+	public static function getRoutes($routeId = null, $params = null)
97
+	{
98
+		$result = Route4Me::makeRequst(array(
99
+			'url'    => Endpoint::ROUTE_V4,
100
+			'method' => 'GET',
101
+			'query'  => array(
102
+				'api_key'                  => Route4Me::getApiKey(),
103
+				'route_id'                 => !is_null($routeId) ? implode(',', (array)$routeId) : null,
104
+				'route_path_output'        => isset($params['route_path_output']) ? $params['route_path_output'] : null,
105
+				'query'                    => isset($params['query']) ? $params['query'] : null,
106
+				'directions'               => isset($params['directions']) ? $params['directions'] : null,
107
+				'device_tracking_history'  => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null,
108
+				'limit'                    => isset($params['limit']) ? $params['limit'] : null,
109
+				'offset'                   => isset($params['offset']) ? $params['offset'] : null
110
+			)
111
+		));
112 112
         
113
-        if ($routeId) {
114
-            return Route::fromArray($result); die("");
115
-        } else {
116
-            $routes = array();
117
-            foreach ($result as $route) {
118
-                $routes[] = Route::fromArray($route);
119
-            }
120
-            return $routes;
121
-        }
122
-    }
113
+		if ($routeId) {
114
+			return Route::fromArray($result); die("");
115
+		} else {
116
+			$routes = array();
117
+			foreach ($result as $route) {
118
+				$routes[] = Route::fromArray($route);
119
+			}
120
+			return $routes;
121
+		}
122
+	}
123 123
 
124
-    public function getRoutePoints($routeId, $params)
125
-    {
126
-        $result = Route4Me::makeRequst(array(
127
-            'url'    => Endpoint::ROUTE_V4,
128
-            'method' => 'GET',
129
-            'query'  => array(
130
-                'api_key'           => Route4Me::getApiKey(),
131
-                'route_id'          => $routeId,
132
-                'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null,
133
-                'compress_path_points' => isset($params['compress_path_points']) ? $params['compress_path_points'] : null,
134
-                'directions'        => isset($params['directions']) ? $params['directions'] : null,
135
-            )
136
-        ));
124
+	public function getRoutePoints($routeId, $params)
125
+	{
126
+		$result = Route4Me::makeRequst(array(
127
+			'url'    => Endpoint::ROUTE_V4,
128
+			'method' => 'GET',
129
+			'query'  => array(
130
+				'api_key'           => Route4Me::getApiKey(),
131
+				'route_id'          => $routeId,
132
+				'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null,
133
+				'compress_path_points' => isset($params['compress_path_points']) ? $params['compress_path_points'] : null,
134
+				'directions'        => isset($params['directions']) ? $params['directions'] : null,
135
+			)
136
+		));
137 137
 
138
-        return $result;
139
-    }
138
+		return $result;
139
+	}
140 140
 
141
-    public function duplicateRoute($route_id)
142
-    {
143
-        $result = Route4Me::makeRequst(array(
144
-            'url'    => Endpoint::ROUTE_DUPLICATE,
145
-            'method' => 'GET',
146
-            'query'  => array(
147
-                'api_key'  => Route4Me::getApiKey(),
148
-                'route_id' => $route_id,
149
-                'to'       => 'none',
150
-            )
151
-        ));
141
+	public function duplicateRoute($route_id)
142
+	{
143
+		$result = Route4Me::makeRequst(array(
144
+			'url'    => Endpoint::ROUTE_DUPLICATE,
145
+			'method' => 'GET',
146
+			'query'  => array(
147
+				'api_key'  => Route4Me::getApiKey(),
148
+				'route_id' => $route_id,
149
+				'to'       => 'none',
150
+			)
151
+		));
152 152
         
153
-        return $result;
154
-    }
153
+		return $result;
154
+	}
155 155
     
156
-    public function resequenceRoute($params)
157
-    {
158
-        $result = Route4Me::makeRequst(array(
159
-            'url'    => Endpoint::ROUTE_V4,
160
-            'method' => 'PUT',
161
-            'query'  => array(
162
-                'api_key'              => Route4Me::getApiKey(),
163
-                'route_id'             => isset($params['route_id']) ? $params['route_id'] : null,
164
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
165
-            ),
166
-            'body'   => array(
167
-                'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
168
-            )
169
-        ));
156
+	public function resequenceRoute($params)
157
+	{
158
+		$result = Route4Me::makeRequst(array(
159
+			'url'    => Endpoint::ROUTE_V4,
160
+			'method' => 'PUT',
161
+			'query'  => array(
162
+				'api_key'              => Route4Me::getApiKey(),
163
+				'route_id'             => isset($params['route_id']) ? $params['route_id'] : null,
164
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
165
+			),
166
+			'body'   => array(
167
+				'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
168
+			)
169
+		));
170 170
         
171
-        return $result;
172
-    }
171
+		return $result;
172
+	}
173 173
     
174
-    public function resequenceAllAddresses($params)
175
-    {
176
-        $result = Route4Me::makeRequst(array(
177
-            'url'    => Endpoint::REOPTIMIZE_V3_2,
178
-            'method' => 'GET',
179
-            'query'  => array(
180
-                'api_key'              => Route4Me::getApiKey(),
181
-                'route_id'             => isset($params['route_id']) ? $params['route_id'] : null,
182
-                'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null,
183
-                'optimize'             => isset($params['optimize']) ? $params['optimize'] : null,
184
-            )
185
-        ));
174
+	public function resequenceAllAddresses($params)
175
+	{
176
+		$result = Route4Me::makeRequst(array(
177
+			'url'    => Endpoint::REOPTIMIZE_V3_2,
178
+			'method' => 'GET',
179
+			'query'  => array(
180
+				'api_key'              => Route4Me::getApiKey(),
181
+				'route_id'             => isset($params['route_id']) ? $params['route_id'] : null,
182
+				'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null,
183
+				'optimize'             => isset($params['optimize']) ? $params['optimize'] : null,
184
+			)
185
+		));
186 186
         
187
-        return $result;
188
-    }
187
+		return $result;
188
+	}
189 189
 
190
-    public function mergeRoutes($params)
191
-    {
192
-        $result = Route4Me::makeRequst(array(
193
-            'url'    => Endpoint::ROUTES_MERGE,
194
-            'method' => 'POST',
195
-            'query'  => array(
196
-                'api_key' => Route4Me::getApiKey(),
197
-              ),
198
-            'body'   => array(
199
-                'route_ids'     => isset($params['route_ids']) ? $params['route_ids'] : null,
200
-                'depot_address' => isset($params['depot_address']) ? $params['depot_address'] : null,
201
-                'remove_origin' => isset($params['remove_origin']) ? $params['remove_origin'] : null,
202
-                'depot_lat'     => isset($params['depot_lat']) ? $params['depot_lat'] : null,
203
-                'depot_lat'     => isset($params['depot_lat']) ? $params['depot_lat'] : null
204
-              ),
205
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
206
-        ));
190
+	public function mergeRoutes($params)
191
+	{
192
+		$result = Route4Me::makeRequst(array(
193
+			'url'    => Endpoint::ROUTES_MERGE,
194
+			'method' => 'POST',
195
+			'query'  => array(
196
+				'api_key' => Route4Me::getApiKey(),
197
+			  ),
198
+			'body'   => array(
199
+				'route_ids'     => isset($params['route_ids']) ? $params['route_ids'] : null,
200
+				'depot_address' => isset($params['depot_address']) ? $params['depot_address'] : null,
201
+				'remove_origin' => isset($params['remove_origin']) ? $params['remove_origin'] : null,
202
+				'depot_lat'     => isset($params['depot_lat']) ? $params['depot_lat'] : null,
203
+				'depot_lat'     => isset($params['depot_lat']) ? $params['depot_lat'] : null
204
+			  ),
205
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
206
+		));
207 207
         
208
-        return $result;
209
-    }
208
+		return $result;
209
+	}
210 210
     
211
-    public function shareRoute($params)
212
-    {
213
-        $result = Route4Me::makeRequst(array(
214
-            'url'    => Endpoint::ROUTE_SHARE,
215
-            'method' => 'POST',
216
-            'query'  => array(
217
-                'api_key'         => Route4Me::getApiKey(),
218
-                'route_id'        => isset($params['route_id']) ? $params['route_id'] : null,
219
-                'response_format' => isset($params['response_format']) ? $params['response_format'] : null,
220
-            ),
221
-            'body'  => array(
222
-                'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null,
223
-            ),
224
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
225
-        ));
211
+	public function shareRoute($params)
212
+	{
213
+		$result = Route4Me::makeRequst(array(
214
+			'url'    => Endpoint::ROUTE_SHARE,
215
+			'method' => 'POST',
216
+			'query'  => array(
217
+				'api_key'         => Route4Me::getApiKey(),
218
+				'route_id'        => isset($params['route_id']) ? $params['route_id'] : null,
219
+				'response_format' => isset($params['response_format']) ? $params['response_format'] : null,
220
+			),
221
+			'body'  => array(
222
+				'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null,
223
+			),
224
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
225
+		));
226 226
         
227
-        return $result;
228
-    }
227
+		return $result;
228
+	}
229 229
     
230
-    // Returns random route_id from existing routes between $offset and $offset+$limit
231
-    public function getRandomRouteId($offset, $limit)
232
-    {
233
-        $query['limit'] = !is_null($limit) ? $limit : 30;
234
-        $query['offset'] = !is_null($offset) ? $offset : 0;
230
+	// Returns random route_id from existing routes between $offset and $offset+$limit
231
+	public function getRandomRouteId($offset, $limit)
232
+	{
233
+		$query['limit'] = !is_null($limit) ? $limit : 30;
234
+		$query['offset'] = !is_null($offset) ? $offset : 0;
235 235
             
236
-        $json = Route4Me::makeRequst(array(
237
-            'url'    => Endpoint::ROUTE_V4,
238
-            'method' => 'GET',
239
-            'query'  => $query
240
-        ));
236
+		$json = Route4Me::makeRequst(array(
237
+			'url'    => Endpoint::ROUTE_V4,
238
+			'method' => 'GET',
239
+			'query'  => $query
240
+		));
241 241
         
242
-        if (sizeof($json)>0) {
243
-            $routes = array();
242
+		if (sizeof($json)>0) {
243
+			$routes = array();
244 244
             
245
-            foreach ($json as $route) {
246
-                $routes[] = Route::fromArray($route);
247
-            }
245
+			foreach ($json as $route) {
246
+				$routes[] = Route::fromArray($route);
247
+			}
248 248
             
249
-            $num = rand(0, sizeof($routes) - 1);
250
-            $rRoute = (array)$routes[$num];
249
+			$num = rand(0, sizeof($routes) - 1);
250
+			$rRoute = (array)$routes[$num];
251 251
             
252
-            if (is_array($rRoute)) {
253
-                return $rRoute["route_id"];
254
-            } else {
255
-                return null;
256
-            }
257
-        } else {
258
-            echo "<br> There are no routes in the account. Please, create the routes first. <br>";
259
-            return null;
260
-        }
261
-    }
252
+			if (is_array($rRoute)) {
253
+				return $rRoute["route_id"];
254
+			} else {
255
+				return null;
256
+			}
257
+		} else {
258
+			echo "<br> There are no routes in the account. Please, create the routes first. <br>";
259
+			return null;
260
+		}
261
+	}
262 262
 
263
-    public function update()
264
-    {
265
-        $route = Route4Me::makeRequst(array(
266
-            'url'    => Endpoint::ROUTE_V4,
267
-            'method' => 'PUT',
268
-            'query'  => array(
269
-                'route_id'  => isset($this->route_id) ? $this->route_id : null
270
-            ),
271
-            'body' => array(
272
-                'parameters' => $this->parameters,
273
-                ),
274
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
275
-        ));
263
+	public function update()
264
+	{
265
+		$route = Route4Me::makeRequst(array(
266
+			'url'    => Endpoint::ROUTE_V4,
267
+			'method' => 'PUT',
268
+			'query'  => array(
269
+				'route_id'  => isset($this->route_id) ? $this->route_id : null
270
+			),
271
+			'body' => array(
272
+				'parameters' => $this->parameters,
273
+				),
274
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
275
+		));
276 276
 
277
-        return Route::fromArray($route);
278
-    }
277
+		return Route::fromArray($route);
278
+	}
279 279
     
280
-    public function updateAddress($address = null)
281
-    {
282
-        $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) 
283
-            : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters));
280
+	public function updateAddress($address = null)
281
+	{
282
+		$body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) 
283
+			: (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters));
284 284
 
285
-        $result = Route4Me::makeRequst(array(
286
-            'url'    => Endpoint::ADDRESS_V4,
287
-            'method' => 'PUT',
288
-            'query'  => array(
289
-                'route_id'             => isset($this->route_id) ? $this->route_id : null,
290
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
291
-            ),
292
-            'body'        => $body,
293
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
294
-        ));
285
+		$result = Route4Me::makeRequst(array(
286
+			'url'    => Endpoint::ADDRESS_V4,
287
+			'method' => 'PUT',
288
+			'query'  => array(
289
+				'route_id'             => isset($this->route_id) ? $this->route_id : null,
290
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
291
+			),
292
+			'body'        => $body,
293
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
294
+		));
295 295
 
296
-        return $result;
297
-    }
296
+		return $result;
297
+	}
298 298
 
299
-    public function updateRouteAddress()
300
-    {
301
-        $result = Route4Me::makeRequst(array(
302
-            'url'    => Endpoint::ADDRESS_V4,
303
-            'method' => 'PUT',
304
-            'query'  => array(
305
-                'route_id'             => isset($this->route_id) ? $this->route_id : null,
306
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
307
-            ),
308
-            'body'        => array(
309
-                "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null,
310
-                "addresses"  => isset($this->addresses) ? $this->addresses : null
311
-            ),
312
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
313
-        ));
299
+	public function updateRouteAddress()
300
+	{
301
+		$result = Route4Me::makeRequst(array(
302
+			'url'    => Endpoint::ADDRESS_V4,
303
+			'method' => 'PUT',
304
+			'query'  => array(
305
+				'route_id'             => isset($this->route_id) ? $this->route_id : null,
306
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
307
+			),
308
+			'body'        => array(
309
+				"parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null,
310
+				"addresses"  => isset($this->addresses) ? $this->addresses : null
311
+			),
312
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
313
+		));
314 314
 
315
-        return $result;
316
-    }
315
+		return $result;
316
+	}
317 317
 
318
-    public function addAddresses($params)
319
-    {
320
-        $route = Route4Me::makeRequst(array(
321
-            'url'    => Endpoint::ROUTE_V4,
322
-            'method' => 'PUT',
323
-            'query'  => array(
324
-                'api_key'   => Route4Me::getApiKey(),
325
-                'route_id'  => isset($params['route_id']) ? $params['route_id'] : null
326
-            ),
327
-            'body'   => array(
328
-                'addresses' => isset($params['addresses']) ? $params['addresses'] : null
329
-            ),
330
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
331
-        ));
318
+	public function addAddresses($params)
319
+	{
320
+		$route = Route4Me::makeRequst(array(
321
+			'url'    => Endpoint::ROUTE_V4,
322
+			'method' => 'PUT',
323
+			'query'  => array(
324
+				'api_key'   => Route4Me::getApiKey(),
325
+				'route_id'  => isset($params['route_id']) ? $params['route_id'] : null
326
+			),
327
+			'body'   => array(
328
+				'addresses' => isset($params['addresses']) ? $params['addresses'] : null
329
+			),
330
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
331
+		));
332 332
 
333
-        return Route::fromArray($route);
334
-    }
333
+		return Route::fromArray($route);
334
+	}
335 335
     
336
-    public function insertAddressOptimalPosition(array $params)
337
-    {
338
-        $route = Route4Me::makeRequst(array(
339
-            'url'    => Endpoint::ROUTE_V4,
340
-            'method' => 'PUT',
341
-            'query'  => array(
342
-                'api_key'  => Route4Me::getApiKey(),
343
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
344
-            ),
345
-            'body'   => array(
346
-                'addresses'        => isset($params['addresses']) ? $params['addresses'] : null,
347
-                'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null,
348
-            )
349
-        ));
336
+	public function insertAddressOptimalPosition(array $params)
337
+	{
338
+		$route = Route4Me::makeRequst(array(
339
+			'url'    => Endpoint::ROUTE_V4,
340
+			'method' => 'PUT',
341
+			'query'  => array(
342
+				'api_key'  => Route4Me::getApiKey(),
343
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
344
+			),
345
+			'body'   => array(
346
+				'addresses'        => isset($params['addresses']) ? $params['addresses'] : null,
347
+				'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null,
348
+			)
349
+		));
350 350
 
351
-        return Route::fromArray($route);
352
-    }
351
+		return Route::fromArray($route);
352
+	}
353 353
     
354
-    public function addNoteFile($params)
355
-    {
356
-        $fname = isset($params['strFilename']) ? $params['strFilename'] : null;
357
-        $rpath = realpath($fname);
354
+	public function addNoteFile($params)
355
+	{
356
+		$fname = isset($params['strFilename']) ? $params['strFilename'] : null;
357
+		$rpath = realpath($fname);
358 358
         
359
-        $result = Route4Me::makeRequst(array(
360
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
361
-            'method' => 'POST',
362
-            'query'  => array(
363
-                'api_key'     => Route4Me::getApiKey(),
364
-                'route_id'    => isset($params['route_id']) ? $params['route_id'] : null,
365
-                'address_id'  => isset($params['address_id']) ? $params['address_id'] : null,
366
-                'dev_lat'     => isset($params['dev_lat']) ? $params['dev_lat'] : null,
367
-                'dev_lng'     => isset($params['dev_lng']) ? $params['dev_lng'] : null,
368
-                'device_type' => isset($params['device_type']) ? $params['device_type'] : null,
369
-                'dev_lng'     => isset($params['dev_lng']) ? $params['dev_lng'] : null,
370
-            ),
371
-            'body'  => array(
372
-                'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
373
-                'strFilename'     => isset($params['strFilename']) ? $params['strFilename'] : null,
374
-                'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
375
-            ),
376
-            'FILE'  => $rpath,
359
+		$result = Route4Me::makeRequst(array(
360
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
361
+			'method' => 'POST',
362
+			'query'  => array(
363
+				'api_key'     => Route4Me::getApiKey(),
364
+				'route_id'    => isset($params['route_id']) ? $params['route_id'] : null,
365
+				'address_id'  => isset($params['address_id']) ? $params['address_id'] : null,
366
+				'dev_lat'     => isset($params['dev_lat']) ? $params['dev_lat'] : null,
367
+				'dev_lng'     => isset($params['dev_lng']) ? $params['dev_lng'] : null,
368
+				'device_type' => isset($params['device_type']) ? $params['device_type'] : null,
369
+				'dev_lng'     => isset($params['dev_lng']) ? $params['dev_lng'] : null,
370
+			),
371
+			'body'  => array(
372
+				'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
373
+				'strFilename'     => isset($params['strFilename']) ? $params['strFilename'] : null,
374
+				'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
375
+			),
376
+			'FILE'  => $rpath,
377 377
 
378
-            'HTTPHEADER' => array(
379
-                'Content-Type: application/x-www-form-urlencoded'
380
-            )
381
-        ));
378
+			'HTTPHEADER' => array(
379
+				'Content-Type: application/x-www-form-urlencoded'
380
+			)
381
+		));
382 382
 
383
-        return $result;
384
-    }
383
+		return $result;
384
+	}
385 385
 
386
-    public function delete($route_id)
387
-    {
388
-        $result = Route4Me::makeRequst(array(
389
-            'url'    => Endpoint::ROUTE_V4,
390
-            'method' => 'DELETE',
391
-            'query'  => array('route_id' => $route_id )
392
-        ));
386
+	public function delete($route_id)
387
+	{
388
+		$result = Route4Me::makeRequst(array(
389
+			'url'    => Endpoint::ROUTE_V4,
390
+			'method' => 'DELETE',
391
+			'query'  => array('route_id' => $route_id )
392
+		));
393 393
         
394
-         $result = Route4Me::makeRequst(array(
395
-            'url'    => Endpoint::ROUTES_DELETE,
396
-            'method' => 'DELETE',
397
-            'query'  => array(
398
-                'api_key' => Route4Me::getApiKey(),
399
-                'route_id' => $route_id,
400
-            )
401
-        ));
394
+		 $result = Route4Me::makeRequst(array(
395
+			'url'    => Endpoint::ROUTES_DELETE,
396
+			'method' => 'DELETE',
397
+			'query'  => array(
398
+				'api_key' => Route4Me::getApiKey(),
399
+				'route_id' => $route_id,
400
+			)
401
+		));
402 402
         
403
-        return $result;
404
-    }
403
+		return $result;
404
+	}
405 405
     
406
-    public function GetAddressesFromRoute($route_id)
407
-    {
408
-        $route1 = Route::getRoutes($route_id,null);
406
+	public function GetAddressesFromRoute($route_id)
407
+	{
408
+		$route1 = Route::getRoutes($route_id,null);
409 409
         
410
-        if (isset($route1)) {
411
-            return $route1->addresses;
412
-        } else {
413
-            return null;
414
-        }
415
-    }
410
+		if (isset($route1)) {
411
+			return $route1->addresses;
412
+		} else {
413
+			return null;
414
+		}
415
+	}
416 416
     
417
-    public function GetRandomAddressFromRoute($route_id)
418
-    {
419
-        $route1 = Route::getRoutes($route_id, null);
417
+	public function GetRandomAddressFromRoute($route_id)
418
+	{
419
+		$route1 = Route::getRoutes($route_id, null);
420 420
         
421
-        if (isset($route1)) {
422
-            $addresses = $route1->addresses;
421
+		if (isset($route1)) {
422
+			$addresses = $route1->addresses;
423 423
             
424
-            $rnd = rand(0, sizeof($addresses) - 1);
424
+			$rnd = rand(0, sizeof($addresses) - 1);
425 425
             
426
-            return $addresses[$rnd];
427
-        } else {
428
-            return null;
429
-        }
430
-    }
426
+			return $addresses[$rnd];
427
+		} else {
428
+			return null;
429
+		}
430
+	}
431 431
 
432
-    public function getRouteId()
433
-    {
434
-        return $this->route_id;
435
-    }
432
+	public function getRouteId()
433
+	{
434
+		return $this->route_id;
435
+	}
436 436
 
437
-    public function getOptimizationId()
438
-    {
439
-        return $this->optimization_problem_id;
440
-    }
437
+	public function getOptimizationId()
438
+	{
439
+		return $this->optimization_problem_id;
440
+	}
441 441
     
442
-    public function GetLastLocation(array $params)
443
-    {
444
-        $route = Route4Me::makeRequst(array(
445
-            'url'    => Endpoint::ROUTE_V4,
446
-            'method' => 'GET',
447
-            'query'  => array(
448
-                'api_key'                 => Route4Me::getApiKey(),
449
-                'route_id'                => isset($params['route_id']) ? $params['route_id'] : null,
450
-                'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null
451
-            )
452
-        ));
442
+	public function GetLastLocation(array $params)
443
+	{
444
+		$route = Route4Me::makeRequst(array(
445
+			'url'    => Endpoint::ROUTE_V4,
446
+			'method' => 'GET',
447
+			'query'  => array(
448
+				'api_key'                 => Route4Me::getApiKey(),
449
+				'route_id'                => isset($params['route_id']) ? $params['route_id'] : null,
450
+				'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null
451
+			)
452
+		));
453 453
 
454
-        return Route::fromArray($route);
455
-    }
454
+		return Route::fromArray($route);
455
+	}
456 456
     
457
-    public function GetTrackingHistoryFromTimeRange(array $params)
458
-    {
459
-        $route = Route4Me::makeRequst(array(
460
-            'url'    => Endpoint::GET_DEVICE_LOCATION,
461
-            'method' => 'GET',
462
-            'query'  => array(
463
-                'api_key'     => Route4Me::getApiKey(),
464
-                'route_id'    => isset($params['route_id']) ? $params['route_id'] : null,
465
-                'format'      => isset($params['format']) ? $params['format'] : null,
466
-                'time_period' => isset($params['time_period']) ? $params['time_period'] : null,
467
-                'start_date'  => isset($params['start_date']) ? $params['start_date'] : null,
468
-                'end_date'    => isset($params['end_date']) ? $params['end_date'] : null
469
-                )
470
-        ));
457
+	public function GetTrackingHistoryFromTimeRange(array $params)
458
+	{
459
+		$route = Route4Me::makeRequst(array(
460
+			'url'    => Endpoint::GET_DEVICE_LOCATION,
461
+			'method' => 'GET',
462
+			'query'  => array(
463
+				'api_key'     => Route4Me::getApiKey(),
464
+				'route_id'    => isset($params['route_id']) ? $params['route_id'] : null,
465
+				'format'      => isset($params['format']) ? $params['format'] : null,
466
+				'time_period' => isset($params['time_period']) ? $params['time_period'] : null,
467
+				'start_date'  => isset($params['start_date']) ? $params['start_date'] : null,
468
+				'end_date'    => isset($params['end_date']) ? $params['end_date'] : null
469
+				)
470
+		));
471 471
 
472
-        return $route;
473
-    }
472
+		return $route;
473
+	}
474 474
     
475
-    public function GetAssetTracking(array $params)
476
-    {
477
-        $route = Route4Me::makeRequst(array(
478
-            'url'    => Endpoint::STATUS_V4,
479
-            'method' => 'GET',
480
-            'query'  => array(
481
-                'api_key'  => Route4Me::getApiKey(),
482
-                'tracking' => isset($params['tracking']) ? $params['tracking'] : null
483
-                )
484
-        ));
475
+	public function GetAssetTracking(array $params)
476
+	{
477
+		$route = Route4Me::makeRequst(array(
478
+			'url'    => Endpoint::STATUS_V4,
479
+			'method' => 'GET',
480
+			'query'  => array(
481
+				'api_key'  => Route4Me::getApiKey(),
482
+				'tracking' => isset($params['tracking']) ? $params['tracking'] : null
483
+				)
484
+		));
485 485
 
486
-        return $route;
487
-    }
486
+		return $route;
487
+	}
488 488
 }
Please login to merge, or discard this patch.
src/Route4Me/AddressBookLocation.php 1 patch
Indentation   +427 added lines, -427 removed lines patch added patch discarded remove patch
@@ -6,510 +6,510 @@
 block discarded – undo
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
-    public static function getAddressBookLocation($addressId)
66
-    {
67
-        $ablocations = Route4Me::makeRequst(array(
68
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
69
-            'method' => 'GET',
70
-            'query'  => array(
71
-                'query' => $addressId,
72
-                'limit' => 30
73
-            )
74
-        ));
65
+	public static function getAddressBookLocation($addressId)
66
+	{
67
+		$ablocations = Route4Me::makeRequst(array(
68
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
69
+			'method' => 'GET',
70
+			'query'  => array(
71
+				'query' => $addressId,
72
+				'limit' => 30
73
+			)
74
+		));
75 75
 
76
-        return $ablocations;
77
-    }
76
+		return $ablocations;
77
+	}
78 78
     
79
-    public static function searchRoutedLocation($params)
80
-    {
81
-        $result = Route4Me::makeRequst(array(
82
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
83
-            'method' => 'GET',
84
-            'query'  => array(
85
-                'display' => isset($params['display']) ? $params['display'] : null,
86
-                'query'   => isset($params['query']) ? $params['query'] : null,
87
-                'fields'  => isset($params['fields']) ? $params['fields'] : null,
88
-                'limit'   => isset($params['limit']) ? $params['limit'] : null,
89
-                'offset'  => isset($params['offset']) ? $params['offset'] : null,
90
-            )
91
-        ));
79
+	public static function searchRoutedLocation($params)
80
+	{
81
+		$result = Route4Me::makeRequst(array(
82
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
83
+			'method' => 'GET',
84
+			'query'  => array(
85
+				'display' => isset($params['display']) ? $params['display'] : null,
86
+				'query'   => isset($params['query']) ? $params['query'] : null,
87
+				'fields'  => isset($params['fields']) ? $params['fields'] : null,
88
+				'limit'   => isset($params['limit']) ? $params['limit'] : null,
89
+				'offset'  => isset($params['offset']) ? $params['offset'] : null,
90
+			)
91
+		));
92 92
 
93
-        return $result;
94
-    }
93
+		return $result;
94
+	}
95 95
     
96
-    public static function getAddressBookLocations($params)
97
-    {
98
-        $ablocations = Route4Me::makeRequst(array(
99
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
100
-            'method' => 'GET',
101
-            'query'  => array(
102
-                'limit'  => isset($params['limit']) ? $params['limit'] : null,
103
-                'offset' => isset($params['offset']) ? $params['offset'] : null,
104
-            )
105
-        ));
96
+	public static function getAddressBookLocations($params)
97
+	{
98
+		$ablocations = Route4Me::makeRequst(array(
99
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
100
+			'method' => 'GET',
101
+			'query'  => array(
102
+				'limit'  => isset($params['limit']) ? $params['limit'] : null,
103
+				'offset' => isset($params['offset']) ? $params['offset'] : null,
104
+			)
105
+		));
106 106
 
107
-        return $ablocations;
108
-    }
107
+		return $ablocations;
108
+	}
109 109
     
110
-    public static function getAddressBookLocationsByIDs($ids)
111
-    {
112
-        $ablocations = Route4Me::makeRequst(array(
113
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
114
-            'method' => 'GET',
115
-            'query'  => array(
116
-                'address_id' => $ids
117
-            )
118
-        ));
110
+	public static function getAddressBookLocationsByIDs($ids)
111
+	{
112
+		$ablocations = Route4Me::makeRequst(array(
113
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
114
+			'method' => 'GET',
115
+			'query'  => array(
116
+				'address_id' => $ids
117
+			)
118
+		));
119 119
 
120
-        return $ablocations;
121
-    }
120
+		return $ablocations;
121
+	}
122 122
     
123
-    public static function getRandomAddressBookLocation($params)
124
-    {
125
-        $ablocations = Route4Me::makeRequst(array(
126
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
127
-            'method' => 'GET',
128
-            'query'  => array(
129
-                'limit'  => isset($params['limit']) ? $params['limit'] : 0,
130
-                'offset' => isset($params['offset']) ? $params['offset'] : 10,
131
-            )
132
-        ));
123
+	public static function getRandomAddressBookLocation($params)
124
+	{
125
+		$ablocations = Route4Me::makeRequst(array(
126
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
127
+			'method' => 'GET',
128
+			'query'  => array(
129
+				'limit'  => isset($params['limit']) ? $params['limit'] : 0,
130
+				'offset' => isset($params['offset']) ? $params['offset'] : 10,
131
+			)
132
+		));
133 133
         
134
-        if (isset($ablocations["results"])) {
135
-            $locationsSize = sizeof($ablocations["results"]);
134
+		if (isset($ablocations["results"])) {
135
+			$locationsSize = sizeof($ablocations["results"]);
136 136
             
137
-            if ($locationsSize>0) {
138
-                $randomLocationIndex = rand(0, $locationsSize - 1);
139
-                return $ablocations["results"][$randomLocationIndex];
140
-            } 
141
-        } 
137
+			if ($locationsSize>0) {
138
+				$randomLocationIndex = rand(0, $locationsSize - 1);
139
+				return $ablocations["results"][$randomLocationIndex];
140
+			} 
141
+		} 
142 142
 
143
-        return null;
144
-    }
143
+		return null;
144
+	}
145 145
     
146
-    /**
147
-     * @param AddressBookLocation $params
148
-    */
149
-    public static function addAdressBookLocation($params)
150
-    {
151
-        $body = array();
152
-        $abLocations = new AddressBookLocation();
146
+	/**
147
+	 * @param AddressBookLocation $params
148
+	 */
149
+	public static function addAdressBookLocation($params)
150
+	{
151
+		$body = array();
152
+		$abLocations = new AddressBookLocation();
153 153
         
154
-        foreach ($params as $key => $value) {
155
-            if ($key=="address_id") {
156
-                continue;
157
-            }
154
+		foreach ($params as $key => $value) {
155
+			if ($key=="address_id") {
156
+				continue;
157
+			}
158 158
             
159
-            if (property_exists($abLocations, $key)) {
160
-                if (isset($params->{$key})) {
161
-                    $body[$key] = $params->{$key};
162
-                } 
163
-            }
164
-        }
159
+			if (property_exists($abLocations, $key)) {
160
+				if (isset($params->{$key})) {
161
+					$body[$key] = $params->{$key};
162
+				} 
163
+			}
164
+		}
165 165
         
166
-        $response = Route4Me::makeRequst(array(
167
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
168
-            'method' => 'POST',
169
-            'body'   => $body
170
-        ));
166
+		$response = Route4Me::makeRequst(array(
167
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
168
+			'method' => 'POST',
169
+			'body'   => $body
170
+		));
171 171
 
172
-        return $response;
173
-    }
172
+		return $response;
173
+	}
174 174
     
175
-    public function deleteAdressBookLocation($address_ids)
176
-    {
177
-        $result = Route4Me::makeRequst(array(
178
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
179
-            'method' => 'DELETEARRAY',
180
-            'query'  => array(
181
-                'address_ids' => $address_ids
182
-            )
183
-        ));
175
+	public function deleteAdressBookLocation($address_ids)
176
+	{
177
+		$result = Route4Me::makeRequst(array(
178
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
179
+			'method' => 'DELETEARRAY',
180
+			'query'  => array(
181
+				'address_ids' => $address_ids
182
+			)
183
+		));
184 184
 
185
-        return $result;
186
-    }
185
+		return $result;
186
+	}
187 187
     
188
-    public function updateAdressBookLocation($params)
189
-    {
190
-        $body = array();
191
-        $abLocations = new AddressBookLocation();
188
+	public function updateAdressBookLocation($params)
189
+	{
190
+		$body = array();
191
+		$abLocations = new AddressBookLocation();
192 192
         
193
-        foreach ($params as $key => $value) {
194
-            if (property_exists($abLocations, $key)) {
195
-                if (isset($params->{$key})) {
196
-                    $body[$key] = $params->{$key};
197
-                } 
198
-            }
199
-        }
193
+		foreach ($params as $key => $value) {
194
+			if (property_exists($abLocations, $key)) {
195
+				if (isset($params->{$key})) {
196
+					$body[$key] = $params->{$key};
197
+				} 
198
+			}
199
+		}
200 200
 
201
-        $response = Route4Me::makeRequst(array(
202
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
203
-            'method' => 'PUT',
204
-            'body'   => $body,
205
-        ));
201
+		$response = Route4Me::makeRequst(array(
202
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
203
+			'method' => 'PUT',
204
+			'body'   => $body,
205
+		));
206 206
 
207
-        return $response;
208
-    }
207
+		return $response;
208
+	}
209 209
         
210
-    public static function get($params)
211
-    {
212
-        $ablocations = Route4Me::makeRequst(array(
213
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
214
-            'method' => 'ADD',
215
-            'query'  => array(
216
-                'first_name' => isset($params->first_name) ? $params->first_name : null,
217
-                'address_1'  => isset($params->address_1) ? $params->address_1 : null,
218
-                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
219
-                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
220
-            )
221
-        ));
210
+	public static function get($params)
211
+	{
212
+		$ablocations = Route4Me::makeRequst(array(
213
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
214
+			'method' => 'ADD',
215
+			'query'  => array(
216
+				'first_name' => isset($params->first_name) ? $params->first_name : null,
217
+				'address_1'  => isset($params->address_1) ? $params->address_1 : null,
218
+				'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
219
+				'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
220
+			)
221
+		));
222 222
 
223
-        return $ablocations;
224
-    }
223
+		return $ablocations;
224
+	}
225 225
     
226
-    public static function validateScheduleMode($scheduleMode)
227
-    {
228
-        $schedMmodes = array("daily", "weekly", "monthly", "annually");
226
+	public static function validateScheduleMode($scheduleMode)
227
+	{
228
+		$schedMmodes = array("daily", "weekly", "monthly", "annually");
229 229
         
230
-        if (in_array($scheduleMode, $schedMmodes)) {
231
-            return TRUE; 
232
-        } else {
233
-            return FALSE;
234
-        }
235
-    }
230
+		if (in_array($scheduleMode, $schedMmodes)) {
231
+			return TRUE; 
232
+		} else {
233
+			return FALSE;
234
+		}
235
+	}
236 236
     
237
-    public static function validateScheduleEnable($scheduleEnabled)
238
-    {
239
-        $schedEnables = array(TRUE, FALSE);
237
+	public static function validateScheduleEnable($scheduleEnabled)
238
+	{
239
+		$schedEnables = array(TRUE, FALSE);
240 240
         
241
-        if (in_array($scheduleEnabled, $schedEnables)) {
242
-            return TRUE;
243
-        } else {
244
-            return FALSE;
245
-        }
246
-    }
241
+		if (in_array($scheduleEnabled, $schedEnables)) {
242
+			return TRUE;
243
+		} else {
244
+			return FALSE;
245
+		}
246
+	}
247 247
     
248
-    public static function validateScheduleEvery($scheduleEvery)
249
-    {
250
-        if (is_numeric($scheduleEvery)) {
251
-            return TRUE;
252
-        } else {
253
-            return FALSE;
254
-        }
255
-    }
248
+	public static function validateScheduleEvery($scheduleEvery)
249
+	{
250
+		if (is_numeric($scheduleEvery)) {
251
+			return TRUE;
252
+		} else {
253
+			return FALSE;
254
+		}
255
+	}
256 256
     
257
-    public static function validateScheduleWeekDays($scheduleWeekDays)
258
-    {
259
-        $weekdays = explode(',', $scheduleWeekDays);
257
+	public static function validateScheduleWeekDays($scheduleWeekDays)
258
+	{
259
+		$weekdays = explode(',', $scheduleWeekDays);
260 260
         
261
-        if (sizeof($weekdays)<1) return FALSE;
261
+		if (sizeof($weekdays)<1) return FALSE;
262 262
         
263
-        $isValid = TRUE;
263
+		$isValid = TRUE;
264 264
         
265
-        for ($i=0; $i<sizeof($weekdays); $i++) { 
266
-            if (is_numeric($weekdays[$i])) {
267
-                $wday = intval($weekdays[$i]);
268
-                if ($wday<1 || $wday>7) $isValid = FALSE;
269
-            } else {
270
-                $isValid = FALSE;
271
-            }
272
-        }
265
+		for ($i=0; $i<sizeof($weekdays); $i++) { 
266
+			if (is_numeric($weekdays[$i])) {
267
+				$wday = intval($weekdays[$i]);
268
+				if ($wday<1 || $wday>7) $isValid = FALSE;
269
+			} else {
270
+				$isValid = FALSE;
271
+			}
272
+		}
273 273
         
274
-        return $isValid;
275
-    }
274
+		return $isValid;
275
+	}
276 276
     
277
-    public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
278
-    {
279
-        $schedMonthlyMmodes = array("dates", "nth");
277
+	public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
278
+	{
279
+		$schedMonthlyMmodes = array("dates", "nth");
280 280
         
281
-        if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) {
282
-            return TRUE;
283
-        } else {
284
-            return FALSE;
285
-        }
286
-    }
281
+		if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) {
282
+			return TRUE;
283
+		} else {
284
+			return FALSE;
285
+		}
286
+	}
287 287
     
288
-    public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
289
-    {
290
-        $monthlyDates = explode(',', $scheduleMonthlyDates);
288
+	public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
289
+	{
290
+		$monthlyDates = explode(',', $scheduleMonthlyDates);
291 291
         
292
-        if (sizeof($monthlyDates) <1) return FALSE;
292
+		if (sizeof($monthlyDates) <1) return FALSE;
293 293
         
294
-        $isValid = TRUE;
294
+		$isValid = TRUE;
295 295
         
296
-        for ($i=0; $i < sizeof($monthlyDates); $i++) { 
297
-            if (is_numeric($monthlyDates[$i])) {
298
-                $mday = intval($monthlyDates[$i]);
299
-                if ($mday <1 || $mday > 31) $isValid = FALSE;
300
-            } else {
301
-                $isValid = FALSE;
302
-            }
303
-        }
296
+		for ($i=0; $i < sizeof($monthlyDates); $i++) { 
297
+			if (is_numeric($monthlyDates[$i])) {
298
+				$mday = intval($monthlyDates[$i]);
299
+				if ($mday <1 || $mday > 31) $isValid = FALSE;
300
+			} else {
301
+				$isValid = FALSE;
302
+			}
303
+		}
304 304
 
305
-        return $isValid;
306
-    }
305
+		return $isValid;
306
+	}
307 307
     
308
-    public static function validateScheduleNthN($scheduleNthN)
309
-    {
310
-        if (!is_numeric($scheduleNthN)) return FALSE;
308
+	public static function validateScheduleNthN($scheduleNthN)
309
+	{
310
+		if (!is_numeric($scheduleNthN)) return FALSE;
311 311
         
312
-        $schedNthNs = array(1, 2, 3, 4, 5, -1);
312
+		$schedNthNs = array(1, 2, 3, 4, 5, -1);
313 313
         
314
-        if (in_array($scheduleNthN, $schedNthNs)) {
315
-            return TRUE;
316
-        } else {
317
-            return FALSE;
318
-        }
319
-    }
314
+		if (in_array($scheduleNthN, $schedNthNs)) {
315
+			return TRUE;
316
+		} else {
317
+			return FALSE;
318
+		}
319
+	}
320 320
     
321
-    public static function validateScheduleNthWhat($scheduleNthWhat)
322
-    {
323
-        if (!is_numeric($scheduleNthWhat)) return FALSE;
321
+	public static function validateScheduleNthWhat($scheduleNthWhat)
322
+	{
323
+		if (!is_numeric($scheduleNthWhat)) return FALSE;
324 324
         
325
-        $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
325
+		$schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
326 326
         
327
-        if (in_array($scheduleNthWhat, $schedNthWhats)) {
328
-            return TRUE;
329
-        } else {
330
-            return FALSE;
331
-        }
332
-    }
327
+		if (in_array($scheduleNthWhat, $schedNthWhats)) {
328
+			return TRUE;
329
+		} else {
330
+			return FALSE;
331
+		}
332
+	}
333 333
     
334
-    /* Function adds the locations (with/without schedule) from the CSV file. 
334
+	/* Function adds the locations (with/without schedule) from the CSV file. 
335 335
      * $csvFileHandle - a file handler.
336 336
      * Returns array $results which contains two arrays: fail and succes.
337 337
      */
338
-    public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
339
-    {
340
-        $max_line_length = 512;
341
-        $delemietr = ',';
338
+	public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
339
+	{
340
+		$max_line_length = 512;
341
+		$delemietr = ',';
342 342
         
343
-        $results = array();
344
-        $results['fail'] = array();
345
-        $results['success'] = array();
343
+		$results = array();
344
+		$results['fail'] = array();
345
+		$results['success'] = array();
346 346
         
347
-        $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
347
+		$columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
348 348
         
349
-        $addressBookFields = array("cached_lat","cached_lng","curbside_lat","curbside_lng","address_alias","address_1","address_2","address_city",
350
-                "address_state_id","address_zip","address_phone_number","schedule","address_group","first_name","last_name","local_time_window_start",
351
-                "local_time_window_end","local_time_window_start_2","local_time_window_end_2","address_email","address_country_id","address_custom_data",
352
-                "schedule_blacklist","service_time","local_timezone_string","color","address_icon","address_stop_type","address_cube","address_pieces",
353
-                "address_reference_no","address_revenue","address_weight","address_priority","address_customer_po");
349
+		$addressBookFields = array("cached_lat","cached_lng","curbside_lat","curbside_lng","address_alias","address_1","address_2","address_city",
350
+				"address_state_id","address_zip","address_phone_number","schedule","address_group","first_name","last_name","local_time_window_start",
351
+				"local_time_window_end","local_time_window_start_2","local_time_window_end_2","address_email","address_country_id","address_custom_data",
352
+				"schedule_blacklist","service_time","local_timezone_string","color","address_icon","address_stop_type","address_cube","address_pieces",
353
+				"address_reference_no","address_revenue","address_weight","address_priority","address_customer_po");
354 354
 
355
-        if (empty($columns)) {
356
-            array_push($results['fail'], 'Empty CSV table');
357
-            return ($results);
358
-        }
355
+		if (empty($columns)) {
356
+			array_push($results['fail'], 'Empty CSV table');
357
+			return ($results);
358
+		}
359 359
 
360
-        $iRow = 1;
360
+		$iRow = 1;
361 361
         
362
-        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
363
-            if ($rows[$locationsFieldsMapping['cached_lat']] 
364
-                  && $rows[$locationsFieldsMapping['cached_lng']] 
365
-                  && $rows[$locationsFieldsMapping['address_1']] 
366
-                  && array(null)!==$rows) {
367
-                $curSchedule = "";
368
-                $mode = "";
362
+		while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
363
+			if ($rows[$locationsFieldsMapping['cached_lat']] 
364
+				  && $rows[$locationsFieldsMapping['cached_lng']] 
365
+				  && $rows[$locationsFieldsMapping['address_1']] 
366
+				  && array(null)!==$rows) {
367
+				$curSchedule = "";
368
+				$mode = "";
369 369
                 
370
-                if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
371
-                    if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
372
-                        $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
373
-                        $mode = $rows[$locationsFieldsMapping['schedule_mode']];
374
-                    } else {
375
-                        array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); 
376
-                        $curSchedule = "";
377
-                    }
378
-                } else {
379
-                    array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); 
380
-                    $curSchedule = "";
381
-                }
370
+				if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
371
+					if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
372
+						$curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
373
+						$mode = $rows[$locationsFieldsMapping['schedule_mode']];
374
+					} else {
375
+						array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); 
376
+						$curSchedule = "";
377
+					}
378
+				} else {
379
+					array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); 
380
+					$curSchedule = "";
381
+				}
382 382
                 
383
-                if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
384
-                    if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
385
-                        $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
386
-                    } else {
387
-                        array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set ");  
388
-                        $curSchedule = "";
389
-                    }
390
-                }
383
+				if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
384
+					if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
385
+						$curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
386
+					} else {
387
+						array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set ");  
388
+						$curSchedule = "";
389
+					}
390
+				}
391 391
                 
392
-                if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
393
-                    if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
394
-                        $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
395
-                        if ($mode == 'daily') {
396
-                            $curSchedule = trim($curSchedule,',');
397
-                            $curSchedule.='}';
398
-                        }
399
-                    } else {
400
-                        array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); 
401
-                        $curSchedule = ""; 
402
-                    }
403
-                }
392
+				if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
393
+					if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
394
+						$curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
395
+						if ($mode == 'daily') {
396
+							$curSchedule = trim($curSchedule,',');
397
+							$curSchedule.='}';
398
+						}
399
+					} else {
400
+						array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); 
401
+						$curSchedule = ""; 
402
+					}
403
+				}
404 404
                 
405
-                if ($mode!='daily') {
406
-                    switch ($mode) {
407
-                        case 'weekly':
408
-                            if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
409
-                                if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
410
-                                     $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
411
-                                } else {
412
-                                    array_push($results['fail'], "$iRow --> Wrong weekdays"); 
413
-                                    $curSchedule = "";
414
-                                }
415
-                            } else {
416
-                                array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); 
417
-                                $curSchedule = "";
418
-                            }
419
-                            break;
420
-                        case 'monthly':
421
-                            $monthlyMode = "";
422
-                            if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
423
-                                if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
424
-                                     $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
425
-                                     $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
426
-                                } else {
427
-                                    array_push($results['fail'], "$iRow --> Wrong monthly mode"); 
428
-                                    $curSchedule = "";
429
-                                }
430
-                            } else {
431
-                                array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); 
432
-                                $curSchedule = "";
433
-                            }
405
+				if ($mode!='daily') {
406
+					switch ($mode) {
407
+						case 'weekly':
408
+							if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
409
+								if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
410
+									 $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
411
+								} else {
412
+									array_push($results['fail'], "$iRow --> Wrong weekdays"); 
413
+									$curSchedule = "";
414
+								}
415
+							} else {
416
+								array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); 
417
+								$curSchedule = "";
418
+							}
419
+							break;
420
+						case 'monthly':
421
+							$monthlyMode = "";
422
+							if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
423
+								if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
424
+									 $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
425
+									 $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
426
+								} else {
427
+									array_push($results['fail'], "$iRow --> Wrong monthly mode"); 
428
+									$curSchedule = "";
429
+								}
430
+							} else {
431
+								array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); 
432
+								$curSchedule = "";
433
+							}
434 434
                             
435
-                            if ($monthlyMode != "") {
436
-                                switch ($monthlyMode) {
437
-                                    case 'dates':
438
-                                        if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
439
-                                            if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
440
-                                                 $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
441
-                                            } else {
442
-                                                array_push($results['fail'], "$iRow --> Wrong monthly dates"); 
443
-                                                $curSchedule = "";
444
-                                            }
445
-                                        }
446
-                                        break;
447
-                                    case 'nth':
448
-                                        if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
449
-                                            if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
450
-                                                 $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
451
-                                            } else {
452
-                                                array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); 
453
-                                                $curSchedule = "";
454
-                                            }
455
-                                        } else {
456
-                                            array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); 
457
-                                            $curSchedule = "";
458
-                                        }
435
+							if ($monthlyMode != "") {
436
+								switch ($monthlyMode) {
437
+									case 'dates':
438
+										if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
439
+											if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
440
+												 $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
441
+											} else {
442
+												array_push($results['fail'], "$iRow --> Wrong monthly dates"); 
443
+												$curSchedule = "";
444
+											}
445
+										}
446
+										break;
447
+									case 'nth':
448
+										if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
449
+											if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
450
+												 $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
451
+											} else {
452
+												array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); 
453
+												$curSchedule = "";
454
+											}
455
+										} else {
456
+											array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); 
457
+											$curSchedule = "";
458
+										}
459 459
                                         
460
-                                        if ($curSchedule != "") {
461
-                                            if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
462
-                                                if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
463
-                                                     $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
464
-                                                } else {
465
-                                                    array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); 
466
-                                                    $curSchedule = "";
467
-                                                }
468
-                                            } else {
469
-                                                array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); 
470
-                                                $curSchedule = "";
471
-                                            }
472
-                                        }
473
-                                        break;
474
-                                }
475
-                            }
476
-                            break;
477
-                        default:
478
-                            $curSchedule = "";
479
-                            break;
480
-                    }
481
-                }
460
+										if ($curSchedule != "") {
461
+											if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
462
+												if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
463
+													 $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
464
+												} else {
465
+													array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); 
466
+													$curSchedule = "";
467
+												}
468
+											} else {
469
+												array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); 
470
+												$curSchedule = "";
471
+											}
472
+										}
473
+										break;
474
+								}
475
+							}
476
+							break;
477
+						default:
478
+							$curSchedule = "";
479
+							break;
480
+					}
481
+				}
482 482
 
483
-                if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") {
484
-                    $iRow++; 
485
-                    continue;
486
-                }
483
+				if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") {
484
+					$iRow++; 
485
+					continue;
486
+				}
487 487
                 
488
-                $curSchedule = strtolower($curSchedule);
488
+				$curSchedule = strtolower($curSchedule);
489 489
                 
490
-                $curSchedule = '[{'.$curSchedule.'}]';
490
+				$curSchedule = '[{'.$curSchedule.'}]';
491 491
 
492
-                $oSchedule = json_decode($curSchedule,TRUE);
492
+				$oSchedule = json_decode($curSchedule,TRUE);
493 493
                 
494
-                $parametersArray = array();
494
+				$parametersArray = array();
495 495
                 
496
-                foreach ($addressBookFields as $addressBookField) {
497
-                    if (isset($locationsFieldsMapping[$addressBookField])) {
498
-                        $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]];
499
-                    }
500
-                }
496
+				foreach ($addressBookFields as $addressBookField) {
497
+					if (isset($locationsFieldsMapping[$addressBookField])) {
498
+						$parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]];
499
+					}
500
+				}
501 501
                 
502
-                $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray);
502
+				$AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray);
503 503
                 
504
-                $abContacts = new AddressBookLocation();
504
+				$abContacts = new AddressBookLocation();
505 505
 
506
-                $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
506
+				$abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
507 507
                 
508
-                array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
509
-            }
510
-        }
508
+				array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
509
+			}
510
+		}
511 511
 
512
-        return $results;
513
-    }
512
+		return $results;
513
+	}
514 514
  }
515
-    
516 515
\ No newline at end of file
516
+	
517 517
\ No newline at end of file
Please login to merge, or discard this patch.
src/Route4Me/Address.php 1 patch
Indentation   +274 added lines, -274 removed lines patch added patch discarded remove patch
@@ -8,315 +8,315 @@
 block discarded – undo
8 8
 
9 9
 class Address extends Common
10 10
 {
11
-    public $route_destination_id;
12
-    public $alias;
13
-    public $member_id;
14
-    public $address;
15
-    public $addressUpdate;
16
-    public $is_depot = false;
17
-    public $lat;
18
-    public $lng;
19
-    public $route_id;
20
-    public $original_route_id;
21
-    public $optimization_problem_id;
22
-    public $sequence_no;
23
-    public $geocoded;
24
-    public $preferred_geocoding;
25
-    public $failed_geocoding;
26
-    public $geocodings = array();
27
-    public $contact_id;
28
-    public $is_visited;
29
-    public $customer_po;
30
-    public $invoice_no;
31
-    public $reference_no;
32
-    public $order_no;
33
-    public $weight;
34
-    public $cost;
35
-    public $revenue;
36
-    public $cube;
37
-    public $pieces;
38
-    public $email;
39
-    public $phone;
40
-    public $tracking_number;
41
-    public $destination_note_count;
42
-    public $drive_time_to_next_destination;
43
-    public $distance_to_next_destination;
44
-    public $generated_time_window_start;
45
-    public $generated_time_window_end;
46
-    public $time_window_start;
47
-    public $time_window_end;
48
-    public $time;
49
-    public $notes;
50
-    public $timestamp_last_visited;
51
-    public $custom_fields = array();
52
-    public $manifest = array();
11
+	public $route_destination_id;
12
+	public $alias;
13
+	public $member_id;
14
+	public $address;
15
+	public $addressUpdate;
16
+	public $is_depot = false;
17
+	public $lat;
18
+	public $lng;
19
+	public $route_id;
20
+	public $original_route_id;
21
+	public $optimization_problem_id;
22
+	public $sequence_no;
23
+	public $geocoded;
24
+	public $preferred_geocoding;
25
+	public $failed_geocoding;
26
+	public $geocodings = array();
27
+	public $contact_id;
28
+	public $is_visited;
29
+	public $customer_po;
30
+	public $invoice_no;
31
+	public $reference_no;
32
+	public $order_no;
33
+	public $weight;
34
+	public $cost;
35
+	public $revenue;
36
+	public $cube;
37
+	public $pieces;
38
+	public $email;
39
+	public $phone;
40
+	public $tracking_number;
41
+	public $destination_note_count;
42
+	public $drive_time_to_next_destination;
43
+	public $distance_to_next_destination;
44
+	public $generated_time_window_start;
45
+	public $generated_time_window_end;
46
+	public $time_window_start;
47
+	public $time_window_end;
48
+	public $time;
49
+	public $notes;
50
+	public $timestamp_last_visited;
51
+	public $custom_fields = array();
52
+	public $manifest = array();
53 53
     
54
-    public $first_name;
55
-    public $last_name;
56
-    public $is_departed;
57
-    public $timestamp_last_departed;
58
-    public $order_id;
59
-    public $priority;
60
-    public $curbside_lat;
61
-    public $curbside_lng;
62
-    public $time_window_start_2;
63
-    public $time_window_end_2;
54
+	public $first_name;
55
+	public $last_name;
56
+	public $is_departed;
57
+	public $timestamp_last_departed;
58
+	public $order_id;
59
+	public $priority;
60
+	public $curbside_lat;
61
+	public $curbside_lng;
62
+	public $time_window_start_2;
63
+	public $time_window_end_2;
64 64
 
65
-    public static function fromArray(array $params)
66
-    {
67
-        $address = new Address();
68
-        foreach ($params as $key => $value) {
69
-            if (property_exists($address, $key)) {
70
-                $address->{$key} = $value;
71
-            }
72
-        }
65
+	public static function fromArray(array $params)
66
+	{
67
+		$address = new Address();
68
+		foreach ($params as $key => $value) {
69
+			if (property_exists($address, $key)) {
70
+				$address->{$key} = $value;
71
+			}
72
+		}
73 73
         
74
-        return $address;
75
-    }
74
+		return $address;
75
+	}
76 76
 
77
-    public static function getAddress($routeId, $addressId)
78
-    {
79
-        $address = Route4Me::makeRequst(array(
80
-            'url'    => Endpoint::ADDRESS_V4,
81
-            'method' => 'GET',
82
-            'query'  => array(
83
-                'route_id'             => $routeId,
84
-                'route_destination_id' => $addressId,
85
-            )
86
-        ));
77
+	public static function getAddress($routeId, $addressId)
78
+	{
79
+		$address = Route4Me::makeRequst(array(
80
+			'url'    => Endpoint::ADDRESS_V4,
81
+			'method' => 'GET',
82
+			'query'  => array(
83
+				'route_id'             => $routeId,
84
+				'route_destination_id' => $addressId,
85
+			)
86
+		));
87 87
     
88
-        return Address::fromArray($address);
89
-    }
88
+		return Address::fromArray($address);
89
+	}
90 90
     
91
-    /*Get notes from the specified route destination
91
+	/*Get notes from the specified route destination
92 92
      * Returns an address object with notes, if an address exists, otherwise - return null.
93 93
      */
94
-    public static function GetAddressesNotes($noteParams)
95
-    {
96
-        $address = Route4Me::makeRequst(array(
97
-            'url'    => Endpoint::ADDRESS_V4,
98
-            'method' => 'GET',
99
-            'query'  => array(
100
-                'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, 
101
-                'route_destination_id' => isset($noteParams['route_destination_id']) 
102
-                                             ? $noteParams['route_destination_id'] : null,
103
-                'notes'                => 1,
104
-            )
105
-        ));
94
+	public static function GetAddressesNotes($noteParams)
95
+	{
96
+		$address = Route4Me::makeRequst(array(
97
+			'url'    => Endpoint::ADDRESS_V4,
98
+			'method' => 'GET',
99
+			'query'  => array(
100
+				'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, 
101
+				'route_destination_id' => isset($noteParams['route_destination_id']) 
102
+											 ? $noteParams['route_destination_id'] : null,
103
+				'notes'                => 1,
104
+			)
105
+		));
106 106
     
107
-        return $address;
108
-    }
107
+		return $address;
108
+	}
109 109
 
110
-    public function update()
111
-    {
112
-        $addressUpdate = Route4Me::makeRequst(array(
113
-            'url'    => Endpoint::ADDRESS_V4,
114
-            'method' => 'PUT',
115
-            'body'   => $this->toArray(),
116
-            'query'  => array(
117
-                'route_id'             => $this->route_id,
118
-                'route_destination_id' => $this->route_destination_id,
119
-            ),
120
-        ));
110
+	public function update()
111
+	{
112
+		$addressUpdate = Route4Me::makeRequst(array(
113
+			'url'    => Endpoint::ADDRESS_V4,
114
+			'method' => 'PUT',
115
+			'body'   => $this->toArray(),
116
+			'query'  => array(
117
+				'route_id'             => $this->route_id,
118
+				'route_destination_id' => $this->route_destination_id,
119
+			),
120
+		));
121 121
     
122
-        return Address::fromArray($addressUpdate);
123
-    }
122
+		return Address::fromArray($addressUpdate);
123
+	}
124 124
     
125
-    public function markAddress($params, $body)
126
-    {
127
-        $result = Route4Me::makeRequst(array(
128
-            'url'    => Endpoint::ADDRESS_V4,
129
-            'method' => 'PUT',
130
-            'query'  => array(
131
-                'route_id'             => isset($params['route_id']) ? $params['route_id'] : null, 
132
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
133
-            ),
134
-            'body'   => $body
135
-        ));
125
+	public function markAddress($params, $body)
126
+	{
127
+		$result = Route4Me::makeRequst(array(
128
+			'url'    => Endpoint::ADDRESS_V4,
129
+			'method' => 'PUT',
130
+			'query'  => array(
131
+				'route_id'             => isset($params['route_id']) ? $params['route_id'] : null, 
132
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
133
+			),
134
+			'body'   => $body
135
+		));
136 136
     
137
-        return $result;
138
-    }
137
+		return $result;
138
+	}
139 139
     
140
-    public function markAsDeparted($params)
141
-    {
142
-        $address = Route4Me::makeRequst(array(
143
-            'url'    => Endpoint::MARK_ADDRESS_DEPARTED,
144
-            'method' => 'GET',
145
-            'query'  => array(
146
-                'route_id'     => isset($params['route_id']) ? $params['route_id'] : null,
147
-                'address_id'   => isset($params['address_id']) ? $params['address_id'] : null,
148
-                'is_departed'  => isset($params['is_departed']) ? $params['is_departed'] : null,
149
-                'member_id'    => isset($params['member_id']) ? $params['member_id'] : null,
150
-            ),
151
-        ));
140
+	public function markAsDeparted($params)
141
+	{
142
+		$address = Route4Me::makeRequst(array(
143
+			'url'    => Endpoint::MARK_ADDRESS_DEPARTED,
144
+			'method' => 'GET',
145
+			'query'  => array(
146
+				'route_id'     => isset($params['route_id']) ? $params['route_id'] : null,
147
+				'address_id'   => isset($params['address_id']) ? $params['address_id'] : null,
148
+				'is_departed'  => isset($params['is_departed']) ? $params['is_departed'] : null,
149
+				'member_id'    => isset($params['member_id']) ? $params['member_id'] : null,
150
+			),
151
+		));
152 152
     
153
-        return $address;
154
-    }
153
+		return $address;
154
+	}
155 155
     
156
-    public function markAsVisited($params)
157
-    {
158
-        $address = Route4Me::makeRequst(array(
159
-            'url'    => Endpoint::UPDATE_ADDRESS_VISITED,
160
-            'method' => 'GET',
161
-            'query'  => array(
162
-                'route_id'   => isset($params['route_id']) ? $params['route_id'] : null,
163
-                'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
164
-                'member_id'  => isset($params['member_id']) ? $params['member_id'] : null,
165
-            ),
166
-            'body'  =>  array(
167
-                'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null
168
-            )
169
-        ));
156
+	public function markAsVisited($params)
157
+	{
158
+		$address = Route4Me::makeRequst(array(
159
+			'url'    => Endpoint::UPDATE_ADDRESS_VISITED,
160
+			'method' => 'GET',
161
+			'query'  => array(
162
+				'route_id'   => isset($params['route_id']) ? $params['route_id'] : null,
163
+				'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
164
+				'member_id'  => isset($params['member_id']) ? $params['member_id'] : null,
165
+			),
166
+			'body'  =>  array(
167
+				'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null
168
+			)
169
+		));
170 170
     
171
-        return $address;
172
-    }
171
+		return $address;
172
+	}
173 173
 
174
-    public function delete()
175
-    {
176
-        $address = Route4Me::makeRequst(array(
177
-            'url'    => Endpoint::ADDRESS_V4,
178
-            'method' => 'DELETE',
179
-            'query'  => array(
180
-                'route_id'             => $this->route_id,
181
-                'route_destination_id' => $this->route_destination_id,
182
-            )
183
-        ));
174
+	public function delete()
175
+	{
176
+		$address = Route4Me::makeRequst(array(
177
+			'url'    => Endpoint::ADDRESS_V4,
178
+			'method' => 'DELETE',
179
+			'query'  => array(
180
+				'route_id'             => $this->route_id,
181
+				'route_destination_id' => $this->route_destination_id,
182
+			)
183
+		));
184 184
     
185
-        return (bool)$address['deleted'];
186
-    }
185
+		return (bool)$address['deleted'];
186
+	}
187 187
     
188
-    public function moveDestinationToRoute($params)
189
-    {
190
-        $result = Route4Me::makeRequst(array(
191
-            'url'    => Endpoint::MOVE_ROUTE_DESTINATION,
192
-            'method' => 'POST',
193
-            'body'  => array(
194
-                'to_route_id'          => isset($params['to_route_id']) ? $params['to_route_id'] : null,
195
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
196
-                'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
197
-            ),
198
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
199
-        ));
188
+	public function moveDestinationToRoute($params)
189
+	{
190
+		$result = Route4Me::makeRequst(array(
191
+			'url'    => Endpoint::MOVE_ROUTE_DESTINATION,
192
+			'method' => 'POST',
193
+			'body'  => array(
194
+				'to_route_id'          => isset($params['to_route_id']) ? $params['to_route_id'] : null,
195
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
196
+				'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
197
+			),
198
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
199
+		));
200 200
 
201
-        return $result;
202
-    }
201
+		return $result;
202
+	}
203 203
     
204
-    public function AddAddressNote($params)
205
-    {
206
-        $result = Route4Me::makeRequst(array(
207
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
208
-            'method' => 'POST',
209
-            'query'  => array(
210
-                'route_id'     =>  isset($params['route_id']) ? $params['route_id'] : null,
211
-                'address_id'   =>  isset($params['address_id']) ? $params['address_id'] : null,
212
-                'dev_lat'      =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
213
-                'dev_lng'      =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
214
-                'device_type'  =>  isset($params['device_type']) ? $params['device_type'] : null
215
-            ),
216
-            'body'  => array(
217
-                'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
218
-                'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null
219
-            ),
220
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
221
-        ));
204
+	public function AddAddressNote($params)
205
+	{
206
+		$result = Route4Me::makeRequst(array(
207
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
208
+			'method' => 'POST',
209
+			'query'  => array(
210
+				'route_id'     =>  isset($params['route_id']) ? $params['route_id'] : null,
211
+				'address_id'   =>  isset($params['address_id']) ? $params['address_id'] : null,
212
+				'dev_lat'      =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
213
+				'dev_lng'      =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
214
+				'device_type'  =>  isset($params['device_type']) ? $params['device_type'] : null
215
+			),
216
+			'body'  => array(
217
+				'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
218
+				'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null
219
+			),
220
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
221
+		));
222 222
 
223
-        return $result;
224
-    }
223
+		return $result;
224
+	}
225 225
 
226
-    public function AddNoteFile($params)
227
-    {
228
-        $result = Route4Me::fileUploadRequest(array(
229
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
230
-            'method' => 'POST',
231
-            'query'  => array(
232
-                'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
233
-                'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
234
-                'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
235
-                'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
236
-                'device_type'   =>  isset($params['device_type']) ? $params['device_type'] : null,
237
-                'strUpdateType' =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null
238
-            ),
239
-            'body'  => array(
240
-                'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null
241
-            ),
242
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
243
-        ));
226
+	public function AddNoteFile($params)
227
+	{
228
+		$result = Route4Me::fileUploadRequest(array(
229
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
230
+			'method' => 'POST',
231
+			'query'  => array(
232
+				'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
233
+				'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
234
+				'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
235
+				'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
236
+				'device_type'   =>  isset($params['device_type']) ? $params['device_type'] : null,
237
+				'strUpdateType' =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null
238
+			),
239
+			'body'  => array(
240
+				'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null
241
+			),
242
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
243
+		));
244 244
 
245
-        return $result;
246
-    }
245
+		return $result;
246
+	}
247 247
 
248
-    public function createCustomNoteType($params)
249
-    {
250
-        $result = Route4Me::makeRequst(array(
251
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
252
-            'method' => 'POST',
253
-            'body'   => array(
254
-                'type'   => isset($params['type']) ? $params['type'] : null,
255
-                'values' => isset($params['values']) ? $params['values'] : null
256
-            )
257
-        ));
248
+	public function createCustomNoteType($params)
249
+	{
250
+		$result = Route4Me::makeRequst(array(
251
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
252
+			'method' => 'POST',
253
+			'body'   => array(
254
+				'type'   => isset($params['type']) ? $params['type'] : null,
255
+				'values' => isset($params['values']) ? $params['values'] : null
256
+			)
257
+		));
258 258
 
259
-        return $result;
260
-    }
259
+		return $result;
260
+	}
261 261
     
262
-    public function removeCustomNoteType($params)
263
-    {
264
-        $result = Route4Me::makeRequst(array(
265
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
266
-            'method' => 'DELETE',
267
-            'body'   => array(
268
-                'id' => isset($params['id']) ? $params['id'] : null
269
-            )
270
-        ));
262
+	public function removeCustomNoteType($params)
263
+	{
264
+		$result = Route4Me::makeRequst(array(
265
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
266
+			'method' => 'DELETE',
267
+			'body'   => array(
268
+				'id' => isset($params['id']) ? $params['id'] : null
269
+			)
270
+		));
271 271
 
272
-        return $result;
273
-    }
272
+		return $result;
273
+	}
274 274
     
275
-    public function getAllCustomNoteTypes()
276
-    {
277
-        $result = Route4Me::makeRequst(array(
278
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
279
-            'method' => 'GET'
280
-        ));
275
+	public function getAllCustomNoteTypes()
276
+	{
277
+		$result = Route4Me::makeRequst(array(
278
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
279
+			'method' => 'GET'
280
+		));
281 281
 
282
-        return $result;
283
-    }
282
+		return $result;
283
+	}
284 284
     
285
-    public function addCustomNoteToRoute($params)
286
-    {
287
-        $customArray = array();
285
+	public function addCustomNoteToRoute($params)
286
+	{
287
+		$customArray = array();
288 288
         
289
-        foreach ($params as $key => $value) {
290
-            $kpos = strpos($key, "custom_note_type");
289
+		foreach ($params as $key => $value) {
290
+			$kpos = strpos($key, "custom_note_type");
291 291
             
292
-            if ($kpos!==false) {
293
-                $customArray[$key] = $value;
294
-            }
295
-        }
292
+			if ($kpos!==false) {
293
+				$customArray[$key] = $value;
294
+			}
295
+		}
296 296
         
297
-        $result = Route4Me::makeRequst(array(
298
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
299
-            'method' => 'POST',
300
-            'query'  => array(
301
-                'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
302
-                'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
303
-                'format'        =>  isset($params['format']) ? $params['format'] : null,
304
-                'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
305
-                'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null
306
-            ),
307
-            'body'  => array_merge(array(
308
-                'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
309
-                'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
310
-                'strNoteContents' =>  isset($params['strNoteContents']) ? $params['strNoteContents'] : null
311
-            ), $customArray),
312
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
313
-        ));
297
+		$result = Route4Me::makeRequst(array(
298
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
299
+			'method' => 'POST',
300
+			'query'  => array(
301
+				'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
302
+				'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
303
+				'format'        =>  isset($params['format']) ? $params['format'] : null,
304
+				'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
305
+				'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null
306
+			),
307
+			'body'  => array_merge(array(
308
+				'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
309
+				'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
310
+				'strNoteContents' =>  isset($params['strNoteContents']) ? $params['strNoteContents'] : null
311
+			), $customArray),
312
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
313
+		));
314 314
 
315
-        return $result;
316
-    }
315
+		return $result;
316
+	}
317 317
 
318
-    function getAddressId()
319
-    {
320
-        return $this->route_destination_id;
321
-    }
318
+	function getAddressId()
319
+	{
320
+		return $this->route_destination_id;
321
+	}
322 322
 }
Please login to merge, or discard this patch.
src/Route4Me/AvoidanceZone.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -7,107 +7,107 @@
 block discarded – undo
7 7
 
8 8
 class AvoidanceZone extends Common
9 9
 {
10
-    public $territory_id;  // Avoidance zone id
11
-    public $territory_name; 
12
-    public $territory_color;
13
-    public $orders;
14
-    public $member_id;
15
-    public $territory; // Territory parameters
10
+	public $territory_id;  // Avoidance zone id
11
+	public $territory_name; 
12
+	public $territory_color;
13
+	public $orders;
14
+	public $member_id;
15
+	public $territory; // Territory parameters
16 16
     
17
-    public static function fromArray(array $params) 
18
-    {
19
-        if (!isset($params['territory_name'])) {
20
-            throw new BadParam('Territory name must be provided');
21
-        }
17
+	public static function fromArray(array $params) 
18
+	{
19
+		if (!isset($params['territory_name'])) {
20
+			throw new BadParam('Territory name must be provided');
21
+		}
22 22
         
23
-        if (!isset($params['territory_color'])) {
24
-            throw new BadParam('Territory color must be provided');
25
-        }
23
+		if (!isset($params['territory_color'])) {
24
+			throw new BadParam('Territory color must be provided');
25
+		}
26 26
         
27
-        if (!isset($params['territory'])) {
28
-            throw new BadParam('Territory must be provided');
29
-        }
27
+		if (!isset($params['territory'])) {
28
+			throw new BadParam('Territory must be provided');
29
+		}
30 30
         
31
-        $avoidanceZoneParameters = new AvoidanceZone();
31
+		$avoidanceZoneParameters = new AvoidanceZone();
32 32
         
33
-        foreach($params as $key => $value) {
34
-            if (property_exists($avoidanceZoneParameters, $key)) {
35
-                $avoidanceZoneParameters->{$key} = $value;
36
-            }
37
-        }
33
+		foreach($params as $key => $value) {
34
+			if (property_exists($avoidanceZoneParameters, $key)) {
35
+				$avoidanceZoneParameters->{$key} = $value;
36
+			}
37
+		}
38 38
         
39
-        return $avoidanceZoneParameters;
40
-    }
39
+		return $avoidanceZoneParameters;
40
+	}
41 41
     
42
-    public static function getAvoidanceZone($territory_id)
43
-    {
44
-        $avoidanceZone = Route4Me::makeRequst(array(
45
-            'url'    => Endpoint::AVOIDANCE_ZONE,
46
-            'method' => 'GET',
47
-            'query'  => array(
48
-                'territory_id' => $territory_id
49
-            )
50
-        ));
42
+	public static function getAvoidanceZone($territory_id)
43
+	{
44
+		$avoidanceZone = Route4Me::makeRequst(array(
45
+			'url'    => Endpoint::AVOIDANCE_ZONE,
46
+			'method' => 'GET',
47
+			'query'  => array(
48
+				'territory_id' => $territory_id
49
+			)
50
+		));
51 51
 
52
-        return $avoidanceZone;
53
-    }
52
+		return $avoidanceZone;
53
+	}
54 54
     
55
-    public static function getAvoidanceZones($params)
56
-    {
57
-        $avoidanceZones = Route4Me::makeRequst(array(
58
-            'url'    => Endpoint::AVOIDANCE_ZONE,
59
-            'method' => 'GET',
60
-            'query'  => array(
61
-                'offset'  => isset($params->offset) ? $params->offset : null,
62
-                'limit'   => isset($params->limit) ? $params->limit : null,
63
-            )
64
-        ));
55
+	public static function getAvoidanceZones($params)
56
+	{
57
+		$avoidanceZones = Route4Me::makeRequst(array(
58
+			'url'    => Endpoint::AVOIDANCE_ZONE,
59
+			'method' => 'GET',
60
+			'query'  => array(
61
+				'offset'  => isset($params->offset) ? $params->offset : null,
62
+				'limit'   => isset($params->limit) ? $params->limit : null,
63
+			)
64
+		));
65 65
 
66
-        return $avoidanceZones;
67
-    }
66
+		return $avoidanceZones;
67
+	}
68 68
 
69
-    public static function addAvoidanceZone($params)
70
-    {
71
-        $terParams = array();
69
+	public static function addAvoidanceZone($params)
70
+	{
71
+		$terParams = array();
72 72
 
73
-        if (isset($params->territory['type'])) $terParams['type'] = $params->territory['type'];
74
-        if (isset($params->territory['data'])) $terParams['data'] = $params->territory['data'];
73
+		if (isset($params->territory['type'])) $terParams['type'] = $params->territory['type'];
74
+		if (isset($params->territory['data'])) $terParams['data'] = $params->territory['data'];
75 75
 
76
-        $abContacts = Route4Me::makeRequst(array(
77
-            'url'    => Endpoint::AVOIDANCE_ZONE,
78
-            'method' => 'POST',
79
-            'body'  => array(
80
-                'territory_name'  => isset($params->territory_name) ? $params->territory_name : null,
81
-                'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
82
-                'territory'       => $terParams
83
-            )
84
-        ));
76
+		$abContacts = Route4Me::makeRequst(array(
77
+			'url'    => Endpoint::AVOIDANCE_ZONE,
78
+			'method' => 'POST',
79
+			'body'  => array(
80
+				'territory_name'  => isset($params->territory_name) ? $params->territory_name : null,
81
+				'territory_color' => isset($params->territory_color) ? $params->territory_color : null,
82
+				'territory'       => $terParams
83
+			)
84
+		));
85 85
 
86
-        return $abContacts;
87
-    }
86
+		return $abContacts;
87
+	}
88 88
     
89
-    public function deleteAvoidanceZone($territory_id)
90
-    {
91
-        $result = Route4Me::makeRequst(array(
92
-            'url'    => Endpoint::AVOIDANCE_ZONE,
93
-            'method' => 'DELETEARRAY',
94
-            'query'  => array(
95
-                'territory_id' => $territory_id
96
-            )
97
-        ));
89
+	public function deleteAvoidanceZone($territory_id)
90
+	{
91
+		$result = Route4Me::makeRequst(array(
92
+			'url'    => Endpoint::AVOIDANCE_ZONE,
93
+			'method' => 'DELETEARRAY',
94
+			'query'  => array(
95
+				'territory_id' => $territory_id
96
+			)
97
+		));
98 98
 
99
-        return $result;
100
-    }
99
+		return $result;
100
+	}
101 101
     
102
-    public function updateAvoidanceZone($params)
103
-    {
104
-        $avoidanceZone = Route4Me::makeRequst(array(
105
-            'url'    => Endpoint::AVOIDANCE_ZONE,
106
-            'method' => 'PUT',
107
-            'body'   => $params,
102
+	public function updateAvoidanceZone($params)
103
+	{
104
+		$avoidanceZone = Route4Me::makeRequst(array(
105
+			'url'    => Endpoint::AVOIDANCE_ZONE,
106
+			'method' => 'PUT',
107
+			'body'   => $params,
108 108
 
109
-        ));
109
+		));
110 110
 
111
-        return $avoidanceZone;
112
-    }
111
+		return $avoidanceZone;
112
+	}
113 113
 }
Please login to merge, or discard this patch.