@@ -16,14 +16,14 @@ |
||
16 | 16 | |
17 | 17 | $territoryParams['type'] = TerritoryTypes::RECT; |
18 | 18 | $territoryParams['data'] = array( |
19 | - "43.51668853502909,-109.3798828125", |
|
20 | - "46.98025235521883,-101.865234375" |
|
19 | + "43.51668853502909,-109.3798828125", |
|
20 | + "46.98025235521883,-101.865234375" |
|
21 | 21 | ); |
22 | 22 | |
23 | 23 | $TerritoryParameters = Territory::fromArray(array( |
24 | - "territory_name" => "Test Rectangular Territory ".strval(rand(10000,99999)), |
|
25 | - "territory_color" => "ff7700", |
|
26 | - "territory" => $territoryParams |
|
24 | + "territory_name" => "Test Rectangular Territory ".strval(rand(10000,99999)), |
|
25 | + "territory_color" => "ff7700", |
|
26 | + "territory" => $territoryParams |
|
27 | 27 | )); |
28 | 28 | |
29 | 29 | $territory = new Territory(); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
5 | 5 | require $root.'/vendor/autoload.php'; |
6 | 6 | |
7 | 7 | use Route4Me\Route4Me; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | ); |
22 | 22 | |
23 | 23 | $TerritoryParameters = Territory::fromArray(array( |
24 | - "territory_name" => "Test Rectangular Territory ".strval(rand(10000,99999)), |
|
24 | + "territory_name" => "Test Rectangular Territory ".strval(rand(10000, 99999)), |
|
25 | 25 | "territory_color" => "ff7700", |
26 | 26 | "territory" => $territoryParams |
27 | 27 | )); |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | |
19 | 19 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
20 | 20 | $territoryParams['data'] = array( |
21 | - "37.569752822786455,-77.47833251953125", |
|
22 | - "5000" |
|
21 | + "37.569752822786455,-77.47833251953125", |
|
22 | + "5000" |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | - "territory_color" => "ff7700", |
|
28 | - "territory" => $territoryParams |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | + "territory_color" => "ff7700", |
|
28 | + "territory" => $territoryParams |
|
29 | 29 | )); |
30 | 30 | |
31 | 31 | $result = (array)$territory->addTerritory($TerritoryParameters); |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | |
39 | 39 | // Update territory |
40 | 40 | $territoryParameters = array ( |
41 | - "type" => TerritoryTypes::RECT, |
|
42 | - "data" => array( |
|
43 | - "29.6600127358956,-95.6593322753906", |
|
44 | - "29.8966150753098,-95.3146362304688" |
|
45 | - ) |
|
41 | + "type" => TerritoryTypes::RECT, |
|
42 | + "data" => array( |
|
43 | + "29.6600127358956,-95.6593322753906", |
|
44 | + "29.8966150753098,-95.3146362304688" |
|
45 | + ) |
|
46 | 46 | ); |
47 | 47 | |
48 | 48 | $TerritoryParameters = Territory::fromArray(array( |
49 | - "territory_id" => $territory_id, |
|
50 | - "territory_name" => "Test Territory Updated as rectangle", |
|
51 | - "territory_color" => "ff5500", |
|
52 | - "territory" => $territoryParameters |
|
49 | + "territory_id" => $territory_id, |
|
50 | + "territory_name" => "Test Territory Updated as rectangle", |
|
51 | + "territory_color" => "ff5500", |
|
52 | + "territory" => $territoryParameters |
|
53 | 53 | )); |
54 | 54 | |
55 | 55 | $result1 = $territory->updateTerritory($TerritoryParameters); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
5 | 5 | require $root.'/vendor/autoload.php'; |
6 | 6 | |
7 | 7 | use Route4Me\Route4Me; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000, 99999)), |
|
27 | 27 | "territory_color" => "ff7700", |
28 | 28 | "territory" => $territoryParams |
29 | 29 | )); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | echo "------------------------------------------------------------------------<br><br>"; |
38 | 38 | |
39 | 39 | // Update territory |
40 | -$territoryParameters = array ( |
|
40 | +$territoryParameters = array( |
|
41 | 41 | "type" => TerritoryTypes::RECT, |
42 | 42 | "data" => array( |
43 | 43 | "29.6600127358956,-95.6593322753906", |
@@ -16,21 +16,21 @@ |
||
16 | 16 | |
17 | 17 | $territoryParams['type'] = TerritoryTypes::POLY; |
18 | 18 | $territoryParams['data'] = array( |
19 | - "37.769752822786455,-77.67833251953125", |
|
20 | - "37.75886716305343,-77.68974800109863", |
|
21 | - "37.74763966054455,-77.6917221069336", |
|
22 | - "37.74655084306813,-77.68863220214844", |
|
23 | - "37.7502255383101,-77.68125076293945", |
|
24 | - "37.74797991274437,-77.67498512268066", |
|
25 | - "37.73327960206065,-77.6411678314209", |
|
26 | - "37.74430510679532,-77.63172645568848", |
|
27 | - "37.76641925847049,-77.66846199035645" |
|
19 | + "37.769752822786455,-77.67833251953125", |
|
20 | + "37.75886716305343,-77.68974800109863", |
|
21 | + "37.74763966054455,-77.6917221069336", |
|
22 | + "37.74655084306813,-77.68863220214844", |
|
23 | + "37.7502255383101,-77.68125076293945", |
|
24 | + "37.74797991274437,-77.67498512268066", |
|
25 | + "37.73327960206065,-77.6411678314209", |
|
26 | + "37.74430510679532,-77.63172645568848", |
|
27 | + "37.76641925847049,-77.66846199035645" |
|
28 | 28 | ); |
29 | 29 | |
30 | 30 | $TerritoryParameters=Territory::fromArray(array( |
31 | - "territory_name" => "Test Polygonian Territory ".strval(rand(10000,99999)), |
|
32 | - "territory_color" => "ff7700", |
|
33 | - "territory" => $territoryParams |
|
31 | + "territory_name" => "Test Polygonian Territory ".strval(rand(10000,99999)), |
|
32 | + "territory_color" => "ff7700", |
|
33 | + "territory" => $territoryParams |
|
34 | 34 | )); |
35 | 35 | |
36 | 36 | $territory = new Territory(); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
5 | 5 | require $root.'/vendor/autoload.php'; |
6 | 6 | |
7 | 7 | use Route4Me\Route4Me; |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | "37.76641925847049,-77.66846199035645" |
28 | 28 | ); |
29 | 29 | |
30 | -$TerritoryParameters=Territory::fromArray(array( |
|
31 | - "territory_name" => "Test Polygonian Territory ".strval(rand(10000,99999)), |
|
30 | +$TerritoryParameters = Territory::fromArray(array( |
|
31 | + "territory_name" => "Test Polygonian Territory ".strval(rand(10000, 99999)), |
|
32 | 32 | "territory_color" => "ff7700", |
33 | 33 | "territory" => $territoryParams |
34 | 34 | )); |
@@ -18,14 +18,14 @@ discard block |
||
18 | 18 | |
19 | 19 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
20 | 20 | $territoryParams['data'] = array( |
21 | - "37.569752822786455,-77.47833251953125", |
|
22 | - "5000" |
|
21 | + "37.569752822786455,-77.47833251953125", |
|
22 | + "5000" |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | - "territory_color" => "ff7700", |
|
28 | - "territory" => $territoryParams |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | + "territory_color" => "ff7700", |
|
28 | + "territory" => $territoryParams |
|
29 | 29 | )); |
30 | 30 | |
31 | 31 | $territory = new Territory(); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | echo "------------------------------------------------------------------------<br><br>"; |
42 | 42 | |
43 | 43 | $params = array( |
44 | - "territory_id" => $territory_id |
|
44 | + "territory_id" => $territory_id |
|
45 | 45 | ); |
46 | 46 | |
47 | 47 | $result1 = $territory->getTerritory($params); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
5 | 5 | require $root.'/vendor/autoload.php'; |
6 | 6 | |
7 | 7 | use Route4Me\Route4Me; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000, 99999)), |
|
27 | 27 | "territory_color" => "ff7700", |
28 | 28 | "territory" => $territoryParams |
29 | 29 | )); |
@@ -134,7 +134,7 @@ |
||
134 | 134 | |
135 | 135 | if ($file!=null) { |
136 | 136 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
137 | - $fp=fopen($file, 'r'); |
|
137 | + $fp = fopen($file, 'r'); |
|
138 | 138 | curl_setopt($ch, CURLOPT_INFILE, $fp); |
139 | 139 | curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
140 | 140 | } |
@@ -198,7 +198,7 @@ |
||
198 | 198 | } else { |
199 | 199 | return $json; |
200 | 200 | } |
201 | - } elseif (409==$code) { |
|
201 | + } elseif (409==$code) { |
|
202 | 202 | throw new ApiError('Wrong API key'); |
203 | 203 | } else { |
204 | 204 | throw new ApiError('Something wrong'); |
@@ -207,12 +207,16 @@ discard block |
||
207 | 207 | |
208 | 208 | /** |
209 | 209 | * @param $object: JSON object |
210 | + * @param \SimpleXMLElement $object |
|
210 | 211 | */ |
211 | 212 | public static function object2array($object) |
212 | 213 | { |
213 | 214 | return @json_decode(@json_encode($object), 1); |
214 | 215 | } |
215 | 216 | |
217 | + /** |
|
218 | + * @param string $url |
|
219 | + */ |
|
216 | 220 | public static function makeUrlRequst($url, $options) { |
217 | 221 | $method = isset($options['method']) ? $options['method'] : 'GET'; |
218 | 222 | $query = isset($options['query']) ? |
@@ -377,6 +381,7 @@ discard block |
||
377 | 381 | * Returns an array of the object properties |
378 | 382 | * @param $object: An object. |
379 | 383 | * @param $exclude: array of the object parameters to be excluded from the returned array. |
384 | + * @param string[] $exclude |
|
380 | 385 | */ |
381 | 386 | public static function getObjectProperties($object, $exclude) |
382 | 387 | { |
@@ -397,6 +402,7 @@ discard block |
||
397 | 402 | * Returns url path generated from the array of the fields and parameters. |
398 | 403 | * @param $allFields; array of the paossible fields (parameter names). |
399 | 404 | * @param $params: input parameters (array or object). |
405 | + * @param string[] $allFields |
|
400 | 406 | */ |
401 | 407 | public static function generateUrlPath($allFields, $params) |
402 | 408 | { |
@@ -7,415 +7,415 @@ |
||
7 | 7 | |
8 | 8 | class Route4Me |
9 | 9 | { |
10 | - static public $apiKey; |
|
11 | - static public $baseUrl = Endpoint::BASE_URL; |
|
10 | + static public $apiKey; |
|
11 | + static public $baseUrl = Endpoint::BASE_URL; |
|
12 | 12 | |
13 | - public static function setApiKey($apiKey) |
|
14 | - { |
|
15 | - self::$apiKey = $apiKey; |
|
16 | - } |
|
13 | + public static function setApiKey($apiKey) |
|
14 | + { |
|
15 | + self::$apiKey = $apiKey; |
|
16 | + } |
|
17 | 17 | |
18 | - public static function getApiKey() |
|
19 | - { |
|
20 | - return self::$apiKey; |
|
21 | - } |
|
18 | + public static function getApiKey() |
|
19 | + { |
|
20 | + return self::$apiKey; |
|
21 | + } |
|
22 | 22 | |
23 | - public static function setBaseUrl($baseUrl) |
|
24 | - { |
|
25 | - self::$baseUrl = $baseUrl; |
|
26 | - } |
|
23 | + public static function setBaseUrl($baseUrl) |
|
24 | + { |
|
25 | + self::$baseUrl = $baseUrl; |
|
26 | + } |
|
27 | 27 | |
28 | - public static function getBaseUrl() |
|
29 | - { |
|
30 | - return self::$baseUrl; |
|
31 | - } |
|
28 | + public static function getBaseUrl() |
|
29 | + { |
|
30 | + return self::$baseUrl; |
|
31 | + } |
|
32 | 32 | |
33 | - public static function fileUploadRequest($options) { |
|
34 | - $query = isset($options['query']) ? array_filter($options['query']) : array(); |
|
33 | + public static function fileUploadRequest($options) { |
|
34 | + $query = isset($options['query']) ? array_filter($options['query']) : array(); |
|
35 | 35 | |
36 | - if (sizeof($query)==0) { |
|
37 | - return null; |
|
36 | + if (sizeof($query)==0) { |
|
37 | + return null; |
|
38 | 38 | |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | - $body = isset($options['body']) ? array_filter($options['body']) : null; |
|
41 | + $body = isset($options['body']) ? array_filter($options['body']) : null; |
|
42 | 42 | |
43 | - $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
|
43 | + $fname = isset($body['strFilename']) ? $body['strFilename'] : ''; |
|
44 | 44 | |
45 | - if ($fname=='') { |
|
46 | - return null; |
|
47 | - } |
|
45 | + if ($fname=='') { |
|
46 | + return null; |
|
47 | + } |
|
48 | 48 | |
49 | - $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname); |
|
49 | + $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname); |
|
50 | 50 | |
51 | - $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(array('api_key' => self::getApiKey()), $query)); |
|
51 | + $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(array('api_key' => self::getApiKey()), $query)); |
|
52 | 52 | |
53 | - $ch = curl_init($url); |
|
53 | + $ch = curl_init($url); |
|
54 | 54 | |
55 | - $curlOpts = array( |
|
56 | - CURLOPT_POST => true, |
|
57 | - CURLOPT_RETURNTRANSFER => false, |
|
58 | - CURLOPT_TIMEOUT => 60, |
|
59 | - CURLOPT_FOLLOWLOCATION => true, |
|
60 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
61 | - CURLOPT_SSL_VERIFYPEER => FALSE |
|
62 | - ); |
|
55 | + $curlOpts = array( |
|
56 | + CURLOPT_POST => true, |
|
57 | + CURLOPT_RETURNTRANSFER => false, |
|
58 | + CURLOPT_TIMEOUT => 60, |
|
59 | + CURLOPT_FOLLOWLOCATION => true, |
|
60 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
61 | + CURLOPT_SSL_VERIFYPEER => FALSE |
|
62 | + ); |
|
63 | 63 | |
64 | - curl_setopt_array($ch, $curlOpts); |
|
64 | + curl_setopt_array($ch, $curlOpts); |
|
65 | 65 | |
66 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
66 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
|
67 | 67 | |
68 | - curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
69 | - "Content-Type: multipart/form-data", |
|
70 | - 'Content-Disposition: form-data; name="strFilename"' |
|
71 | - )); |
|
72 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
73 | - curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); |
|
68 | + curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
|
69 | + "Content-Type: multipart/form-data", |
|
70 | + 'Content-Disposition: form-data; name="strFilename"' |
|
71 | + )); |
|
72 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
73 | + curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); |
|
74 | 74 | |
75 | - $result = curl_exec($ch); |
|
75 | + $result = curl_exec($ch); |
|
76 | 76 | |
77 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
78 | - curl_close($ch); |
|
77 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
78 | + curl_close($ch); |
|
79 | 79 | |
80 | - $json = json_decode($result, true); |
|
80 | + $json = json_decode($result, true); |
|
81 | 81 | |
82 | - if (200==$code) { |
|
83 | - return $json; |
|
84 | - } elseif (isset($json['errors'])) { |
|
85 | - throw new ApiError(implode(', ', $json['errors'])); |
|
86 | - } else { |
|
87 | - throw new ApiError('Something wrong'); |
|
88 | - } |
|
89 | - } |
|
82 | + if (200==$code) { |
|
83 | + return $json; |
|
84 | + } elseif (isset($json['errors'])) { |
|
85 | + throw new ApiError(implode(', ', $json['errors'])); |
|
86 | + } else { |
|
87 | + throw new ApiError('Something wrong'); |
|
88 | + } |
|
89 | + } |
|
90 | 90 | |
91 | - public static function makeRequst($options) { |
|
92 | - $errorHandler = new myErrorHandler(); |
|
91 | + public static function makeRequst($options) { |
|
92 | + $errorHandler = new myErrorHandler(); |
|
93 | 93 | |
94 | - $old_error_handler = set_error_handler(array($errorHandler, "proc_error")); |
|
94 | + $old_error_handler = set_error_handler(array($errorHandler, "proc_error")); |
|
95 | 95 | |
96 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
97 | - $query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
96 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
97 | + $query = isset($options['query']) ? array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
98 | 98 | |
99 | - $body = isset($options['body']) ? $options['body'] : null; |
|
100 | - $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
101 | - $headers = array( |
|
102 | - "User-Agent: Route4Me php-sdk" |
|
103 | - ); |
|
99 | + $body = isset($options['body']) ? $options['body'] : null; |
|
100 | + $file = isset($options['FILE']) ? $options['FILE'] : null; |
|
101 | + $headers = array( |
|
102 | + "User-Agent: Route4Me php-sdk" |
|
103 | + ); |
|
104 | 104 | |
105 | - if (isset($options['HTTPHEADER'])) { |
|
106 | - $headers[] = $options['HTTPHEADER']; |
|
107 | - } |
|
105 | + if (isset($options['HTTPHEADER'])) { |
|
106 | + $headers[] = $options['HTTPHEADER']; |
|
107 | + } |
|
108 | 108 | |
109 | - if (isset($options['HTTPHEADERS'])) { |
|
110 | - foreach ($options['HTTPHEADERS'] As $header) { |
|
111 | - $headers[] = $header; |
|
112 | - } |
|
113 | - } |
|
109 | + if (isset($options['HTTPHEADERS'])) { |
|
110 | + foreach ($options['HTTPHEADERS'] As $header) { |
|
111 | + $headers[] = $header; |
|
112 | + } |
|
113 | + } |
|
114 | 114 | |
115 | - $ch = curl_init(); |
|
115 | + $ch = curl_init(); |
|
116 | 116 | |
117 | - $url = $options['url'].'?'.http_build_query(array_merge( |
|
118 | - $query, array('api_key' => self::getApiKey()) |
|
119 | - )); |
|
117 | + $url = $options['url'].'?'.http_build_query(array_merge( |
|
118 | + $query, array('api_key' => self::getApiKey()) |
|
119 | + )); |
|
120 | 120 | |
121 | - $baseUrl = self::getBaseUrl(); |
|
121 | + $baseUrl = self::getBaseUrl(); |
|
122 | 122 | |
123 | - $curlOpts = arraY( |
|
124 | - CURLOPT_URL => $baseUrl.$url, |
|
125 | - CURLOPT_RETURNTRANSFER => true, |
|
126 | - CURLOPT_TIMEOUT => 80, |
|
127 | - CURLOPT_FOLLOWLOCATION => true, |
|
128 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
129 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
130 | - CURLOPT_HTTPHEADER => $headers |
|
131 | - ); |
|
123 | + $curlOpts = arraY( |
|
124 | + CURLOPT_URL => $baseUrl.$url, |
|
125 | + CURLOPT_RETURNTRANSFER => true, |
|
126 | + CURLOPT_TIMEOUT => 80, |
|
127 | + CURLOPT_FOLLOWLOCATION => true, |
|
128 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
129 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
130 | + CURLOPT_HTTPHEADER => $headers |
|
131 | + ); |
|
132 | 132 | |
133 | - curl_setopt_array($ch, $curlOpts); |
|
133 | + curl_setopt_array($ch, $curlOpts); |
|
134 | 134 | |
135 | - if ($file!=null) { |
|
136 | - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
|
137 | - $fp=fopen($file, 'r'); |
|
138 | - curl_setopt($ch, CURLOPT_INFILE, $fp); |
|
139 | - curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
|
140 | - } |
|
135 | + if ($file!=null) { |
|
136 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); |
|
137 | + $fp=fopen($file, 'r'); |
|
138 | + curl_setopt($ch, CURLOPT_INFILE, $fp); |
|
139 | + curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file)); |
|
140 | + } |
|
141 | 141 | |
142 | - switch ($method) { |
|
143 | - case 'DELETE': |
|
144 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
145 | - break; |
|
146 | - case 'DELETEARRAY': |
|
147 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
148 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
149 | - break; |
|
150 | - case 'PUT': |
|
151 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
152 | - break; |
|
153 | - case 'POST': |
|
154 | - if (isset($body)) { |
|
155 | - $bodyData = json_encode($body); |
|
156 | - if (isset($options['HTTPHEADER'])) { |
|
157 | - if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) { |
|
158 | - $bodyData = $body; |
|
159 | - } |
|
160 | - } |
|
142 | + switch ($method) { |
|
143 | + case 'DELETE': |
|
144 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
145 | + break; |
|
146 | + case 'DELETEARRAY': |
|
147 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
148 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
149 | + break; |
|
150 | + case 'PUT': |
|
151 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
152 | + break; |
|
153 | + case 'POST': |
|
154 | + if (isset($body)) { |
|
155 | + $bodyData = json_encode($body); |
|
156 | + if (isset($options['HTTPHEADER'])) { |
|
157 | + if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) { |
|
158 | + $bodyData = $body; |
|
159 | + } |
|
160 | + } |
|
161 | 161 | |
162 | - curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
163 | - } |
|
164 | - break; |
|
165 | - case 'ADD': |
|
166 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
167 | - } |
|
162 | + curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); |
|
163 | + } |
|
164 | + break; |
|
165 | + case 'ADD': |
|
166 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
167 | + } |
|
168 | 168 | |
169 | - if (is_numeric(array_search($method, array('DELETE', 'PUT')))) { |
|
170 | - if (isset($body)) { |
|
171 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
172 | - } |
|
173 | - } |
|
169 | + if (is_numeric(array_search($method, array('DELETE', 'PUT')))) { |
|
170 | + if (isset($body)) { |
|
171 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
172 | + } |
|
173 | + } |
|
174 | 174 | |
175 | - $result = curl_exec($ch); |
|
175 | + $result = curl_exec($ch); |
|
176 | 176 | |
177 | - $isxml = FALSE; |
|
178 | - $jxml = ""; |
|
179 | - if (strpos($result, '<?xml')>-1) { |
|
180 | - $xml = simplexml_load_string($result); |
|
181 | - //$jxml = json_encode($xml); |
|
182 | - $jxml = self::object2array($xml); |
|
183 | - $isxml = TRUE; |
|
184 | - } |
|
177 | + $isxml = FALSE; |
|
178 | + $jxml = ""; |
|
179 | + if (strpos($result, '<?xml')>-1) { |
|
180 | + $xml = simplexml_load_string($result); |
|
181 | + //$jxml = json_encode($xml); |
|
182 | + $jxml = self::object2array($xml); |
|
183 | + $isxml = TRUE; |
|
184 | + } |
|
185 | 185 | |
186 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
187 | - curl_close($ch); |
|
186 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
187 | + curl_close($ch); |
|
188 | 188 | |
189 | - if (200==$code) { |
|
190 | - if ($isxml) { |
|
191 | - $json = $jxml; |
|
192 | - } else { |
|
193 | - $json = json_decode($result, true); |
|
194 | - } |
|
189 | + if (200==$code) { |
|
190 | + if ($isxml) { |
|
191 | + $json = $jxml; |
|
192 | + } else { |
|
193 | + $json = json_decode($result, true); |
|
194 | + } |
|
195 | 195 | |
196 | - if (isset($json['errors'])) { |
|
197 | - throw new ApiError(implode(', ', $json['errors'])); |
|
198 | - } else { |
|
199 | - return $json; |
|
200 | - } |
|
201 | - } elseif (409==$code) { |
|
202 | - throw new ApiError('Wrong API key'); |
|
203 | - } else { |
|
204 | - throw new ApiError('Something wrong'); |
|
205 | - } |
|
206 | - } |
|
196 | + if (isset($json['errors'])) { |
|
197 | + throw new ApiError(implode(', ', $json['errors'])); |
|
198 | + } else { |
|
199 | + return $json; |
|
200 | + } |
|
201 | + } elseif (409==$code) { |
|
202 | + throw new ApiError('Wrong API key'); |
|
203 | + } else { |
|
204 | + throw new ApiError('Something wrong'); |
|
205 | + } |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * @param $object: JSON object |
|
210 | - */ |
|
211 | - public static function object2array($object) |
|
212 | - { |
|
213 | - return @json_decode(@json_encode($object), 1); |
|
214 | - } |
|
208 | + /** |
|
209 | + * @param $object: JSON object |
|
210 | + */ |
|
211 | + public static function object2array($object) |
|
212 | + { |
|
213 | + return @json_decode(@json_encode($object), 1); |
|
214 | + } |
|
215 | 215 | |
216 | - public static function makeUrlRequst($url, $options) { |
|
217 | - $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
218 | - $query = isset($options['query']) ? |
|
219 | - array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
220 | - $body = isset($options['body']) ? $options['body'] : null; |
|
221 | - $ch = curl_init(); |
|
216 | + public static function makeUrlRequst($url, $options) { |
|
217 | + $method = isset($options['method']) ? $options['method'] : 'GET'; |
|
218 | + $query = isset($options['query']) ? |
|
219 | + array_filter($options['query'], function($x) { return !is_null($x); } ) : array(); |
|
220 | + $body = isset($options['body']) ? $options['body'] : null; |
|
221 | + $ch = curl_init(); |
|
222 | 222 | |
223 | - $curlOpts = arraY( |
|
224 | - CURLOPT_URL => $url, |
|
225 | - CURLOPT_RETURNTRANSFER => true, |
|
226 | - CURLOPT_TIMEOUT => 60, |
|
227 | - CURLOPT_FOLLOWLOCATION => true, |
|
228 | - CURLOPT_SSL_VERIFYHOST => FALSE, |
|
229 | - CURLOPT_SSL_VERIFYPEER => FALSE, |
|
230 | - CURLOPT_HTTPHEADER => array( |
|
231 | - 'User-Agent' => 'Route4Me php-sdk' |
|
232 | - ) |
|
233 | - ); |
|
223 | + $curlOpts = arraY( |
|
224 | + CURLOPT_URL => $url, |
|
225 | + CURLOPT_RETURNTRANSFER => true, |
|
226 | + CURLOPT_TIMEOUT => 60, |
|
227 | + CURLOPT_FOLLOWLOCATION => true, |
|
228 | + CURLOPT_SSL_VERIFYHOST => FALSE, |
|
229 | + CURLOPT_SSL_VERIFYPEER => FALSE, |
|
230 | + CURLOPT_HTTPHEADER => array( |
|
231 | + 'User-Agent' => 'Route4Me php-sdk' |
|
232 | + ) |
|
233 | + ); |
|
234 | 234 | |
235 | - curl_setopt_array($ch, $curlOpts); |
|
235 | + curl_setopt_array($ch, $curlOpts); |
|
236 | 236 | |
237 | - switch ($method) { |
|
238 | - case 'DELETE': |
|
239 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
240 | - break; |
|
241 | - case 'DELETEARRAY': |
|
242 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
243 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
244 | - break; |
|
245 | - case 'PUT': |
|
246 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
247 | - break; |
|
248 | - case 'POST': |
|
249 | - curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
250 | - break; |
|
251 | - case 'ADD': |
|
252 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
253 | - } |
|
237 | + switch ($method) { |
|
238 | + case 'DELETE': |
|
239 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
240 | + break; |
|
241 | + case 'DELETEARRAY': |
|
242 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); |
|
243 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); |
|
244 | + break; |
|
245 | + case 'PUT': |
|
246 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); |
|
247 | + break; |
|
248 | + case 'POST': |
|
249 | + curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
|
250 | + break; |
|
251 | + case 'ADD': |
|
252 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break; |
|
253 | + } |
|
254 | 254 | |
255 | - if (is_numeric(array_search($method, array('DELETE', 'PUT', 'POST')))) { |
|
256 | - if (isset($body)) { |
|
257 | - curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
258 | - } |
|
259 | - } |
|
255 | + if (is_numeric(array_search($method, array('DELETE', 'PUT', 'POST')))) { |
|
256 | + if (isset($body)) { |
|
257 | + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); |
|
258 | + } |
|
259 | + } |
|
260 | 260 | |
261 | - $result = curl_exec($ch); |
|
261 | + $result = curl_exec($ch); |
|
262 | 262 | |
263 | - $isxml = FALSE; |
|
264 | - $jxml = ""; |
|
263 | + $isxml = FALSE; |
|
264 | + $jxml = ""; |
|
265 | 265 | |
266 | - if (strpos($result, '<?xml')>-1) { |
|
267 | - $xml = simplexml_load_string($result); |
|
268 | - $jxml = json_encode($xml); |
|
269 | - $isxml = TRUE; |
|
270 | - } |
|
266 | + if (strpos($result, '<?xml')>-1) { |
|
267 | + $xml = simplexml_load_string($result); |
|
268 | + $jxml = json_encode($xml); |
|
269 | + $isxml = TRUE; |
|
270 | + } |
|
271 | 271 | |
272 | - $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
273 | - curl_close($ch); |
|
272 | + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); |
|
273 | + curl_close($ch); |
|
274 | 274 | |
275 | - if ($isxml) { |
|
276 | - $json = $jxml; |
|
277 | - } else { |
|
278 | - $json = json_decode($result, true); |
|
279 | - } |
|
275 | + if ($isxml) { |
|
276 | + $json = $jxml; |
|
277 | + } else { |
|
278 | + $json = json_decode($result, true); |
|
279 | + } |
|
280 | 280 | |
281 | - if (200==$code) { |
|
282 | - return $json; |
|
283 | - } elseif (isset($json['errors'])) { |
|
284 | - throw new ApiError(implode(', ', $json['errors'])); |
|
285 | - } else { |
|
286 | - throw new ApiError('Something wrong'); |
|
287 | - } |
|
288 | - } |
|
281 | + if (200==$code) { |
|
282 | + return $json; |
|
283 | + } elseif (isset($json['errors'])) { |
|
284 | + throw new ApiError(implode(', ', $json['errors'])); |
|
285 | + } else { |
|
286 | + throw new ApiError('Something wrong'); |
|
287 | + } |
|
288 | + } |
|
289 | 289 | |
290 | - /** |
|
291 | - * Prints on the screen main keys and values of the array |
|
292 | - * @param $results: object to be printed on the screen. |
|
293 | - * @param $deepPrinting: if true, object will be printed recursively. |
|
294 | - */ |
|
295 | - public static function simplePrint($results, $deepPrinting = null) |
|
296 | - { |
|
297 | - if (isset($results)) { |
|
298 | - if (is_array($results)) { |
|
299 | - foreach ($results as $key=>$result) { |
|
300 | - if (is_array($result)) { |
|
301 | - foreach ($result as $key1=>$result1) { |
|
302 | - if (is_array($result1)) { |
|
303 | - if ($deepPrinting) { |
|
304 | - echo "<br>$key1 ------><br>"; |
|
305 | - Route4Me::simplePrint($result1, true); |
|
306 | - echo "------<br>"; |
|
307 | - } else { |
|
308 | - echo $key1." --> "."Array() <br>"; |
|
309 | - } |
|
310 | - } else { |
|
311 | - if (is_object($result1)) { |
|
312 | - if ($deepPrinting) { |
|
313 | - echo "<br>$key1 ------><br>"; |
|
314 | - $oarray = (array)$result1; |
|
315 | - Route4Me::simplePrint($oarray, true); |
|
316 | - echo "------<br>"; |
|
317 | - } else { |
|
318 | - echo $key1." --> "."Object <br>"; |
|
319 | - } |
|
320 | - } else { |
|
321 | - if (!is_null($result1)) { |
|
322 | - echo $key1." --> ".$result1."<br>"; |
|
323 | - } |
|
324 | - } |
|
325 | - } |
|
326 | - } |
|
327 | - } else { |
|
328 | - if (is_object($result)) { |
|
329 | - if ($deepPrinting) { |
|
330 | - echo "<br>$key ------><br>"; |
|
331 | - $oarray = (array)$result; |
|
332 | - Route4Me::simplePrint($oarray, true); |
|
333 | - echo "------<br>"; |
|
334 | - } else { |
|
335 | - echo $key." --> "."Object <br>"; |
|
336 | - } |
|
337 | - } else { |
|
338 | - if (!is_null($result)) { |
|
339 | - echo $key." --> ".$result."<br>"; |
|
340 | - } |
|
341 | - } |
|
290 | + /** |
|
291 | + * Prints on the screen main keys and values of the array |
|
292 | + * @param $results: object to be printed on the screen. |
|
293 | + * @param $deepPrinting: if true, object will be printed recursively. |
|
294 | + */ |
|
295 | + public static function simplePrint($results, $deepPrinting = null) |
|
296 | + { |
|
297 | + if (isset($results)) { |
|
298 | + if (is_array($results)) { |
|
299 | + foreach ($results as $key=>$result) { |
|
300 | + if (is_array($result)) { |
|
301 | + foreach ($result as $key1=>$result1) { |
|
302 | + if (is_array($result1)) { |
|
303 | + if ($deepPrinting) { |
|
304 | + echo "<br>$key1 ------><br>"; |
|
305 | + Route4Me::simplePrint($result1, true); |
|
306 | + echo "------<br>"; |
|
307 | + } else { |
|
308 | + echo $key1." --> "."Array() <br>"; |
|
309 | + } |
|
310 | + } else { |
|
311 | + if (is_object($result1)) { |
|
312 | + if ($deepPrinting) { |
|
313 | + echo "<br>$key1 ------><br>"; |
|
314 | + $oarray = (array)$result1; |
|
315 | + Route4Me::simplePrint($oarray, true); |
|
316 | + echo "------<br>"; |
|
317 | + } else { |
|
318 | + echo $key1." --> "."Object <br>"; |
|
319 | + } |
|
320 | + } else { |
|
321 | + if (!is_null($result1)) { |
|
322 | + echo $key1." --> ".$result1."<br>"; |
|
323 | + } |
|
324 | + } |
|
325 | + } |
|
326 | + } |
|
327 | + } else { |
|
328 | + if (is_object($result)) { |
|
329 | + if ($deepPrinting) { |
|
330 | + echo "<br>$key ------><br>"; |
|
331 | + $oarray = (array)$result; |
|
332 | + Route4Me::simplePrint($oarray, true); |
|
333 | + echo "------<br>"; |
|
334 | + } else { |
|
335 | + echo $key." --> "."Object <br>"; |
|
336 | + } |
|
337 | + } else { |
|
338 | + if (!is_null($result)) { |
|
339 | + echo $key." --> ".$result."<br>"; |
|
340 | + } |
|
341 | + } |
|
342 | 342 | |
343 | - } |
|
344 | - //echo "<br>"; |
|
345 | - } |
|
346 | - } |
|
347 | - } |
|
348 | - } |
|
343 | + } |
|
344 | + //echo "<br>"; |
|
345 | + } |
|
346 | + } |
|
347 | + } |
|
348 | + } |
|
349 | 349 | |
350 | - /** |
|
351 | - * Generates query or body parameters. |
|
352 | - * @param $allFields: all known fields could be used for parameters generation. |
|
353 | - * @param $params: input parameters (array or object) |
|
354 | - */ |
|
355 | - public static function generateRequestParameters($allFields, $params) |
|
356 | - { |
|
357 | - $generatedParams = array(); |
|
350 | + /** |
|
351 | + * Generates query or body parameters. |
|
352 | + * @param $allFields: all known fields could be used for parameters generation. |
|
353 | + * @param $params: input parameters (array or object) |
|
354 | + */ |
|
355 | + public static function generateRequestParameters($allFields, $params) |
|
356 | + { |
|
357 | + $generatedParams = array(); |
|
358 | 358 | |
359 | - if (is_array($params)) { |
|
360 | - foreach ($allFields as $field) { |
|
361 | - if (isset($params[$field])) { |
|
362 | - $generatedParams[$field] = $params[$field]; |
|
363 | - } |
|
364 | - } |
|
365 | - } elseif (is_object($params)) { |
|
366 | - foreach ($allFields as $field) { |
|
367 | - if (isset($params->{$field})) { |
|
368 | - $generatedParams[$field] = $params->{$field}; |
|
369 | - } |
|
370 | - } |
|
371 | - } |
|
359 | + if (is_array($params)) { |
|
360 | + foreach ($allFields as $field) { |
|
361 | + if (isset($params[$field])) { |
|
362 | + $generatedParams[$field] = $params[$field]; |
|
363 | + } |
|
364 | + } |
|
365 | + } elseif (is_object($params)) { |
|
366 | + foreach ($allFields as $field) { |
|
367 | + if (isset($params->{$field})) { |
|
368 | + $generatedParams[$field] = $params->{$field}; |
|
369 | + } |
|
370 | + } |
|
371 | + } |
|
372 | 372 | |
373 | - return $generatedParams; |
|
374 | - } |
|
373 | + return $generatedParams; |
|
374 | + } |
|
375 | 375 | |
376 | - /** |
|
377 | - * Returns an array of the object properties |
|
378 | - * @param $object: An object. |
|
379 | - * @param $exclude: array of the object parameters to be excluded from the returned array. |
|
380 | - */ |
|
381 | - public static function getObjectProperties($object, $exclude) |
|
382 | - { |
|
383 | - $objectParameters = array(); |
|
376 | + /** |
|
377 | + * Returns an array of the object properties |
|
378 | + * @param $object: An object. |
|
379 | + * @param $exclude: array of the object parameters to be excluded from the returned array. |
|
380 | + */ |
|
381 | + public static function getObjectProperties($object, $exclude) |
|
382 | + { |
|
383 | + $objectParameters = array(); |
|
384 | 384 | |
385 | - foreach (get_object_vars($object) as $key => $value) { |
|
386 | - if (property_exists($object, $key)) { |
|
387 | - if (!is_numeric(array_search($key, $exclude))) { |
|
388 | - array_push($objectParameters, $key); |
|
389 | - } |
|
390 | - } |
|
391 | - } |
|
385 | + foreach (get_object_vars($object) as $key => $value) { |
|
386 | + if (property_exists($object, $key)) { |
|
387 | + if (!is_numeric(array_search($key, $exclude))) { |
|
388 | + array_push($objectParameters, $key); |
|
389 | + } |
|
390 | + } |
|
391 | + } |
|
392 | 392 | |
393 | - return $objectParameters; |
|
394 | - } |
|
393 | + return $objectParameters; |
|
394 | + } |
|
395 | 395 | |
396 | - /** |
|
397 | - * Returns url path generated from the array of the fields and parameters. |
|
398 | - * @param $allFields; array of the paossible fields (parameter names). |
|
399 | - * @param $params: input parameters (array or object). |
|
400 | - */ |
|
401 | - public static function generateUrlPath($allFields, $params) |
|
402 | - { |
|
403 | - $generatedPath = ""; |
|
396 | + /** |
|
397 | + * Returns url path generated from the array of the fields and parameters. |
|
398 | + * @param $allFields; array of the paossible fields (parameter names). |
|
399 | + * @param $params: input parameters (array or object). |
|
400 | + */ |
|
401 | + public static function generateUrlPath($allFields, $params) |
|
402 | + { |
|
403 | + $generatedPath = ""; |
|
404 | 404 | |
405 | - if (is_array($params)) { |
|
406 | - foreach ($allFields as $field) { |
|
407 | - if (isset($params[$field])) { |
|
408 | - $generatedPath .= $params[$field].'/'; |
|
409 | - } |
|
410 | - } |
|
411 | - } elseif (is_object($params)) { |
|
412 | - foreach ($allFields as $field) { |
|
413 | - if (isset($params->{$field})) { |
|
414 | - $generatedPath .= $params->{$field}.'/'; |
|
415 | - } |
|
416 | - } |
|
417 | - } |
|
405 | + if (is_array($params)) { |
|
406 | + foreach ($allFields as $field) { |
|
407 | + if (isset($params[$field])) { |
|
408 | + $generatedPath .= $params[$field].'/'; |
|
409 | + } |
|
410 | + } |
|
411 | + } elseif (is_object($params)) { |
|
412 | + foreach ($allFields as $field) { |
|
413 | + if (isset($params->{$field})) { |
|
414 | + $generatedPath .= $params->{$field}.'/'; |
|
415 | + } |
|
416 | + } |
|
417 | + } |
|
418 | 418 | |
419 | - return $generatedPath; |
|
420 | - } |
|
419 | + return $generatedPath; |
|
420 | + } |
|
421 | 421 | } |
@@ -258,14 +258,18 @@ discard block |
||
258 | 258 | { |
259 | 259 | $weekdays = explode(',', $scheduleWeekDays); |
260 | 260 | |
261 | - if (sizeof($weekdays)<1) return FALSE; |
|
261 | + if (sizeof($weekdays)<1) { |
|
262 | + return FALSE; |
|
263 | + } |
|
262 | 264 | |
263 | 265 | $isValid = TRUE; |
264 | 266 | |
265 | 267 | for ($i=0; $i<sizeof($weekdays); $i++) { |
266 | 268 | if (is_numeric($weekdays[$i])) { |
267 | 269 | $wday = intval($weekdays[$i]); |
268 | - if ($wday<1 || $wday>7) $isValid = FALSE; |
|
270 | + if ($wday<1 || $wday>7) { |
|
271 | + $isValid = FALSE; |
|
272 | + } |
|
269 | 273 | } else { |
270 | 274 | $isValid = FALSE; |
271 | 275 | } |
@@ -289,14 +293,18 @@ discard block |
||
289 | 293 | { |
290 | 294 | $monthlyDates = explode(',', $scheduleMonthlyDates); |
291 | 295 | |
292 | - if (sizeof($monthlyDates) <1) return FALSE; |
|
296 | + if (sizeof($monthlyDates) <1) { |
|
297 | + return FALSE; |
|
298 | + } |
|
293 | 299 | |
294 | 300 | $isValid = TRUE; |
295 | 301 | |
296 | 302 | for ($i=0; $i < sizeof($monthlyDates); $i++) { |
297 | 303 | if (is_numeric($monthlyDates[$i])) { |
298 | 304 | $mday = intval($monthlyDates[$i]); |
299 | - if ($mday <1 || $mday > 31) $isValid = FALSE; |
|
305 | + if ($mday <1 || $mday > 31) { |
|
306 | + $isValid = FALSE; |
|
307 | + } |
|
300 | 308 | } else { |
301 | 309 | $isValid = FALSE; |
302 | 310 | } |
@@ -307,7 +315,9 @@ discard block |
||
307 | 315 | |
308 | 316 | public static function validateScheduleNthN($scheduleNthN) |
309 | 317 | { |
310 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
318 | + if (!is_numeric($scheduleNthN)) { |
|
319 | + return FALSE; |
|
320 | + } |
|
311 | 321 | |
312 | 322 | $schedNthNs = array(1, 2, 3, 4, 5, -1); |
313 | 323 | |
@@ -320,7 +330,9 @@ discard block |
||
320 | 330 | |
321 | 331 | public static function validateScheduleNthWhat($scheduleNthWhat) |
322 | 332 | { |
323 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
333 | + if (!is_numeric($scheduleNthWhat)) { |
|
334 | + return FALSE; |
|
335 | + } |
|
324 | 336 | |
325 | 337 | $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
326 | 338 |
@@ -351,70 +351,70 @@ |
||
351 | 351 | |
352 | 352 | if ($mode!='daily') { |
353 | 353 | switch ($mode) { |
354 | - case 'weekly': |
|
355 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
356 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
357 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
358 | - } else { |
|
359 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
360 | - } |
|
354 | + case 'weekly': |
|
355 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
356 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
357 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
361 | 358 | } else { |
362 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
359 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
363 | 360 | } |
364 | - break; |
|
365 | - case 'monthly': |
|
366 | - $monthlyMode = ""; |
|
367 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
368 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
369 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
370 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
371 | - } else { |
|
372 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
373 | - } |
|
361 | + } else { |
|
362 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
363 | + } |
|
364 | + break; |
|
365 | + case 'monthly': |
|
366 | + $monthlyMode = ""; |
|
367 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
368 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
369 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
370 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
374 | 371 | } else { |
375 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
372 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
376 | 373 | } |
374 | + } else { |
|
375 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
376 | + } |
|
377 | 377 | |
378 | - if ($monthlyMode!="") { |
|
379 | - switch ($monthlyMode) { |
|
380 | - case 'dates': |
|
381 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
382 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
383 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
384 | - } else { |
|
385 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
386 | - } |
|
387 | - } |
|
388 | - break; |
|
389 | - case 'nth': |
|
390 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
391 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
392 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
393 | - } else { |
|
394 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
395 | - } |
|
396 | - } else { |
|
397 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
398 | - } |
|
378 | + if ($monthlyMode!="") { |
|
379 | + switch ($monthlyMode) { |
|
380 | + case 'dates': |
|
381 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
382 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
383 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
384 | + } else { |
|
385 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
386 | + } |
|
387 | + } |
|
388 | + break; |
|
389 | + case 'nth': |
|
390 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
391 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
392 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
393 | + } else { |
|
394 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
395 | + } |
|
396 | + } else { |
|
397 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
398 | + } |
|
399 | 399 | |
400 | - if ($curSchedule!="") { |
|
401 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
402 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
403 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
404 | - } else { |
|
405 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
406 | - } |
|
407 | - } else { |
|
408 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
409 | - } |
|
410 | - } |
|
411 | - break; |
|
400 | + if ($curSchedule!="") { |
|
401 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
402 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
403 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
404 | + } else { |
|
405 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
412 | 406 | } |
407 | + } else { |
|
408 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
409 | + } |
|
413 | 410 | } |
414 | 411 | break; |
415 | - default: |
|
416 | - $curSchedule = ""; |
|
412 | + } |
|
413 | + } |
|
417 | 414 | break; |
415 | + default: |
|
416 | + $curSchedule = ""; |
|
417 | + break; |
|
418 | 418 | } |
419 | 419 | } |
420 | 420 |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | |
215 | 215 | $isValid = TRUE; |
216 | 216 | |
217 | - for ($i=0; $i<sizeof($weekdays); $i++) { |
|
217 | + for ($i = 0; $i<sizeof($weekdays); $i++) { |
|
218 | 218 | if (is_numeric($weekdays[$i])) { |
219 | 219 | $wday = intval($weekdays[$i]); |
220 | 220 | if ($wday<1 || $wday>7) $isValid = FALSE; |
@@ -241,14 +241,14 @@ discard block |
||
241 | 241 | { |
242 | 242 | $monthlyDates = explode(',', $scheduleMonthlyDates); |
243 | 243 | |
244 | - if (sizeof($monthlyDates) <1) return FALSE; |
|
244 | + if (sizeof($monthlyDates)<1) return FALSE; |
|
245 | 245 | |
246 | 246 | $isValid = TRUE; |
247 | 247 | |
248 | - for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
248 | + for ($i = 0; $i<sizeof($monthlyDates); $i++) { |
|
249 | 249 | if (is_numeric($monthlyDates[$i])) { |
250 | 250 | $mday = intval($monthlyDates[$i]); |
251 | - if ($mday <1 || $mday > 31) $isValid = FALSE; |
|
251 | + if ($mday<1 || $mday>31) $isValid = FALSE; |
|
252 | 252 | } else { |
253 | 253 | $isValid = FALSE; |
254 | 254 | } |
@@ -339,10 +339,10 @@ discard block |
||
339 | 339 | |
340 | 340 | if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
341 | 341 | if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
342 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
342 | + $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
343 | 343 | if ($mode=='daily') { |
344 | - $curSchedule = trim($curSchedule,','); |
|
345 | - $curSchedule.='}'; |
|
344 | + $curSchedule = trim($curSchedule, ','); |
|
345 | + $curSchedule .= '}'; |
|
346 | 346 | } |
347 | 347 | } else { |
348 | 348 | array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | |
432 | 432 | $curSchedule = '[{'.$curSchedule.'}]'; |
433 | 433 | |
434 | - $oSchedule = json_decode($curSchedule,TRUE); |
|
434 | + $oSchedule = json_decode($curSchedule, TRUE); |
|
435 | 435 | |
436 | 436 | $parametersArray = array(); |
437 | 437 |
@@ -6,439 +6,439 @@ |
||
6 | 6 | |
7 | 7 | class AddressBookLocation extends Common |
8 | 8 | { |
9 | - public $address_id; |
|
10 | - public $address_group; |
|
11 | - public $address_alias; |
|
12 | - public $address_1; |
|
13 | - public $address_2; |
|
14 | - public $first_name; |
|
15 | - public $last_name; |
|
16 | - public $address_email; |
|
17 | - public $address_phone_number; |
|
18 | - public $address_city; |
|
19 | - public $address_state_id; |
|
20 | - public $address_country_id; |
|
21 | - public $address_zip; |
|
22 | - public $cached_lat; |
|
23 | - public $cached_lng; |
|
24 | - public $curbside_lat; |
|
25 | - public $curbside_lng; |
|
26 | - public $color; |
|
27 | - public $address_custom_data; |
|
28 | - public $schedule; |
|
9 | + public $address_id; |
|
10 | + public $address_group; |
|
11 | + public $address_alias; |
|
12 | + public $address_1; |
|
13 | + public $address_2; |
|
14 | + public $first_name; |
|
15 | + public $last_name; |
|
16 | + public $address_email; |
|
17 | + public $address_phone_number; |
|
18 | + public $address_city; |
|
19 | + public $address_state_id; |
|
20 | + public $address_country_id; |
|
21 | + public $address_zip; |
|
22 | + public $cached_lat; |
|
23 | + public $cached_lng; |
|
24 | + public $curbside_lat; |
|
25 | + public $curbside_lng; |
|
26 | + public $color; |
|
27 | + public $address_custom_data; |
|
28 | + public $schedule; |
|
29 | 29 | |
30 | - public $created_timestamp; |
|
31 | - public $member_id; |
|
32 | - public $schedule_blacklist; |
|
33 | - public $in_route_count; |
|
34 | - public $last_visited_timestamp; |
|
35 | - public $last_routed_timestamp; |
|
36 | - public $local_time_window_start; |
|
37 | - public $local_time_window_end; |
|
38 | - public $local_time_window_start_2; |
|
39 | - public $local_time_window_end_2; |
|
40 | - public $service_time; |
|
41 | - public $local_timezone_string; |
|
42 | - public $address_icon; |
|
43 | - public $address_stop_type; |
|
44 | - public $address_cube; |
|
45 | - public $address_pieces; |
|
46 | - public $address_reference_no; |
|
47 | - public $address_revenue; |
|
48 | - public $address_weight; |
|
49 | - public $address_priority; |
|
50 | - public $address_customer_po; |
|
30 | + public $created_timestamp; |
|
31 | + public $member_id; |
|
32 | + public $schedule_blacklist; |
|
33 | + public $in_route_count; |
|
34 | + public $last_visited_timestamp; |
|
35 | + public $last_routed_timestamp; |
|
36 | + public $local_time_window_start; |
|
37 | + public $local_time_window_end; |
|
38 | + public $local_time_window_start_2; |
|
39 | + public $local_time_window_end_2; |
|
40 | + public $service_time; |
|
41 | + public $local_timezone_string; |
|
42 | + public $address_icon; |
|
43 | + public $address_stop_type; |
|
44 | + public $address_cube; |
|
45 | + public $address_pieces; |
|
46 | + public $address_reference_no; |
|
47 | + public $address_revenue; |
|
48 | + public $address_weight; |
|
49 | + public $address_priority; |
|
50 | + public $address_customer_po; |
|
51 | 51 | |
52 | - public static function fromArray(array $params) |
|
53 | - { |
|
54 | - $addressbooklocation = new AddressBookLocation(); |
|
52 | + public static function fromArray(array $params) |
|
53 | + { |
|
54 | + $addressbooklocation = new AddressBookLocation(); |
|
55 | 55 | |
56 | - foreach ($params as $key => $value) { |
|
57 | - if (property_exists($addressbooklocation, $key)) { |
|
58 | - $addressbooklocation->{$key} = $value; |
|
59 | - } |
|
60 | - } |
|
56 | + foreach ($params as $key => $value) { |
|
57 | + if (property_exists($addressbooklocation, $key)) { |
|
58 | + $addressbooklocation->{$key} = $value; |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - return $addressbooklocation; |
|
63 | - } |
|
62 | + return $addressbooklocation; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | |
67 | - public static function getAddressBookLocation($addressId) |
|
68 | - { |
|
69 | - $ablocations = Route4Me::makeRequst(array( |
|
70 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
71 | - 'method' => 'GET', |
|
72 | - 'query' => array( |
|
73 | - 'query' => $addressId, |
|
74 | - 'limit' => 30 |
|
75 | - ) |
|
76 | - )); |
|
67 | + public static function getAddressBookLocation($addressId) |
|
68 | + { |
|
69 | + $ablocations = Route4Me::makeRequst(array( |
|
70 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
71 | + 'method' => 'GET', |
|
72 | + 'query' => array( |
|
73 | + 'query' => $addressId, |
|
74 | + 'limit' => 30 |
|
75 | + ) |
|
76 | + )); |
|
77 | 77 | |
78 | - return $ablocations; |
|
79 | - } |
|
78 | + return $ablocations; |
|
79 | + } |
|
80 | 80 | |
81 | - public static function searchAddressBookLocations($params) |
|
82 | - { |
|
83 | - $allQueryFields = array('display', 'query', 'fields', 'limit', 'offset'); |
|
81 | + public static function searchAddressBookLocations($params) |
|
82 | + { |
|
83 | + $allQueryFields = array('display', 'query', 'fields', 'limit', 'offset'); |
|
84 | 84 | |
85 | - $result = Route4Me::makeRequst(array( |
|
86 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
87 | - 'method' => 'GET', |
|
88 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
89 | - )); |
|
85 | + $result = Route4Me::makeRequst(array( |
|
86 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
87 | + 'method' => 'GET', |
|
88 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
89 | + )); |
|
90 | 90 | |
91 | - return $result; |
|
92 | - } |
|
91 | + return $result; |
|
92 | + } |
|
93 | 93 | |
94 | - public static function getAddressBookLocations($params) |
|
95 | - { |
|
96 | - $allQueryFields = array('limit', 'offset', 'address_id'); |
|
94 | + public static function getAddressBookLocations($params) |
|
95 | + { |
|
96 | + $allQueryFields = array('limit', 'offset', 'address_id'); |
|
97 | 97 | |
98 | - $ablocations = Route4Me::makeRequst(array( |
|
99 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
100 | - 'method' => 'GET', |
|
101 | - 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
102 | - )); |
|
98 | + $ablocations = Route4Me::makeRequst(array( |
|
99 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
100 | + 'method' => 'GET', |
|
101 | + 'query' => Route4Me::generateRequestParameters($allQueryFields, $params) |
|
102 | + )); |
|
103 | 103 | |
104 | - return $ablocations; |
|
105 | - } |
|
104 | + return $ablocations; |
|
105 | + } |
|
106 | 106 | |
107 | - public static function getRandomAddressBookLocation($params) |
|
108 | - { |
|
109 | - $ablocations = self::getAddressBookLocations($params); |
|
107 | + public static function getRandomAddressBookLocation($params) |
|
108 | + { |
|
109 | + $ablocations = self::getAddressBookLocations($params); |
|
110 | 110 | |
111 | - if (isset($ablocations["results"])) { |
|
112 | - $locationsSize = sizeof($ablocations["results"]); |
|
111 | + if (isset($ablocations["results"])) { |
|
112 | + $locationsSize = sizeof($ablocations["results"]); |
|
113 | 113 | |
114 | - if ($locationsSize>0) { |
|
115 | - $randomLocationIndex = rand(0, $locationsSize - 1); |
|
116 | - return $ablocations["results"][$randomLocationIndex]; |
|
117 | - } |
|
118 | - } |
|
114 | + if ($locationsSize>0) { |
|
115 | + $randomLocationIndex = rand(0, $locationsSize - 1); |
|
116 | + return $ablocations["results"][$randomLocationIndex]; |
|
117 | + } |
|
118 | + } |
|
119 | 119 | |
120 | - return null; |
|
121 | - } |
|
120 | + return null; |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * @param AddressBookLocation $params |
|
125 | - */ |
|
126 | - public static function addAdressBookLocation($params) |
|
127 | - { |
|
128 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
123 | + /** |
|
124 | + * @param AddressBookLocation $params |
|
125 | + */ |
|
126 | + public static function addAdressBookLocation($params) |
|
127 | + { |
|
128 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
129 | 129 | |
130 | - $response = Route4Me::makeRequst(array( |
|
131 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
132 | - 'method' => 'POST', |
|
133 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
134 | - )); |
|
130 | + $response = Route4Me::makeRequst(array( |
|
131 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
132 | + 'method' => 'POST', |
|
133 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
134 | + )); |
|
135 | 135 | |
136 | - return $response; |
|
137 | - } |
|
136 | + return $response; |
|
137 | + } |
|
138 | 138 | |
139 | - public function deleteAdressBookLocation($address_ids) |
|
140 | - { |
|
141 | - $result = Route4Me::makeRequst(array( |
|
142 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
143 | - 'method' => 'DELETEARRAY', |
|
144 | - 'query' => array( |
|
145 | - 'address_ids' => $address_ids |
|
146 | - ) |
|
147 | - )); |
|
139 | + public function deleteAdressBookLocation($address_ids) |
|
140 | + { |
|
141 | + $result = Route4Me::makeRequst(array( |
|
142 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
143 | + 'method' => 'DELETEARRAY', |
|
144 | + 'query' => array( |
|
145 | + 'address_ids' => $address_ids |
|
146 | + ) |
|
147 | + )); |
|
148 | 148 | |
149 | - return $result; |
|
150 | - } |
|
149 | + return $result; |
|
150 | + } |
|
151 | 151 | |
152 | - public function updateAdressBookLocation($params) |
|
153 | - { |
|
154 | - $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
152 | + public function updateAdressBookLocation($params) |
|
153 | + { |
|
154 | + $allBodyFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('in_route_count')); |
|
155 | 155 | |
156 | - $response = Route4Me::makeRequst(array( |
|
157 | - 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
158 | - 'method' => 'PUT', |
|
159 | - 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
160 | - )); |
|
156 | + $response = Route4Me::makeRequst(array( |
|
157 | + 'url' => Endpoint::ADDRESS_BOOK_V4, |
|
158 | + 'method' => 'PUT', |
|
159 | + 'body' => Route4Me::generateRequestParameters($allBodyFields, $params) |
|
160 | + )); |
|
161 | 161 | |
162 | - return $response; |
|
163 | - } |
|
162 | + return $response; |
|
163 | + } |
|
164 | 164 | |
165 | - public static function validateScheduleMode($scheduleMode) |
|
166 | - { |
|
167 | - $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
165 | + public static function validateScheduleMode($scheduleMode) |
|
166 | + { |
|
167 | + $schedMmodes = array("daily", "weekly", "monthly", "annually"); |
|
168 | 168 | |
169 | - if (in_array($scheduleMode, $schedMmodes)) { |
|
170 | - return TRUE; |
|
171 | - } else { |
|
172 | - return FALSE; |
|
173 | - } |
|
174 | - } |
|
169 | + if (in_array($scheduleMode, $schedMmodes)) { |
|
170 | + return TRUE; |
|
171 | + } else { |
|
172 | + return FALSE; |
|
173 | + } |
|
174 | + } |
|
175 | 175 | |
176 | - public static function validateScheduleEnable($scheduleEnabled) |
|
177 | - { |
|
178 | - $schedEnables = array(TRUE, FALSE); |
|
176 | + public static function validateScheduleEnable($scheduleEnabled) |
|
177 | + { |
|
178 | + $schedEnables = array(TRUE, FALSE); |
|
179 | 179 | |
180 | - if (in_array($scheduleEnabled, $schedEnables)) { |
|
181 | - return TRUE; |
|
182 | - } else { |
|
183 | - return FALSE; |
|
184 | - } |
|
185 | - } |
|
180 | + if (in_array($scheduleEnabled, $schedEnables)) { |
|
181 | + return TRUE; |
|
182 | + } else { |
|
183 | + return FALSE; |
|
184 | + } |
|
185 | + } |
|
186 | 186 | |
187 | - public static function validateScheduleEvery($scheduleEvery) |
|
188 | - { |
|
189 | - if (is_numeric($scheduleEvery)) { |
|
190 | - return TRUE; |
|
191 | - } else { |
|
192 | - return FALSE; |
|
193 | - } |
|
194 | - } |
|
187 | + public static function validateScheduleEvery($scheduleEvery) |
|
188 | + { |
|
189 | + if (is_numeric($scheduleEvery)) { |
|
190 | + return TRUE; |
|
191 | + } else { |
|
192 | + return FALSE; |
|
193 | + } |
|
194 | + } |
|
195 | 195 | |
196 | - public static function validateScheduleWeekDays($scheduleWeekDays) |
|
197 | - { |
|
198 | - $weekdays = explode(',', $scheduleWeekDays); |
|
196 | + public static function validateScheduleWeekDays($scheduleWeekDays) |
|
197 | + { |
|
198 | + $weekdays = explode(',', $scheduleWeekDays); |
|
199 | 199 | |
200 | - if (sizeof($weekdays)<1) return FALSE; |
|
200 | + if (sizeof($weekdays)<1) return FALSE; |
|
201 | 201 | |
202 | - $isValid = TRUE; |
|
202 | + $isValid = TRUE; |
|
203 | 203 | |
204 | - for ($i=0; $i<sizeof($weekdays); $i++) { |
|
205 | - if (is_numeric($weekdays[$i])) { |
|
206 | - $wday = intval($weekdays[$i]); |
|
207 | - if ($wday<1 || $wday>7) $isValid = FALSE; |
|
208 | - } else { |
|
209 | - $isValid = FALSE; |
|
210 | - } |
|
211 | - } |
|
204 | + for ($i=0; $i<sizeof($weekdays); $i++) { |
|
205 | + if (is_numeric($weekdays[$i])) { |
|
206 | + $wday = intval($weekdays[$i]); |
|
207 | + if ($wday<1 || $wday>7) $isValid = FALSE; |
|
208 | + } else { |
|
209 | + $isValid = FALSE; |
|
210 | + } |
|
211 | + } |
|
212 | 212 | |
213 | - return $isValid; |
|
214 | - } |
|
213 | + return $isValid; |
|
214 | + } |
|
215 | 215 | |
216 | - public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
217 | - { |
|
218 | - $schedMonthlyMmodes = array("dates", "nth"); |
|
216 | + public static function validateScheduleMonthlyMode($scheduleMonthlyMode) |
|
217 | + { |
|
218 | + $schedMonthlyMmodes = array("dates", "nth"); |
|
219 | 219 | |
220 | - if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
221 | - return TRUE; |
|
222 | - } else { |
|
223 | - return FALSE; |
|
224 | - } |
|
225 | - } |
|
220 | + if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) { |
|
221 | + return TRUE; |
|
222 | + } else { |
|
223 | + return FALSE; |
|
224 | + } |
|
225 | + } |
|
226 | 226 | |
227 | - public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
228 | - { |
|
229 | - $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
227 | + public static function validateScheduleMonthlyDates($scheduleMonthlyDates) |
|
228 | + { |
|
229 | + $monthlyDates = explode(',', $scheduleMonthlyDates); |
|
230 | 230 | |
231 | - if (sizeof($monthlyDates) <1) return FALSE; |
|
231 | + if (sizeof($monthlyDates) <1) return FALSE; |
|
232 | 232 | |
233 | - $isValid = TRUE; |
|
233 | + $isValid = TRUE; |
|
234 | 234 | |
235 | - for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
236 | - if (is_numeric($monthlyDates[$i])) { |
|
237 | - $mday = intval($monthlyDates[$i]); |
|
238 | - if ($mday <1 || $mday > 31) $isValid = FALSE; |
|
239 | - } else { |
|
240 | - $isValid = FALSE; |
|
241 | - } |
|
242 | - } |
|
235 | + for ($i=0; $i < sizeof($monthlyDates); $i++) { |
|
236 | + if (is_numeric($monthlyDates[$i])) { |
|
237 | + $mday = intval($monthlyDates[$i]); |
|
238 | + if ($mday <1 || $mday > 31) $isValid = FALSE; |
|
239 | + } else { |
|
240 | + $isValid = FALSE; |
|
241 | + } |
|
242 | + } |
|
243 | 243 | |
244 | - return $isValid; |
|
245 | - } |
|
244 | + return $isValid; |
|
245 | + } |
|
246 | 246 | |
247 | - public static function validateScheduleNthN($scheduleNthN) |
|
248 | - { |
|
249 | - if (!is_numeric($scheduleNthN)) return FALSE; |
|
247 | + public static function validateScheduleNthN($scheduleNthN) |
|
248 | + { |
|
249 | + if (!is_numeric($scheduleNthN)) return FALSE; |
|
250 | 250 | |
251 | - $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
251 | + $schedNthNs = array(1, 2, 3, 4, 5, -1); |
|
252 | 252 | |
253 | - if (in_array($scheduleNthN, $schedNthNs)) { |
|
254 | - return TRUE; |
|
255 | - } else { |
|
256 | - return FALSE; |
|
257 | - } |
|
258 | - } |
|
253 | + if (in_array($scheduleNthN, $schedNthNs)) { |
|
254 | + return TRUE; |
|
255 | + } else { |
|
256 | + return FALSE; |
|
257 | + } |
|
258 | + } |
|
259 | 259 | |
260 | - public static function validateScheduleNthWhat($scheduleNthWhat) |
|
261 | - { |
|
262 | - if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
260 | + public static function validateScheduleNthWhat($scheduleNthWhat) |
|
261 | + { |
|
262 | + if (!is_numeric($scheduleNthWhat)) return FALSE; |
|
263 | 263 | |
264 | - $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
264 | + $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); |
|
265 | 265 | |
266 | - if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
267 | - return TRUE; |
|
268 | - } else { |
|
269 | - return FALSE; |
|
270 | - } |
|
271 | - } |
|
266 | + if (in_array($scheduleNthWhat, $schedNthWhats)) { |
|
267 | + return TRUE; |
|
268 | + } else { |
|
269 | + return FALSE; |
|
270 | + } |
|
271 | + } |
|
272 | 272 | |
273 | - /** Function adds the locations (with/without schedule) from the CSV file. |
|
274 | - * $csvFileHandle - a file handler. |
|
275 | - * Returns array $results which contains two arrays: fail and succes. |
|
276 | - */ |
|
277 | - public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
278 | - { |
|
279 | - $max_line_length = 512; |
|
280 | - $delemietr = ','; |
|
273 | + /** Function adds the locations (with/without schedule) from the CSV file. |
|
274 | + * $csvFileHandle - a file handler. |
|
275 | + * Returns array $results which contains two arrays: fail and succes. |
|
276 | + */ |
|
277 | + public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping) |
|
278 | + { |
|
279 | + $max_line_length = 512; |
|
280 | + $delemietr = ','; |
|
281 | 281 | |
282 | - $results = array(); |
|
283 | - $results['fail'] = array(); |
|
284 | - $results['success'] = array(); |
|
282 | + $results = array(); |
|
283 | + $results['fail'] = array(); |
|
284 | + $results['success'] = array(); |
|
285 | 285 | |
286 | - $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
286 | + $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr); |
|
287 | 287 | |
288 | - $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
288 | + $addressBookFields = Route4Me::getObjectProperties(new AddressBookLocation(), array('address_id', 'in_route_count')); |
|
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 (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
299 | - || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
300 | - continue; |
|
301 | - } |
|
297 | + while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) { |
|
298 | + if (!isset($rows[$locationsFieldsMapping['cached_lat']]) || !isset($rows[$locationsFieldsMapping['cached_lng']]) |
|
299 | + || !isset($rows[$locationsFieldsMapping['address_1']]) || array(null)==$rows) { |
|
300 | + continue; |
|
301 | + } |
|
302 | 302 | |
303 | - $curSchedule = ""; |
|
304 | - $mode = ""; |
|
303 | + $curSchedule = ""; |
|
304 | + $mode = ""; |
|
305 | 305 | |
306 | - $failCount = sizeof($results['fail']); |
|
306 | + $failCount = sizeof($results['fail']); |
|
307 | 307 | |
308 | - if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
309 | - if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
310 | - $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
311 | - $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
312 | - } else { |
|
313 | - array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
314 | - } |
|
315 | - } else { |
|
316 | - array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
317 | - } |
|
308 | + if (isset($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
309 | + if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) { |
|
310 | + $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; |
|
311 | + $mode = $rows[$locationsFieldsMapping['schedule_mode']]; |
|
312 | + } else { |
|
313 | + array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); |
|
314 | + } |
|
315 | + } else { |
|
316 | + array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); |
|
317 | + } |
|
318 | 318 | |
319 | - if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
320 | - if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
321 | - $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
322 | - } else { |
|
323 | - array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
324 | - } |
|
325 | - } |
|
319 | + if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
320 | + if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { |
|
321 | + $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].','; |
|
322 | + } else { |
|
323 | + array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set "); |
|
324 | + } |
|
325 | + } |
|
326 | 326 | |
327 | - if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
328 | - if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
329 | - $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
330 | - if ($mode=='daily') { |
|
331 | - $curSchedule = trim($curSchedule,','); |
|
332 | - $curSchedule.='}'; |
|
333 | - } |
|
334 | - } else { |
|
335 | - array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
336 | - } |
|
337 | - } |
|
327 | + if (isset($rows[$locationsFieldsMapping['schedule_every']])) { |
|
328 | + if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) { |
|
329 | + $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; |
|
330 | + if ($mode=='daily') { |
|
331 | + $curSchedule = trim($curSchedule,','); |
|
332 | + $curSchedule.='}'; |
|
333 | + } |
|
334 | + } else { |
|
335 | + array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); |
|
336 | + } |
|
337 | + } |
|
338 | 338 | |
339 | - if ($mode!='daily') { |
|
340 | - switch ($mode) { |
|
341 | - case 'weekly': |
|
342 | - if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
343 | - if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
344 | - $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
345 | - } else { |
|
346 | - array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
347 | - } |
|
348 | - } else { |
|
349 | - array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
350 | - } |
|
351 | - break; |
|
352 | - case 'monthly': |
|
353 | - $monthlyMode = ""; |
|
354 | - if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
355 | - if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
356 | - $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
357 | - $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
358 | - } else { |
|
359 | - array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
360 | - } |
|
361 | - } else { |
|
362 | - array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
363 | - } |
|
339 | + if ($mode!='daily') { |
|
340 | + switch ($mode) { |
|
341 | + case 'weekly': |
|
342 | + if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
343 | + if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) { |
|
344 | + $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}'; |
|
345 | + } else { |
|
346 | + array_push($results['fail'], "$iRow --> Wrong weekdays"); |
|
347 | + } |
|
348 | + } else { |
|
349 | + array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); |
|
350 | + } |
|
351 | + break; |
|
352 | + case 'monthly': |
|
353 | + $monthlyMode = ""; |
|
354 | + if (isset($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
355 | + if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) { |
|
356 | + $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']]; |
|
357 | + $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",'; |
|
358 | + } else { |
|
359 | + array_push($results['fail'], "$iRow --> Wrong monthly mode"); |
|
360 | + } |
|
361 | + } else { |
|
362 | + array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); |
|
363 | + } |
|
364 | 364 | |
365 | - if ($monthlyMode!="") { |
|
366 | - switch ($monthlyMode) { |
|
367 | - case 'dates': |
|
368 | - if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
369 | - if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
370 | - $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
371 | - } else { |
|
372 | - array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
373 | - } |
|
374 | - } |
|
375 | - break; |
|
376 | - case 'nth': |
|
377 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
378 | - if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
379 | - $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
380 | - } else { |
|
381 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
382 | - } |
|
383 | - } else { |
|
384 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
385 | - } |
|
365 | + if ($monthlyMode!="") { |
|
366 | + switch ($monthlyMode) { |
|
367 | + case 'dates': |
|
368 | + if (isset($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
369 | + if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) { |
|
370 | + $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}'; |
|
371 | + } else { |
|
372 | + array_push($results['fail'], "$iRow --> Wrong monthly dates"); |
|
373 | + } |
|
374 | + } |
|
375 | + break; |
|
376 | + case 'nth': |
|
377 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
378 | + if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) { |
|
379 | + $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].','; |
|
380 | + } else { |
|
381 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); |
|
382 | + } |
|
383 | + } else { |
|
384 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); |
|
385 | + } |
|
386 | 386 | |
387 | - if ($curSchedule!="") { |
|
388 | - if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
389 | - if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
390 | - $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
391 | - } else { |
|
392 | - array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
393 | - } |
|
394 | - } else { |
|
395 | - array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
396 | - } |
|
397 | - } |
|
398 | - break; |
|
399 | - } |
|
400 | - } |
|
401 | - break; |
|
402 | - default: |
|
403 | - $curSchedule = ""; |
|
404 | - break; |
|
405 | - } |
|
406 | - } |
|
387 | + if ($curSchedule!="") { |
|
388 | + if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
389 | + if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) { |
|
390 | + $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}'; |
|
391 | + } else { |
|
392 | + array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); |
|
393 | + } |
|
394 | + } else { |
|
395 | + array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); |
|
396 | + } |
|
397 | + } |
|
398 | + break; |
|
399 | + } |
|
400 | + } |
|
401 | + break; |
|
402 | + default: |
|
403 | + $curSchedule = ""; |
|
404 | + break; |
|
405 | + } |
|
406 | + } |
|
407 | 407 | |
408 | - if (sizeof($results['fail'])>$failCount) { |
|
409 | - $curSchedule = ""; |
|
410 | - } |
|
408 | + if (sizeof($results['fail'])>$failCount) { |
|
409 | + $curSchedule = ""; |
|
410 | + } |
|
411 | 411 | |
412 | - if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
413 | - $iRow++; |
|
414 | - continue; |
|
415 | - } |
|
412 | + if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") { |
|
413 | + $iRow++; |
|
414 | + continue; |
|
415 | + } |
|
416 | 416 | |
417 | - $curSchedule = strtolower($curSchedule); |
|
417 | + $curSchedule = strtolower($curSchedule); |
|
418 | 418 | |
419 | - $curSchedule = '[{'.$curSchedule.'}]'; |
|
419 | + $curSchedule = '[{'.$curSchedule.'}]'; |
|
420 | 420 | |
421 | - $oSchedule = json_decode($curSchedule,TRUE); |
|
421 | + $oSchedule = json_decode($curSchedule,TRUE); |
|
422 | 422 | |
423 | - $parametersArray = array(); |
|
423 | + $parametersArray = array(); |
|
424 | 424 | |
425 | - foreach ($addressBookFields as $addressBookField) { |
|
426 | - if (isset($locationsFieldsMapping[$addressBookField])) { |
|
427 | - $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
428 | - } |
|
429 | - } |
|
425 | + foreach ($addressBookFields as $addressBookField) { |
|
426 | + if (isset($locationsFieldsMapping[$addressBookField])) { |
|
427 | + $parametersArray[$addressBookField] = $rows[$locationsFieldsMapping[$addressBookField]]; |
|
428 | + } |
|
429 | + } |
|
430 | 430 | |
431 | - $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
431 | + $AdressBookLocationParameters = AddressBookLocation::fromArray($parametersArray); |
|
432 | 432 | |
433 | - $abContacts = new AddressBookLocation(); |
|
433 | + $abContacts = new AddressBookLocation(); |
|
434 | 434 | |
435 | - $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
435 | + $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry |
|
436 | 436 | |
437 | - array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
438 | - } |
|
437 | + array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly."); |
|
438 | + } |
|
439 | 439 | |
440 | - return $results; |
|
441 | - } |
|
440 | + return $results; |
|
441 | + } |
|
442 | 442 | |
443 | 443 | } |
444 | 444 | |
445 | 445 | \ No newline at end of file |
@@ -18,14 +18,14 @@ |
||
18 | 18 | |
19 | 19 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
20 | 20 | $territoryParams['data'] = array( |
21 | - "37.569752822786455,-77.47833251953125", |
|
22 | - "5000" |
|
21 | + "37.569752822786455,-77.47833251953125", |
|
22 | + "5000" |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $AvoisanceZoneParameters = AvoidanceZone::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | - "territory_color" => "ff7700", |
|
28 | - "territory" => $territoryParams |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | + "territory_color" => "ff7700", |
|
28 | + "territory" => $territoryParams |
|
29 | 29 | )); |
30 | 30 | |
31 | 31 | $avoidancezone = new AvoidanceZone(); |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | -$root = realpath(dirname(__FILE__) . '/../../'); |
|
5 | -require $root . '/vendor/autoload.php'; |
|
4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
5 | +require $root.'/vendor/autoload.php'; |
|
6 | 6 | |
7 | 7 | use Route4Me\Route4Me; |
8 | 8 | use Route4Me\Enum\TerritoryTypes; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ); |
24 | 24 | |
25 | 25 | $AvoisanceZoneParameters = AvoidanceZone::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000, 99999)), |
|
27 | 27 | "territory_color" => "ff7700", |
28 | 28 | "territory" => $territoryParams |
29 | 29 | )); |
@@ -18,14 +18,14 @@ |
||
18 | 18 | |
19 | 19 | $territoryParams['type'] = TerritoryTypes::CIRCLE; |
20 | 20 | $territoryParams['data'] = array( |
21 | - "37.569752822786455,-77.47833251953125", |
|
22 | - "5000" |
|
21 | + "37.569752822786455,-77.47833251953125", |
|
22 | + "5000" |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | - "territory_color" => "ff7700", |
|
28 | - "territory" => $territoryParams |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
27 | + "territory_color" => "ff7700", |
|
28 | + "territory" => $territoryParams |
|
29 | 29 | )); |
30 | 30 | |
31 | 31 | $territory = new Territory(); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | -$root=realpath(dirname(__FILE__).'/../../'); |
|
4 | +$root = realpath(dirname(__FILE__).'/../../'); |
|
5 | 5 | require $root.'/vendor/autoload.php'; |
6 | 6 | |
7 | 7 | use Route4Me\Route4Me; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ); |
24 | 24 | |
25 | 25 | $TerritoryParameters = Territory::fromArray(array( |
26 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
26 | + "territory_name" => "Test Territory ".strval(rand(10000, 99999)), |
|
27 | 27 | "territory_color" => "ff7700", |
28 | 28 | "territory" => $territoryParams |
29 | 29 | )); |
@@ -17,9 +17,9 @@ |
||
17 | 17 | // Example refers to the process of searching for the routed locations |
18 | 18 | |
19 | 19 | $params = array( |
20 | - 'offset' => 0, |
|
21 | - 'limit' => 5, |
|
22 | - 'display' => 'routed' |
|
20 | + 'offset' => 0, |
|
21 | + 'limit' => 5, |
|
22 | + 'display' => 'routed' |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $abcResult = $ablocation->searchAddressBookLocations($params); |