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.
Completed
Branch Editing-Fixing (c4d168)
by Igor
03:30
created
examples/Optimizations/hybridOptimization.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,6 @@
 block discarded – undo
5 5
 require $root . '/vendor/autoload.php';
6 6
 
7 7
 use Route4Me\OptimizationProblem;
8
-use Route4Me\Route;
9 8
 use Route4Me\Route4Me;
10 9
 
11 10
 /* The example demonstrates process of creating a Hybrid Optimization using scheduling addresses and orders.
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -45,22 +45,22 @@  discard block
 block discarded – undo
45 45
 $locationsFieldsMapping['monthly_nth_wwhat'] = 17;
46 46
 
47 47
 if (($handle = fopen("$source_file", "r")) !== FALSE) {
48
-        $oAbook = new AddressBookLocation();
48
+		$oAbook = new AddressBookLocation();
49 49
 
50
-        $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping);
50
+		$results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping);
51 51
         
52
-        echo "Errors: <br><br>";
52
+		echo "Errors: <br><br>";
53 53
         
54
-        foreach ($results['fail'] as $evalue) {
55
-            echo $evalue."<br>";
56
-        }
54
+		foreach ($results['fail'] as $evalue) {
55
+			echo $evalue."<br>";
56
+		}
57 57
         
58
-        echo "Successes: <br><br>";
58
+		echo "Successes: <br><br>";
59 59
         
60
-        foreach ($results['success'] as $svalue) {
61
-            echo $svalue."<br>";
62
-        }
63
-    }
60
+		foreach ($results['success'] as $svalue) {
61
+			echo $svalue."<br>";
62
+		}
63
+	}
64 64
 
65 65
 /* Add orders with schedules from a CSV file  */
66 66
 
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
 $ordersFieldsMapping['day_scheduled_for_YYMMDD'] = 8;
80 80
 
81 81
 if (($handle = fopen("$orders_file", "r")) !== FALSE) {
82
-    $order = new Order();
83
-    $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping);
82
+	$order = new Order();
83
+	$results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping);
84 84
     
85
-    echo "Errors: <br><br>";
85
+	echo "Errors: <br><br>";
86 86
     
87
-    foreach ($results['fail'] as $evalue) {
88
-        echo $evalue."<br>";
89
-    }
87
+	foreach ($results['fail'] as $evalue) {
88
+		echo $evalue."<br>";
89
+	}
90 90
     
91
-    echo "Successes: <br><br>";
91
+	echo "Successes: <br><br>";
92 92
     
93
-    foreach ($results['success'] as $svalue) {
94
-        echo $svalue."<br>";
95
-    }
93
+	foreach ($results['success'] as $svalue) {
94
+		echo $svalue."<br>";
95
+	}
96 96
 }
97 97
 
98 98
 /* Get Hybrid Optimization */
@@ -101,65 +101,65 @@  discard block
 block discarded – undo
101 101
 $sched_date = date("Y-m-d", $ep);
102 102
 
103 103
 $hybridParams = array(
104
-    "target_date_string" => $sched_date,
105
-    "timezone_offset_minutes" => 480
104
+	"target_date_string" => $sched_date,
105
+	"timezone_offset_minutes" => 480
106 106
 );
107 107
 
108 108
 $optimization = new OptimizationProblem(); 
109 109
 $hybridOptimization = $optimization->getHybridOptimization($hybridParams);
110 110
 
111 111
 if ($hybridOptimization!=null) {
112
-    if (isset($hybridOptimization['optimization_problem_id'])) {
113
-        $optid = $hybridOptimization['optimization_problem_id'];
112
+	if (isset($hybridOptimization['optimization_problem_id'])) {
113
+		$optid = $hybridOptimization['optimization_problem_id'];
114 114
         
115
-        echo "Hibrid optimization with optimization_problem_id = $optid <br><br>";
115
+		echo "Hibrid optimization with optimization_problem_id = $optid <br><br>";
116 116
         
117
-        /* Add depots to the Hybrid Optimization */
118
-        $depotfile = "depots.csv";
117
+		/* Add depots to the Hybrid Optimization */
118
+		$depotfile = "depots.csv";
119 119
         
120
-        if (($handle = fopen("$depotfile", "r")) !== FALSE) {
121
-            $columns = fgetcsv($handle, $max_line_length, $delemietr);
120
+		if (($handle = fopen("$depotfile", "r")) !== FALSE) {
121
+			$columns = fgetcsv($handle, $max_line_length, $delemietr);
122 122
             
123
-            if (!$columns) {
124
-                $error['message'] = 'Empty';
125
-                 return ($error);
126
-            }
123
+			if (!$columns) {
124
+				$error['message'] = 'Empty';
125
+				 return ($error);
126
+			}
127 127
             
128
-            $depotsParams = array(
129
-                'optimization_problem_id' => $optid,
130
-                'delete_old_depots'       => true,
131
-            );
128
+			$depotsParams = array(
129
+				'optimization_problem_id' => $optid,
130
+				'delete_old_depots'       => true,
131
+			);
132 132
             
133
-            $iRow = 1;
134
-            $depotAddresses = array();
133
+			$iRow = 1;
134
+			$depotAddresses = array();
135 135
             
136
-            while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) {
137
-                if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) {
138
-                    $depotAddress['lat'] = $rows[0];
139
-                    $depotAddress['lng'] = $rows[1];
140
-                    $depotAddress['address'] = $rows[3];   
141
-                    array_push($depotAddresses,$depotAddress);
142
-                }
143
-            }
136
+			while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) {
137
+				if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) {
138
+					$depotAddress['lat'] = $rows[0];
139
+					$depotAddress['lng'] = $rows[1];
140
+					$depotAddress['address'] = $rows[3];   
141
+					array_push($depotAddresses,$depotAddress);
142
+				}
143
+			}
144 144
             
145
-            $depotsParams['new_depots'] = $depotAddresses;
145
+			$depotsParams['new_depots'] = $depotAddresses;
146 146
             
147
-            $optProblem = new OptimizationProblem();
147
+			$optProblem = new OptimizationProblem();
148 148
             
149
-            $resultDepots = $optProblem->addDepotsToHybrid($depotsParams);
149
+			$resultDepots = $optProblem->addDepotsToHybrid($depotsParams);
150 150
             
151
-            var_dump($resultDepots);
151
+			var_dump($resultDepots);
152 152
             
153
-            /* Reoptimize hybrid optimization */
153
+			/* Reoptimize hybrid optimization */
154 154
             
155
-            if ($resultDepots != null) {
156
-                $problemParams = array(
157
-                    'optimization_problem_id'  =>  $optid
158
-                );
159
-                $problem = OptimizationProblem::reoptimize($problemParams);
155
+			if ($resultDepots != null) {
156
+				$problemParams = array(
157
+					'optimization_problem_id'  =>  $optid
158
+				);
159
+				$problem = OptimizationProblem::reoptimize($problemParams);
160 160
                 
161
-                Route4Me::simplePrint($problem);
162
-            }
163
-        }
164
-    }
161
+				Route4Me::simplePrint($problem);
162
+			}
163
+		}
164
+	}
165 165
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
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\OptimizationProblem;
8 8
 use Route4Me\Route;
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 $locationsFieldsMapping['monthly_nth_n'] = 16;
45 45
 $locationsFieldsMapping['monthly_nth_wwhat'] = 17;
46 46
 
47
-if (($handle = fopen("$source_file", "r")) !== FALSE) {
47
+if (($handle = fopen("$source_file", "r"))!==FALSE) {
48 48
         $oAbook = new AddressBookLocation();
49 49
 
50 50
         $results = $oAbook->addLocationsFromCsvFile($handle, $locationsFieldsMapping);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 $ordersFieldsMapping['EXT_FIELD_phone'] = 7;
79 79
 $ordersFieldsMapping['day_scheduled_for_YYMMDD'] = 8;
80 80
 
81
-if (($handle = fopen("$orders_file", "r")) !== FALSE) {
81
+if (($handle = fopen("$orders_file", "r"))!==FALSE) {
82 82
     $order = new Order();
83 83
     $results = $order->addOrdersFromCsvFile($handle, $ordersFieldsMapping);
84 84
     
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 /* Get Hybrid Optimization */
99 99
 
100
-$ep = time()+604800;
100
+$ep = time() + 604800;
101 101
 $sched_date = date("Y-m-d", $ep);
102 102
 
103 103
 $hybridParams = array(
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         /* Add depots to the Hybrid Optimization */
118 118
         $depotfile = "depots.csv";
119 119
         
120
-        if (($handle = fopen("$depotfile", "r")) !== FALSE) {
120
+        if (($handle = fopen("$depotfile", "r"))!==FALSE) {
121 121
             $columns = fgetcsv($handle, $max_line_length, $delemietr);
122 122
             
123 123
             if (!$columns) {
@@ -133,12 +133,12 @@  discard block
 block discarded – undo
133 133
             $iRow = 1;
134 134
             $depotAddresses = array();
135 135
             
136
-            while (($rows = fgetcsv($handle, $max_line_length, $delemietr)) !== false) {
137
-                if ($rows[0] && $rows[1] && $rows[3] && array(null) !== $rows) {
136
+            while (($rows = fgetcsv($handle, $max_line_length, $delemietr))!==false) {
137
+                if ($rows[0] && $rows[1] && $rows[3] && array(null)!==$rows) {
138 138
                     $depotAddress['lat'] = $rows[0];
139 139
                     $depotAddress['lng'] = $rows[1];
140 140
                     $depotAddress['address'] = $rows[3];   
141
-                    array_push($depotAddresses,$depotAddress);
141
+                    array_push($depotAddresses, $depotAddress);
142 142
                 }
143 143
             }
144 144
             
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
             
153 153
             /* Reoptimize hybrid optimization */
154 154
             
155
-            if ($resultDepots != null) {
155
+            if ($resultDepots!=null) {
156 156
                 $problemParams = array(
157 157
                     'optimization_problem_id'  =>  $optid
158 158
                 );
Please login to merge, or discard this patch.
src/Route4Me/Address.php 3 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -3,7 +3,6 @@
 block discarded – undo
3 3
 
4 4
 use Route4Me\Exception\BadParam;
5 5
 use Route4Me\Route4Me;
6
-use GuzzleHttp\Client;
7 6
 use Route4Me\Common;
8 7
 use Route4Me\Enum\Endpoint;
9 8
 
Please login to merge, or discard this patch.
Indentation   +275 added lines, -275 removed lines patch added patch discarded remove patch
@@ -9,63 +9,63 @@  discard block
 block discarded – undo
9 9
 
10 10
 class Address extends Common
11 11
 {
12
-    public $route_destination_id;
13
-    public $alias;
14
-    public $member_id;
15
-    public $address;
16
-    public $addressUpdate;
17
-    public $is_depot = false;
18
-    public $lat;
19
-    public $lng;
20
-    public $route_id;
21
-    public $original_route_id;
22
-    public $optimization_problem_id;
23
-    public $sequence_no;
24
-    public $geocoded;
25
-    public $preferred_geocoding;
26
-    public $failed_geocoding;
27
-    public $geocodings = array();
28
-    public $contact_id;
29
-    public $is_visited;
30
-    public $customer_po;
31
-    public $invoice_no;
32
-    public $reference_no;
33
-    public $order_no;
34
-    public $weight;
35
-    public $cost;
36
-    public $revenue;
37
-    public $cube;
38
-    public $pieces;
39
-    public $email;
40
-    public $phone;
41
-    public $tracking_number;
42
-    public $destination_note_count;
43
-    public $drive_time_to_next_destination;
44
-    public $distance_to_next_destination;
45
-    public $generated_time_window_start;
46
-    public $generated_time_window_end;
47
-    public $time_window_start;
48
-    public $time_window_end;
49
-    public $time;
50
-    public $notes;
51
-    public $timestamp_last_visited;
52
-    public $custom_fields = array();
53
-    public $manifest = array();
12
+	public $route_destination_id;
13
+	public $alias;
14
+	public $member_id;
15
+	public $address;
16
+	public $addressUpdate;
17
+	public $is_depot = false;
18
+	public $lat;
19
+	public $lng;
20
+	public $route_id;
21
+	public $original_route_id;
22
+	public $optimization_problem_id;
23
+	public $sequence_no;
24
+	public $geocoded;
25
+	public $preferred_geocoding;
26
+	public $failed_geocoding;
27
+	public $geocodings = array();
28
+	public $contact_id;
29
+	public $is_visited;
30
+	public $customer_po;
31
+	public $invoice_no;
32
+	public $reference_no;
33
+	public $order_no;
34
+	public $weight;
35
+	public $cost;
36
+	public $revenue;
37
+	public $cube;
38
+	public $pieces;
39
+	public $email;
40
+	public $phone;
41
+	public $tracking_number;
42
+	public $destination_note_count;
43
+	public $drive_time_to_next_destination;
44
+	public $distance_to_next_destination;
45
+	public $generated_time_window_start;
46
+	public $generated_time_window_end;
47
+	public $time_window_start;
48
+	public $time_window_end;
49
+	public $time;
50
+	public $notes;
51
+	public $timestamp_last_visited;
52
+	public $custom_fields = array();
53
+	public $manifest = array();
54 54
     
55
-    public $first_name;
56
-    public $last_name;
57
-    public $is_departed;
58
-    public $timestamp_last_departed;
59
-    public $order_id;
60
-    public $priority;
61
-    public $curbside_lat;
62
-    public $curbside_lng;
63
-    public $time_window_start_2;
64
-    public $time_window_end_2;
55
+	public $first_name;
56
+	public $last_name;
57
+	public $is_departed;
58
+	public $timestamp_last_departed;
59
+	public $order_id;
60
+	public $priority;
61
+	public $curbside_lat;
62
+	public $curbside_lng;
63
+	public $time_window_start_2;
64
+	public $time_window_end_2;
65 65
 
66
-    public static function fromArray(array $params)
67
-    {
68
-        /*if (!isset($params['address'])) {
66
+	public static function fromArray(array $params)
67
+	{
68
+		/*if (!isset($params['address'])) {
69 69
             throw new BadParam('address must be provided');
70 70
         }
71 71
 
@@ -77,260 +77,260 @@  discard block
 block discarded – undo
77 77
             throw new BadParam('lng must be provided');
78 78
         }*/
79 79
 
80
-        $address = new Address();
81
-        foreach($params as $key => $value) {
82
-            if (property_exists($address, $key)) {
83
-                $address->{$key} = $value;
84
-            }
85
-        }
80
+		$address = new Address();
81
+		foreach($params as $key => $value) {
82
+			if (property_exists($address, $key)) {
83
+				$address->{$key} = $value;
84
+			}
85
+		}
86 86
 
87
-        return $address;
88
-    }
87
+		return $address;
88
+	}
89 89
 
90
-    public static function getAddress($routeId, $addressId)
91
-    {
92
-        $address = Route4Me::makeRequst(array(
93
-            'url'    => Endpoint::ADDRESS_V4,
94
-            'method' => 'GET',
95
-            'query'  => array(
96
-                'route_id'             => $routeId,
97
-                'route_destination_id' => $addressId,
98
-            )
99
-        ));
90
+	public static function getAddress($routeId, $addressId)
91
+	{
92
+		$address = Route4Me::makeRequst(array(
93
+			'url'    => Endpoint::ADDRESS_V4,
94
+			'method' => 'GET',
95
+			'query'  => array(
96
+				'route_id'             => $routeId,
97
+				'route_destination_id' => $addressId,
98
+			)
99
+		));
100 100
 
101
-        return Address::fromArray($address);
102
-    }
101
+		return Address::fromArray($address);
102
+	}
103 103
     
104
-    /*Get notes from the specified route destination
104
+	/*Get notes from the specified route destination
105 105
      * Returns an address object with notes, if an address exists, otherwise - return null.
106 106
      */
107
-    public static function GetAddressesNotes($noteParams)
108
-    {
109
-        $address = Route4Me::makeRequst(array(
110
-            'url'    => Endpoint::ADDRESS_V4,
111
-            'method' => 'GET',
112
-            'query'  => array(
113
-                'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, 
114
-                'route_destination_id' => isset($noteParams['route_destination_id']) 
115
-                                             ? $noteParams['route_destination_id'] : null,
116
-                'notes'                => 1,
117
-            )
118
-        ));
107
+	public static function GetAddressesNotes($noteParams)
108
+	{
109
+		$address = Route4Me::makeRequst(array(
110
+			'url'    => Endpoint::ADDRESS_V4,
111
+			'method' => 'GET',
112
+			'query'  => array(
113
+				'route_id'             => isset($noteParams['route_id']) ? $noteParams['route_id'] : null, 
114
+				'route_destination_id' => isset($noteParams['route_destination_id']) 
115
+											 ? $noteParams['route_destination_id'] : null,
116
+				'notes'                => 1,
117
+			)
118
+		));
119 119
 
120
-        return $address;
121
-    }
120
+		return $address;
121
+	}
122 122
 
123
-    public function update()
124
-    {
125
-        $addressUpdate = Route4Me::makeRequst(array(
126
-            'url'    => Endpoint::ADDRESS_V4,
127
-            'method' => 'PUT',
128
-            'body'   => $this->toArray(),
129
-            'query'  => array(
130
-                'route_id'             => $this->route_id,
131
-                'route_destination_id' => $this->route_destination_id,
132
-            ),
133
-        ));
123
+	public function update()
124
+	{
125
+		$addressUpdate = Route4Me::makeRequst(array(
126
+			'url'    => Endpoint::ADDRESS_V4,
127
+			'method' => 'PUT',
128
+			'body'   => $this->toArray(),
129
+			'query'  => array(
130
+				'route_id'             => $this->route_id,
131
+				'route_destination_id' => $this->route_destination_id,
132
+			),
133
+		));
134 134
 
135
-        return Address::fromArray($addressUpdate);
136
-    }
135
+		return Address::fromArray($addressUpdate);
136
+	}
137 137
     
138
-    public function markAddress($params, $body)
139
-    {
140
-        $result = Route4Me::makeRequst(array(
141
-            'url'    => Endpoint::ADDRESS_V4,
142
-            'method' => 'PUT',
143
-            'query'  => array(
144
-                'route_id'             => isset($params['route_id']) ? $params['route_id'] : null, 
145
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
146
-            ),
147
-            'body'   => $body
148
-        ));
138
+	public function markAddress($params, $body)
139
+	{
140
+		$result = Route4Me::makeRequst(array(
141
+			'url'    => Endpoint::ADDRESS_V4,
142
+			'method' => 'PUT',
143
+			'query'  => array(
144
+				'route_id'             => isset($params['route_id']) ? $params['route_id'] : null, 
145
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
146
+			),
147
+			'body'   => $body
148
+		));
149 149
 
150
-        return $result;
151
-    }
150
+		return $result;
151
+	}
152 152
     
153
-    public function markAsDeparted($params)
154
-    {
155
-        $address = Route4Me::makeRequst(array(
156
-            'url'    => Endpoint::MARK_ADDRESS_DEPARTED,
157
-            'method' => 'GET',
158
-            'query'  => array(
159
-                'route_id'     => isset($params['route_id']) ? $params['route_id']: null,
160
-                'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
161
-                'is_departed'  => isset($params['is_departed']) ? $params['is_departed']: null,
162
-                'member_id'    => isset($params['member_id']) ? $params['member_id']: null,
163
-            ),
164
-        ));
153
+	public function markAsDeparted($params)
154
+	{
155
+		$address = Route4Me::makeRequst(array(
156
+			'url'    => Endpoint::MARK_ADDRESS_DEPARTED,
157
+			'method' => 'GET',
158
+			'query'  => array(
159
+				'route_id'     => isset($params['route_id']) ? $params['route_id']: null,
160
+				'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
161
+				'is_departed'  => isset($params['is_departed']) ? $params['is_departed']: null,
162
+				'member_id'    => isset($params['member_id']) ? $params['member_id']: null,
163
+			),
164
+		));
165 165
 
166
-        return $address;
167
-    }
166
+		return $address;
167
+	}
168 168
     
169
-    public function markAsVisited($params)
170
-    {
171
-        $address = Route4Me::makeRequst(array(
172
-            'url'    => Endpoint::UPDATE_ADDRESS_VISITED,
173
-            'method' => 'GET',
174
-            'query'  => array(
175
-                'route_id'   => isset($params['route_id']) ? $params['route_id'] : null,
176
-                'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
177
-                'member_id'  => isset($params['member_id']) ? $params['member_id'] : null,
178
-            ),
179
-            'body'  =>  array(
180
-                'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null
181
-            )
182
-        ));
169
+	public function markAsVisited($params)
170
+	{
171
+		$address = Route4Me::makeRequst(array(
172
+			'url'    => Endpoint::UPDATE_ADDRESS_VISITED,
173
+			'method' => 'GET',
174
+			'query'  => array(
175
+				'route_id'   => isset($params['route_id']) ? $params['route_id'] : null,
176
+				'address_id' => isset($params['address_id']) ? $params['address_id'] : null,
177
+				'member_id'  => isset($params['member_id']) ? $params['member_id'] : null,
178
+			),
179
+			'body'  =>  array(
180
+				'is_visited' => isset($params['is_visited']) ? $params['is_visited'] : null
181
+			)
182
+		));
183 183
 
184
-        return $address;
185
-    }
184
+		return $address;
185
+	}
186 186
 
187
-    public function delete()
188
-    {
189
-        $address = Route4Me::makeRequst(array(
190
-            'url'    => Endpoint::ADDRESS_V4,
191
-            'method' => 'DELETE',
192
-            'query'  => array(
193
-                'route_id'             => $this->route_id,
194
-                'route_destination_id' => $this->route_destination_id,
195
-            )
196
-        ));
187
+	public function delete()
188
+	{
189
+		$address = Route4Me::makeRequst(array(
190
+			'url'    => Endpoint::ADDRESS_V4,
191
+			'method' => 'DELETE',
192
+			'query'  => array(
193
+				'route_id'             => $this->route_id,
194
+				'route_destination_id' => $this->route_destination_id,
195
+			)
196
+		));
197 197
 
198
-        return (bool)$address['deleted'];
199
-    }
198
+		return (bool)$address['deleted'];
199
+	}
200 200
     
201
-    public function moveDestinationToRoute($params)
202
-    {
203
-        $result = Route4Me::makeRequst(array(
204
-            'url'    => Endpoint::MOVE_ROUTE_DESTINATION,
205
-            'method' => 'POST',
206
-            'body'  => array(
207
-                'to_route_id'          => isset($params['to_route_id']) ? $params['to_route_id'] : null,
208
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
209
-                'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
210
-            ),
211
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
212
-        ));
201
+	public function moveDestinationToRoute($params)
202
+	{
203
+		$result = Route4Me::makeRequst(array(
204
+			'url'    => Endpoint::MOVE_ROUTE_DESTINATION,
205
+			'method' => 'POST',
206
+			'body'  => array(
207
+				'to_route_id'          => isset($params['to_route_id']) ? $params['to_route_id'] : null,
208
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
209
+				'after_destination_id' => isset($params['after_destination_id']) ? $params['after_destination_id'] : null
210
+			),
211
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
212
+		));
213 213
 
214
-        return $result;
214
+		return $result;
215 215
         
216
-    }
216
+	}
217 217
     
218
-    public function AddAddressNote($params)
219
-    {
220
-        $result = Route4Me::makeRequst(array(
221
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
222
-            'method' => 'POST',
223
-            'query'  => array(
224
-                'route_id'     =>  isset($params['route_id']) ? $params['route_id'] : null,
225
-                'address_id'   =>  isset($params['address_id']) ? $params['address_id'] : null,
226
-                'dev_lat'      =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
227
-                'dev_lng'      =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
228
-                'device_type'  =>  isset($params['device_type']) ? $params['device_type'] : null
229
-            ),
230
-            'body'  => array(
231
-                'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
232
-                'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null
233
-            ),
234
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
235
-        ));
218
+	public function AddAddressNote($params)
219
+	{
220
+		$result = Route4Me::makeRequst(array(
221
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
222
+			'method' => 'POST',
223
+			'query'  => array(
224
+				'route_id'     =>  isset($params['route_id']) ? $params['route_id'] : null,
225
+				'address_id'   =>  isset($params['address_id']) ? $params['address_id'] : null,
226
+				'dev_lat'      =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
227
+				'dev_lng'      =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
228
+				'device_type'  =>  isset($params['device_type']) ? $params['device_type'] : null
229
+			),
230
+			'body'  => array(
231
+				'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
232
+				'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null
233
+			),
234
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
235
+		));
236 236
 
237
-        return $result;
238
-    }
237
+		return $result;
238
+	}
239 239
 
240
-    public function AddNoteFile($params)
241
-    {
242
-        $result = Route4Me::fileUploadRequest(array(
243
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
244
-            'method' => 'POST',
245
-            'query'  => array(
246
-                'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
247
-                'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
248
-                'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
249
-                'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
250
-                'device_type'   =>  isset($params['device_type']) ? $params['device_type'] : null,
251
-                'strUpdateType' =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null
252
-            ),
253
-            'body'  => array(
254
-                'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null
255
-            ),
256
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
257
-        ));
240
+	public function AddNoteFile($params)
241
+	{
242
+		$result = Route4Me::fileUploadRequest(array(
243
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
244
+			'method' => 'POST',
245
+			'query'  => array(
246
+				'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
247
+				'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
248
+				'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
249
+				'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null,
250
+				'device_type'   =>  isset($params['device_type']) ? $params['device_type'] : null,
251
+				'strUpdateType' =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null
252
+			),
253
+			'body'  => array(
254
+				'strFilename' => isset($params['strFilename']) ? $params['strFilename'] : null
255
+			),
256
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
257
+		));
258 258
 
259
-        return $result;
260
-    }
259
+		return $result;
260
+	}
261 261
 
262
-    public function createCustomNoteType($params)
263
-    {
264
-        $result = Route4Me::makeRequst(array(
265
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
266
-            'method' => 'POST',
267
-            'body'   => array(
268
-                'type'   => isset($params['type']) ? $params['type'] : null,
269
-                'values' => isset($params['values']) ? $params['values'] : null
270
-            )
271
-        ));
262
+	public function createCustomNoteType($params)
263
+	{
264
+		$result = Route4Me::makeRequst(array(
265
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
266
+			'method' => 'POST',
267
+			'body'   => array(
268
+				'type'   => isset($params['type']) ? $params['type'] : null,
269
+				'values' => isset($params['values']) ? $params['values'] : null
270
+			)
271
+		));
272 272
 
273
-        return $result;
274
-    }
273
+		return $result;
274
+	}
275 275
     
276
-    public function removeCustomNoteType($params)
277
-    {
278
-        $result = Route4Me::makeRequst(array(
279
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
280
-            'method' => 'DELETE',
281
-            'body'   => array(
282
-                'id' => isset($params['id']) ? $params['id'] : null
283
-            )
284
-        ));
276
+	public function removeCustomNoteType($params)
277
+	{
278
+		$result = Route4Me::makeRequst(array(
279
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
280
+			'method' => 'DELETE',
281
+			'body'   => array(
282
+				'id' => isset($params['id']) ? $params['id'] : null
283
+			)
284
+		));
285 285
 
286
-        return $result;
287
-    }
286
+		return $result;
287
+	}
288 288
     
289
-    public function getAllCustomNoteTypes()
290
-    {
291
-        $result = Route4Me::makeRequst(array(
292
-            'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
293
-            'method' => 'GET'
294
-        ));
289
+	public function getAllCustomNoteTypes()
290
+	{
291
+		$result = Route4Me::makeRequst(array(
292
+			'url'    => Endpoint::NOTE_CUSTOM_TYPES_V4,
293
+			'method' => 'GET'
294
+		));
295 295
 
296
-        return $result;
297
-    }
296
+		return $result;
297
+	}
298 298
     
299
-    public function addCustomNoteToRoute($params)
300
-    {
301
-        $customArray = array();
299
+	public function addCustomNoteToRoute($params)
300
+	{
301
+		$customArray = array();
302 302
         
303
-        foreach ($params as $key => $value) {
304
-            $kpos = strpos($key, "custom_note_type");
303
+		foreach ($params as $key => $value) {
304
+			$kpos = strpos($key, "custom_note_type");
305 305
             
306
-            if ($kpos !== false) {
307
-                $customArray[$key]=$value;
308
-            }
309
-        }
306
+			if ($kpos !== false) {
307
+				$customArray[$key]=$value;
308
+			}
309
+		}
310 310
         
311
-        $result = Route4Me::makeRequst(array(
312
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
313
-            'method' => 'POST',
314
-            'query'  => array(
315
-                'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
316
-                'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
317
-                'format'        =>  isset($params['format']) ? $params['format'] : null,
318
-                'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
319
-                'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null
320
-            ),
321
-            'body'  => array_merge(array(
322
-                'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
323
-                'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
324
-                'strNoteContents' =>  isset($params['strNoteContents']) ? $params['strNoteContents'] : null
325
-            ), $customArray),
326
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
327
-        ));
311
+		$result = Route4Me::makeRequst(array(
312
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
313
+			'method' => 'POST',
314
+			'query'  => array(
315
+				'route_id'      =>  isset($params['route_id']) ? $params['route_id'] : null,
316
+				'address_id'    =>  isset($params['address_id']) ? $params['address_id'] : null,
317
+				'format'        =>  isset($params['format']) ? $params['format'] : null,
318
+				'dev_lat'       =>  isset($params['dev_lat']) ? $params['dev_lat'] : null,
319
+				'dev_lng'       =>  isset($params['dev_lng']) ? $params['dev_lng'] : null
320
+			),
321
+			'body'  => array_merge(array(
322
+				'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
323
+				'strUpdateType'   =>  isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
324
+				'strNoteContents' =>  isset($params['strNoteContents']) ? $params['strNoteContents'] : null
325
+			), $customArray),
326
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
327
+		));
328 328
 
329
-        return $result;
330
-    }
329
+		return $result;
330
+	}
331 331
 
332
-    function getAddressId()
333
-    {
334
-        return $this->route_destination_id;
335
-    }
332
+	function getAddressId()
333
+	{
334
+		return $this->route_destination_id;
335
+	}
336 336
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         }*/
79 79
 
80 80
         $address = new Address();
81
-        foreach($params as $key => $value) {
81
+        foreach ($params as $key => $value) {
82 82
             if (property_exists($address, $key)) {
83 83
                 $address->{$key} = $value;
84 84
             }
@@ -156,10 +156,10 @@  discard block
 block discarded – undo
156 156
             'url'    => Endpoint::MARK_ADDRESS_DEPARTED,
157 157
             'method' => 'GET',
158 158
             'query'  => array(
159
-                'route_id'     => isset($params['route_id']) ? $params['route_id']: null,
160
-                'address_id'   => isset($params['address_id']) ? $params['address_id']: null,
161
-                'is_departed'  => isset($params['is_departed']) ? $params['is_departed']: null,
162
-                'member_id'    => isset($params['member_id']) ? $params['member_id']: null,
159
+                'route_id'     => isset($params['route_id']) ? $params['route_id'] : null,
160
+                'address_id'   => isset($params['address_id']) ? $params['address_id'] : null,
161
+                'is_departed'  => isset($params['is_departed']) ? $params['is_departed'] : null,
162
+                'member_id'    => isset($params['member_id']) ? $params['member_id'] : null,
163 163
             ),
164 164
         ));
165 165
 
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
         foreach ($params as $key => $value) {
304 304
             $kpos = strpos($key, "custom_note_type");
305 305
             
306
-            if ($kpos !== false) {
307
-                $customArray[$key]=$value;
306
+            if ($kpos!==false) {
307
+                $customArray[$key] = $value;
308 308
             }
309 309
         }
310 310
         
Please login to merge, or discard this patch.
src/Route4Me/AddressBookLocation.php 5 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -143,6 +143,9 @@
 block discarded – undo
143 143
         return null;
144 144
     }
145 145
     
146
+    /**
147
+     * @param AddressBookLocation $params
148
+     */
146 149
     public static function addAdressBookLocation($params)
147 150
     {
148 151
         $body = array();
Please login to merge, or discard this patch.
Indentation   +470 added lines, -470 removed lines patch added patch discarded remove patch
@@ -6,549 +6,549 @@
 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
-    public static function addAdressBookLocation($params)
147
-    {
148
-        $body = array();
149
-        $abLocations = new AddressBookLocation();
146
+	public static function addAdressBookLocation($params)
147
+	{
148
+		$body = array();
149
+		$abLocations = new AddressBookLocation();
150 150
         
151
-        foreach($params as $key => $value) {
152
-            if ($key == "address_id") continue; 
153
-            if (property_exists($abLocations, $key)) {
154
-                if (isset($params->{$key})) {
155
-                    $body[$key] = $params->{$key};
156
-                } 
157
-            }
158
-        }
151
+		foreach($params as $key => $value) {
152
+			if ($key == "address_id") continue; 
153
+			if (property_exists($abLocations, $key)) {
154
+				if (isset($params->{$key})) {
155
+					$body[$key] = $params->{$key};
156
+				} 
157
+			}
158
+		}
159 159
         
160
-        $response = Route4Me::makeRequst(array(
161
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
162
-            'method' => 'POST',
163
-            'body'   => $body
164
-        ));
160
+		$response = Route4Me::makeRequst(array(
161
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
162
+			'method' => 'POST',
163
+			'body'   => $body
164
+		));
165 165
 
166
-        return $response;
167
-    }
166
+		return $response;
167
+	}
168 168
     
169
-    public function deleteAdressBookLocation($address_ids)
170
-    {
171
-        $result = Route4Me::makeRequst(array(
172
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
173
-            'method' => 'DELETEARRAY',
174
-            'query'  => array(
175
-                'address_ids' => $address_ids
176
-            )
177
-        ));
169
+	public function deleteAdressBookLocation($address_ids)
170
+	{
171
+		$result = Route4Me::makeRequst(array(
172
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
173
+			'method' => 'DELETEARRAY',
174
+			'query'  => array(
175
+				'address_ids' => $address_ids
176
+			)
177
+		));
178 178
 
179
-        return $result;
180
-    }
179
+		return $result;
180
+	}
181 181
     
182
-    public function updateAdressBookLocation($params)
183
-    {
184
-        $body = array();
185
-        $abLocations = new AddressBookLocation();
182
+	public function updateAdressBookLocation($params)
183
+	{
184
+		$body = array();
185
+		$abLocations = new AddressBookLocation();
186 186
         
187
-        foreach($params as $key => $value) {
188
-            if (property_exists($abLocations, $key)) {
189
-                if (isset($params->{$key})) {
190
-                    $body[$key] = $params->{$key};
191
-                } 
192
-            }
193
-        }
187
+		foreach($params as $key => $value) {
188
+			if (property_exists($abLocations, $key)) {
189
+				if (isset($params->{$key})) {
190
+					$body[$key] = $params->{$key};
191
+				} 
192
+			}
193
+		}
194 194
 
195
-        $response = Route4Me::makeRequst(array(
196
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
197
-            'method' => 'PUT',
198
-            'body'   => $body,
199
-        ));
195
+		$response = Route4Me::makeRequst(array(
196
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
197
+			'method' => 'PUT',
198
+			'body'   => $body,
199
+		));
200 200
 
201
-        return $response;
202
-    }
201
+		return $response;
202
+	}
203 203
         
204
-    public static function get($params)
205
-    {
206
-        $ablocations = Route4Me::makeRequst(array(
207
-            'url'    => Endpoint::ADDRESS_BOOK_V4,
208
-            'method' => 'ADD',
209
-            'query'  => array(
210
-                'first_name' => isset($params->first_name) ? $params->first_name : null,
211
-                'address_1'  => isset($params->address_1) ? $params->address_1 : null,
212
-                'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
213
-                'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
214
-            )
215
-        ));
204
+	public static function get($params)
205
+	{
206
+		$ablocations = Route4Me::makeRequst(array(
207
+			'url'    => Endpoint::ADDRESS_BOOK_V4,
208
+			'method' => 'ADD',
209
+			'query'  => array(
210
+				'first_name' => isset($params->first_name) ? $params->first_name : null,
211
+				'address_1'  => isset($params->address_1) ? $params->address_1 : null,
212
+				'cached_lat' => isset($params->cached_lat) ? $params->cached_lat : null,
213
+				'cached_lng' => isset($params->cached_lng) ? $params->cached_lng : null,
214
+			)
215
+		));
216 216
 
217
-        return $ablocations;
218
-    }
217
+		return $ablocations;
218
+	}
219 219
     
220
-    public static function validateScheduleMode($scheduleMode)
221
-    {
222
-        $schedMmodes = array("daily","weekly","monthly","annually");
220
+	public static function validateScheduleMode($scheduleMode)
221
+	{
222
+		$schedMmodes = array("daily","weekly","monthly","annually");
223 223
         
224
-        if (in_array($scheduleMode, $schedMmodes)) 
225
-            return TRUE; 
226
-        else 
227
-            return FALSE;
228
-    }
224
+		if (in_array($scheduleMode, $schedMmodes)) 
225
+			return TRUE; 
226
+		else 
227
+			return FALSE;
228
+	}
229 229
     
230
-    public static function validateScheduleEnable($scheduleEnabled)
231
-    {
232
-        $schedEnambles = array(TRUE,FALSE);
230
+	public static function validateScheduleEnable($scheduleEnabled)
231
+	{
232
+		$schedEnambles = array(TRUE,FALSE);
233 233
         
234
-        if (in_array($scheduleEnabled, $schedEnambles))
235
-            return TRUE;
236
-        else
237
-            return FALSE;
238
-    }
234
+		if (in_array($scheduleEnabled, $schedEnambles))
235
+			return TRUE;
236
+		else
237
+			return FALSE;
238
+	}
239 239
     
240
-    public static function validateScheduleEvery($scheduleEvery)
241
-    {
242
-        if (is_numeric($scheduleEvery))
243
-            return TRUE;
244
-        else
245
-            return FALSE;
246
-    }
240
+	public static function validateScheduleEvery($scheduleEvery)
241
+	{
242
+		if (is_numeric($scheduleEvery))
243
+			return TRUE;
244
+		else
245
+			return FALSE;
246
+	}
247 247
     
248
-    public static function validateScheduleWeekDays($scheduleWeekDays)
249
-    {
250
-        $weekdays = explode(',', $scheduleWeekDays);
248
+	public static function validateScheduleWeekDays($scheduleWeekDays)
249
+	{
250
+		$weekdays = explode(',', $scheduleWeekDays);
251 251
         
252
-        if (sizeof($weekdays) < 1) return FALSE;
252
+		if (sizeof($weekdays) < 1) return FALSE;
253 253
         
254
-        $isValid = TRUE;
254
+		$isValid = TRUE;
255 255
         
256
-        for ($i=0; $i < sizeof($weekdays); $i++) { 
257
-            if (is_numeric($weekdays[$i])) {
258
-                $wday = intval($weekdays[$i]);
259
-                if ($wday < 1 || $wday > 7) $isValid = FALSE;
260
-            }
261
-            else $isValid = FALSE;
262
-        }
256
+		for ($i=0; $i < sizeof($weekdays); $i++) { 
257
+			if (is_numeric($weekdays[$i])) {
258
+				$wday = intval($weekdays[$i]);
259
+				if ($wday < 1 || $wday > 7) $isValid = FALSE;
260
+			}
261
+			else $isValid = FALSE;
262
+		}
263 263
         
264
-        return $isValid;
265
-    }
264
+		return $isValid;
265
+	}
266 266
     
267
-    public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
268
-    {
269
-        $schedMonthlyMmodes = array("dates","nth");
267
+	public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
268
+	{
269
+		$schedMonthlyMmodes = array("dates","nth");
270 270
         
271
-        if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes))
272
-            return TRUE;
273
-        else
274
-            return FALSE;
275
-    }
271
+		if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes))
272
+			return TRUE;
273
+		else
274
+			return FALSE;
275
+	}
276 276
     
277
-    public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
278
-    {
279
-        $monthlyDates = explode(',', $scheduleMonthlyDates);
277
+	public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
278
+	{
279
+		$monthlyDates = explode(',', $scheduleMonthlyDates);
280 280
         
281
-        if (sizeof($monthlyDates) <1) return FALSE;
281
+		if (sizeof($monthlyDates) <1) return FALSE;
282 282
         
283
-        $isValid = TRUE;
283
+		$isValid = TRUE;
284 284
         
285
-        for ($i=0; $i < sizeof($monthlyDates); $i++) { 
286
-            if (is_numeric($monthlyDates[$i])) {
287
-                $mday = intval($monthlyDates[$i]);
288
-                if ($mday <1 || $mday > 31) $isValid = FALSE;
289
-            }
290
-            else $isValid = FALSE;
291
-        }
285
+		for ($i=0; $i < sizeof($monthlyDates); $i++) { 
286
+			if (is_numeric($monthlyDates[$i])) {
287
+				$mday = intval($monthlyDates[$i]);
288
+				if ($mday <1 || $mday > 31) $isValid = FALSE;
289
+			}
290
+			else $isValid = FALSE;
291
+		}
292 292
 
293
-        return $isValid;
294
-    }
293
+		return $isValid;
294
+	}
295 295
     
296
-    public static function validateScheduleNthN($scheduleNthN)
297
-    {
298
-        if (!is_numeric($scheduleNthN)) return FALSE;
296
+	public static function validateScheduleNthN($scheduleNthN)
297
+	{
298
+		if (!is_numeric($scheduleNthN)) return FALSE;
299 299
         
300
-        $schedNthNs = array(1,2,3,4,5,-1);
300
+		$schedNthNs = array(1,2,3,4,5,-1);
301 301
         
302
-        if (in_array($scheduleNthN, $schedNthNs))
303
-            return TRUE;
304
-        else
305
-            return FALSE;
306
-    }
302
+		if (in_array($scheduleNthN, $schedNthNs))
303
+			return TRUE;
304
+		else
305
+			return FALSE;
306
+	}
307 307
     
308
-    public static function validateScheduleNthWhat($scheduleNthWhat)
309
-    {
310
-        if (!is_numeric($scheduleNthWhat)) return FALSE;
308
+	public static function validateScheduleNthWhat($scheduleNthWhat)
309
+	{
310
+		if (!is_numeric($scheduleNthWhat)) return FALSE;
311 311
         
312
-        $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
312
+		$schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
313 313
         
314
-        if (in_array($scheduleNthWhat, $schedNthWhats))
315
-            return TRUE;
316
-        else
317
-            return FALSE;
318
-    }
314
+		if (in_array($scheduleNthWhat, $schedNthWhats))
315
+			return TRUE;
316
+		else
317
+			return FALSE;
318
+	}
319 319
     
320
-    /* Function adds the locations (with/without schedule) from the CSV file. 
320
+	/* Function adds the locations (with/without schedule) from the CSV file. 
321 321
      * $csvFileHandle - a file handler.
322 322
      * Returns array $results which contains two arrays: fail and succes.
323 323
      */
324
-    public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
325
-    {
326
-        $max_line_length = 512;
327
-        $delemietr = ',';
324
+	public function addLocationsFromCsvFile($csvFileHandle, $locationsFieldsMapping)
325
+	{
326
+		$max_line_length = 512;
327
+		$delemietr = ',';
328 328
         
329
-        $results = array();
330
-        $results['fail'] = array();
331
-        $results['success'] = array();
329
+		$results = array();
330
+		$results['fail'] = array();
331
+		$results['success'] = array();
332 332
         
333
-        $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
333
+		$columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
334 334
 
335
-        if (empty($columns)) {
336
-            array_push($results['fail'],'Empty CSV table');
337
-            return ($results);
338
-        }
335
+		if (empty($columns)) {
336
+			array_push($results['fail'],'Empty CSV table');
337
+			return ($results);
338
+		}
339 339
 
340
-        $iRow = 1;
340
+		$iRow = 1;
341 341
         
342
-        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
343
-            if ($rows[$locationsFieldsMapping['cached_lat']] 
344
-                  && $rows[$locationsFieldsMapping['cached_lng']] 
345
-                  && $rows[$locationsFieldsMapping['address_1']] 
346
-                  && array(null) !== $rows) {
347
-                $curSchedule = "";
348
-                $mode = "";
342
+		while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
343
+			if ($rows[$locationsFieldsMapping['cached_lat']] 
344
+				  && $rows[$locationsFieldsMapping['cached_lng']] 
345
+				  && $rows[$locationsFieldsMapping['address_1']] 
346
+				  && array(null) !== $rows) {
347
+				$curSchedule = "";
348
+				$mode = "";
349 349
                 
350
-                if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
351
-                    if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
352
-                        $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
353
-                        $mode = $rows[$locationsFieldsMapping['schedule_mode']];
354
-                    } else {
355
-                        array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); 
356
-                        $curSchedule = "";
357
-                    }
358
-                } else {
359
-                    array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); 
360
-                    $curSchedule = "";
361
-                }
350
+				if (isset($rows[$locationsFieldsMapping['schedule_mode']])) {
351
+					if ($this->validateScheduleMode($rows[$locationsFieldsMapping['schedule_mode']])) {
352
+						$curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
353
+						$mode = $rows[$locationsFieldsMapping['schedule_mode']];
354
+					} else {
355
+						array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); 
356
+						$curSchedule = "";
357
+					}
358
+				} else {
359
+					array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); 
360
+					$curSchedule = "";
361
+				}
362 362
                 
363
-                if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
364
-                    if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
365
-                        $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
366
-                    } else {
367
-                        array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set ");  
368
-                        $curSchedule = "";
369
-                    }
370
-                }
363
+				if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
364
+					if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
365
+						$curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
366
+					} else {
367
+						array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set ");  
368
+						$curSchedule = "";
369
+					}
370
+				}
371 371
                 
372
-                if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
373
-                    if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
374
-                        $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
375
-                        if ($mode == 'daily') {
376
-                            $curSchedule = trim($curSchedule,',');
377
-                            $curSchedule.='}';
378
-                        }
379
-                    } else {
380
-                        array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); 
381
-                        $curSchedule = ""; 
382
-                    }
383
-                }
372
+				if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
373
+					if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
374
+						$curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
375
+						if ($mode == 'daily') {
376
+							$curSchedule = trim($curSchedule,',');
377
+							$curSchedule.='}';
378
+						}
379
+					} else {
380
+						array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); 
381
+						$curSchedule = ""; 
382
+					}
383
+				}
384 384
                 
385
-                if ($mode!='daily') {
386
-                    switch ($mode) {
387
-                        case 'weekly':
388
-                            if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
389
-                                if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
390
-                                     $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
391
-                                } else {
392
-                                    array_push($results['fail'],"$iRow --> Wrong weekdays"); 
393
-                                    $curSchedule = "";
394
-                                }
395
-                            } else {
396
-                                array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); 
397
-                                $curSchedule = "";
398
-                            }
399
-                            break;
400
-                        case 'monthly':
401
-                            $monthlyMode = "";
402
-                            if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
403
-                                if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
404
-                                     $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
405
-                                     $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
406
-                                } else {
407
-                                    array_push($results['fail'],"$iRow --> Wrong monthly mode"); 
408
-                                    $curSchedule = "";
409
-                                }
410
-                            } else {
411
-                                array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); 
412
-                                $curSchedule = "";
413
-                            }
385
+				if ($mode!='daily') {
386
+					switch ($mode) {
387
+						case 'weekly':
388
+							if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
389
+								if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
390
+									 $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
391
+								} else {
392
+									array_push($results['fail'],"$iRow --> Wrong weekdays"); 
393
+									$curSchedule = "";
394
+								}
395
+							} else {
396
+								array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); 
397
+								$curSchedule = "";
398
+							}
399
+							break;
400
+						case 'monthly':
401
+							$monthlyMode = "";
402
+							if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
403
+								if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
404
+									 $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
405
+									 $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
406
+								} else {
407
+									array_push($results['fail'],"$iRow --> Wrong monthly mode"); 
408
+									$curSchedule = "";
409
+								}
410
+							} else {
411
+								array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); 
412
+								$curSchedule = "";
413
+							}
414 414
                             
415
-                            if ($monthlyMode != "") {
416
-                                switch ($monthlyMode) {
417
-                                    case 'dates':
418
-                                        if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
419
-                                            if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
420
-                                                 $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
421
-                                            } else {
422
-                                                array_push($results['fail'],"$iRow --> Wrong monthly dates"); 
423
-                                                $curSchedule = "";
424
-                                            }
425
-                                        }
426
-                                        break;
427
-                                    case 'nth':
428
-                                        if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
429
-                                            if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
430
-                                                 $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
431
-                                            } else {
432
-                                                array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); 
433
-                                                $curSchedule = "";
434
-                                            }
435
-                                        } else {
436
-                                            array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); 
437
-                                            $curSchedule = "";
438
-                                        }
415
+							if ($monthlyMode != "") {
416
+								switch ($monthlyMode) {
417
+									case 'dates':
418
+										if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
419
+											if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
420
+												 $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
421
+											} else {
422
+												array_push($results['fail'],"$iRow --> Wrong monthly dates"); 
423
+												$curSchedule = "";
424
+											}
425
+										}
426
+										break;
427
+									case 'nth':
428
+										if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
429
+											if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
430
+												 $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
431
+											} else {
432
+												array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); 
433
+												$curSchedule = "";
434
+											}
435
+										} else {
436
+											array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); 
437
+											$curSchedule = "";
438
+										}
439 439
                                         
440
-                                        if ($curSchedule != "") {
441
-                                            if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
442
-                                                if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
443
-                                                     $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
444
-                                                } else {
445
-                                                    array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); 
446
-                                                    $curSchedule = "";
447
-                                                }
448
-                                            } else {
449
-                                                array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); 
450
-                                                $curSchedule = "";
451
-                                            }
452
-                                        }
453
-                                        break;
454
-                                }
455
-                            }
456
-                            break;
457
-                        default:
458
-                            $curSchedule = "";
459
-                            break;
460
-                    }
461
-                }
440
+										if ($curSchedule != "") {
441
+											if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
442
+												if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
443
+													 $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
444
+												} else {
445
+													array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); 
446
+													$curSchedule = "";
447
+												}
448
+											} else {
449
+												array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); 
450
+												$curSchedule = "";
451
+											}
452
+										}
453
+										break;
454
+								}
455
+							}
456
+							break;
457
+						default:
458
+							$curSchedule = "";
459
+							break;
460
+					}
461
+				}
462 462
 
463
-                if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") {
464
-                    $iRow++; 
465
-                    continue;
466
-                }
463
+				if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") {
464
+					$iRow++; 
465
+					continue;
466
+				}
467 467
                 
468
-                $curSchedule =strtolower($curSchedule);
468
+				$curSchedule =strtolower($curSchedule);
469 469
                 
470
-                $curSchedule = '[{'.$curSchedule.'}]';
470
+				$curSchedule = '[{'.$curSchedule.'}]';
471 471
 
472
-                $oSchedule = json_decode($curSchedule,TRUE);
472
+				$oSchedule = json_decode($curSchedule,TRUE);
473 473
                 
474
-                $AdressBookLocationParameters = AddressBookLocation::fromArray(array(
475
-                    "cached_lat"                 => $rows[$locationsFieldsMapping['cached_lat']],
476
-                    "cached_lng"                 => $rows[$locationsFieldsMapping['cached_lng']],
477
-                    "curbside_lat"               => isset($locationsFieldsMapping['curbside_lat'])
478
-                                                     ? $rows[$locationsFieldsMapping['curbside_lat']] : null,
479
-                    "curbside_lng"               => isset($locationsFieldsMapping['curbside_lng'])
480
-                                                     ? $rows[$locationsFieldsMapping['curbside_lng']] : null,
481
-                    "address_alias"              => isset($locationsFieldsMapping['address_alias'])
482
-                                                     ? $rows[$locationsFieldsMapping['address_alias']] : null,
483
-                    "address_1"                  => $rows[$locationsFieldsMapping['address_1']],
484
-                    "address_2"                  => isset($locationsFieldsMapping['address_2'])
485
-                                                     ? $rows[$locationsFieldsMapping['address_2']] : null,
486
-                    "address_city"               => isset($locationsFieldsMapping['address_city'])
487
-                                                      ? $rows[$locationsFieldsMapping['address_city']] : null,
488
-                    "address_state_id"           => isset($locationsFieldsMapping['address_state_id'])
489
-                                                      ? $rows[$locationsFieldsMapping['address_state_id']] : null,
490
-                    "address_zip"                => isset($locationsFieldsMapping['address_zip'])
491
-                                                      ? $rows[$locationsFieldsMapping['address_zip']] : null,
492
-                    "address_phone_number"       => isset($locationsFieldsMapping['address_phone_number'])
493
-                                                      ? $rows[$locationsFieldsMapping['address_phone_number']] : null,
494
-                    "schedule"                   => isset($oSchedule) ? $oSchedule : null,
495
-                    "address_group"              => isset($locationsFieldsMapping['address_group']) 
496
-                                                      ? $rows[$locationsFieldsMapping['address_group']] : null,
497
-                    "first_name"                 => isset($locationsFieldsMapping['first_name']) 
498
-                                                      ? $rows[$locationsFieldsMapping['first_name']] : null,
499
-                    "last_name"                  => isset($locationsFieldsMapping['last_name']) 
500
-                                                      ? $rows[$locationsFieldsMapping['last_name']] : null,
501
-                    "local_time_window_start"    => isset($locationsFieldsMapping['local_time_window_start'])
502
-                                                      ? $rows[$locationsFieldsMapping['local_time_window_start']] : null,
503
-                    "local_time_window_end"      => isset($locationsFieldsMapping['local_time_window_end'])
504
-                                                      ? $rows[$locationsFieldsMapping['local_time_window_end']] : null,
505
-                    "local_time_window_start_2"  => isset($locationsFieldsMapping['local_time_window_start_2'])
506
-                                                      ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null,
507
-                    "local_time_window_end_2"    => isset($locationsFieldsMapping['local_time_window_end_2'])
508
-                                                      ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null,
509
-                    "address_email"              => isset($locationsFieldsMapping['address_email'])
510
-                                                      ? $rows[$locationsFieldsMapping['address_email']] : null,
511
-                    "address_country_id"         => isset($locationsFieldsMapping['address_country_id'])
512
-                                                      ? $rows[$locationsFieldsMapping['address_country_id']] : null,
513
-                    "address_custom_data"        => isset($locationsFieldsMapping['address_custom_data'])
514
-                                                      ? $rows[$locationsFieldsMapping['address_custom_data']] : null,
515
-                    "schedule_blacklist"         => isset($locationsFieldsMapping['schedule_blacklist'])
516
-                                                      ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null,
517
-                    "service_time"               => isset($locationsFieldsMapping['service_time'])
518
-                                                      ? $rows[$locationsFieldsMapping['service_time']] : null,
519
-                    "local_timezone_string"      => isset($locationsFieldsMapping['local_timezone_string'])
520
-                                                      ? $rows[$locationsFieldsMapping['local_timezone_string']] : null,
521
-                    "color"                      => isset($locationsFieldsMapping['color'])
522
-                                                      ? $rows[$locationsFieldsMapping['color']] : null,
523
-                    "address_icon"               => isset($locationsFieldsMapping['address_icon'])
524
-                                                      ? $rows[$locationsFieldsMapping['address_icon']] : null,
525
-                    "address_stop_type"          => isset($locationsFieldsMapping['address_stop_type'])
526
-                                                      ? $rows[$locationsFieldsMapping['address_stop_type']] : null,
527
-                    "address_cube"               => isset($locationsFieldsMapping['address_cube'])
528
-                                                      ? $rows[$locationsFieldsMapping['address_cube']] : null,
529
-                    "address_pieces"             => isset($locationsFieldsMapping['address_pieces'])
530
-                                                      ? $rows[$locationsFieldsMapping['address_pieces']] : null,
531
-                    "address_reference_no"       => isset($locationsFieldsMapping['address_reference_no'])
532
-                                                      ? $rows[$locationsFieldsMapping['address_reference_no']] : null,
533
-                    "address_revenue"            => isset($locationsFieldsMapping['address_revenue'])
534
-                                                      ? $rows[$locationsFieldsMapping['address_revenue']] : null,
535
-                    "address_weight"             => isset($locationsFieldsMapping['address_weight'])
536
-                                                      ? $rows[$locationsFieldsMapping['address_weight']] : null,
537
-                    "address_priority"           => isset($locationsFieldsMapping['address_priority'])
538
-                                                      ? $rows[$locationsFieldsMapping['address_priority']] : null,
539
-                    "address_customer_po"        => isset($locationsFieldsMapping['address_customer_po'])
540
-                                                      ? $rows[$locationsFieldsMapping['address_customer_po']] : null,
541
-                ));
474
+				$AdressBookLocationParameters = AddressBookLocation::fromArray(array(
475
+					"cached_lat"                 => $rows[$locationsFieldsMapping['cached_lat']],
476
+					"cached_lng"                 => $rows[$locationsFieldsMapping['cached_lng']],
477
+					"curbside_lat"               => isset($locationsFieldsMapping['curbside_lat'])
478
+													 ? $rows[$locationsFieldsMapping['curbside_lat']] : null,
479
+					"curbside_lng"               => isset($locationsFieldsMapping['curbside_lng'])
480
+													 ? $rows[$locationsFieldsMapping['curbside_lng']] : null,
481
+					"address_alias"              => isset($locationsFieldsMapping['address_alias'])
482
+													 ? $rows[$locationsFieldsMapping['address_alias']] : null,
483
+					"address_1"                  => $rows[$locationsFieldsMapping['address_1']],
484
+					"address_2"                  => isset($locationsFieldsMapping['address_2'])
485
+													 ? $rows[$locationsFieldsMapping['address_2']] : null,
486
+					"address_city"               => isset($locationsFieldsMapping['address_city'])
487
+													  ? $rows[$locationsFieldsMapping['address_city']] : null,
488
+					"address_state_id"           => isset($locationsFieldsMapping['address_state_id'])
489
+													  ? $rows[$locationsFieldsMapping['address_state_id']] : null,
490
+					"address_zip"                => isset($locationsFieldsMapping['address_zip'])
491
+													  ? $rows[$locationsFieldsMapping['address_zip']] : null,
492
+					"address_phone_number"       => isset($locationsFieldsMapping['address_phone_number'])
493
+													  ? $rows[$locationsFieldsMapping['address_phone_number']] : null,
494
+					"schedule"                   => isset($oSchedule) ? $oSchedule : null,
495
+					"address_group"              => isset($locationsFieldsMapping['address_group']) 
496
+													  ? $rows[$locationsFieldsMapping['address_group']] : null,
497
+					"first_name"                 => isset($locationsFieldsMapping['first_name']) 
498
+													  ? $rows[$locationsFieldsMapping['first_name']] : null,
499
+					"last_name"                  => isset($locationsFieldsMapping['last_name']) 
500
+													  ? $rows[$locationsFieldsMapping['last_name']] : null,
501
+					"local_time_window_start"    => isset($locationsFieldsMapping['local_time_window_start'])
502
+													  ? $rows[$locationsFieldsMapping['local_time_window_start']] : null,
503
+					"local_time_window_end"      => isset($locationsFieldsMapping['local_time_window_end'])
504
+													  ? $rows[$locationsFieldsMapping['local_time_window_end']] : null,
505
+					"local_time_window_start_2"  => isset($locationsFieldsMapping['local_time_window_start_2'])
506
+													  ? $rows[$locationsFieldsMapping['local_time_window_start_2']] : null,
507
+					"local_time_window_end_2"    => isset($locationsFieldsMapping['local_time_window_end_2'])
508
+													  ? $rows[$locationsFieldsMapping['local_time_window_end_2']] : null,
509
+					"address_email"              => isset($locationsFieldsMapping['address_email'])
510
+													  ? $rows[$locationsFieldsMapping['address_email']] : null,
511
+					"address_country_id"         => isset($locationsFieldsMapping['address_country_id'])
512
+													  ? $rows[$locationsFieldsMapping['address_country_id']] : null,
513
+					"address_custom_data"        => isset($locationsFieldsMapping['address_custom_data'])
514
+													  ? $rows[$locationsFieldsMapping['address_custom_data']] : null,
515
+					"schedule_blacklist"         => isset($locationsFieldsMapping['schedule_blacklist'])
516
+													  ? $rows[$locationsFieldsMapping['schedule_blacklist']] : null,
517
+					"service_time"               => isset($locationsFieldsMapping['service_time'])
518
+													  ? $rows[$locationsFieldsMapping['service_time']] : null,
519
+					"local_timezone_string"      => isset($locationsFieldsMapping['local_timezone_string'])
520
+													  ? $rows[$locationsFieldsMapping['local_timezone_string']] : null,
521
+					"color"                      => isset($locationsFieldsMapping['color'])
522
+													  ? $rows[$locationsFieldsMapping['color']] : null,
523
+					"address_icon"               => isset($locationsFieldsMapping['address_icon'])
524
+													  ? $rows[$locationsFieldsMapping['address_icon']] : null,
525
+					"address_stop_type"          => isset($locationsFieldsMapping['address_stop_type'])
526
+													  ? $rows[$locationsFieldsMapping['address_stop_type']] : null,
527
+					"address_cube"               => isset($locationsFieldsMapping['address_cube'])
528
+													  ? $rows[$locationsFieldsMapping['address_cube']] : null,
529
+					"address_pieces"             => isset($locationsFieldsMapping['address_pieces'])
530
+													  ? $rows[$locationsFieldsMapping['address_pieces']] : null,
531
+					"address_reference_no"       => isset($locationsFieldsMapping['address_reference_no'])
532
+													  ? $rows[$locationsFieldsMapping['address_reference_no']] : null,
533
+					"address_revenue"            => isset($locationsFieldsMapping['address_revenue'])
534
+													  ? $rows[$locationsFieldsMapping['address_revenue']] : null,
535
+					"address_weight"             => isset($locationsFieldsMapping['address_weight'])
536
+													  ? $rows[$locationsFieldsMapping['address_weight']] : null,
537
+					"address_priority"           => isset($locationsFieldsMapping['address_priority'])
538
+													  ? $rows[$locationsFieldsMapping['address_priority']] : null,
539
+					"address_customer_po"        => isset($locationsFieldsMapping['address_customer_po'])
540
+													  ? $rows[$locationsFieldsMapping['address_customer_po']] : null,
541
+				));
542 542
                 
543
-                $abContacts = new AddressBookLocation();
543
+				$abContacts = new AddressBookLocation();
544 544
 
545
-                $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
545
+				$abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
546 546
                 
547
-                array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
548
-            }
549
-        }
547
+				array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
548
+			}
549
+		}
550 550
 
551
-        return $results;
552
-    }
551
+		return $results;
552
+	}
553 553
  }
554
-    
555 554
\ No newline at end of file
555
+	
556 556
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -384,79 +384,79 @@
 block discarded – undo
384 384
                 
385 385
                 if ($mode!='daily') {
386 386
                     switch ($mode) {
387
-                        case 'weekly':
388
-                            if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
389
-                                if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
390
-                                     $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
391
-                                } else {
392
-                                    array_push($results['fail'],"$iRow --> Wrong weekdays"); 
393
-                                    $curSchedule = "";
394
-                                }
387
+                    case 'weekly':
388
+                        if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
389
+                            if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
390
+                                 $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
391
+                            } else {
392
+                                array_push($results['fail'],"$iRow --> Wrong weekdays"); 
393
+                                $curSchedule = "";
394
+                            }
395
+                        } else {
396
+                            array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); 
397
+                            $curSchedule = "";
398
+                        }
399
+                        break;
400
+                    case 'monthly':
401
+                        $monthlyMode = "";
402
+                        if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
403
+                            if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
404
+                                 $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
405
+                                 $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
395 406
                             } else {
396
-                                array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); 
407
+                                array_push($results['fail'],"$iRow --> Wrong monthly mode"); 
397 408
                                 $curSchedule = "";
398 409
                             }
410
+                        } else {
411
+                            array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); 
412
+                            $curSchedule = "";
413
+                        }
414
+                            
415
+                        if ($monthlyMode != "") {
416
+                            switch ($monthlyMode) {
417
+                            case 'dates':
418
+                            if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
419
+                            if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
420
+                                 $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
421
+                            } else {
422
+                                array_push($results['fail'],"$iRow --> Wrong monthly dates"); 
423
+                                $curSchedule = "";
424
+                            }
425
+                            }
399 426
                             break;
400
-                        case 'monthly':
401
-                            $monthlyMode = "";
402
-                            if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
403
-                                if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
404
-                                     $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
405
-                                     $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
427
+                            case 'nth':
428
+                            if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
429
+                            if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
430
+                                 $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
431
+                            } else {
432
+                                array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); 
433
+                                $curSchedule = "";
434
+                            }
435
+                            } else {
436
+                            array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); 
437
+                            $curSchedule = "";
438
+                            }
439
+                                        
440
+                            if ($curSchedule != "") {
441
+                            if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
442
+                                if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
443
+                                     $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
406 444
                                 } else {
407
-                                    array_push($results['fail'],"$iRow --> Wrong monthly mode"); 
445
+                                    array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); 
408 446
                                     $curSchedule = "";
409 447
                                 }
410 448
                             } else {
411
-                                array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); 
449
+                                array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); 
412 450
                                 $curSchedule = "";
413 451
                             }
414
-                            
415
-                            if ($monthlyMode != "") {
416
-                                switch ($monthlyMode) {
417
-                                    case 'dates':
418
-                                        if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
419
-                                            if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
420
-                                                 $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
421
-                                            } else {
422
-                                                array_push($results['fail'],"$iRow --> Wrong monthly dates"); 
423
-                                                $curSchedule = "";
424
-                                            }
425
-                                        }
426
-                                        break;
427
-                                    case 'nth':
428
-                                        if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
429
-                                            if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
430
-                                                 $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
431
-                                            } else {
432
-                                                array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); 
433
-                                                $curSchedule = "";
434
-                                            }
435
-                                        } else {
436
-                                            array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); 
437
-                                            $curSchedule = "";
438
-                                        }
439
-                                        
440
-                                        if ($curSchedule != "") {
441
-                                            if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
442
-                                                if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
443
-                                                     $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
444
-                                                } else {
445
-                                                    array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); 
446
-                                                    $curSchedule = "";
447
-                                                }
448
-                                            } else {
449
-                                                array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); 
450
-                                                $curSchedule = "";
451
-                                            }
452
-                                        }
453
-                                        break;
454
-                                }
455 452
                             }
456 453
                             break;
457
-                        default:
458
-                            $curSchedule = "";
454
+                            }
455
+                            }
459 456
                             break;
457
+                    default:
458
+                        $curSchedule = "";
459
+                        break;
460 460
                     }
461 461
                 }
462 462
 
Please login to merge, or discard this patch.
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     {
54 54
         $addressbooklocation = new AddressBookLocation();
55 55
         
56
-        foreach($params as $key => $value) {
56
+        foreach ($params as $key => $value) {
57 57
             if (property_exists($addressbooklocation, $key)) {
58 58
                 $addressbooklocation->{$key} = $value;
59 59
             }
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     
79 79
     public static function searchRoutedLocation($params)
80 80
     {
81
-        $result= Route4Me::makeRequst(array(
81
+        $result = Route4Me::makeRequst(array(
82 82
             'url'    => Endpoint::ADDRESS_BOOK_V4,
83 83
             'method' => 'GET',
84 84
             'query'  => array(
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         if (isset($ablocations["results"])) {
135 135
             $locationsSize = sizeof($ablocations["results"]);
136 136
             
137
-            if ($locationsSize > 0) {
137
+            if ($locationsSize>0) {
138 138
                 $randomLocationIndex = rand(0, $locationsSize - 1);
139 139
                 return $ablocations["results"][$randomLocationIndex];
140 140
             } 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
         $body = array();
149 149
         $abLocations = new AddressBookLocation();
150 150
         
151
-        foreach($params as $key => $value) {
152
-            if ($key == "address_id") continue; 
151
+        foreach ($params as $key => $value) {
152
+            if ($key=="address_id") continue; 
153 153
             if (property_exists($abLocations, $key)) {
154 154
                 if (isset($params->{$key})) {
155 155
                     $body[$key] = $params->{$key};
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         $body = array();
185 185
         $abLocations = new AddressBookLocation();
186 186
         
187
-        foreach($params as $key => $value) {
187
+        foreach ($params as $key => $value) {
188 188
             if (property_exists($abLocations, $key)) {
189 189
                 if (isset($params->{$key})) {
190 190
                     $body[$key] = $params->{$key};
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
     
220 220
     public static function validateScheduleMode($scheduleMode)
221 221
     {
222
-        $schedMmodes = array("daily","weekly","monthly","annually");
222
+        $schedMmodes = array("daily", "weekly", "monthly", "annually");
223 223
         
224 224
         if (in_array($scheduleMode, $schedMmodes)) 
225 225
             return TRUE; 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     
230 230
     public static function validateScheduleEnable($scheduleEnabled)
231 231
     {
232
-        $schedEnambles = array(TRUE,FALSE);
232
+        $schedEnambles = array(TRUE, FALSE);
233 233
         
234 234
         if (in_array($scheduleEnabled, $schedEnambles))
235 235
             return TRUE;
@@ -249,14 +249,14 @@  discard block
 block discarded – undo
249 249
     {
250 250
         $weekdays = explode(',', $scheduleWeekDays);
251 251
         
252
-        if (sizeof($weekdays) < 1) return FALSE;
252
+        if (sizeof($weekdays)<1) return FALSE;
253 253
         
254 254
         $isValid = TRUE;
255 255
         
256
-        for ($i=0; $i < sizeof($weekdays); $i++) { 
256
+        for ($i = 0; $i<sizeof($weekdays); $i++) { 
257 257
             if (is_numeric($weekdays[$i])) {
258 258
                 $wday = intval($weekdays[$i]);
259
-                if ($wday < 1 || $wday > 7) $isValid = FALSE;
259
+                if ($wday<1 || $wday>7) $isValid = FALSE;
260 260
             }
261 261
             else $isValid = FALSE;
262 262
         }
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
     
267 267
     public static function validateScheduleMonthlyMode($scheduleMonthlyMode)
268 268
     {
269
-        $schedMonthlyMmodes = array("dates","nth");
269
+        $schedMonthlyMmodes = array("dates", "nth");
270 270
         
271 271
         if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes))
272 272
             return TRUE;
@@ -278,14 +278,14 @@  discard block
 block discarded – undo
278 278
     {
279 279
         $monthlyDates = explode(',', $scheduleMonthlyDates);
280 280
         
281
-        if (sizeof($monthlyDates) <1) return FALSE;
281
+        if (sizeof($monthlyDates)<1) return FALSE;
282 282
         
283 283
         $isValid = TRUE;
284 284
         
285
-        for ($i=0; $i < sizeof($monthlyDates); $i++) { 
285
+        for ($i = 0; $i<sizeof($monthlyDates); $i++) { 
286 286
             if (is_numeric($monthlyDates[$i])) {
287 287
                 $mday = intval($monthlyDates[$i]);
288
-                if ($mday <1 || $mday > 31) $isValid = FALSE;
288
+                if ($mday<1 || $mday>31) $isValid = FALSE;
289 289
             }
290 290
             else $isValid = FALSE;
291 291
         }
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
     {
298 298
         if (!is_numeric($scheduleNthN)) return FALSE;
299 299
         
300
-        $schedNthNs = array(1,2,3,4,5,-1);
300
+        $schedNthNs = array(1, 2, 3, 4, 5, -1);
301 301
         
302 302
         if (in_array($scheduleNthN, $schedNthNs))
303 303
             return TRUE;
@@ -333,17 +333,17 @@  discard block
 block discarded – undo
333 333
         $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
334 334
 
335 335
         if (empty($columns)) {
336
-            array_push($results['fail'],'Empty CSV table');
336
+            array_push($results['fail'], 'Empty CSV table');
337 337
             return ($results);
338 338
         }
339 339
 
340 340
         $iRow = 1;
341 341
         
342
-        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
342
+        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) {
343 343
             if ($rows[$locationsFieldsMapping['cached_lat']] 
344 344
                   && $rows[$locationsFieldsMapping['cached_lng']] 
345 345
                   && $rows[$locationsFieldsMapping['address_1']] 
346
-                  && array(null) !== $rows) {
346
+                  && array(null)!==$rows) {
347 347
                 $curSchedule = "";
348 348
                 $mode = "";
349 349
                 
@@ -352,32 +352,32 @@  discard block
 block discarded – undo
352 352
                         $curSchedule = '"mode":"'.$rows[$locationsFieldsMapping['schedule_mode']].'",'; 
353 353
                         $mode = $rows[$locationsFieldsMapping['schedule_mode']];
354 354
                     } else {
355
-                        array_push($results['fail'],"$iRow --> Wrong schedule mode parameter"); 
355
+                        array_push($results['fail'], "$iRow --> Wrong schedule mode parameter"); 
356 356
                         $curSchedule = "";
357 357
                     }
358 358
                 } else {
359
-                    array_push($results['fail'],"$iRow --> The schedule mode parameter is not set"); 
359
+                    array_push($results['fail'], "$iRow --> The schedule mode parameter is not set"); 
360 360
                     $curSchedule = "";
361 361
                 }
362 362
                 
363 363
                 if (isset($rows[$locationsFieldsMapping['schedule_enabled']])) {
364 364
                     if ($this->validateScheduleEnable($rows[$locationsFieldsMapping['schedule_enabled']])) { 
365
-                        $curSchedule.='"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
365
+                        $curSchedule .= '"enabled":'.$rows[$locationsFieldsMapping['schedule_enabled']].',';
366 366
                     } else {
367
-                        array_push($results['fail'],"$iRow --> The schedule enabled parameter is not set ");  
367
+                        array_push($results['fail'], "$iRow --> The schedule enabled parameter is not set ");  
368 368
                         $curSchedule = "";
369 369
                     }
370 370
                 }
371 371
                 
372 372
                 if (isset($rows[$locationsFieldsMapping['schedule_every']])) {
373 373
                     if ($this->validateScheduleEvery($rows[$locationsFieldsMapping['schedule_every']])) {
374
-                        $curSchedule.='"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
375
-                        if ($mode == 'daily') {
376
-                            $curSchedule = trim($curSchedule,',');
377
-                            $curSchedule.='}';
374
+                        $curSchedule .= '"'.$mode.'":{'.'"every":'.$rows[$locationsFieldsMapping['schedule_every']].','; 
375
+                        if ($mode=='daily') {
376
+                            $curSchedule = trim($curSchedule, ',');
377
+                            $curSchedule .= '}';
378 378
                         }
379 379
                     } else {
380
-                        array_push($results['fail'],"$iRow --> The parameter sched_every is not set"); 
380
+                        array_push($results['fail'], "$iRow --> The parameter sched_every is not set"); 
381 381
                         $curSchedule = ""; 
382 382
                     }
383 383
                 }
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
                         case 'weekly':
388 388
                             if (isset($rows[$locationsFieldsMapping['schedule_weekdays']])) {
389 389
                                 if ($this->validateScheduleWeekDays($rows[$locationsFieldsMapping['schedule_weekdays']])) {
390
-                                     $curSchedule.='"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
390
+                                     $curSchedule .= '"weekdays":['.$rows[$locationsFieldsMapping['schedule_weekdays']].']}';
391 391
                                 } else {
392
-                                    array_push($results['fail'],"$iRow --> Wrong weekdays"); 
392
+                                    array_push($results['fail'], "$iRow --> Wrong weekdays"); 
393 393
                                     $curSchedule = "";
394 394
                                 }
395 395
                             } else {
396
-                                array_push($results['fail'],"$iRow --> The parameters sched_weekdays is not set"); 
396
+                                array_push($results['fail'], "$iRow --> The parameters sched_weekdays is not set"); 
397 397
                                 $curSchedule = "";
398 398
                             }
399 399
                             break;
@@ -402,24 +402,24 @@  discard block
 block discarded – undo
402 402
                             if (isset($rows[$locationsFieldsMapping['monthly_mode']])) {
403 403
                                 if ($this->validateScheduleMonthlyMode($rows[$locationsFieldsMapping['monthly_mode']])) {
404 404
                                      $monthlyMode = $rows[$locationsFieldsMapping['monthly_mode']];
405
-                                     $curSchedule.='"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
405
+                                     $curSchedule .= '"mode": "'.$rows[$locationsFieldsMapping['monthly_mode']].'",';
406 406
                                 } else {
407
-                                    array_push($results['fail'],"$iRow --> Wrong monthly mode"); 
407
+                                    array_push($results['fail'], "$iRow --> Wrong monthly mode"); 
408 408
                                     $curSchedule = "";
409 409
                                 }
410 410
                             } else {
411
-                                array_push($results['fail'],"$iRow --> The parameter sched_monthly_mode is not set"); 
411
+                                array_push($results['fail'], "$iRow --> The parameter sched_monthly_mode is not set"); 
412 412
                                 $curSchedule = "";
413 413
                             }
414 414
                             
415
-                            if ($monthlyMode != "") {
415
+                            if ($monthlyMode!="") {
416 416
                                 switch ($monthlyMode) {
417 417
                                     case 'dates':
418 418
                                         if (isset($rows[$locationsFieldsMapping['monthly_dates']])) {
419 419
                                             if ($this->validateScheduleMonthlyDates($rows[$locationsFieldsMapping['monthly_dates']])) {
420
-                                                 $curSchedule.='"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
420
+                                                 $curSchedule .= '"dates":['.$rows[$locationsFieldsMapping['monthly_dates']].']}';
421 421
                                             } else {
422
-                                                array_push($results['fail'],"$iRow --> Wrong monthly dates"); 
422
+                                                array_push($results['fail'], "$iRow --> Wrong monthly dates"); 
423 423
                                                 $curSchedule = "";
424 424
                                             }
425 425
                                         }
@@ -427,26 +427,26 @@  discard block
 block discarded – undo
427 427
                                     case 'nth':
428 428
                                         if (isset($rows[$locationsFieldsMapping['monthly_nth_n']])) {
429 429
                                             if ($this->validateScheduleNthN($rows[$locationsFieldsMapping['monthly_nth_n']])) {
430
-                                                 $curSchedule.='"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
430
+                                                 $curSchedule .= '"nth":{"n":'.$rows[$locationsFieldsMapping['monthly_nth_n']].',';
431 431
                                             } else {
432
-                                                array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_n"); 
432
+                                                array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_n"); 
433 433
                                                 $curSchedule = "";
434 434
                                             }
435 435
                                         } else {
436
-                                            array_push($results['fail'],"$iRow --> The parameter sched_nth_n is not set"); 
436
+                                            array_push($results['fail'], "$iRow --> The parameter sched_nth_n is not set"); 
437 437
                                             $curSchedule = "";
438 438
                                         }
439 439
                                         
440
-                                        if ($curSchedule != "") {
440
+                                        if ($curSchedule!="") {
441 441
                                             if (isset($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
442 442
                                                 if ($this->validateScheduleNthWhat($rows[$locationsFieldsMapping['monthly_nth_wwhat']])) {
443
-                                                     $curSchedule.='"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
443
+                                                     $curSchedule .= '"what":'.$rows[$locationsFieldsMapping['monthly_nth_wwhat']].'}}';
444 444
                                                 } else {
445
-                                                    array_push($results['fail'],"$iRow --> Wrong parameter sched_nth_what"); 
445
+                                                    array_push($results['fail'], "$iRow --> Wrong parameter sched_nth_what"); 
446 446
                                                     $curSchedule = "";
447 447
                                                 }
448 448
                                             } else {
449
-                                                array_push($results['fail'],"$iRow --> The parameter sched_nth_what is not set"); 
449
+                                                array_push($results['fail'], "$iRow --> The parameter sched_nth_what is not set"); 
450 450
                                                 $curSchedule = "";
451 451
                                             }
452 452
                                         }
@@ -460,16 +460,16 @@  discard block
 block discarded – undo
460 460
                     }
461 461
                 }
462 462
 
463
-                if (($mode == 'daily' || $mode == 'weekly' || $mode == 'monthy') && $curSchedule == "") {
463
+                if (($mode=='daily' || $mode=='weekly' || $mode=='monthy') && $curSchedule=="") {
464 464
                     $iRow++; 
465 465
                     continue;
466 466
                 }
467 467
                 
468
-                $curSchedule =strtolower($curSchedule);
468
+                $curSchedule = strtolower($curSchedule);
469 469
                 
470 470
                 $curSchedule = '[{'.$curSchedule.'}]';
471 471
 
472
-                $oSchedule = json_decode($curSchedule,TRUE);
472
+                $oSchedule = json_decode($curSchedule, TRUE);
473 473
                 
474 474
                 $AdressBookLocationParameters = AddressBookLocation::fromArray(array(
475 475
                     "cached_lat"                 => $rows[$locationsFieldsMapping['cached_lat']],
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 
545 545
                 $abcResults = $abContacts->addAdressBookLocation($AdressBookLocationParameters); //temporarry
546 546
                 
547
-                array_push($results['success'],"The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
547
+                array_push($results['success'], "The schedule location with address_id = ".strval($abcResults["address_id"])." added successfuly.");
548 548
             }
549 549
         }
550 550
 
Please login to merge, or discard this patch.
Braces   +55 added lines, -33 removed lines patch added patch discarded remove patch
@@ -149,7 +149,9 @@  discard block
 block discarded – undo
149 149
         $abLocations = new AddressBookLocation();
150 150
         
151 151
         foreach($params as $key => $value) {
152
-            if ($key == "address_id") continue; 
152
+            if ($key == "address_id") {
153
+            	continue;
154
+            }
153 155
             if (property_exists($abLocations, $key)) {
154 156
                 if (isset($params->{$key})) {
155 157
                     $body[$key] = $params->{$key};
@@ -221,44 +223,52 @@  discard block
 block discarded – undo
221 223
     {
222 224
         $schedMmodes = array("daily","weekly","monthly","annually");
223 225
         
224
-        if (in_array($scheduleMode, $schedMmodes)) 
225
-            return TRUE; 
226
-        else 
227
-            return FALSE;
226
+        if (in_array($scheduleMode, $schedMmodes)) {
227
+                    return TRUE;
228
+        } else {
229
+                    return FALSE;
230
+        }
228 231
     }
229 232
     
230 233
     public static function validateScheduleEnable($scheduleEnabled)
231 234
     {
232 235
         $schedEnambles = array(TRUE,FALSE);
233 236
         
234
-        if (in_array($scheduleEnabled, $schedEnambles))
235
-            return TRUE;
236
-        else
237
-            return FALSE;
237
+        if (in_array($scheduleEnabled, $schedEnambles)) {
238
+                    return TRUE;
239
+        } else {
240
+                    return FALSE;
241
+        }
238 242
     }
239 243
     
240 244
     public static function validateScheduleEvery($scheduleEvery)
241 245
     {
242
-        if (is_numeric($scheduleEvery))
243
-            return TRUE;
244
-        else
245
-            return FALSE;
246
+        if (is_numeric($scheduleEvery)) {
247
+                    return TRUE;
248
+        } else {
249
+                    return FALSE;
250
+        }
246 251
     }
247 252
     
248 253
     public static function validateScheduleWeekDays($scheduleWeekDays)
249 254
     {
250 255
         $weekdays = explode(',', $scheduleWeekDays);
251 256
         
252
-        if (sizeof($weekdays) < 1) return FALSE;
257
+        if (sizeof($weekdays) < 1) {
258
+        	return FALSE;
259
+        }
253 260
         
254 261
         $isValid = TRUE;
255 262
         
256 263
         for ($i=0; $i < sizeof($weekdays); $i++) { 
257 264
             if (is_numeric($weekdays[$i])) {
258 265
                 $wday = intval($weekdays[$i]);
259
-                if ($wday < 1 || $wday > 7) $isValid = FALSE;
266
+                if ($wday < 1 || $wday > 7) {
267
+                	$isValid = FALSE;
268
+                }
269
+            } else {
270
+            	$isValid = FALSE;
260 271
             }
261
-            else $isValid = FALSE;
262 272
         }
263 273
         
264 274
         return $isValid;
@@ -268,26 +278,32 @@  discard block
 block discarded – undo
268 278
     {
269 279
         $schedMonthlyMmodes = array("dates","nth");
270 280
         
271
-        if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes))
272
-            return TRUE;
273
-        else
274
-            return FALSE;
281
+        if (in_array($scheduleMonthlyMode, $schedMonthlyMmodes)) {
282
+                    return TRUE;
283
+        } else {
284
+                    return FALSE;
285
+        }
275 286
     }
276 287
     
277 288
     public static function validateScheduleMonthlyDates($scheduleMonthlyDates)
278 289
     {
279 290
         $monthlyDates = explode(',', $scheduleMonthlyDates);
280 291
         
281
-        if (sizeof($monthlyDates) <1) return FALSE;
292
+        if (sizeof($monthlyDates) <1) {
293
+        	return FALSE;
294
+        }
282 295
         
283 296
         $isValid = TRUE;
284 297
         
285 298
         for ($i=0; $i < sizeof($monthlyDates); $i++) { 
286 299
             if (is_numeric($monthlyDates[$i])) {
287 300
                 $mday = intval($monthlyDates[$i]);
288
-                if ($mday <1 || $mday > 31) $isValid = FALSE;
301
+                if ($mday <1 || $mday > 31) {
302
+                	$isValid = FALSE;
303
+                }
304
+            } else {
305
+            	$isValid = FALSE;
289 306
             }
290
-            else $isValid = FALSE;
291 307
         }
292 308
 
293 309
         return $isValid;
@@ -295,26 +311,32 @@  discard block
 block discarded – undo
295 311
     
296 312
     public static function validateScheduleNthN($scheduleNthN)
297 313
     {
298
-        if (!is_numeric($scheduleNthN)) return FALSE;
314
+        if (!is_numeric($scheduleNthN)) {
315
+        	return FALSE;
316
+        }
299 317
         
300 318
         $schedNthNs = array(1,2,3,4,5,-1);
301 319
         
302
-        if (in_array($scheduleNthN, $schedNthNs))
303
-            return TRUE;
304
-        else
305
-            return FALSE;
320
+        if (in_array($scheduleNthN, $schedNthNs)) {
321
+                    return TRUE;
322
+        } else {
323
+                    return FALSE;
324
+        }
306 325
     }
307 326
     
308 327
     public static function validateScheduleNthWhat($scheduleNthWhat)
309 328
     {
310
-        if (!is_numeric($scheduleNthWhat)) return FALSE;
329
+        if (!is_numeric($scheduleNthWhat)) {
330
+        	return FALSE;
331
+        }
311 332
         
312 333
         $schedNthWhats = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
313 334
         
314
-        if (in_array($scheduleNthWhat, $schedNthWhats))
315
-            return TRUE;
316
-        else
317
-            return FALSE;
335
+        if (in_array($scheduleNthWhat, $schedNthWhats)) {
336
+                    return TRUE;
337
+        } else {
338
+                    return FALSE;
339
+        }
318 340
     }
319 341
     
320 342
     /* Function adds the locations (with/without schedule) from the CSV file. 
Please login to merge, or discard this patch.
src/Route4Me/OptimizationProblem.php 4 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,6 @@
 block discarded – undo
7 7
 use Route4Me\OptimizationProblemParams;
8 8
 use Route4Me\Route;
9 9
 use Route4Me\Route4Me;
10
-use GuzzleHttp\Client;
11 10
 use Route4Me\Enum\Endpoint;
12 11
 
13 12
 class OptimizationProblem extends Common
Please login to merge, or discard this patch.
Indentation   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -12,267 +12,267 @@
 block discarded – undo
12 12
 
13 13
 class OptimizationProblem extends Common
14 14
 {
15
-    public $optimization_problem_id;
16
-    public $user_errors = array();
17
-    public $state;
18
-    public $optimization_errors = array();
19
-    public $parameters;
20
-    public $sent_to_background;
21
-    public $created_timestamp;
22
-    public $scheduled_for;
23
-    public $optimization_completed_timestamp;
24
-    public $addresses = array();
25
-    public $routes = array();
26
-    public $links = array();
15
+	public $optimization_problem_id;
16
+	public $user_errors = array();
17
+	public $state;
18
+	public $optimization_errors = array();
19
+	public $parameters;
20
+	public $sent_to_background;
21
+	public $created_timestamp;
22
+	public $scheduled_for;
23
+	public $optimization_completed_timestamp;
24
+	public $addresses = array();
25
+	public $routes = array();
26
+	public $links = array();
27 27
 
28
-    function __construct()
29
-    {
30
-        $this->parameters = new RouteParameters;
31
-    }
28
+	function __construct()
29
+	{
30
+		$this->parameters = new RouteParameters;
31
+	}
32 32
 
33
-    public static function fromArray(array $params)
34
-    {
35
-        $problem = new OptimizationProblem;
36
-        $problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
37
-        $problem->user_errors = Common::getValue($params, 'user_errors', array());
38
-        $problem->state = Common::getValue($params, 'state', array());
39
-        $problem->sent_to_background = Common::getValue($params, 'sent_to_background', array());
40
-        $problem->links = Common::getValue($params, 'links', array());
33
+	public static function fromArray(array $params)
34
+	{
35
+		$problem = new OptimizationProblem;
36
+		$problem->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
37
+		$problem->user_errors = Common::getValue($params, 'user_errors', array());
38
+		$problem->state = Common::getValue($params, 'state', array());
39
+		$problem->sent_to_background = Common::getValue($params, 'sent_to_background', array());
40
+		$problem->links = Common::getValue($params, 'links', array());
41 41
 
42
-        if (isset($params['parameters'])) {
43
-            $problem->parameters = RouteParameters::fromArray($params['parameters']);
44
-        }
42
+		if (isset($params['parameters'])) {
43
+			$problem->parameters = RouteParameters::fromArray($params['parameters']);
44
+		}
45 45
 
46
-        if (isset($params['addresses'])) {
47
-            $addresses = array();
46
+		if (isset($params['addresses'])) {
47
+			$addresses = array();
48 48
             
49
-            foreach ($params['addresses'] as $address) {
50
-                $addresses[] = Address::fromArray($address);
51
-            }
49
+			foreach ($params['addresses'] as $address) {
50
+				$addresses[] = Address::fromArray($address);
51
+			}
52 52
             
53
-            $problem->addresses = $addresses;
54
-        }
53
+			$problem->addresses = $addresses;
54
+		}
55 55
 
56
-        if (isset($params['routes'])) {
57
-            $routes = array();
56
+		if (isset($params['routes'])) {
57
+			$routes = array();
58 58
             
59
-            foreach ($params['routes'] as $route) {
60
-                $routes[] = Route::fromArray($route);
61
-            }
59
+			foreach ($params['routes'] as $route) {
60
+				$routes[] = Route::fromArray($route);
61
+			}
62 62
             
63
-            $problem->routes = $routes;
64
-        }
63
+			$problem->routes = $routes;
64
+		}
65 65
 
66
-        return $problem;
67
-    }
66
+		return $problem;
67
+	}
68 68
 
69
-    public static function optimize(OptimizationProblemParams $params)
70
-    {
71
-        $optimize = Route4Me::makeRequst(array(
72
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
73
-            'method' => 'POST',
74
-            'query'  => array(
75
-                'redirect'               => isset($params->redirect) ? $params->redirect : null,
76
-                'directions'             => isset($params->directions) ? $params->directions : null, 
77
-                'format'                 => isset($params->format) ? $params->format : null,
78
-                'route_path_output'      => isset($params->route_path_output) ? $params->route_path_output : null,
79
-                'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null
80
-            ),
81
-            'body'   => array(
82
-                'addresses'  => $params->getAddressesArray(),
83
-                'parameters' => $params->getParametersArray()
84
-            )
85
-        ));
69
+	public static function optimize(OptimizationProblemParams $params)
70
+	{
71
+		$optimize = Route4Me::makeRequst(array(
72
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
73
+			'method' => 'POST',
74
+			'query'  => array(
75
+				'redirect'               => isset($params->redirect) ? $params->redirect : null,
76
+				'directions'             => isset($params->directions) ? $params->directions : null, 
77
+				'format'                 => isset($params->format) ? $params->format : null,
78
+				'route_path_output'      => isset($params->route_path_output) ? $params->route_path_output : null,
79
+				'optimized_callback_url' => isset($params->optimized_callback_url) ? $params->optimized_callback_url : null
80
+			),
81
+			'body'   => array(
82
+				'addresses'  => $params->getAddressesArray(),
83
+				'parameters' => $params->getParametersArray()
84
+			)
85
+		));
86 86
 
87
-        return OptimizationProblem::fromArray($optimize);
88
-    }
87
+		return OptimizationProblem::fromArray($optimize);
88
+	}
89 89
 
90
-    public static function get($params)
91
-    {
92
-        $optimize = Route4Me::makeRequst(array(
93
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
94
-            'method' => 'GET',
95
-            'query'  => array(
96
-                'state'  => isset($params['state'])  ? $params['state'] : null,
97
-                'limit'  => isset($params['limit'])  ? $params['limit'] : null,
98
-                'offset' => isset($params['offset']) ? $params['offset'] : null,
99
-                'optimization_problem_id' => isset($params['optimization_problem_id']) 
100
-                    ? $params['optimization_problem_id'] : null,
101
-                'wait_for_final_state' => isset($params['wait_for_final_state']) 
102
-                    ? $params['wait_for_final_state'] : null,
103
-            )
104
-        ));
90
+	public static function get($params)
91
+	{
92
+		$optimize = Route4Me::makeRequst(array(
93
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
94
+			'method' => 'GET',
95
+			'query'  => array(
96
+				'state'  => isset($params['state'])  ? $params['state'] : null,
97
+				'limit'  => isset($params['limit'])  ? $params['limit'] : null,
98
+				'offset' => isset($params['offset']) ? $params['offset'] : null,
99
+				'optimization_problem_id' => isset($params['optimization_problem_id']) 
100
+					? $params['optimization_problem_id'] : null,
101
+				'wait_for_final_state' => isset($params['wait_for_final_state']) 
102
+					? $params['wait_for_final_state'] : null,
103
+			)
104
+		));
105 105
 
106
-        if (isset($optimize['optimizations'])) {
107
-            $problems = array();
106
+		if (isset($optimize['optimizations'])) {
107
+			$problems = array();
108 108
             
109
-            foreach($optimize['optimizations'] as $problem) {
110
-                $problems[] = OptimizationProblem::fromArray($problem);
111
-            }
109
+			foreach($optimize['optimizations'] as $problem) {
110
+				$problems[] = OptimizationProblem::fromArray($problem);
111
+			}
112 112
             
113
-            return $problems;
114
-        } else {
115
-            return OptimizationProblem::fromArray($optimize);
116
-        }
117
-    }
113
+			return $problems;
114
+		} else {
115
+			return OptimizationProblem::fromArray($optimize);
116
+		}
117
+	}
118 118
 
119
-    public static function reoptimize($params)
120
-    {
121
-        $param = new OptimizationProblemParams;
122
-        $param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null;
123
-        $param->reoptimize = 1;
119
+	public static function reoptimize($params)
120
+	{
121
+		$param = new OptimizationProblemParams;
122
+		$param->optimization_problem_id = isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null;
123
+		$param->reoptimize = 1;
124 124
 
125
-        return self::update((array)$param);
126
-    }
125
+		return self::update((array)$param);
126
+	}
127 127
 
128
-    public static function update($params)
129
-    {
130
-        $optimize = Route4Me::makeRequst(array(
131
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
132
-            'method' => 'PUT',
133
-            'query'  => array(
134
-                'optimization_problem_id' => isset($params['optimization_problem_id'])
135
-                                               ? $params['optimization_problem_id'] : null,
136
-                'addresses'  => isset($params['addresses']) ? $params['addresses'] : null,
137
-                'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null,
138
-            )
139
-        ));
128
+	public static function update($params)
129
+	{
130
+		$optimize = Route4Me::makeRequst(array(
131
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
132
+			'method' => 'PUT',
133
+			'query'  => array(
134
+				'optimization_problem_id' => isset($params['optimization_problem_id'])
135
+											   ? $params['optimization_problem_id'] : null,
136
+				'addresses'  => isset($params['addresses']) ? $params['addresses'] : null,
137
+				'reoptimize' => isset($params['reoptimize']) ? $params['reoptimize'] : null,
138
+			)
139
+		));
140 140
         
141
-        return $optimize;
142
-    }
141
+		return $optimize;
142
+	}
143 143
 
144
-    public function getOptimizationId()
145
-    {
146
-        return $this->optimization_problem_id;
147
-    }
144
+	public function getOptimizationId()
145
+	{
146
+		return $this->optimization_problem_id;
147
+	}
148 148
 
149
-    public function getRoutes()
150
-    {
151
-        return $this->routes;
152
-    }
149
+	public function getRoutes()
150
+	{
151
+		return $this->routes;
152
+	}
153 153
     
154
-    public function getRandomOptimizationId($offset,$limit)
155
-    {
156
-        $query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
157
-        $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
154
+	public function getRandomOptimizationId($offset,$limit)
155
+	{
156
+		$query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
157
+		$query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
158 158
             
159
-        $json = Route4Me::makeRequst(array(
160
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
161
-            'method' => 'GET',
162
-            'query'  => $query
163
-        ));
159
+		$json = Route4Me::makeRequst(array(
160
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
161
+			'method' => 'GET',
162
+			'query'  => $query
163
+		));
164 164
         
165
-        $optimizations = array();
166
-            foreach($json as $optimization) {
167
-                if (gettype($optimization)!="array") continue;
165
+		$optimizations = array();
166
+			foreach($json as $optimization) {
167
+				if (gettype($optimization)!="array") continue;
168 168
                 
169
-                foreach ($optimization as $otp1) {
170
-                    $optimizations[] = $otp1;
171
-                }
172
-            }
169
+				foreach ($optimization as $otp1) {
170
+					$optimizations[] = $otp1;
171
+				}
172
+			}
173 173
             
174
-            $num = rand(0,sizeof($optimizations)-1);
174
+			$num = rand(0,sizeof($optimizations)-1);
175 175
             
176
-            $rOptimization = $optimizations[$num];
176
+			$rOptimization = $optimizations[$num];
177 177
             
178
-            return $rOptimization['optimization_problem_id'];
179
-    }
178
+			return $rOptimization['optimization_problem_id'];
179
+	}
180 180
     
181
-    public function getAddresses($opt_id)
182
-    {
183
-        if ($opt_id == null) return null;
181
+	public function getAddresses($opt_id)
182
+	{
183
+		if ($opt_id == null) return null;
184 184
         
185
-        $params = array( "optimization_problem_id" => $opt_id );
185
+		$params = array( "optimization_problem_id" => $opt_id );
186 186
         
187
-        $optimization = (array)$this->get($params);
187
+		$optimization = (array)$this->get($params);
188 188
         
189
-        $addresses = $optimization["addresses"];
189
+		$addresses = $optimization["addresses"];
190 190
         
191
-        return $addresses;
192
-    }
191
+		return $addresses;
192
+	}
193 193
     
194
-    public function getRandomAddressFromOptimization($opt_id)
195
-    {
196
-        $addresses = (array)$this->getAddresses($opt_id);
194
+	public function getRandomAddressFromOptimization($opt_id)
195
+	{
196
+		$addresses = (array)$this->getAddresses($opt_id);
197 197
         
198
-        if ($addresses == null) {
199
-            echo "There are no addresses in this optimization!.. Try again.";
200
-            return null;
201
-        }
198
+		if ($addresses == null) {
199
+			echo "There are no addresses in this optimization!.. Try again.";
200
+			return null;
201
+		}
202 202
         
203
-        $num = rand(0,sizeof($addresses)-1);
203
+		$num = rand(0,sizeof($addresses)-1);
204 204
         
205
-        $rAddress = $addresses[$num];
205
+		$rAddress = $addresses[$num];
206 206
         
207
-        return $rAddress;
208
-    }
207
+		return $rAddress;
208
+	}
209 209
     
210
-    public function removeAddress($params)
211
-    {
212
-        $response = Route4Me::makeRequst(array(
213
-            'url'    => Endpoint::ADDRESS_V4,
214
-            'method' => 'DELETE',
215
-            'query'  => array(
216
-                'optimization_problem_id' => isset($params['optimization_problem_id'])
217
-                                               ? $params['optimization_problem_id'] : null,
218
-                'route_destination_id'    => isset($params['route_destination_id'])
219
-                                               ? $params['route_destination_id'] : null,
220
-            )
221
-        ));
210
+	public function removeAddress($params)
211
+	{
212
+		$response = Route4Me::makeRequst(array(
213
+			'url'    => Endpoint::ADDRESS_V4,
214
+			'method' => 'DELETE',
215
+			'query'  => array(
216
+				'optimization_problem_id' => isset($params['optimization_problem_id'])
217
+											   ? $params['optimization_problem_id'] : null,
218
+				'route_destination_id'    => isset($params['route_destination_id'])
219
+											   ? $params['route_destination_id'] : null,
220
+			)
221
+		));
222 222
         
223
-        return $response;
224
-    }
223
+		return $response;
224
+	}
225 225
     
226
-    public function removeOptimization($params)
227
-    {
228
-        $response = Route4Me::makeRequst(array(
229
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
230
-            'method' => 'DELETE',
231
-            'query'  => array(
232
-                'redirect' => isset($params['redirect']) ? $params['redirect'] : null,
233
-            ),
234
-            'body'   => array(
235
-                'optimization_problem_ids' => isset($params['optimization_problem_ids'])
236
-                                                ? $params['optimization_problem_ids'] : null,
237
-            )
238
-        ));
226
+	public function removeOptimization($params)
227
+	{
228
+		$response = Route4Me::makeRequst(array(
229
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
230
+			'method' => 'DELETE',
231
+			'query'  => array(
232
+				'redirect' => isset($params['redirect']) ? $params['redirect'] : null,
233
+			),
234
+			'body'   => array(
235
+				'optimization_problem_ids' => isset($params['optimization_problem_ids'])
236
+												? $params['optimization_problem_ids'] : null,
237
+			)
238
+		));
239 239
         
240
-        return $response;
241
-    }
240
+		return $response;
241
+	}
242 242
     
243
-    public function getHybridOptimization($params)
244
-    {
245
-        $optimize = Route4Me::makeRequst(array(
246
-            'url'    => Endpoint::HYBRID_DATE_OPTIMIZATION,
247
-            'method' => 'GET',
248
-            'query'  => array(
249
-                'target_date_string'      => isset($params['target_date_string'])
250
-                                               ? $params['target_date_string'] : null,
251
-                'timezone_offset_minutes' => isset($params['timezone_offset_minutes'])
252
-                                               ? $params['timezone_offset_minutes'] : null
253
-            )
254
-        ));
243
+	public function getHybridOptimization($params)
244
+	{
245
+		$optimize = Route4Me::makeRequst(array(
246
+			'url'    => Endpoint::HYBRID_DATE_OPTIMIZATION,
247
+			'method' => 'GET',
248
+			'query'  => array(
249
+				'target_date_string'      => isset($params['target_date_string'])
250
+											   ? $params['target_date_string'] : null,
251
+				'timezone_offset_minutes' => isset($params['timezone_offset_minutes'])
252
+											   ? $params['timezone_offset_minutes'] : null
253
+			)
254
+		));
255 255
 
256
-        return $optimize;
257
-    }
256
+		return $optimize;
257
+	}
258 258
     
259
-    Public function addDepotsToHybrid($params)
260
-    {
261
-        $depots = Route4Me::makeRequst(array( 
262
-            'url'    => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT,
263
-            'method' => 'POST',
264
-            'query'  => array(
265
-                'optimization_problem_id' => isset($params['optimization_problem_id'])
266
-                                               ? $params['optimization_problem_id'] : null,
267
-                ),
268
-            'body'   => array(
269
-                'optimization_problem_id' => isset($params['optimization_problem_id'])
270
-                                               ? $params['optimization_problem_id'] : null,
271
-                'delete_old_depots'       => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null,
272
-                'new_depots'              => isset($params['new_depots']) ? $params['new_depots'] : null,
273
-            )
274
-        ));
259
+	Public function addDepotsToHybrid($params)
260
+	{
261
+		$depots = Route4Me::makeRequst(array( 
262
+			'url'    => Endpoint::CHANGE_HYBRID_OPTIMIZATION_DEPOT,
263
+			'method' => 'POST',
264
+			'query'  => array(
265
+				'optimization_problem_id' => isset($params['optimization_problem_id'])
266
+											   ? $params['optimization_problem_id'] : null,
267
+				),
268
+			'body'   => array(
269
+				'optimization_problem_id' => isset($params['optimization_problem_id'])
270
+											   ? $params['optimization_problem_id'] : null,
271
+				'delete_old_depots'       => isset($params['delete_old_depots']) ? $params['delete_old_depots'] : null,
272
+				'new_depots'              => isset($params['new_depots']) ? $params['new_depots'] : null,
273
+			)
274
+		));
275 275
         
276
-        return $depots;
277
-    }
276
+		return $depots;
277
+	}
278 278
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
             'url'    => Endpoint::OPTIMIZATION_PROBLEM,
94 94
             'method' => 'GET',
95 95
             'query'  => array(
96
-                'state'  => isset($params['state'])  ? $params['state'] : null,
97
-                'limit'  => isset($params['limit'])  ? $params['limit'] : null,
96
+                'state'  => isset($params['state']) ? $params['state'] : null,
97
+                'limit'  => isset($params['limit']) ? $params['limit'] : null,
98 98
                 'offset' => isset($params['offset']) ? $params['offset'] : null,
99 99
                 'optimization_problem_id' => isset($params['optimization_problem_id']) 
100 100
                     ? $params['optimization_problem_id'] : null,
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         if (isset($optimize['optimizations'])) {
107 107
             $problems = array();
108 108
             
109
-            foreach($optimize['optimizations'] as $problem) {
109
+            foreach ($optimize['optimizations'] as $problem) {
110 110
                 $problems[] = OptimizationProblem::fromArray($problem);
111 111
             }
112 112
             
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         return $this->routes;
152 152
     }
153 153
     
154
-    public function getRandomOptimizationId($offset,$limit)
154
+    public function getRandomOptimizationId($offset, $limit)
155 155
     {
156 156
         $query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
157 157
         $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         ));
164 164
         
165 165
         $optimizations = array();
166
-            foreach($json as $optimization) {
166
+            foreach ($json as $optimization) {
167 167
                 if (gettype($optimization)!="array") continue;
168 168
                 
169 169
                 foreach ($optimization as $otp1) {
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
                 }
172 172
             }
173 173
             
174
-            $num = rand(0,sizeof($optimizations)-1);
174
+            $num = rand(0, sizeof($optimizations) - 1);
175 175
             
176 176
             $rOptimization = $optimizations[$num];
177 177
             
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
     
181 181
     public function getAddresses($opt_id)
182 182
     {
183
-        if ($opt_id == null) return null;
183
+        if ($opt_id==null) return null;
184 184
         
185
-        $params = array( "optimization_problem_id" => $opt_id );
185
+        $params = array("optimization_problem_id" => $opt_id);
186 186
         
187 187
         $optimization = (array)$this->get($params);
188 188
         
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
     {
196 196
         $addresses = (array)$this->getAddresses($opt_id);
197 197
         
198
-        if ($addresses == null) {
198
+        if ($addresses==null) {
199 199
             echo "There are no addresses in this optimization!.. Try again.";
200 200
             return null;
201 201
         }
202 202
         
203
-        $num = rand(0,sizeof($addresses)-1);
203
+        $num = rand(0, sizeof($addresses) - 1);
204 204
         
205 205
         $rAddress = $addresses[$num];
206 206
         
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -164,7 +164,9 @@  discard block
 block discarded – undo
164 164
         
165 165
         $optimizations = array();
166 166
             foreach($json as $optimization) {
167
-                if (gettype($optimization)!="array") continue;
167
+                if (gettype($optimization)!="array") {
168
+                	continue;
169
+                }
168 170
                 
169 171
                 foreach ($optimization as $otp1) {
170 172
                     $optimizations[] = $otp1;
@@ -180,7 +182,9 @@  discard block
 block discarded – undo
180 182
     
181 183
     public function getAddresses($opt_id)
182 184
     {
183
-        if ($opt_id == null) return null;
185
+        if ($opt_id == null) {
186
+        	return null;
187
+        }
184 188
         
185 189
         $params = array( "optimization_problem_id" => $opt_id );
186 190
         
Please login to merge, or discard this patch.
src/Route4Me/Order.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -71,6 +71,9 @@
 block discarded – undo
71 71
         return $order;
72 72
     }
73 73
     
74
+    /**
75
+     * @param Order $params
76
+     */
74 77
     public static function addOrder($params)
75 78
     {
76 79
         $response = Route4Me::makeRequst(array(
Please login to merge, or discard this patch.
Indentation   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -6,380 +6,380 @@
 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
-    public static function addOrder($params)
75
-    {
76
-        $response = Route4Me::makeRequst(array(
77
-            'url'    => Endpoint::ORDER_V4,
78
-            'method' => 'POST',
79
-            'body'   => array(
80
-                'address_1'                 =>  isset($params->address_1) ? $params->address_1: null,
81
-                'address_2'                 =>  isset($params->address_2) ? $params->address_2: null,
82
-                'member_id'                 =>  isset($params->member_id) ? $params->member_id: null,
83
-                'cached_lat'                =>  isset($params->cached_lat) ? $params->cached_lat : null,
84
-                'cached_lng'                =>  isset($params->cached_lng) ? $params->cached_lng : null,
85
-                'curbside_lat'              =>  isset($params->curbside_lat) ? $params->curbside_lat : null,
86
-                'curbside_lng'              =>  isset($params->curbside_lng) ? $params->curbside_lng : null,
87
-                'color'                     =>  isset($params->color) ? $params->color : null,
88
-                'order_icon'                =>  isset($params->order_icon) ? $params->order_icon : null,
89
-                'day_scheduled_for_YYMMDD'  =>  isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null,
90
-                'address_alias'             =>  isset($params->address_alias) ? $params->address_alias : null,
91
-                'address_city'              =>  isset($params->address_city) ? $params->address_city: null,
92
-                'address_state_id'          =>  isset($params->address_state_id) ? $params->address_state_id: null,
93
-                'address_country_id'        =>  isset($params->address_country_id) ? $params->address_country_id: null,
94
-                'address_zip'               =>  isset($params->address_zip) ? $params->address_zip: null,
95
-                'local_time_window_start'   =>  isset($params->local_time_window_start) ? $params->local_time_window_start: null,
96
-                'local_time_window_end'     =>  isset($params->local_time_window_end) ? $params->local_time_window_end: null,
97
-                'local_time_window_start_2' =>  isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null,
98
-                'local_time_window_end_2'   =>  isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null,
99
-                'service_time'              =>  isset($params->service_time) ? $params->service_time: null,
100
-                'local_timezone_string'     =>  isset($params->local_timezone_string) ? $params->local_timezone_string: null,
101
-                'EXT_FIELD_first_name'      =>  isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null,
102
-                'EXT_FIELD_last_name'       =>  isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null,
103
-                'EXT_FIELD_email'           =>  isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null,
104
-                'EXT_FIELD_phone'           =>  isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null,
105
-                'EXT_FIELD_custom_data'     =>  isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null,
106
-                'is_validated'              =>  isset($params->is_validated) ? $params->is_validated: null,
107
-                'is_pending'                =>  isset($params->is_pending) ? $params->is_pending: null,
108
-                'is_accepted'               =>  isset($params->is_accepted) ? $params->is_accepted: null,
109
-                'is_started'                =>  isset($params->is_started) ? $params->is_started: null,
110
-                'is_completed'              =>  isset($params->is_completed) ? $params->is_completed: null,
111
-                'custom_user_fields'        =>  isset($params->custom_user_fields) ? $params->custom_user_fields: null
112
-            )
113
-        ));
74
+	public static function addOrder($params)
75
+	{
76
+		$response = Route4Me::makeRequst(array(
77
+			'url'    => Endpoint::ORDER_V4,
78
+			'method' => 'POST',
79
+			'body'   => array(
80
+				'address_1'                 =>  isset($params->address_1) ? $params->address_1: null,
81
+				'address_2'                 =>  isset($params->address_2) ? $params->address_2: null,
82
+				'member_id'                 =>  isset($params->member_id) ? $params->member_id: null,
83
+				'cached_lat'                =>  isset($params->cached_lat) ? $params->cached_lat : null,
84
+				'cached_lng'                =>  isset($params->cached_lng) ? $params->cached_lng : null,
85
+				'curbside_lat'              =>  isset($params->curbside_lat) ? $params->curbside_lat : null,
86
+				'curbside_lng'              =>  isset($params->curbside_lng) ? $params->curbside_lng : null,
87
+				'color'                     =>  isset($params->color) ? $params->color : null,
88
+				'order_icon'                =>  isset($params->order_icon) ? $params->order_icon : null,
89
+				'day_scheduled_for_YYMMDD'  =>  isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null,
90
+				'address_alias'             =>  isset($params->address_alias) ? $params->address_alias : null,
91
+				'address_city'              =>  isset($params->address_city) ? $params->address_city: null,
92
+				'address_state_id'          =>  isset($params->address_state_id) ? $params->address_state_id: null,
93
+				'address_country_id'        =>  isset($params->address_country_id) ? $params->address_country_id: null,
94
+				'address_zip'               =>  isset($params->address_zip) ? $params->address_zip: null,
95
+				'local_time_window_start'   =>  isset($params->local_time_window_start) ? $params->local_time_window_start: null,
96
+				'local_time_window_end'     =>  isset($params->local_time_window_end) ? $params->local_time_window_end: null,
97
+				'local_time_window_start_2' =>  isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null,
98
+				'local_time_window_end_2'   =>  isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null,
99
+				'service_time'              =>  isset($params->service_time) ? $params->service_time: null,
100
+				'local_timezone_string'     =>  isset($params->local_timezone_string) ? $params->local_timezone_string: null,
101
+				'EXT_FIELD_first_name'      =>  isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null,
102
+				'EXT_FIELD_last_name'       =>  isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null,
103
+				'EXT_FIELD_email'           =>  isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null,
104
+				'EXT_FIELD_phone'           =>  isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null,
105
+				'EXT_FIELD_custom_data'     =>  isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null,
106
+				'is_validated'              =>  isset($params->is_validated) ? $params->is_validated: null,
107
+				'is_pending'                =>  isset($params->is_pending) ? $params->is_pending: null,
108
+				'is_accepted'               =>  isset($params->is_accepted) ? $params->is_accepted: null,
109
+				'is_started'                =>  isset($params->is_started) ? $params->is_started: null,
110
+				'is_completed'              =>  isset($params->is_completed) ? $params->is_completed: null,
111
+				'custom_user_fields'        =>  isset($params->custom_user_fields) ? $params->custom_user_fields: null
112
+			)
113
+		));
114 114
 
115
-        return $response;
116
-    }
115
+		return $response;
116
+	}
117 117
 
118
-    public static function addOrder2Route($params,$body)
119
-    {
120
-        $response = Route4Me::makeRequst(array(
121
-            'url'    => Endpoint::ROUTE_V4,
122
-            'method' => 'PUT',
123
-            'query'  => array(
124
-                'route_id' => isset($params->route_id) ? $params->route_id: null,
125
-                'redirect' => isset($params->redirect) ? $params->redirect : null
126
-            ),
127
-            'body' => (array)$body
128
-        ));
118
+	public static function addOrder2Route($params,$body)
119
+	{
120
+		$response = Route4Me::makeRequst(array(
121
+			'url'    => Endpoint::ROUTE_V4,
122
+			'method' => 'PUT',
123
+			'query'  => array(
124
+				'route_id' => isset($params->route_id) ? $params->route_id: null,
125
+				'redirect' => isset($params->redirect) ? $params->redirect : null
126
+			),
127
+			'body' => (array)$body
128
+		));
129 129
 
130
-        return $response;
131
-    }
130
+		return $response;
131
+	}
132 132
     
133
-    public static function addOrder2Optimization($params,$body)
134
-    {
135
-        $response = Route4Me::makeRequst(array(
136
-            'url'    => Endpoint::OPTIMIZATION_PROBLEM,
137
-            'method' => 'PUT',
138
-            'query'  => array(
139
-                'optimization_problem_id' =>  isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null,
140
-                'redirect'                => isset($params['redirect']) ? $params['redirect'] : null,
141
-                'device_type'             => isset($params['device_type']) ? $params['device_type'] : null
142
-            ),
143
-            'body'  => (array)$body
144
-        ));
133
+	public static function addOrder2Optimization($params,$body)
134
+	{
135
+		$response = Route4Me::makeRequst(array(
136
+			'url'    => Endpoint::OPTIMIZATION_PROBLEM,
137
+			'method' => 'PUT',
138
+			'query'  => array(
139
+				'optimization_problem_id' =>  isset($params['optimization_problem_id']) ? $params['optimization_problem_id'] : null,
140
+				'redirect'                => isset($params['redirect']) ? $params['redirect'] : null,
141
+				'device_type'             => isset($params['device_type']) ? $params['device_type'] : null
142
+			),
143
+			'body'  => (array)$body
144
+		));
145 145
 
146
-        return $response;
147
-    }
146
+		return $response;
147
+	}
148 148
     
149
-    public static function getOrder($params)
150
-    {
151
-        $response = Route4Me::makeRequst(array(
152
-            'url'    => Endpoint::ORDER_V4,
153
-            'method' => 'GET',
154
-            'query'  => array(
155
-                'order_id'             => isset($params->order_id) ? $params->order_id: null,
156
-                'fields'               => isset($params->fields) ? $params->fields: null,
157
-                'day_added_YYMMDD'     => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null,
158
-                'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null,
159
-                'query'                => isset($params->query) ? $params->query: null,
160
-                'offset'               => isset($params->offset) ? $params->offset: null,
161
-                'limit'                => isset($params->limit) ? $params->limit: null
162
-            )
163
-        ));
149
+	public static function getOrder($params)
150
+	{
151
+		$response = Route4Me::makeRequst(array(
152
+			'url'    => Endpoint::ORDER_V4,
153
+			'method' => 'GET',
154
+			'query'  => array(
155
+				'order_id'             => isset($params->order_id) ? $params->order_id: null,
156
+				'fields'               => isset($params->fields) ? $params->fields: null,
157
+				'day_added_YYMMDD'     => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null,
158
+				'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null,
159
+				'query'                => isset($params->query) ? $params->query: null,
160
+				'offset'               => isset($params->offset) ? $params->offset: null,
161
+				'limit'                => isset($params->limit) ? $params->limit: null
162
+			)
163
+		));
164 164
 
165
-        return $response;
166
-    }
165
+		return $response;
166
+	}
167 167
     
168
-    public static function getOrders($params)
169
-    {
170
-        $response = Route4Me::makeRequst(array(
171
-            'url'    => Endpoint::ORDER_V4,
172
-            'method' => 'GET',
173
-            'query'  => array(
174
-                'offset' => isset($params->offset) ? $params->offset: null,
175
-                'limit'  => isset($params->limit) ? $params->limit: null
176
-            )
177
-        ));
168
+	public static function getOrders($params)
169
+	{
170
+		$response = Route4Me::makeRequst(array(
171
+			'url'    => Endpoint::ORDER_V4,
172
+			'method' => 'GET',
173
+			'query'  => array(
174
+				'offset' => isset($params->offset) ? $params->offset: null,
175
+				'limit'  => isset($params->limit) ? $params->limit: null
176
+			)
177
+		));
178 178
 
179
-        return $response;
180
-    }
179
+		return $response;
180
+	}
181 181
     
182
-    public function getRandomOrderId($offset,$limit)
183
-    {
184
-        $params = array('offset' => $offset, 'limit' => $limit);
182
+	public function getRandomOrderId($offset,$limit)
183
+	{
184
+		$params = array('offset' => $offset, 'limit' => $limit);
185 185
         
186
-        $orders = self::getOrders($params);
186
+		$orders = self::getOrders($params);
187 187
         
188
-        if (is_null($orders)) return null;
189
-        if (!isset($orders['results'])) return null;
188
+		if (is_null($orders)) return null;
189
+		if (!isset($orders['results'])) return null;
190 190
         
191
-        $randomIndex = rand(0, sizeof($orders['results'])-1);
191
+		$randomIndex = rand(0, sizeof($orders['results'])-1);
192 192
         
193
-        $order = $orders['results'][$randomIndex];
193
+		$order = $orders['results'][$randomIndex];
194 194
         
195
-        return $order['order_id'];
196
-    }
195
+		return $order['order_id'];
196
+	}
197 197
     
198
-    public function getRandomOrder($offset,$limit)
199
-    {
200
-        $params = array('offset' => $offset, 'limit' => $limit);
198
+	public function getRandomOrder($offset,$limit)
199
+	{
200
+		$params = array('offset' => $offset, 'limit' => $limit);
201 201
         
202
-        $orders = self::getOrders($params);
202
+		$orders = self::getOrders($params);
203 203
         
204
-        if (is_null($orders)) return null;
205
-        if (!isset($orders['results'])) return null;
204
+		if (is_null($orders)) return null;
205
+		if (!isset($orders['results'])) return null;
206 206
         
207
-        $randomIndex = rand(0, sizeof($orders['results'])-1);
207
+		$randomIndex = rand(0, sizeof($orders['results'])-1);
208 208
         
209
-        $order = $orders['results'][$randomIndex];
209
+		$order = $orders['results'][$randomIndex];
210 210
         
211
-        return $order;
212
-    }
211
+		return $order;
212
+	}
213 213
     
214
-    public static function removeOrder($params)
215
-    {
216
-        $response = Route4Me::makeRequst(array(
217
-            'url'    => Endpoint::ORDER_V4,
218
-            'method' => 'DELETE',
219
-            'body'   => array(
220
-                'order_ids' =>  isset($params->order_ids) ? $params->order_ids: null
221
-            )
222
-        ));
214
+	public static function removeOrder($params)
215
+	{
216
+		$response = Route4Me::makeRequst(array(
217
+			'url'    => Endpoint::ORDER_V4,
218
+			'method' => 'DELETE',
219
+			'body'   => array(
220
+				'order_ids' =>  isset($params->order_ids) ? $params->order_ids: null
221
+			)
222
+		));
223 223
 
224
-        return $response;
225
-    }
224
+		return $response;
225
+	}
226 226
     
227
-    public static function updateOrder($body)
228
-    {
229
-        $response = Route4Me::makeRequst(array(
230
-            'url'    => Endpoint::ORDER_V4,
231
-            'method' => 'PUT',
232
-            'body'   => (array)$body
233
-        ));
227
+	public static function updateOrder($body)
228
+	{
229
+		$response = Route4Me::makeRequst(array(
230
+			'url'    => Endpoint::ORDER_V4,
231
+			'method' => 'PUT',
232
+			'body'   => (array)$body
233
+		));
234 234
 
235
-        return $response;
236
-    }
235
+		return $response;
236
+	}
237 237
     
238
-    public static function searchOrder($params)
239
-    {
240
-        $response = Route4Me::makeRequst(array(
241
-            'url'    => Endpoint::ORDER_V4,
242
-            'method' => 'GET',
243
-            'query'  => array(
244
-                'day_added_YYMMDD'     =>  isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null,
245
-                'scheduled_for_YYMMDD' =>  isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null,
246
-                'fields'               =>  isset($params->fields) ? $params->fields: null,
247
-                'offset'               =>  isset($params->offset) ? $params->offset: null,
248
-                'limit'                =>  isset($params->limit) ? $params->limit: null,
249
-                'query'                =>  isset($params->query) ? $params->query: null,
250
-            )
251
-        ));
238
+	public static function searchOrder($params)
239
+	{
240
+		$response = Route4Me::makeRequst(array(
241
+			'url'    => Endpoint::ORDER_V4,
242
+			'method' => 'GET',
243
+			'query'  => array(
244
+				'day_added_YYMMDD'     =>  isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null,
245
+				'scheduled_for_YYMMDD' =>  isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null,
246
+				'fields'               =>  isset($params->fields) ? $params->fields: null,
247
+				'offset'               =>  isset($params->offset) ? $params->offset: null,
248
+				'limit'                =>  isset($params->limit) ? $params->limit: null,
249
+				'query'                =>  isset($params->query) ? $params->query: null,
250
+			)
251
+		));
252 252
 
253
-        return $response;
254
-    }
253
+		return $response;
254
+	}
255 255
     
256
-    public static function validateLatitude($lat)
257
-    {
258
-        if (!is_numeric($lat)) return false;
256
+	public static function validateLatitude($lat)
257
+	{
258
+		if (!is_numeric($lat)) return false;
259 259
         
260
-        if ($lat>90 || $lat<-90) return false;
260
+		if ($lat>90 || $lat<-90) return false;
261 261
         
262
-        return true;
263
-    }
262
+		return true;
263
+	}
264 264
     
265
-    public static function validateLongitude($lng)
266
-    {
267
-        if (!is_numeric($lng)) return false;
265
+	public static function validateLongitude($lng)
266
+	{
267
+		if (!is_numeric($lng)) return false;
268 268
         
269
-        if ($lng>180 || $lng<-180) return false;
269
+		if ($lng>180 || $lng<-180) return false;
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
-        if (!empty($columns)) {
286
-             array_push($results['fail'],'Empty CSV table');
287
-             return ($results);
288
-        }
285
+		if (!empty($columns)) {
286
+			 array_push($results['fail'],'Empty CSV table');
287
+			 return ($results);
288
+		}
289 289
                  
290
-        $iRow=1;
290
+		$iRow=1;
291 291
         
292
-        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
293
-            if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null) !== $rows) {
292
+		while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
293
+			if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null) !== $rows) {
294 294
                 
295
-                $cached_lat = 0.000;
295
+				$cached_lat = 0.000;
296 296
                 
297
-                if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) {
298
-                    array_push($results['fail'],"$iRow --> Wrong cached_lat"); 
299
-                    $iRow++;
300
-                    continue;
301
-                }
302
-                else $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]);
297
+				if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) {
298
+					array_push($results['fail'],"$iRow --> Wrong cached_lat"); 
299
+					$iRow++;
300
+					continue;
301
+				}
302
+				else $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]);
303 303
                 
304
-                $cached_lng = 0.000;
304
+				$cached_lng = 0.000;
305 305
                 
306
-                if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) {
307
-                    array_push($results['fail'],"$iRow --> Wrong cached_lng"); 
308
-                    $iRow++;
309
-                    continue;
310
-                }
311
-                else $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]);
306
+				if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) {
307
+					array_push($results['fail'],"$iRow --> Wrong cached_lng"); 
308
+					$iRow++;
309
+					continue;
310
+				}
311
+				else $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]);
312 312
                 
313
-                if (isset($ordersFieldsMapping['curbside_lat'])) {
314
-                    if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) {
315
-                        array_push($results['fail'],"$iRow --> Wrong curbside_lat"); 
316
-                        $iRow++;
317
-                        continue;
318
-                    }
319
-                }
313
+				if (isset($ordersFieldsMapping['curbside_lat'])) {
314
+					if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) {
315
+						array_push($results['fail'],"$iRow --> Wrong curbside_lat"); 
316
+						$iRow++;
317
+						continue;
318
+					}
319
+				}
320 320
                 
321
-                if (isset($ordersFieldsMapping['curbside_lng'])) {
322
-                    if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) {
323
-                        array_push($results['fail'],"$iRow --> Wrong curbside_lng"); 
324
-                        $iRow++;
325
-                        continue;
326
-                    }
327
-                }
321
+				if (isset($ordersFieldsMapping['curbside_lng'])) {
322
+					if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) {
323
+						array_push($results['fail'],"$iRow --> Wrong curbside_lng"); 
324
+						$iRow++;
325
+						continue;
326
+					}
327
+				}
328 328
                 
329
-                $address = $rows[$ordersFieldsMapping['address_1']];
329
+				$address = $rows[$ordersFieldsMapping['address_1']];
330 330
                 
331
-                if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']];
332
-                if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']];
333
-                if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']];
334
-                if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']];
331
+				if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']];
332
+				if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']];
333
+				if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']];
334
+				if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']];
335 335
                 
336
-                echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>";
336
+				echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>";
337 337
                 
338
-                $orderParameters = Order::fromArray(array(
339
-                    "cached_lat"                => $cached_lat,
340
-                    "cached_lng"                => $cached_lng,
341
-                    "curbside_lat"              => isset($ordersFieldsMapping['curbside_lat']) ? $rows[$ordersFieldsMapping['curbside_lat']] : null,
342
-                    "curbside_lng"              => isset($ordersFieldsMapping['curbside_lng']) ? $rows[$ordersFieldsMapping['curbside_lng']] : null,
343
-                    "color"                     => isset($ordersFieldsMapping['color']) ? $rows[$ordersFieldsMapping['color']] : null,
344
-                    "day_scheduled_for_YYMMDD"  => isset($ordersFieldsMapping['day_scheduled_for_YYMMDD'])
345
-                                                      ? $rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']] : null,
346
-                    "address_alias"             => isset($ordersFieldsMapping['address_alias']) ? $rows[$ordersFieldsMapping['address_alias']] : null,
347
-                    "address_1"                 => $address,
348
-                    "address_2"                 => isset($ordersFieldsMapping['address_2']) ? $rows[$ordersFieldsMapping['address_2']] : null,
349
-                    "local_time_window_start"   => isset($ordersFieldsMapping['local_time_window_start'])
350
-                                                      ? $rows[$ordersFieldsMapping['local_time_window_start']] : null,
351
-                    "local_time_window_end"     => isset($ordersFieldsMapping['local_time_window_end'])
352
-                                                      ? $rows[$ordersFieldsMapping['local_time_window_end']] : null,
353
-                    "local_time_window_start_2" => isset($ordersFieldsMapping['local_time_window_start_2'])
354
-                                                      ? $rows[$ordersFieldsMapping['local_time_window_start_2']] : null,
355
-                    "local_time_window_end_2"   => isset($ordersFieldsMapping['local_time_window_end_2'])
356
-                                                      ? $rows[$ordersFieldsMapping['local_time_window_end_2']] : null,
357
-                    "service_time"              => isset($ordersFieldsMapping['service_time'])
358
-                                                      ? $rows[$ordersFieldsMapping['service_time']] : null,
359
-                    "EXT_FIELD_first_name"      => isset($ordersFieldsMapping['EXT_FIELD_first_name'])
360
-                                                      ? $rows[$ordersFieldsMapping['EXT_FIELD_first_name']] : null,
361
-                    "EXT_FIELD_last_name"       => isset($ordersFieldsMapping['EXT_FIELD_last_name'])
362
-                                                      ? $rows[$ordersFieldsMapping['EXT_FIELD_last_name']] : null,
363
-                    "EXT_FIELD_email"           => isset($ordersFieldsMapping['EXT_FIELD_email'])
364
-                                                      ? $rows[$ordersFieldsMapping['EXT_FIELD_email']] : null,
365
-                    "EXT_FIELD_phone"           => isset($ordersFieldsMapping['EXT_FIELD_phone'])
366
-                                                      ? $rows[$ordersFieldsMapping['EXT_FIELD_phone']] : null,
367
-                    "EXT_FIELD_custom_data"     => isset($ordersFieldsMapping['EXT_FIELD_custom_data'])
368
-                                                      ? $rows[$ordersFieldsMapping['EXT_FIELD_custom_data']] : null,
369
-                    "order_icon"                => isset($ordersFieldsMapping['order_icon']) ? $rows[$ordersFieldsMapping['order_icon']] : null,
370
-                ));
338
+				$orderParameters = Order::fromArray(array(
339
+					"cached_lat"                => $cached_lat,
340
+					"cached_lng"                => $cached_lng,
341
+					"curbside_lat"              => isset($ordersFieldsMapping['curbside_lat']) ? $rows[$ordersFieldsMapping['curbside_lat']] : null,
342
+					"curbside_lng"              => isset($ordersFieldsMapping['curbside_lng']) ? $rows[$ordersFieldsMapping['curbside_lng']] : null,
343
+					"color"                     => isset($ordersFieldsMapping['color']) ? $rows[$ordersFieldsMapping['color']] : null,
344
+					"day_scheduled_for_YYMMDD"  => isset($ordersFieldsMapping['day_scheduled_for_YYMMDD'])
345
+													  ? $rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']] : null,
346
+					"address_alias"             => isset($ordersFieldsMapping['address_alias']) ? $rows[$ordersFieldsMapping['address_alias']] : null,
347
+					"address_1"                 => $address,
348
+					"address_2"                 => isset($ordersFieldsMapping['address_2']) ? $rows[$ordersFieldsMapping['address_2']] : null,
349
+					"local_time_window_start"   => isset($ordersFieldsMapping['local_time_window_start'])
350
+													  ? $rows[$ordersFieldsMapping['local_time_window_start']] : null,
351
+					"local_time_window_end"     => isset($ordersFieldsMapping['local_time_window_end'])
352
+													  ? $rows[$ordersFieldsMapping['local_time_window_end']] : null,
353
+					"local_time_window_start_2" => isset($ordersFieldsMapping['local_time_window_start_2'])
354
+													  ? $rows[$ordersFieldsMapping['local_time_window_start_2']] : null,
355
+					"local_time_window_end_2"   => isset($ordersFieldsMapping['local_time_window_end_2'])
356
+													  ? $rows[$ordersFieldsMapping['local_time_window_end_2']] : null,
357
+					"service_time"              => isset($ordersFieldsMapping['service_time'])
358
+													  ? $rows[$ordersFieldsMapping['service_time']] : null,
359
+					"EXT_FIELD_first_name"      => isset($ordersFieldsMapping['EXT_FIELD_first_name'])
360
+													  ? $rows[$ordersFieldsMapping['EXT_FIELD_first_name']] : null,
361
+					"EXT_FIELD_last_name"       => isset($ordersFieldsMapping['EXT_FIELD_last_name'])
362
+													  ? $rows[$ordersFieldsMapping['EXT_FIELD_last_name']] : null,
363
+					"EXT_FIELD_email"           => isset($ordersFieldsMapping['EXT_FIELD_email'])
364
+													  ? $rows[$ordersFieldsMapping['EXT_FIELD_email']] : null,
365
+					"EXT_FIELD_phone"           => isset($ordersFieldsMapping['EXT_FIELD_phone'])
366
+													  ? $rows[$ordersFieldsMapping['EXT_FIELD_phone']] : null,
367
+					"EXT_FIELD_custom_data"     => isset($ordersFieldsMapping['EXT_FIELD_custom_data'])
368
+													  ? $rows[$ordersFieldsMapping['EXT_FIELD_custom_data']] : null,
369
+					"order_icon"                => isset($ordersFieldsMapping['order_icon']) ? $rows[$ordersFieldsMapping['order_icon']] : null,
370
+				));
371 371
                 
372
-                $order = new Order();
372
+				$order = new Order();
373 373
                 
374
-                $orderResults = $order->addOrder($orderParameters);
374
+				$orderResults = $order->addOrder($orderParameters);
375 375
                 
376
-                array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
377
-            }
378
-            else {
379
-                array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
380
-            }
376
+				array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
377
+			}
378
+			else {
379
+				array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
380
+			}
381 381
             
382
-            $iRow++;
383
-        }
384
-    }
382
+			$iRow++;
383
+		}
384
+	}
385 385
 }
Please login to merge, or discard this patch.
Spacing   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
     public $custom_user_fields;
62 62
     
63 63
     public static function fromArray(array $params) {
64
-        $order= new Order();
65
-        foreach($params as $key => $value) {
64
+        $order = new Order();
65
+        foreach ($params as $key => $value) {
66 66
             if (property_exists($order, $key)) {
67 67
                 $order->{$key} = $value;
68 68
             }
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
             'url'    => Endpoint::ORDER_V4,
78 78
             'method' => 'POST',
79 79
             'body'   => array(
80
-                'address_1'                 =>  isset($params->address_1) ? $params->address_1: null,
81
-                'address_2'                 =>  isset($params->address_2) ? $params->address_2: null,
82
-                'member_id'                 =>  isset($params->member_id) ? $params->member_id: null,
80
+                'address_1'                 =>  isset($params->address_1) ? $params->address_1 : null,
81
+                'address_2'                 =>  isset($params->address_2) ? $params->address_2 : null,
82
+                'member_id'                 =>  isset($params->member_id) ? $params->member_id : null,
83 83
                 'cached_lat'                =>  isset($params->cached_lat) ? $params->cached_lat : null,
84 84
                 'cached_lng'                =>  isset($params->cached_lng) ? $params->cached_lng : null,
85 85
                 'curbside_lat'              =>  isset($params->curbside_lat) ? $params->curbside_lat : null,
@@ -88,40 +88,40 @@  discard block
 block discarded – undo
88 88
                 'order_icon'                =>  isset($params->order_icon) ? $params->order_icon : null,
89 89
                 'day_scheduled_for_YYMMDD'  =>  isset($params->day_scheduled_for_YYMMDD) ? $params->day_scheduled_for_YYMMDD : null,
90 90
                 'address_alias'             =>  isset($params->address_alias) ? $params->address_alias : null,
91
-                'address_city'              =>  isset($params->address_city) ? $params->address_city: null,
92
-                'address_state_id'          =>  isset($params->address_state_id) ? $params->address_state_id: null,
93
-                'address_country_id'        =>  isset($params->address_country_id) ? $params->address_country_id: null,
94
-                'address_zip'               =>  isset($params->address_zip) ? $params->address_zip: null,
95
-                'local_time_window_start'   =>  isset($params->local_time_window_start) ? $params->local_time_window_start: null,
96
-                'local_time_window_end'     =>  isset($params->local_time_window_end) ? $params->local_time_window_end: null,
97
-                'local_time_window_start_2' =>  isset($params->local_time_window_start_2) ? $params->local_time_window_start_2: null,
98
-                'local_time_window_end_2'   =>  isset($params->local_time_window_end_2) ? $params->local_time_window_end_2: null,
99
-                'service_time'              =>  isset($params->service_time) ? $params->service_time: null,
100
-                'local_timezone_string'     =>  isset($params->local_timezone_string) ? $params->local_timezone_string: null,
101
-                'EXT_FIELD_first_name'      =>  isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name: null,
102
-                'EXT_FIELD_last_name'       =>  isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name: null,
103
-                'EXT_FIELD_email'           =>  isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email: null,
104
-                'EXT_FIELD_phone'           =>  isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone: null,
105
-                'EXT_FIELD_custom_data'     =>  isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data: null,
106
-                'is_validated'              =>  isset($params->is_validated) ? $params->is_validated: null,
107
-                'is_pending'                =>  isset($params->is_pending) ? $params->is_pending: null,
108
-                'is_accepted'               =>  isset($params->is_accepted) ? $params->is_accepted: null,
109
-                'is_started'                =>  isset($params->is_started) ? $params->is_started: null,
110
-                'is_completed'              =>  isset($params->is_completed) ? $params->is_completed: null,
111
-                'custom_user_fields'        =>  isset($params->custom_user_fields) ? $params->custom_user_fields: null
91
+                'address_city'              =>  isset($params->address_city) ? $params->address_city : null,
92
+                'address_state_id'          =>  isset($params->address_state_id) ? $params->address_state_id : null,
93
+                'address_country_id'        =>  isset($params->address_country_id) ? $params->address_country_id : null,
94
+                'address_zip'               =>  isset($params->address_zip) ? $params->address_zip : null,
95
+                'local_time_window_start'   =>  isset($params->local_time_window_start) ? $params->local_time_window_start : null,
96
+                'local_time_window_end'     =>  isset($params->local_time_window_end) ? $params->local_time_window_end : null,
97
+                'local_time_window_start_2' =>  isset($params->local_time_window_start_2) ? $params->local_time_window_start_2 : null,
98
+                'local_time_window_end_2'   =>  isset($params->local_time_window_end_2) ? $params->local_time_window_end_2 : null,
99
+                'service_time'              =>  isset($params->service_time) ? $params->service_time : null,
100
+                'local_timezone_string'     =>  isset($params->local_timezone_string) ? $params->local_timezone_string : null,
101
+                'EXT_FIELD_first_name'      =>  isset($params->EXT_FIELD_first_name) ? $params->EXT_FIELD_first_name : null,
102
+                'EXT_FIELD_last_name'       =>  isset($params->EXT_FIELD_last_name) ? $params->EXT_FIELD_last_name : null,
103
+                'EXT_FIELD_email'           =>  isset($params->EXT_FIELD_email) ? $params->EXT_FIELD_email : null,
104
+                'EXT_FIELD_phone'           =>  isset($params->EXT_FIELD_phone) ? $params->EXT_FIELD_phone : null,
105
+                'EXT_FIELD_custom_data'     =>  isset($params->EXT_FIELD_custom_data) ? $params->EXT_FIELD_custom_data : null,
106
+                'is_validated'              =>  isset($params->is_validated) ? $params->is_validated : null,
107
+                'is_pending'                =>  isset($params->is_pending) ? $params->is_pending : null,
108
+                'is_accepted'               =>  isset($params->is_accepted) ? $params->is_accepted : null,
109
+                'is_started'                =>  isset($params->is_started) ? $params->is_started : null,
110
+                'is_completed'              =>  isset($params->is_completed) ? $params->is_completed : null,
111
+                'custom_user_fields'        =>  isset($params->custom_user_fields) ? $params->custom_user_fields : null
112 112
             )
113 113
         ));
114 114
 
115 115
         return $response;
116 116
     }
117 117
 
118
-    public static function addOrder2Route($params,$body)
118
+    public static function addOrder2Route($params, $body)
119 119
     {
120 120
         $response = Route4Me::makeRequst(array(
121 121
             'url'    => Endpoint::ROUTE_V4,
122 122
             'method' => 'PUT',
123 123
             'query'  => array(
124
-                'route_id' => isset($params->route_id) ? $params->route_id: null,
124
+                'route_id' => isset($params->route_id) ? $params->route_id : null,
125 125
                 'redirect' => isset($params->redirect) ? $params->redirect : null
126 126
             ),
127 127
             'body' => (array)$body
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
         return $response;
131 131
     }
132 132
     
133
-    public static function addOrder2Optimization($params,$body)
133
+    public static function addOrder2Optimization($params, $body)
134 134
     {
135 135
         $response = Route4Me::makeRequst(array(
136 136
             'url'    => Endpoint::OPTIMIZATION_PROBLEM,
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
             'url'    => Endpoint::ORDER_V4,
153 153
             'method' => 'GET',
154 154
             'query'  => array(
155
-                'order_id'             => isset($params->order_id) ? $params->order_id: null,
156
-                'fields'               => isset($params->fields) ? $params->fields: null,
157
-                'day_added_YYMMDD'     => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null,
158
-                'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null,
159
-                'query'                => isset($params->query) ? $params->query: null,
160
-                'offset'               => isset($params->offset) ? $params->offset: null,
161
-                'limit'                => isset($params->limit) ? $params->limit: null
155
+                'order_id'             => isset($params->order_id) ? $params->order_id : null,
156
+                'fields'               => isset($params->fields) ? $params->fields : null,
157
+                'day_added_YYMMDD'     => isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD : null,
158
+                'scheduled_for_YYMMDD' => isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD : null,
159
+                'query'                => isset($params->query) ? $params->query : null,
160
+                'offset'               => isset($params->offset) ? $params->offset : null,
161
+                'limit'                => isset($params->limit) ? $params->limit : null
162 162
             )
163 163
         ));
164 164
 
@@ -171,15 +171,15 @@  discard block
 block discarded – undo
171 171
             'url'    => Endpoint::ORDER_V4,
172 172
             'method' => 'GET',
173 173
             'query'  => array(
174
-                'offset' => isset($params->offset) ? $params->offset: null,
175
-                'limit'  => isset($params->limit) ? $params->limit: null
174
+                'offset' => isset($params->offset) ? $params->offset : null,
175
+                'limit'  => isset($params->limit) ? $params->limit : null
176 176
             )
177 177
         ));
178 178
 
179 179
         return $response;
180 180
     }
181 181
     
182
-    public function getRandomOrderId($offset,$limit)
182
+    public function getRandomOrderId($offset, $limit)
183 183
     {
184 184
         $params = array('offset' => $offset, 'limit' => $limit);
185 185
         
@@ -188,14 +188,14 @@  discard block
 block discarded – undo
188 188
         if (is_null($orders)) return null;
189 189
         if (!isset($orders['results'])) return null;
190 190
         
191
-        $randomIndex = rand(0, sizeof($orders['results'])-1);
191
+        $randomIndex = rand(0, sizeof($orders['results']) - 1);
192 192
         
193 193
         $order = $orders['results'][$randomIndex];
194 194
         
195 195
         return $order['order_id'];
196 196
     }
197 197
     
198
-    public function getRandomOrder($offset,$limit)
198
+    public function getRandomOrder($offset, $limit)
199 199
     {
200 200
         $params = array('offset' => $offset, 'limit' => $limit);
201 201
         
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
         if (is_null($orders)) return null;
205 205
         if (!isset($orders['results'])) return null;
206 206
         
207
-        $randomIndex = rand(0, sizeof($orders['results'])-1);
207
+        $randomIndex = rand(0, sizeof($orders['results']) - 1);
208 208
         
209 209
         $order = $orders['results'][$randomIndex];
210 210
         
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
             'url'    => Endpoint::ORDER_V4,
218 218
             'method' => 'DELETE',
219 219
             'body'   => array(
220
-                'order_ids' =>  isset($params->order_ids) ? $params->order_ids: null
220
+                'order_ids' =>  isset($params->order_ids) ? $params->order_ids : null
221 221
             )
222 222
         ));
223 223
 
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
             'url'    => Endpoint::ORDER_V4,
242 242
             'method' => 'GET',
243 243
             'query'  => array(
244
-                'day_added_YYMMDD'     =>  isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD: null,
245
-                'scheduled_for_YYMMDD' =>  isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD: null,
246
-                'fields'               =>  isset($params->fields) ? $params->fields: null,
247
-                'offset'               =>  isset($params->offset) ? $params->offset: null,
248
-                'limit'                =>  isset($params->limit) ? $params->limit: null,
249
-                'query'                =>  isset($params->query) ? $params->query: null,
244
+                'day_added_YYMMDD'     =>  isset($params->day_added_YYMMDD) ? $params->day_added_YYMMDD : null,
245
+                'scheduled_for_YYMMDD' =>  isset($params->scheduled_for_YYMMDD) ? $params->scheduled_for_YYMMDD : null,
246
+                'fields'               =>  isset($params->fields) ? $params->fields : null,
247
+                'offset'               =>  isset($params->offset) ? $params->offset : null,
248
+                'limit'                =>  isset($params->limit) ? $params->limit : null,
249
+                'query'                =>  isset($params->query) ? $params->query : null,
250 250
             )
251 251
         ));
252 252
 
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
         $columns = fgetcsv($csvFileHandle, $max_line_length, $delemietr);
284 284
         
285 285
         if (!empty($columns)) {
286
-             array_push($results['fail'],'Empty CSV table');
286
+             array_push($results['fail'], 'Empty CSV table');
287 287
              return ($results);
288 288
         }
289 289
                  
290
-        $iRow=1;
290
+        $iRow = 1;
291 291
         
292
-        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr)) !== false) {
293
-            if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null) !== $rows) {
292
+        while (($rows = fgetcsv($csvFileHandle, $max_line_length, $delemietr))!==false) {
293
+            if ($rows[$ordersFieldsMapping['cached_lat']] && $rows[$ordersFieldsMapping['cached_lng']] && $rows[$ordersFieldsMapping['address_1']] && array(null)!==$rows) {
294 294
                 
295 295
                 $cached_lat = 0.000;
296 296
                 
297 297
                 if (!$this->validateLatitude($rows[$ordersFieldsMapping['cached_lat']])) {
298
-                    array_push($results['fail'],"$iRow --> Wrong cached_lat"); 
298
+                    array_push($results['fail'], "$iRow --> Wrong cached_lat"); 
299 299
                     $iRow++;
300 300
                     continue;
301 301
                 }
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
                 $cached_lng = 0.000;
305 305
                 
306 306
                 if (!$this->validateLongitude($rows[$ordersFieldsMapping['cached_lng']])) {
307
-                    array_push($results['fail'],"$iRow --> Wrong cached_lng"); 
307
+                    array_push($results['fail'], "$iRow --> Wrong cached_lng"); 
308 308
                     $iRow++;
309 309
                     continue;
310 310
                 }
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
                 
313 313
                 if (isset($ordersFieldsMapping['curbside_lat'])) {
314 314
                     if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) {
315
-                        array_push($results['fail'],"$iRow --> Wrong curbside_lat"); 
315
+                        array_push($results['fail'], "$iRow --> Wrong curbside_lat"); 
316 316
                         $iRow++;
317 317
                         continue;
318 318
                     }
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
                 
321 321
                 if (isset($ordersFieldsMapping['curbside_lng'])) {
322 322
                     if (!$this->validateLongitude($rows[$ordersFieldsMapping['curbside_lng']])) {
323
-                        array_push($results['fail'],"$iRow --> Wrong curbside_lng"); 
323
+                        array_push($results['fail'], "$iRow --> Wrong curbside_lng"); 
324 324
                         $iRow++;
325 325
                         continue;
326 326
                     }
@@ -328,10 +328,10 @@  discard block
 block discarded – undo
328 328
                 
329 329
                 $address = $rows[$ordersFieldsMapping['address_1']];
330 330
                 
331
-                if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']];
332
-                if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']];
333
-                if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']];
334
-                if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']];
331
+                if (isset($ordersFieldsMapping['order_city'])) $address .= ', '.$rows[$ordersFieldsMapping['order_city']];
332
+                if (isset($ordersFieldsMapping['order_state_id'])) $address .= ', '.$rows[$ordersFieldsMapping['order_state_id']];
333
+                if (isset($ordersFieldsMapping['order_zip_code'])) $address .= ', '.$rows[$ordersFieldsMapping['order_zip_code']];
334
+                if (isset($ordersFieldsMapping['order_country_id'])) $address .= ', '.$rows[$ordersFieldsMapping['order_country_id']];
335 335
                 
336 336
                 echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>";
337 337
                 
@@ -373,10 +373,10 @@  discard block
 block discarded – undo
373 373
                 
374 374
                 $orderResults = $order->addOrder($orderParameters);
375 375
                 
376
-                array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
376
+                array_push($results['success'], "The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
377 377
             }
378 378
             else {
379
-                array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
379
+                array_push($results['fail'], "$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
380 380
             }
381 381
             
382 382
             $iRow++;
Please login to merge, or discard this patch.
Braces   +41 added lines, -16 removed lines patch added patch discarded remove patch
@@ -185,8 +185,12 @@  discard block
 block discarded – undo
185 185
         
186 186
         $orders = self::getOrders($params);
187 187
         
188
-        if (is_null($orders)) return null;
189
-        if (!isset($orders['results'])) return null;
188
+        if (is_null($orders)) {
189
+        	return null;
190
+        }
191
+        if (!isset($orders['results'])) {
192
+        	return null;
193
+        }
190 194
         
191 195
         $randomIndex = rand(0, sizeof($orders['results'])-1);
192 196
         
@@ -201,8 +205,12 @@  discard block
 block discarded – undo
201 205
         
202 206
         $orders = self::getOrders($params);
203 207
         
204
-        if (is_null($orders)) return null;
205
-        if (!isset($orders['results'])) return null;
208
+        if (is_null($orders)) {
209
+        	return null;
210
+        }
211
+        if (!isset($orders['results'])) {
212
+        	return null;
213
+        }
206 214
         
207 215
         $randomIndex = rand(0, sizeof($orders['results'])-1);
208 216
         
@@ -255,18 +263,26 @@  discard block
 block discarded – undo
255 263
     
256 264
     public static function validateLatitude($lat)
257 265
     {
258
-        if (!is_numeric($lat)) return false;
266
+        if (!is_numeric($lat)) {
267
+        	return false;
268
+        }
259 269
         
260
-        if ($lat>90 || $lat<-90) return false;
270
+        if ($lat>90 || $lat<-90) {
271
+        	return false;
272
+        }
261 273
         
262 274
         return true;
263 275
     }
264 276
     
265 277
     public static function validateLongitude($lng)
266 278
     {
267
-        if (!is_numeric($lng)) return false;
279
+        if (!is_numeric($lng)) {
280
+        	return false;
281
+        }
268 282
         
269
-        if ($lng>180 || $lng<-180) return false;
283
+        if ($lng>180 || $lng<-180) {
284
+        	return false;
285
+        }
270 286
         
271 287
         return true;
272 288
     }
@@ -298,8 +314,9 @@  discard block
 block discarded – undo
298 314
                     array_push($results['fail'],"$iRow --> Wrong cached_lat"); 
299 315
                     $iRow++;
300 316
                     continue;
317
+                } else {
318
+                	$cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]);
301 319
                 }
302
-                else $cached_lat = doubleval($rows[$ordersFieldsMapping['cached_lat']]);
303 320
                 
304 321
                 $cached_lng = 0.000;
305 322
                 
@@ -307,8 +324,9 @@  discard block
 block discarded – undo
307 324
                     array_push($results['fail'],"$iRow --> Wrong cached_lng"); 
308 325
                     $iRow++;
309 326
                     continue;
327
+                } else {
328
+                	$cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]);
310 329
                 }
311
-                else $cached_lng = doubleval($rows[$ordersFieldsMapping['cached_lng']]);
312 330
                 
313 331
                 if (isset($ordersFieldsMapping['curbside_lat'])) {
314 332
                     if (!$this->validateLatitude($rows[$ordersFieldsMapping['curbside_lat']])) {
@@ -328,10 +346,18 @@  discard block
 block discarded – undo
328 346
                 
329 347
                 $address = $rows[$ordersFieldsMapping['address_1']];
330 348
                 
331
-                if (isset($ordersFieldsMapping['order_city'])) $address.=', '.$rows[$ordersFieldsMapping['order_city']];
332
-                if (isset($ordersFieldsMapping['order_state_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_state_id']];
333
-                if (isset($ordersFieldsMapping['order_zip_code'])) $address.=', '.$rows[$ordersFieldsMapping['order_zip_code']];
334
-                if (isset($ordersFieldsMapping['order_country_id'])) $address.=', '.$rows[$ordersFieldsMapping['order_country_id']];
349
+                if (isset($ordersFieldsMapping['order_city'])) {
350
+                	$address.=', '.$rows[$ordersFieldsMapping['order_city']];
351
+                }
352
+                if (isset($ordersFieldsMapping['order_state_id'])) {
353
+                	$address.=', '.$rows[$ordersFieldsMapping['order_state_id']];
354
+                }
355
+                if (isset($ordersFieldsMapping['order_zip_code'])) {
356
+                	$address.=', '.$rows[$ordersFieldsMapping['order_zip_code']];
357
+                }
358
+                if (isset($ordersFieldsMapping['order_country_id'])) {
359
+                	$address.=', '.$rows[$ordersFieldsMapping['order_country_id']];
360
+                }
335 361
                 
336 362
                 echo "$iRow --> ".$ordersFieldsMapping['day_scheduled_for_YYMMDD'].", ".$rows[$ordersFieldsMapping['day_scheduled_for_YYMMDD']]."<br>";
337 363
                 
@@ -374,8 +400,7 @@  discard block
 block discarded – undo
374 400
                 $orderResults = $order->addOrder($orderParameters);
375 401
                 
376 402
                 array_push($results['success'],"The order with order_id = ".strval($orderResults["order_id"])." added successfuly.");
377
-            }
378
-            else {
403
+            } else {
379 404
                 array_push($results['fail'],"$iRow --> one of the parameters cached_lat, cached_lng, address_1 is not set"); 
380 405
             }
381 406
             
Please login to merge, or discard this patch.
src/Route4Me/Route.php 3 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -3,10 +3,8 @@
 block discarded – undo
3 3
 
4 4
 use Route4Me\Common;
5 5
 use Route4Me\Address;
6
-use Route4Me\Exception\BadParam;
7 6
 use Route4Me\RouteParameters;
8 7
 use Route4Me\Route4Me;
9
-use GuzzleHttp\Client;
10 8
 use Route4Me\Enum\Endpoint;
11 9
 
12 10
 class Route extends Common
Please login to merge, or discard this patch.
Indentation   +416 added lines, -416 removed lines patch added patch discarded remove patch
@@ -11,480 +11,480 @@
 block discarded – undo
11 11
 
12 12
 class Route extends Common
13 13
 {
14
-    public $route_id;
15
-    public $member_id;
16
-    public $route_destination_id;
17
-    public $optimization_problem_id;
18
-    public $vehicle_alias;
19
-    public $driver_alias;
20
-    public $trip_distance;
21
-    public $mpg;
22
-    public $gas_price;
23
-    public $route_duration_sec;
24
-    public $destination_count;
25
-    public $parameters;
26
-    public $addresses = array();
27
-    public $links = array();
28
-    public $directions = array();
29
-    public $path = array();
30
-    public $tracking_history = array();
31
-    public $recipient_email;
32
-    public $httpheaders;
33
-    public $is_unrouted;
34
-    public $time;
14
+	public $route_id;
15
+	public $member_id;
16
+	public $route_destination_id;
17
+	public $optimization_problem_id;
18
+	public $vehicle_alias;
19
+	public $driver_alias;
20
+	public $trip_distance;
21
+	public $mpg;
22
+	public $gas_price;
23
+	public $route_duration_sec;
24
+	public $destination_count;
25
+	public $parameters;
26
+	public $addresses = array();
27
+	public $links = array();
28
+	public $directions = array();
29
+	public $path = array();
30
+	public $tracking_history = array();
31
+	public $recipient_email;
32
+	public $httpheaders;
33
+	public $is_unrouted;
34
+	public $time;
35 35
     
36
-    public $dev_lat;
37
-    public $dev_lng;
36
+	public $dev_lat;
37
+	public $dev_lng;
38 38
     
39
-    public $user_route_rating;
40
-    public $member_email;
41
-    public $member_first_name;
42
-    public $member_last_name;
43
-    public $channel_name;
44
-    public $route_cost;
45
-    public $route_revenue;
46
-    public $net_revenue_per_distance_unit;
47
-    public $created_timestamp;
48
-    public $planned_total_route_duration;
49
-    public $actual_travel_distance;
50
-    public $actual_travel_time;
51
-    public $actual_footsteps;
52
-    public $working_time;
53
-    public $driving_time;
54
-    public $idling_time;
55
-    public $paying_miles;
56
-    public $geofence_polygon_type;
57
-    public $geofence_polygon_size;
58
-    public $notes;
59
-    public $member_config_storage;
39
+	public $user_route_rating;
40
+	public $member_email;
41
+	public $member_first_name;
42
+	public $member_last_name;
43
+	public $channel_name;
44
+	public $route_cost;
45
+	public $route_revenue;
46
+	public $net_revenue_per_distance_unit;
47
+	public $created_timestamp;
48
+	public $planned_total_route_duration;
49
+	public $actual_travel_distance;
50
+	public $actual_travel_time;
51
+	public $actual_footsteps;
52
+	public $working_time;
53
+	public $driving_time;
54
+	public $idling_time;
55
+	public $paying_miles;
56
+	public $geofence_polygon_type;
57
+	public $geofence_polygon_size;
58
+	public $notes;
59
+	public $member_config_storage;
60 60
 
61
-    public static function fromArray(array $params) 
62
-    {
63
-        $route = new Route();
64
-        $route->route_id                = Common::getValue($params, 'route_id');
65
-        $route->member_id               = Common::getValue($params, 'member_id');
66
-        $route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
67
-        $route->vehicle_alias           = Common::getValue($params, 'vehicle_alias');
68
-        $route->driver_alias            = Common::getValue($params, 'driver_alias');
69
-        $route->trip_distance           = Common::getValue($params, 'trip_distance');
70
-        $route->mpg                     = Common::getValue($params, 'mpg');
71
-        $route->gas_price               = Common::getValue($params, 'gas_price');
72
-        $route->route_duration_sec      = Common::getvalue($params, 'route_duration_sec');
73
-        $route->destination_count       = Common::getvalue($params, 'destination_count');
74
-        $route->is_unrouted             = Common::getvalue($params, 'is_unrouted');
61
+	public static function fromArray(array $params) 
62
+	{
63
+		$route = new Route();
64
+		$route->route_id                = Common::getValue($params, 'route_id');
65
+		$route->member_id               = Common::getValue($params, 'member_id');
66
+		$route->optimization_problem_id = Common::getValue($params, 'optimization_problem_id');
67
+		$route->vehicle_alias           = Common::getValue($params, 'vehicle_alias');
68
+		$route->driver_alias            = Common::getValue($params, 'driver_alias');
69
+		$route->trip_distance           = Common::getValue($params, 'trip_distance');
70
+		$route->mpg                     = Common::getValue($params, 'mpg');
71
+		$route->gas_price               = Common::getValue($params, 'gas_price');
72
+		$route->route_duration_sec      = Common::getvalue($params, 'route_duration_sec');
73
+		$route->destination_count       = Common::getvalue($params, 'destination_count');
74
+		$route->is_unrouted             = Common::getvalue($params, 'is_unrouted');
75 75
 
76
-        // Make RouteParameters
77
-        if (isset($params['parameters'])) {
78
-            $route->parameters = RouteParameters::fromArray($params['parameters']);
79
-        }
76
+		// Make RouteParameters
77
+		if (isset($params['parameters'])) {
78
+			$route->parameters = RouteParameters::fromArray($params['parameters']);
79
+		}
80 80
 
81
-        if (isset($params['addresses'])) {
82
-            $addresses = array();
83
-            foreach ($params['addresses'] as $address) {
84
-                $addresses[] = Address::fromArray($address);
85
-            }
81
+		if (isset($params['addresses'])) {
82
+			$addresses = array();
83
+			foreach ($params['addresses'] as $address) {
84
+				$addresses[] = Address::fromArray($address);
85
+			}
86 86
 
87
-            $route->addresses = $addresses;
88
-        }
87
+			$route->addresses = $addresses;
88
+		}
89 89
 
90
-        $route->links            = Common::getValue($params, 'links', array());
91
-        $route->directions       = Common::getValue($params, 'directions', array());
92
-        $route->path             = Common::getValue($params, 'path', array());
93
-        $route->tracking_history = Common::getValue($params, 'tracking_history', array());
90
+		$route->links            = Common::getValue($params, 'links', array());
91
+		$route->directions       = Common::getValue($params, 'directions', array());
92
+		$route->path             = Common::getValue($params, 'path', array());
93
+		$route->tracking_history = Common::getValue($params, 'tracking_history', array());
94 94
 
95
-        return $route;
96
-    }
95
+		return $route;
96
+	}
97 97
 
98
-    public static function getRoutes($routeId=null, $params=null)
99
-    {
100
-        $result = Route4Me::makeRequst(array(
101
-            'url'    => Endpoint::ROUTE_V4,
102
-            'method' => 'GET',
103
-            'query'  => array(
104
-                'api_key'                  => Route4Me::getApiKey(),
105
-                'route_id'                 => !is_null($routeId) ? implode(',', (array) $routeId) : null,
106
-                'route_path_output'        => isset($params['route_path_output']) ? $params['route_path_output'] : null,
107
-                'query'                    => isset($params['query']) ? $params['query'] : null,
108
-                'directions'               => isset($params['directions']) ? $params['directions'] : null,
109
-                'device_tracking_history'  => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null,
110
-                'limit'                    => isset($params['limit']) ? $params['limit'] : null,
111
-                'offset'                   => isset($params['offset']) ? $params['offset'] : null
112
-            )
113
-        ));
98
+	public static function getRoutes($routeId=null, $params=null)
99
+	{
100
+		$result = Route4Me::makeRequst(array(
101
+			'url'    => Endpoint::ROUTE_V4,
102
+			'method' => 'GET',
103
+			'query'  => array(
104
+				'api_key'                  => Route4Me::getApiKey(),
105
+				'route_id'                 => !is_null($routeId) ? implode(',', (array) $routeId) : null,
106
+				'route_path_output'        => isset($params['route_path_output']) ? $params['route_path_output'] : null,
107
+				'query'                    => isset($params['query']) ? $params['query'] : null,
108
+				'directions'               => isset($params['directions']) ? $params['directions'] : null,
109
+				'device_tracking_history'  => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null,
110
+				'limit'                    => isset($params['limit']) ? $params['limit'] : null,
111
+				'offset'                   => isset($params['offset']) ? $params['offset'] : null
112
+			)
113
+		));
114 114
         
115
-        if ($routeId) {
116
-            return Route::fromArray($result); die("");
117
-        } else {
118
-            $routes = array();
119
-            foreach($result as $route) {
120
-                $routes[] = Route::fromArray($route);
121
-            }
122
-            return $routes;
123
-        }
124
-    }
115
+		if ($routeId) {
116
+			return Route::fromArray($result); die("");
117
+		} else {
118
+			$routes = array();
119
+			foreach($result as $route) {
120
+				$routes[] = Route::fromArray($route);
121
+			}
122
+			return $routes;
123
+		}
124
+	}
125 125
 
126
-    public function getRoutePoints($routeId, $params)
127
-    {
128
-        $result = Route4Me::makeRequst(array(
129
-            'url'    => Endpoint::ROUTE_V4,
130
-            'method' => 'GET',
131
-            'query'  => array(
132
-                'api_key'           => Route4Me::getApiKey(),
133
-                'route_id'          => $routeId,
134
-                'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null,
135
-                'compress_path_points' => isset($params['compress_path_points']) ? $params['compress_path_points'] : null,
136
-                'directions'        => isset($params['directions']) ? $params['directions'] : null,
137
-            )
138
-        ));
126
+	public function getRoutePoints($routeId, $params)
127
+	{
128
+		$result = Route4Me::makeRequst(array(
129
+			'url'    => Endpoint::ROUTE_V4,
130
+			'method' => 'GET',
131
+			'query'  => array(
132
+				'api_key'           => Route4Me::getApiKey(),
133
+				'route_id'          => $routeId,
134
+				'route_path_output' => isset($params['route_path_output']) ? $params['route_path_output'] : null,
135
+				'compress_path_points' => isset($params['compress_path_points']) ? $params['compress_path_points'] : null,
136
+				'directions'        => isset($params['directions']) ? $params['directions'] : null,
137
+			)
138
+		));
139 139
 
140
-        return $result;
141
-    }
140
+		return $result;
141
+	}
142 142
 
143
-    public function duplicateRoute($route_id)
144
-    {
145
-        $result = Route4Me::makeRequst(array(
146
-            'url'    => Endpoint::ROUTE_DUPLICATE,
147
-            'method' => 'GET',
148
-            'query'  => array(
149
-                'api_key'  => Route4Me::getApiKey(),
150
-                'route_id' => $route_id,
151
-                'to'       => 'none',
152
-            )
153
-        ));
143
+	public function duplicateRoute($route_id)
144
+	{
145
+		$result = Route4Me::makeRequst(array(
146
+			'url'    => Endpoint::ROUTE_DUPLICATE,
147
+			'method' => 'GET',
148
+			'query'  => array(
149
+				'api_key'  => Route4Me::getApiKey(),
150
+				'route_id' => $route_id,
151
+				'to'       => 'none',
152
+			)
153
+		));
154 154
         
155
-        return $result;
156
-    }
155
+		return $result;
156
+	}
157 157
     
158
-    public function resequenceRoute($params)
159
-    {
160
-        $result = Route4Me::makeRequst(array(
161
-            'url'    => Endpoint::ROUTE_V4,
162
-            'method' => 'PUT',
163
-            'query'  => array(
164
-                'api_key'              => Route4Me::getApiKey(),
165
-                'route_id'             => isset($params['route_id']) ? $params['route_id'] : null,
166
-                'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
167
-            ),
168
-            'body'   => array(
169
-                'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
170
-            )
171
-        ));
158
+	public function resequenceRoute($params)
159
+	{
160
+		$result = Route4Me::makeRequst(array(
161
+			'url'    => Endpoint::ROUTE_V4,
162
+			'method' => 'PUT',
163
+			'query'  => array(
164
+				'api_key'              => Route4Me::getApiKey(),
165
+				'route_id'             => isset($params['route_id']) ? $params['route_id'] : null,
166
+				'route_destination_id' => isset($params['route_destination_id']) ? $params['route_destination_id'] : null,
167
+			),
168
+			'body'   => array(
169
+				'addresses' => isset($params['addresses']) ? $params['addresses'] : null,
170
+			)
171
+		));
172 172
         
173
-        return $result;
174
-    }
173
+		return $result;
174
+	}
175 175
     
176
-    public function resequenceAllAddresses($params)
177
-    {
178
-        $result = Route4Me::makeRequst(array(
179
-            'url'    => Endpoint::REOPTIMIZE_V3_2,
180
-            'method' => 'GET',
181
-            'query'  => array(
182
-                'api_key'              => Route4Me::getApiKey(),
183
-                'route_id'             => isset($params['route_id']) ? $params['route_id'] : null,
184
-                'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null,
185
-                'optimize'             => isset($params['optimize']) ? $params['optimize'] : null,
186
-            )
187
-        ));
176
+	public function resequenceAllAddresses($params)
177
+	{
178
+		$result = Route4Me::makeRequst(array(
179
+			'url'    => Endpoint::REOPTIMIZE_V3_2,
180
+			'method' => 'GET',
181
+			'query'  => array(
182
+				'api_key'              => Route4Me::getApiKey(),
183
+				'route_id'             => isset($params['route_id']) ? $params['route_id'] : null,
184
+				'disable_optimization' => isset($params['disable_optimization']) ? $params['disable_optimization'] : null,
185
+				'optimize'             => isset($params['optimize']) ? $params['optimize'] : null,
186
+			)
187
+		));
188 188
         
189
-        return $result;
190
-    }
189
+		return $result;
190
+	}
191 191
 
192
-    public function mergeRoutes($params)
193
-    {
194
-        $result = Route4Me::makeRequst(array(
195
-            'url'    => Endpoint::ROUTES_MERGE,
196
-            'method' => 'POST',
197
-            'query'  => array(
198
-                'api_key' => Route4Me::getApiKey(),
199
-              ),
200
-            'body'   => array(
201
-                'route_ids'     => isset($params['route_ids']) ? $params['route_ids'] : null,
202
-                'depot_address' => isset($params['depot_address']) ? $params['depot_address'] : null,
203
-                'remove_origin' => isset($params['remove_origin']) ? $params['remove_origin'] : null,
204
-                'depot_lat'     => isset($params['depot_lat']) ? $params['depot_lat'] : null,
205
-                'depot_lat'     => isset($params['depot_lat']) ? $params['depot_lat'] : null
206
-              ),
207
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
208
-        ));
192
+	public function mergeRoutes($params)
193
+	{
194
+		$result = Route4Me::makeRequst(array(
195
+			'url'    => Endpoint::ROUTES_MERGE,
196
+			'method' => 'POST',
197
+			'query'  => array(
198
+				'api_key' => Route4Me::getApiKey(),
199
+			  ),
200
+			'body'   => array(
201
+				'route_ids'     => isset($params['route_ids']) ? $params['route_ids'] : null,
202
+				'depot_address' => isset($params['depot_address']) ? $params['depot_address'] : null,
203
+				'remove_origin' => isset($params['remove_origin']) ? $params['remove_origin'] : null,
204
+				'depot_lat'     => isset($params['depot_lat']) ? $params['depot_lat'] : null,
205
+				'depot_lat'     => isset($params['depot_lat']) ? $params['depot_lat'] : null
206
+			  ),
207
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
208
+		));
209 209
         
210
-        return $result;
211
-    }
210
+		return $result;
211
+	}
212 212
     
213
-    public function shareRoute($params)
214
-    {
215
-        $result = Route4Me::makeRequst(array(
216
-            'url'    => Endpoint::ROUTE_SHARE,
217
-            'method' => 'POST',
218
-            'query'  => array(
219
-                'api_key'         => Route4Me::getApiKey(),
220
-                'route_id'        => isset($params['route_id']) ? $params['route_id'] : null,
221
-                'response_format' => isset($params['response_format']) ? $params['response_format'] : null,
222
-            ),
223
-            'body'  => array(
224
-                'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null,
225
-            ),
226
-            'HTTPHEADER'  => 'Content-Type: multipart/form-data'
227
-        ));
213
+	public function shareRoute($params)
214
+	{
215
+		$result = Route4Me::makeRequst(array(
216
+			'url'    => Endpoint::ROUTE_SHARE,
217
+			'method' => 'POST',
218
+			'query'  => array(
219
+				'api_key'         => Route4Me::getApiKey(),
220
+				'route_id'        => isset($params['route_id']) ? $params['route_id'] : null,
221
+				'response_format' => isset($params['response_format']) ? $params['response_format'] : null,
222
+			),
223
+			'body'  => array(
224
+				'recipient_email' => isset($params['recipient_email']) ? $params['recipient_email'] : null,
225
+			),
226
+			'HTTPHEADER'  => 'Content-Type: multipart/form-data'
227
+		));
228 228
         
229
-        return $result;
230
-    }
229
+		return $result;
230
+	}
231 231
     
232
-    // Returns random route_id from existing routes between $offset and $offset+$limit
233
-    public function getRandomRouteId($offset,$limit)
234
-    {
235
-        $query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
236
-        $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
232
+	// Returns random route_id from existing routes between $offset and $offset+$limit
233
+	public function getRandomRouteId($offset,$limit)
234
+	{
235
+		$query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
236
+		$query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
237 237
             
238
-        $json = Route4Me::makeRequst(array(
239
-            'url'    => Endpoint::ROUTE_V4,
240
-            'method' => 'GET',
241
-            'query'  => $query
242
-        ));
238
+		$json = Route4Me::makeRequst(array(
239
+			'url'    => Endpoint::ROUTE_V4,
240
+			'method' => 'GET',
241
+			'query'  => $query
242
+		));
243 243
         
244
-        if (sizeof($json)>0) {
245
-            $routes = array();
244
+		if (sizeof($json)>0) {
245
+			$routes = array();
246 246
             
247
-            foreach($json as $route) {
248
-                $routes[] = Route::fromArray($route);
249
-            }
247
+			foreach($json as $route) {
248
+				$routes[] = Route::fromArray($route);
249
+			}
250 250
             
251
-            $num=rand(0,sizeof($routes)-1);
252
-            $rRoute=(array)$routes[$num];
251
+			$num=rand(0,sizeof($routes)-1);
252
+			$rRoute=(array)$routes[$num];
253 253
             
254
-            if (is_array($rRoute)) {
255
-                return $rRoute["route_id"];
256
-            } else {
257
-                return null;
258
-            }
259
-        } else {
260
-            echo "<br> There are no routes in the account. Please, create the routes first. <br>";
261
-            return null;
262
-        }
263
-    }
254
+			if (is_array($rRoute)) {
255
+				return $rRoute["route_id"];
256
+			} else {
257
+				return null;
258
+			}
259
+		} else {
260
+			echo "<br> There are no routes in the account. Please, create the routes first. <br>";
261
+			return null;
262
+		}
263
+	}
264 264
 
265
-    public function update()
266
-    {
267
-        $route = Route4Me::makeRequst(array(
268
-            'url'    => Endpoint::ROUTE_V4,
269
-            'method' => 'PUT',
270
-            'query'  => array(
271
-                'route_id'  => isset($this->route_id) ? $this->route_id : null
272
-            ),
273
-            'body' => array (
274
-                'parameters' => $this->parameters,
275
-                ),
276
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
277
-        ));
265
+	public function update()
266
+	{
267
+		$route = Route4Me::makeRequst(array(
268
+			'url'    => Endpoint::ROUTE_V4,
269
+			'method' => 'PUT',
270
+			'query'  => array(
271
+				'route_id'  => isset($this->route_id) ? $this->route_id : null
272
+			),
273
+			'body' => array (
274
+				'parameters' => $this->parameters,
275
+				),
276
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
277
+		));
278 278
 
279
-        return Route::fromArray($route);
280
-    }
279
+		return Route::fromArray($route);
280
+	}
281 281
     
282
-    public function updateAddress($address=null)
283
-    {
284
-        $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) 
285
-            : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters));
282
+	public function updateAddress($address=null)
283
+	{
284
+		$body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) 
285
+			: (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters));
286 286
 
287
-        $result = Route4Me::makeRequst(array(
288
-            'url'    => Endpoint::ADDRESS_V4,
289
-            'method' => 'PUT',
290
-            'query'  => array(
291
-                'route_id'             => isset($this->route_id) ? $this->route_id : null,
292
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
293
-            ),
294
-            'body'        => $body,
295
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
296
-        ));
287
+		$result = Route4Me::makeRequst(array(
288
+			'url'    => Endpoint::ADDRESS_V4,
289
+			'method' => 'PUT',
290
+			'query'  => array(
291
+				'route_id'             => isset($this->route_id) ? $this->route_id : null,
292
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
293
+			),
294
+			'body'        => $body,
295
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
296
+		));
297 297
 
298
-        return $result;
299
-    }
298
+		return $result;
299
+	}
300 300
 
301
-    public function updateRouteAddress()
302
-    {
303
-        $result = Route4Me::makeRequst(array(
304
-            'url'    => Endpoint::ADDRESS_V4,
305
-            'method' => 'PUT',
306
-            'query'  => array(
307
-                'route_id'             => isset($this->route_id) ? $this->route_id : null,
308
-                'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
309
-            ),
310
-            'body'        => array(
311
-                "parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null,
312
-                "addresses"  => isset($this->addresses) ? $this->addresses : null
313
-            ),
314
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
315
-        ));
301
+	public function updateRouteAddress()
302
+	{
303
+		$result = Route4Me::makeRequst(array(
304
+			'url'    => Endpoint::ADDRESS_V4,
305
+			'method' => 'PUT',
306
+			'query'  => array(
307
+				'route_id'             => isset($this->route_id) ? $this->route_id : null,
308
+				'route_destination_id' => isset($this->route_destination_id) ? $this->route_destination_id : null,
309
+			),
310
+			'body'        => array(
311
+				"parameters" => isset($this->parameters) ? get_object_vars($this->parameters) : null,
312
+				"addresses"  => isset($this->addresses) ? $this->addresses : null
313
+			),
314
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
315
+		));
316 316
 
317
-        return $result;
318
-    }
317
+		return $result;
318
+	}
319 319
 
320
-    public function addAddresses($params)
321
-    {
322
-        $route = Route4Me::makeRequst(array(
323
-            'url'    => Endpoint::ROUTE_V4,
324
-            'method' => 'PUT',
325
-            'query'  => array(
326
-                'api_key'   => Route4Me::getApiKey(),
327
-                'route_id'  => isset($params['route_id']) ? $params['route_id'] : null
328
-            ),
329
-            'body'   => array(
330
-                'addresses' => isset($params['addresses']) ? $params['addresses'] : null
331
-            ),
332
-            'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
333
-        ));
320
+	public function addAddresses($params)
321
+	{
322
+		$route = Route4Me::makeRequst(array(
323
+			'url'    => Endpoint::ROUTE_V4,
324
+			'method' => 'PUT',
325
+			'query'  => array(
326
+				'api_key'   => Route4Me::getApiKey(),
327
+				'route_id'  => isset($params['route_id']) ? $params['route_id'] : null
328
+			),
329
+			'body'   => array(
330
+				'addresses' => isset($params['addresses']) ? $params['addresses'] : null
331
+			),
332
+			'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
333
+		));
334 334
 
335
-        return Route::fromArray($route);
336
-    }
335
+		return Route::fromArray($route);
336
+	}
337 337
     
338
-    public function insertAddressOptimalPosition(array $params)
339
-    {
340
-        $route = Route4Me::makeRequst(array(
341
-            'url'    => Endpoint::ROUTE_V4,
342
-            'method' => 'PUT',
343
-            'query'  => array(
344
-                'api_key'  => Route4Me::getApiKey(),
345
-                'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
346
-            ),
347
-            'body'   => array(
348
-                'addresses'        => isset($params['addresses']) ? $params['addresses'] : null,
349
-                'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null,
350
-            )
351
-        ));
338
+	public function insertAddressOptimalPosition(array $params)
339
+	{
340
+		$route = Route4Me::makeRequst(array(
341
+			'url'    => Endpoint::ROUTE_V4,
342
+			'method' => 'PUT',
343
+			'query'  => array(
344
+				'api_key'  => Route4Me::getApiKey(),
345
+				'route_id' => isset($params['route_id']) ? $params['route_id'] : null,
346
+			),
347
+			'body'   => array(
348
+				'addresses'        => isset($params['addresses']) ? $params['addresses'] : null,
349
+				'optimal_position' => isset($params['optimal_position']) ? $params['optimal_position'] : null,
350
+			)
351
+		));
352 352
 
353
-        return Route::fromArray($route);
354
-    }
353
+		return Route::fromArray($route);
354
+	}
355 355
     
356
-    public function addNoteFile($params)
357
-    {
358
-        $fname = isset($params['strFilename']) ? $params['strFilename'] : null;
359
-        $rpath = realpath($fname);
356
+	public function addNoteFile($params)
357
+	{
358
+		$fname = isset($params['strFilename']) ? $params['strFilename'] : null;
359
+		$rpath = realpath($fname);
360 360
         
361
-        $result= Route4Me::makeRequst(array(
362
-            'url'    => Endpoint::ROUTE_NOTES_ADD,
363
-            'method' => 'POST',
364
-            'query'  => array(
365
-                'api_key'     => Route4Me::getApiKey(),
366
-                'route_id'    => isset($params['route_id']) ? $params['route_id'] : null,
367
-                'address_id'  => isset($params['address_id']) ? $params['address_id'] : null,
368
-                'dev_lat'     => isset($params['dev_lat']) ? $params['dev_lat'] : null,
369
-                'dev_lng'     => isset($params['dev_lng']) ? $params['dev_lng'] : null,
370
-                'device_type' => isset($params['device_type']) ? $params['device_type'] : null,
371
-                'dev_lng'     => isset($params['dev_lng']) ? $params['dev_lng'] : null,
372
-            ),
373
-            'body'  => array(
374
-                'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
375
-                'strFilename'     => isset($params['strFilename']) ? $params['strFilename'] : null,
376
-                'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
377
-            ),
378
-            'FILE'  => $rpath,
361
+		$result= Route4Me::makeRequst(array(
362
+			'url'    => Endpoint::ROUTE_NOTES_ADD,
363
+			'method' => 'POST',
364
+			'query'  => array(
365
+				'api_key'     => Route4Me::getApiKey(),
366
+				'route_id'    => isset($params['route_id']) ? $params['route_id'] : null,
367
+				'address_id'  => isset($params['address_id']) ? $params['address_id'] : null,
368
+				'dev_lat'     => isset($params['dev_lat']) ? $params['dev_lat'] : null,
369
+				'dev_lng'     => isset($params['dev_lng']) ? $params['dev_lng'] : null,
370
+				'device_type' => isset($params['device_type']) ? $params['device_type'] : null,
371
+				'dev_lng'     => isset($params['dev_lng']) ? $params['dev_lng'] : null,
372
+			),
373
+			'body'  => array(
374
+				'strUpdateType'   => isset($params['strUpdateType']) ? $params['strUpdateType'] : null,
375
+				'strFilename'     => isset($params['strFilename']) ? $params['strFilename'] : null,
376
+				'strNoteContents' => isset($params['strNoteContents']) ? $params['strNoteContents'] : null,
377
+			),
378
+			'FILE'  => $rpath,
379 379
 
380
-            'HTTPHEADER' => array(
381
-                'Content-Type: application/x-www-form-urlencoded'
382
-            )
383
-        ));
380
+			'HTTPHEADER' => array(
381
+				'Content-Type: application/x-www-form-urlencoded'
382
+			)
383
+		));
384 384
 
385
-        return $result;
386
-    }
385
+		return $result;
386
+	}
387 387
 
388
-    public function delete($route_id)
389
-    {
390
-        $result = Route4Me::makeRequst(array(
391
-            'url'    => Endpoint::ROUTE_V4,
392
-            'method' => 'DELETE',
393
-            'query'  => array( 'route_id' => $route_id )
394
-        ));
388
+	public function delete($route_id)
389
+	{
390
+		$result = Route4Me::makeRequst(array(
391
+			'url'    => Endpoint::ROUTE_V4,
392
+			'method' => 'DELETE',
393
+			'query'  => array( 'route_id' => $route_id )
394
+		));
395 395
         
396
-         $result = Route4Me::makeRequst(array(
397
-            'url'    => Endpoint::ROUTES_DELETE,
398
-            'method' => 'DELETE',
399
-            'query'  => array(
400
-                'api_key' => Route4Me::getApiKey(),
401
-                'route_id' => $route_id,
402
-            )
403
-        ));
396
+		 $result = Route4Me::makeRequst(array(
397
+			'url'    => Endpoint::ROUTES_DELETE,
398
+			'method' => 'DELETE',
399
+			'query'  => array(
400
+				'api_key' => Route4Me::getApiKey(),
401
+				'route_id' => $route_id,
402
+			)
403
+		));
404 404
         
405
-        return $result;
406
-    }
405
+		return $result;
406
+	}
407 407
     
408
-    public function GetAddressesFromRoute($route_id)
409
-    {
410
-        $route1=Route::getRoutes($route_id,null);
411
-        if (isset($route1)) {
412
-            return $route1->addresses;
413
-        } else {
414
-            return null;
415
-        }
416
-    }
408
+	public function GetAddressesFromRoute($route_id)
409
+	{
410
+		$route1=Route::getRoutes($route_id,null);
411
+		if (isset($route1)) {
412
+			return $route1->addresses;
413
+		} else {
414
+			return null;
415
+		}
416
+	}
417 417
     
418
-    public function GetRandomAddressFromRoute($route_id)
419
-    {
420
-        $route1 = Route::getRoutes($route_id,null);
418
+	public function GetRandomAddressFromRoute($route_id)
419
+	{
420
+		$route1 = Route::getRoutes($route_id,null);
421 421
         
422
-        if (isset($route1)) {
423
-            $addresses = $route1->addresses;
422
+		if (isset($route1)) {
423
+			$addresses = $route1->addresses;
424 424
             
425
-            $rnd = rand(0,sizeof($addresses)-1);
425
+			$rnd = rand(0,sizeof($addresses)-1);
426 426
             
427
-            return $addresses[$rnd];
427
+			return $addresses[$rnd];
428 428
             
429
-        } else {
430
-            return null;
431
-        }
432
-    }
429
+		} else {
430
+			return null;
431
+		}
432
+	}
433 433
 
434
-    public function getRouteId()
435
-    {
436
-        return $this->route_id;
437
-    }
434
+	public function getRouteId()
435
+	{
436
+		return $this->route_id;
437
+	}
438 438
 
439
-    public function getOptimizationId()
440
-    {
441
-        return $this->optimization_problem_id;
442
-    }
439
+	public function getOptimizationId()
440
+	{
441
+		return $this->optimization_problem_id;
442
+	}
443 443
     
444
-    public function GetLastLocation(array $params)
445
-    {
446
-        $route = Route4Me::makeRequst(array(
447
-            'url'    => Endpoint::ROUTE_V4,
448
-            'method' => 'GET',
449
-            'query'  => array(
450
-                'api_key'                 => Route4Me::getApiKey(),
451
-                'route_id'                => isset($params['route_id']) ? $params['route_id'] : null,
452
-                'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null
453
-            )
454
-        ));
444
+	public function GetLastLocation(array $params)
445
+	{
446
+		$route = Route4Me::makeRequst(array(
447
+			'url'    => Endpoint::ROUTE_V4,
448
+			'method' => 'GET',
449
+			'query'  => array(
450
+				'api_key'                 => Route4Me::getApiKey(),
451
+				'route_id'                => isset($params['route_id']) ? $params['route_id'] : null,
452
+				'device_tracking_history' => isset($params['device_tracking_history']) ? $params['device_tracking_history'] : null
453
+			)
454
+		));
455 455
 
456
-        return Route::fromArray($route);
457
-    }
456
+		return Route::fromArray($route);
457
+	}
458 458
     
459
-    public function GetTrackingHistoryFromTimeRange(array $params)
460
-    {
461
-        $route = Route4Me::makeRequst(array(
462
-            'url'    => Endpoint::GET_DEVICE_LOCATION,
463
-            'method' => 'GET',
464
-            'query'  => array(
465
-                'api_key'     => Route4Me::getApiKey(),
466
-                'route_id'    => isset($params['route_id']) ? $params['route_id'] : null,
467
-                'format'      => isset($params['format']) ? $params['format'] : null,
468
-                'time_period' => isset($params['time_period']) ? $params['time_period'] : null,
469
-                'start_date'  => isset($params['start_date']) ? $params['start_date'] : null,
470
-                'end_date'    => isset($params['end_date']) ? $params['end_date'] : null
471
-                )
472
-        ));
459
+	public function GetTrackingHistoryFromTimeRange(array $params)
460
+	{
461
+		$route = Route4Me::makeRequst(array(
462
+			'url'    => Endpoint::GET_DEVICE_LOCATION,
463
+			'method' => 'GET',
464
+			'query'  => array(
465
+				'api_key'     => Route4Me::getApiKey(),
466
+				'route_id'    => isset($params['route_id']) ? $params['route_id'] : null,
467
+				'format'      => isset($params['format']) ? $params['format'] : null,
468
+				'time_period' => isset($params['time_period']) ? $params['time_period'] : null,
469
+				'start_date'  => isset($params['start_date']) ? $params['start_date'] : null,
470
+				'end_date'    => isset($params['end_date']) ? $params['end_date'] : null
471
+				)
472
+		));
473 473
 
474
-        return $route;
475
-    }
474
+		return $route;
475
+	}
476 476
     
477
-    public function GetAssetTracking(array $params)
478
-    {
479
-        $route = Route4Me::makeRequst(array(
480
-            'url'    => Endpoint::STATUS_V4,
481
-            'method' => 'GET',
482
-            'query'  => array(
483
-                'api_key'  => Route4Me::getApiKey(),
484
-                'tracking' => isset($params['tracking']) ? $params['tracking'] : null
485
-                )
486
-        ));
477
+	public function GetAssetTracking(array $params)
478
+	{
479
+		$route = Route4Me::makeRequst(array(
480
+			'url'    => Endpoint::STATUS_V4,
481
+			'method' => 'GET',
482
+			'query'  => array(
483
+				'api_key'  => Route4Me::getApiKey(),
484
+				'tracking' => isset($params['tracking']) ? $params['tracking'] : null
485
+				)
486
+		));
487 487
 
488
-        return $route;
489
-    }
488
+		return $route;
489
+	}
490 490
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
         return $route;
96 96
     }
97 97
 
98
-    public static function getRoutes($routeId=null, $params=null)
98
+    public static function getRoutes($routeId = null, $params = null)
99 99
     {
100 100
         $result = Route4Me::makeRequst(array(
101 101
             'url'    => Endpoint::ROUTE_V4,
102 102
             'method' => 'GET',
103 103
             'query'  => array(
104 104
                 'api_key'                  => Route4Me::getApiKey(),
105
-                'route_id'                 => !is_null($routeId) ? implode(',', (array) $routeId) : null,
105
+                'route_id'                 => !is_null($routeId) ? implode(',', (array)$routeId) : null,
106 106
                 'route_path_output'        => isset($params['route_path_output']) ? $params['route_path_output'] : null,
107 107
                 'query'                    => isset($params['query']) ? $params['query'] : null,
108 108
                 'directions'               => isset($params['directions']) ? $params['directions'] : null,
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
             return Route::fromArray($result); die("");
117 117
         } else {
118 118
             $routes = array();
119
-            foreach($result as $route) {
119
+            foreach ($result as $route) {
120 120
                 $routes[] = Route::fromArray($route);
121 121
             }
122 122
             return $routes;
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
     }
231 231
     
232 232
     // Returns random route_id from existing routes between $offset and $offset+$limit
233
-    public function getRandomRouteId($offset,$limit)
233
+    public function getRandomRouteId($offset, $limit)
234 234
     {
235 235
         $query['limit'] = isset($params['limit']) ? $params['limit'] : 30;
236 236
         $query['offset'] = isset($params['offset']) ? $params['offset'] : 0;
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
         if (sizeof($json)>0) {
245 245
             $routes = array();
246 246
             
247
-            foreach($json as $route) {
247
+            foreach ($json as $route) {
248 248
                 $routes[] = Route::fromArray($route);
249 249
             }
250 250
             
251
-            $num=rand(0,sizeof($routes)-1);
252
-            $rRoute=(array)$routes[$num];
251
+            $num = rand(0, sizeof($routes) - 1);
252
+            $rRoute = (array)$routes[$num];
253 253
             
254 254
             if (is_array($rRoute)) {
255 255
                 return $rRoute["route_id"];
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
             'query'  => array(
271 271
                 'route_id'  => isset($this->route_id) ? $this->route_id : null
272 272
             ),
273
-            'body' => array (
273
+            'body' => array(
274 274
                 'parameters' => $this->parameters,
275 275
                 ),
276 276
             'HTTPHEADER'  => isset($this->httpheaders) ? $this->httpheaders : null,
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         return Route::fromArray($route);
280 280
     }
281 281
     
282
-    public function updateAddress($address=null)
282
+    public function updateAddress($address = null)
283 283
     {
284 284
         $body = sizeof($this->addresses)<1 ? get_object_vars($this->parameters) 
285 285
             : (isset($this->addresses[0]) ? $this->addresses[0] : get_object_vars($this->parameters));
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         $fname = isset($params['strFilename']) ? $params['strFilename'] : null;
359 359
         $rpath = realpath($fname);
360 360
         
361
-        $result= Route4Me::makeRequst(array(
361
+        $result = Route4Me::makeRequst(array(
362 362
             'url'    => Endpoint::ROUTE_NOTES_ADD,
363 363
             'method' => 'POST',
364 364
             'query'  => array(
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
         $result = Route4Me::makeRequst(array(
391 391
             'url'    => Endpoint::ROUTE_V4,
392 392
             'method' => 'DELETE',
393
-            'query'  => array( 'route_id' => $route_id )
393
+            'query'  => array('route_id' => $route_id)
394 394
         ));
395 395
         
396 396
          $result = Route4Me::makeRequst(array(
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     
408 408
     public function GetAddressesFromRoute($route_id)
409 409
     {
410
-        $route1=Route::getRoutes($route_id,null);
410
+        $route1 = Route::getRoutes($route_id, null);
411 411
         if (isset($route1)) {
412 412
             return $route1->addresses;
413 413
         } else {
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
     
418 418
     public function GetRandomAddressFromRoute($route_id)
419 419
     {
420
-        $route1 = Route::getRoutes($route_id,null);
420
+        $route1 = Route::getRoutes($route_id, null);
421 421
         
422 422
         if (isset($route1)) {
423 423
             $addresses = $route1->addresses;
424 424
             
425
-            $rnd = rand(0,sizeof($addresses)-1);
425
+            $rnd = rand(0, sizeof($addresses) - 1);
426 426
             
427 427
             return $addresses[$rnd];
428 428
             
Please login to merge, or discard this patch.
src/Route4Me/Route4Me.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -200,6 +200,9 @@
 block discarded – undo
200 200
         }
201 201
     }
202 202
 
203
+    /**
204
+     * @param \SimpleXMLElement $object
205
+     */
203 206
     public static function object2array($object)
204 207
     {
205 208
         return @json_decode(@json_encode($object),1);
Please login to merge, or discard this patch.
Indentation   +282 added lines, -282 removed lines patch added patch discarded remove patch
@@ -7,341 +7,341 @@
 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']) ?
35
-            array_filter($options['query']) : array();
33
+	public static function fileUploadRequest($options) {
34
+		$query = isset($options['query']) ?
35
+			array_filter($options['query']) : array();
36 36
 
37
-        if (sizeof($query)==0) return null;
37
+		if (sizeof($query)==0) return null;
38 38
 
39
-        $body = isset($options['body']) ?
40
-            array_filter($options['body']) : null;
39
+		$body = isset($options['body']) ?
40
+			array_filter($options['body']) : null;
41 41
             
42
-        $fname = isset($body['strFilename']) ? $body['strFilename'] : '';
43
-        if ($fname=='') return null;
42
+		$fname = isset($body['strFilename']) ? $body['strFilename'] : '';
43
+		if ($fname=='') return null;
44 44
 
45
-        $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname);
45
+		$rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname);
46 46
         
47
-        $url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge(
48
-            array( 'api_key' => self::getApiKey()), $query)
49
-        );
47
+		$url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge(
48
+			array( 'api_key' => self::getApiKey()), $query)
49
+		);
50 50
         
51
-        $ch = curl_init($url);
51
+		$ch = curl_init($url);
52 52
         
53
-        $curlOpts = array(
54
-            CURLOPT_POST => true,
55
-            CURLOPT_RETURNTRANSFER => false,
56
-            CURLOPT_TIMEOUT        => 60,
57
-            CURLOPT_FOLLOWLOCATION => true,
58
-            CURLOPT_SSL_VERIFYHOST => FALSE,
59
-            CURLOPT_SSL_VERIFYPEER => FALSE
60
-        );
53
+		$curlOpts = array(
54
+			CURLOPT_POST => true,
55
+			CURLOPT_RETURNTRANSFER => false,
56
+			CURLOPT_TIMEOUT        => 60,
57
+			CURLOPT_FOLLOWLOCATION => true,
58
+			CURLOPT_SSL_VERIFYHOST => FALSE,
59
+			CURLOPT_SSL_VERIFYPEER => FALSE
60
+		);
61 61
         
62
-        curl_setopt_array($ch, $curlOpts);
62
+		curl_setopt_array($ch, $curlOpts);
63 63
         
64
-        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
64
+		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
65 65
         
66
-        curl_setopt($ch, CURLOPT_HTTPHEADER, array(
67
-            "Content-Type: multipart/form-data",
68
-            'Content-Disposition: form-data; name="strFilename"'
69
-        ));
70
-        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
71
-        curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); 
66
+		curl_setopt($ch, CURLOPT_HTTPHEADER, array(
67
+			"Content-Type: multipart/form-data",
68
+			'Content-Disposition: form-data; name="strFilename"'
69
+		));
70
+		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
71
+		curl_setopt($ch, CURLOPT_POSTFIELDS, array('strFilename' => $rpath)); 
72 72
         
73
-        $result = curl_exec($ch);
73
+		$result = curl_exec($ch);
74 74
 
75
-        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
76
-        curl_close($ch);
75
+		$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
76
+		curl_close($ch);
77 77
 
78
-        $json = json_decode($result, true);
78
+		$json = json_decode($result, true);
79 79
         
80
-        if (200 == $code) {
81
-            return $json;
82
-        } elseif (isset($json['errors'])) {
83
-            throw new ApiError(implode(', ', $json['errors']));
84
-        } else {
85
-            throw new ApiError('Something wrong');
86
-        }
87
-    }
80
+		if (200 == $code) {
81
+			return $json;
82
+		} elseif (isset($json['errors'])) {
83
+			throw new ApiError(implode(', ', $json['errors']));
84
+		} else {
85
+			throw new ApiError('Something wrong');
86
+		}
87
+	}
88 88
 
89
-    public static function makeRequst($options) {
90
-        $errorHandler = new myErrorHandler();
89
+	public static function makeRequst($options) {
90
+		$errorHandler = new myErrorHandler();
91 91
         
92
-        $old_error_handler = set_error_handler(array( $errorHandler, "proc_error"));
93
-        $method = isset($options['method']) ? $options['method'] : 'GET';
94
-        $query = isset($options['query']) ?
95
-            array_filter($options['query'], function($x) { return !is_null($x); } ) : array();
92
+		$old_error_handler = set_error_handler(array( $errorHandler, "proc_error"));
93
+		$method = isset($options['method']) ? $options['method'] : 'GET';
94
+		$query = isset($options['query']) ?
95
+			array_filter($options['query'], function($x) { return !is_null($x); } ) : array();
96 96
 
97
-        $body = isset($options['body']) ? $options['body'] : null;
98
-        $file = isset($options['FILE']) ? $options['FILE'] : null;
99
-        $headers = array(
100
-            "User-Agent: Route4Me php-sdk"
101
-        );
97
+		$body = isset($options['body']) ? $options['body'] : null;
98
+		$file = isset($options['FILE']) ? $options['FILE'] : null;
99
+		$headers = array(
100
+			"User-Agent: Route4Me php-sdk"
101
+		);
102 102
         
103
-        if (isset($options['HTTPHEADER'])) {
104
-            $headers[]=$options['HTTPHEADER'];
105
-        }
103
+		if (isset($options['HTTPHEADER'])) {
104
+			$headers[]=$options['HTTPHEADER'];
105
+		}
106 106
          
107
-        if (isset($options['HTTPHEADERS'])) {
108
-            foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header;
109
-        }
107
+		if (isset($options['HTTPHEADERS'])) {
108
+			foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header;
109
+		}
110 110
 
111
-        $ch = curl_init();
112
-        $url = $options['url'] . '?' . http_build_query(array_merge(
113
-            $query, array( 'api_key' => self::getApiKey())
114
-        ));
111
+		$ch = curl_init();
112
+		$url = $options['url'] . '?' . http_build_query(array_merge(
113
+			$query, array( 'api_key' => self::getApiKey())
114
+		));
115 115
 
116
-        $baseUrl=self::getBaseUrl();
116
+		$baseUrl=self::getBaseUrl();
117 117
 
118
-        $curlOpts = arraY(
119
-            CURLOPT_URL            => $baseUrl. $url,
120
-            CURLOPT_RETURNTRANSFER => true,
121
-            CURLOPT_TIMEOUT        => 80,
122
-            CURLOPT_FOLLOWLOCATION => true,
123
-            CURLOPT_SSL_VERIFYHOST => FALSE,
124
-            CURLOPT_SSL_VERIFYPEER => FALSE,
125
-            CURLOPT_HTTPHEADER     => $headers
126
-        );
118
+		$curlOpts = arraY(
119
+			CURLOPT_URL            => $baseUrl. $url,
120
+			CURLOPT_RETURNTRANSFER => true,
121
+			CURLOPT_TIMEOUT        => 80,
122
+			CURLOPT_FOLLOWLOCATION => true,
123
+			CURLOPT_SSL_VERIFYHOST => FALSE,
124
+			CURLOPT_SSL_VERIFYPEER => FALSE,
125
+			CURLOPT_HTTPHEADER     => $headers
126
+		);
127 127
         
128
-        curl_setopt_array($ch, $curlOpts);
128
+		curl_setopt_array($ch, $curlOpts);
129 129
         
130
-        if ($file !=null) {
131
-            curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
132
-            $fp=fopen($file,'r');
133
-            curl_setopt($ch, CURLOPT_INFILE , $fp);
134
-            curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
135
-        }
130
+		if ($file !=null) {
131
+			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
132
+			$fp=fopen($file,'r');
133
+			curl_setopt($ch, CURLOPT_INFILE , $fp);
134
+			curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
135
+		}
136 136
 
137
-        switch($method) {
138
-        case 'DELETE':
139
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
137
+		switch($method) {
138
+		case 'DELETE':
139
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
140 140
 
141
-            if (isset($body)) {
141
+			if (isset($body)) {
142 142
                 
143
-                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
144
-            }
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");
143
+				curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
144
+			}
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 152
 
153
-            if (isset($body)) {
154
-                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
155
-            }
156
-            break;
157
-        case 'POST':
158
-           if (isset($body)) {
159
-                $bodyData = json_encode($body);
160
-               if (isset($options['HTTPHEADER'])) {
161
-                  if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) $bodyData = $body;
162
-               }
153
+			if (isset($body)) {
154
+				curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
155
+			}
156
+			break;
157
+		case 'POST':
158
+		   if (isset($body)) {
159
+				$bodyData = json_encode($body);
160
+			   if (isset($options['HTTPHEADER'])) {
161
+				  if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) $bodyData = $body;
162
+			   }
163 163
                
164
-               curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); 
165
-            } 
166
-            break;
167
-        case 'ADD':
168
-            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
169
-        }
164
+			   curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); 
165
+			} 
166
+			break;
167
+		case 'ADD':
168
+			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
169
+		}
170 170
 
171
-        $result = curl_exec($ch);
171
+		$result = curl_exec($ch);
172 172
         
173
-        $isxml=FALSE;
174
-        $jxml="";
175
-        if (strpos($result, '<?xml')>-1)
176
-        {
177
-            $xml = simplexml_load_string($result);
178
-            //$jxml = json_encode($xml);
179
-            $jxml=self::object2array($xml);
180
-            $isxml = TRUE;
181
-        }
173
+		$isxml=FALSE;
174
+		$jxml="";
175
+		if (strpos($result, '<?xml')>-1)
176
+		{
177
+			$xml = simplexml_load_string($result);
178
+			//$jxml = json_encode($xml);
179
+			$jxml=self::object2array($xml);
180
+			$isxml = TRUE;
181
+		}
182 182
         
183
-        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
184
-        curl_close($ch);
183
+		$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
184
+		curl_close($ch);
185 185
         
186
-        if (200 == $code) {
187
-            if ($isxml) {
188
-                $json = $jxml;
189
-            } else $json = json_decode($result, true);
186
+		if (200 == $code) {
187
+			if ($isxml) {
188
+				$json = $jxml;
189
+			} else $json = json_decode($result, true);
190 190
             
191
-            if (isset($json['errors'])) {
192
-                throw new ApiError(implode(', ', $json['errors']));
193
-            } else {
194
-                return $json;
195
-            }
196
-        }  elseif (409 == $code) {
197
-            throw new ApiError('Wrong API key');
198
-        } else {
199
-            throw new ApiError('Something wrong');
200
-        }
201
-    }
191
+			if (isset($json['errors'])) {
192
+				throw new ApiError(implode(', ', $json['errors']));
193
+			} else {
194
+				return $json;
195
+			}
196
+		}  elseif (409 == $code) {
197
+			throw new ApiError('Wrong API key');
198
+		} else {
199
+			throw new ApiError('Something wrong');
200
+		}
201
+	}
202 202
 
203
-    public static function object2array($object)
204
-    {
205
-        return @json_decode(@json_encode($object),1);
206
-    }
203
+	public static function object2array($object)
204
+	{
205
+		return @json_decode(@json_encode($object),1);
206
+	}
207 207
 
208
-    public static function makeUrlRequst($url, $options) {
209
-        $method = isset($options['method']) ? $options['method'] : 'GET';
210
-        $query = isset($options['query']) ?
211
-            array_filter($options['query'], function($x) { return !is_null($x); } ) : array();
212
-        $body = isset($options['body']) ? $options['body'] : null;
213
-        $ch = curl_init();
208
+	public static function makeUrlRequst($url, $options) {
209
+		$method = isset($options['method']) ? $options['method'] : 'GET';
210
+		$query = isset($options['query']) ?
211
+			array_filter($options['query'], function($x) { return !is_null($x); } ) : array();
212
+		$body = isset($options['body']) ? $options['body'] : null;
213
+		$ch = curl_init();
214 214
         
215
-        $curlOpts = arraY(
216
-            CURLOPT_URL            => $url,
217
-            CURLOPT_RETURNTRANSFER => true,
218
-            CURLOPT_TIMEOUT        => 60,
219
-            CURLOPT_FOLLOWLOCATION => true,
220
-            CURLOPT_SSL_VERIFYHOST => FALSE,
221
-            CURLOPT_SSL_VERIFYPEER => FALSE,
222
-            CURLOPT_HTTPHEADER     => array(
223
-                'User-Agent' => 'Route4Me php-sdk'
224
-            )
225
-        );
215
+		$curlOpts = arraY(
216
+			CURLOPT_URL            => $url,
217
+			CURLOPT_RETURNTRANSFER => true,
218
+			CURLOPT_TIMEOUT        => 60,
219
+			CURLOPT_FOLLOWLOCATION => true,
220
+			CURLOPT_SSL_VERIFYHOST => FALSE,
221
+			CURLOPT_SSL_VERIFYPEER => FALSE,
222
+			CURLOPT_HTTPHEADER     => array(
223
+				'User-Agent' => 'Route4Me php-sdk'
224
+			)
225
+		);
226 226
         
227
-        curl_setopt_array($ch, $curlOpts);
227
+		curl_setopt_array($ch, $curlOpts);
228 228
         
229
-        switch($method) {
230
-        case 'DELETE':
231
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
229
+		switch($method) {
230
+		case 'DELETE':
231
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
232 232
 
233
-            if (isset($body)) {
234
-                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
235
-            }
236
-            break;
237
-        case 'DELETEARRAY':
238
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
239
-            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
240
-            break;
241
-        case 'PUT':
242
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
243
-            if (isset($query)) {
244
-                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
245
-            }
233
+			if (isset($body)) {
234
+				curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
235
+			}
236
+			break;
237
+		case 'DELETEARRAY':
238
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
239
+			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
240
+			break;
241
+		case 'PUT':
242
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
243
+			if (isset($query)) {
244
+				curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
245
+			}
246 246
 
247
-            if (isset($body)) {
248
-                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
249
-            }
250
-            break;
251
-        case 'POST':
252
-            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
253
-            if (isset($query)) {
254
-                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); 
255
-            }
247
+			if (isset($body)) {
248
+				curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
249
+			}
250
+			break;
251
+		case 'POST':
252
+			curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
253
+			if (isset($query)) {
254
+				curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); 
255
+			}
256 256
 
257
-            if (isset($body)) {
258
-                curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
259
-            } 
260
-            break;
261
-        case 'ADD':
262
-            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
263
-        }
257
+			if (isset($body)) {
258
+				curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body)); 
259
+			} 
260
+			break;
261
+		case 'ADD':
262
+			curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query)); break;
263
+		}
264 264
 
265
-        $result = curl_exec($ch);
265
+		$result = curl_exec($ch);
266 266
         
267
-        $isxml=FALSE;
268
-        $jxml="";
269
-        if (strpos($result, '<?xml')>-1)
270
-        {
271
-            $xml = simplexml_load_string($result);
272
-            $jxml = json_encode($xml);
273
-            $isxml = TRUE;
274
-        }
267
+		$isxml=FALSE;
268
+		$jxml="";
269
+		if (strpos($result, '<?xml')>-1)
270
+		{
271
+			$xml = simplexml_load_string($result);
272
+			$jxml = json_encode($xml);
273
+			$isxml = TRUE;
274
+		}
275 275
         
276
-        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
277
-        curl_close($ch);
276
+		$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
277
+		curl_close($ch);
278 278
         
279
-        if ($isxml) {
280
-            $json = $jxml;
281
-        } else $json = json_decode($result, true);
279
+		if ($isxml) {
280
+			$json = $jxml;
281
+		} else $json = json_decode($result, true);
282 282
         
283
-        if (200 == $code) {
284
-            return $json;
285
-        } elseif (isset($json['errors'])) {
286
-            throw new ApiError(implode(', ', $json['errors']));
287
-        } else {
288
-            throw new ApiError('Something wrong');
289
-        }
290
-    }
283
+		if (200 == $code) {
284
+			return $json;
285
+		} elseif (isset($json['errors'])) {
286
+			throw new ApiError(implode(', ', $json['errors']));
287
+		} else {
288
+			throw new ApiError('Something wrong');
289
+		}
290
+	}
291 291
     
292
-    /**
293
-     * Prints on the screen main keys and values of the array 
294
-     *
295
-     */
296
-    public static function simplePrint($results, $deepPrinting=null)
297
-    {
298
-        if (isset($results)) {
299
-            if (is_array($results)) {
300
-                foreach ($results as $key=>$result) {
301
-                    if (is_array($result)) {
302
-                        foreach ($result as $key1=>$result1) {
303
-                            if (is_array($result1)) {
304
-                                  if ($deepPrinting) {
305
-                                      echo "<br>$key1 ------><br>";
306
-                                      Route4Me::simplePrint($result1,true);
307
-                                      echo "------<br>";
308
-                                  } else {
309
-                                      echo $key1." --> "."Array() <br>";
310
-                                  } 
311
-                            } else {
312
-                                if (is_object($result1)) {
313
-                                    if ($deepPrinting) {
314
-                                        echo "<br>$key1 ------><br>";
315
-                                        $oarray=(array)$result1;
316
-                                        Route4Me::simplePrint($oarray,true);
317
-                                        echo "------<br>";
318
-                                    } else {
319
-                                        echo $key1." --> "."Object <br>";
320
-                                    } 
321
-                                } else {
322
-                                    if (!is_null($result1)) echo $key1." --> ".$result1."<br>";    
323
-                                }
324
-                            }
325
-                        }
326
-                    } else {
327
-                        if (is_object($result)) {
328
-                            if ($deepPrinting) {
329
-                                echo "<br>$key ------><br>";
330
-                                $oarray=(array)$result;
331
-                                Route4Me::simplePrint($oarray,true);
332
-                                echo "------<br>";
333
-                            } else {
334
-                                echo $key." --> "."Object <br>";
335
-                            } 
336
-                        } else {
337
-                            if (!is_null($result)) echo $key." --> ".$result."<br>";
338
-                        }
292
+	/**
293
+	 * Prints on the screen main keys and values of the array 
294
+	 *
295
+	 */
296
+	public static function simplePrint($results, $deepPrinting=null)
297
+	{
298
+		if (isset($results)) {
299
+			if (is_array($results)) {
300
+				foreach ($results as $key=>$result) {
301
+					if (is_array($result)) {
302
+						foreach ($result as $key1=>$result1) {
303
+							if (is_array($result1)) {
304
+								  if ($deepPrinting) {
305
+									  echo "<br>$key1 ------><br>";
306
+									  Route4Me::simplePrint($result1,true);
307
+									  echo "------<br>";
308
+								  } else {
309
+									  echo $key1." --> "."Array() <br>";
310
+								  } 
311
+							} else {
312
+								if (is_object($result1)) {
313
+									if ($deepPrinting) {
314
+										echo "<br>$key1 ------><br>";
315
+										$oarray=(array)$result1;
316
+										Route4Me::simplePrint($oarray,true);
317
+										echo "------<br>";
318
+									} else {
319
+										echo $key1." --> "."Object <br>";
320
+									} 
321
+								} else {
322
+									if (!is_null($result1)) echo $key1." --> ".$result1."<br>";    
323
+								}
324
+							}
325
+						}
326
+					} else {
327
+						if (is_object($result)) {
328
+							if ($deepPrinting) {
329
+								echo "<br>$key ------><br>";
330
+								$oarray=(array)$result;
331
+								Route4Me::simplePrint($oarray,true);
332
+								echo "------<br>";
333
+							} else {
334
+								echo $key." --> "."Object <br>";
335
+							} 
336
+						} else {
337
+							if (!is_null($result)) echo $key." --> ".$result."<br>";
338
+						}
339 339
                         
340
-                    }
341
-                    //echo "<br>";
342
-                }
343
-            } 
344
-        }
345
-    }
340
+					}
341
+					//echo "<br>";
342
+				}
343
+			} 
344
+		}
345
+	}
346 346
 
347 347
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 
45 45
         $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname);
46 46
         
47
-        $url = self::$baseUrl.$options['url'] . '?' . http_build_query(array_merge(
48
-            array( 'api_key' => self::getApiKey()), $query)
47
+        $url = self::$baseUrl.$options['url'].'?'.http_build_query(array_merge(
48
+            array('api_key' => self::getApiKey()), $query)
49 49
         );
50 50
         
51 51
         $ch = curl_init($url);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
         $json = json_decode($result, true);
79 79
         
80
-        if (200 == $code) {
80
+        if (200==$code) {
81 81
             return $json;
82 82
         } elseif (isset($json['errors'])) {
83 83
             throw new ApiError(implode(', ', $json['errors']));
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
     public static function makeRequst($options) {
90 90
         $errorHandler = new myErrorHandler();
91 91
         
92
-        $old_error_handler = set_error_handler(array( $errorHandler, "proc_error"));
92
+        $old_error_handler = set_error_handler(array($errorHandler, "proc_error"));
93 93
         $method = isset($options['method']) ? $options['method'] : 'GET';
94 94
         $query = isset($options['query']) ?
95 95
             array_filter($options['query'], function($x) { return !is_null($x); } ) : array();
@@ -101,22 +101,22 @@  discard block
 block discarded – undo
101 101
         );
102 102
         
103 103
         if (isset($options['HTTPHEADER'])) {
104
-            $headers[]=$options['HTTPHEADER'];
104
+            $headers[] = $options['HTTPHEADER'];
105 105
         }
106 106
          
107 107
         if (isset($options['HTTPHEADERS'])) {
108
-            foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header;
108
+            foreach ($options['HTTPHEADERS'] As $header) $headers[] = $header;
109 109
         }
110 110
 
111 111
         $ch = curl_init();
112
-        $url = $options['url'] . '?' . http_build_query(array_merge(
113
-            $query, array( 'api_key' => self::getApiKey())
112
+        $url = $options['url'].'?'.http_build_query(array_merge(
113
+            $query, array('api_key' => self::getApiKey())
114 114
         ));
115 115
 
116
-        $baseUrl=self::getBaseUrl();
116
+        $baseUrl = self::getBaseUrl();
117 117
 
118 118
         $curlOpts = arraY(
119
-            CURLOPT_URL            => $baseUrl. $url,
119
+            CURLOPT_URL            => $baseUrl.$url,
120 120
             CURLOPT_RETURNTRANSFER => true,
121 121
             CURLOPT_TIMEOUT        => 80,
122 122
             CURLOPT_FOLLOWLOCATION => true,
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
         
128 128
         curl_setopt_array($ch, $curlOpts);
129 129
         
130
-        if ($file !=null) {
130
+        if ($file!=null) {
131 131
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
132
-            $fp=fopen($file,'r');
133
-            curl_setopt($ch, CURLOPT_INFILE , $fp);
132
+            $fp = fopen($file, 'r');
133
+            curl_setopt($ch, CURLOPT_INFILE, $fp);
134 134
             curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file));
135 135
         }
136 136
 
137
-        switch($method) {
137
+        switch ($method) {
138 138
         case 'DELETE':
139 139
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
140 140
 
@@ -170,20 +170,20 @@  discard block
 block discarded – undo
170 170
 
171 171
         $result = curl_exec($ch);
172 172
         
173
-        $isxml=FALSE;
174
-        $jxml="";
173
+        $isxml = FALSE;
174
+        $jxml = "";
175 175
         if (strpos($result, '<?xml')>-1)
176 176
         {
177 177
             $xml = simplexml_load_string($result);
178 178
             //$jxml = json_encode($xml);
179
-            $jxml=self::object2array($xml);
179
+            $jxml = self::object2array($xml);
180 180
             $isxml = TRUE;
181 181
         }
182 182
         
183 183
         $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
184 184
         curl_close($ch);
185 185
         
186
-        if (200 == $code) {
186
+        if (200==$code) {
187 187
             if ($isxml) {
188 188
                 $json = $jxml;
189 189
             } else $json = json_decode($result, true);
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
             } else {
194 194
                 return $json;
195 195
             }
196
-        }  elseif (409 == $code) {
196
+        }  elseif (409==$code) {
197 197
             throw new ApiError('Wrong API key');
198 198
         } else {
199 199
             throw new ApiError('Something wrong');
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
     public static function object2array($object)
204 204
     {
205
-        return @json_decode(@json_encode($object),1);
205
+        return @json_decode(@json_encode($object), 1);
206 206
     }
207 207
 
208 208
     public static function makeUrlRequst($url, $options) {
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         
227 227
         curl_setopt_array($ch, $curlOpts);
228 228
         
229
-        switch($method) {
229
+        switch ($method) {
230 230
         case 'DELETE':
231 231
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE"); 
232 232
 
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 
265 265
         $result = curl_exec($ch);
266 266
         
267
-        $isxml=FALSE;
268
-        $jxml="";
267
+        $isxml = FALSE;
268
+        $jxml = "";
269 269
         if (strpos($result, '<?xml')>-1)
270 270
         {
271 271
             $xml = simplexml_load_string($result);
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
             $json = $jxml;
281 281
         } else $json = json_decode($result, true);
282 282
         
283
-        if (200 == $code) {
283
+        if (200==$code) {
284 284
             return $json;
285 285
         } elseif (isset($json['errors'])) {
286 286
             throw new ApiError(implode(', ', $json['errors']));
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
      * Prints on the screen main keys and values of the array 
294 294
      *
295 295
      */
296
-    public static function simplePrint($results, $deepPrinting=null)
296
+    public static function simplePrint($results, $deepPrinting = null)
297 297
     {
298 298
         if (isset($results)) {
299 299
             if (is_array($results)) {
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
                             if (is_array($result1)) {
304 304
                                   if ($deepPrinting) {
305 305
                                       echo "<br>$key1 ------><br>";
306
-                                      Route4Me::simplePrint($result1,true);
306
+                                      Route4Me::simplePrint($result1, true);
307 307
                                       echo "------<br>";
308 308
                                   } else {
309 309
                                       echo $key1." --> "."Array() <br>";
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
                                 if (is_object($result1)) {
313 313
                                     if ($deepPrinting) {
314 314
                                         echo "<br>$key1 ------><br>";
315
-                                        $oarray=(array)$result1;
316
-                                        Route4Me::simplePrint($oarray,true);
315
+                                        $oarray = (array)$result1;
316
+                                        Route4Me::simplePrint($oarray, true);
317 317
                                         echo "------<br>";
318 318
                                     } else {
319 319
                                         echo $key1." --> "."Object <br>";
@@ -327,8 +327,8 @@  discard block
 block discarded – undo
327 327
                         if (is_object($result)) {
328 328
                             if ($deepPrinting) {
329 329
                                 echo "<br>$key ------><br>";
330
-                                $oarray=(array)$result;
331
-                                Route4Me::simplePrint($oarray,true);
330
+                                $oarray = (array)$result;
331
+                                Route4Me::simplePrint($oarray, true);
332 332
                                 echo "------<br>";
333 333
                             } else {
334 334
                                 echo $key." --> "."Object <br>";
Please login to merge, or discard this patch.
Braces   +25 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,13 +34,17 @@  discard block
 block discarded – undo
34 34
         $query = isset($options['query']) ?
35 35
             array_filter($options['query']) : array();
36 36
 
37
-        if (sizeof($query)==0) return null;
37
+        if (sizeof($query)==0) {
38
+        	return null;
39
+        }
38 40
 
39 41
         $body = isset($options['body']) ?
40 42
             array_filter($options['body']) : null;
41 43
             
42 44
         $fname = isset($body['strFilename']) ? $body['strFilename'] : '';
43
-        if ($fname=='') return null;
45
+        if ($fname=='') {
46
+        	return null;
47
+        }
44 48
 
45 49
         $rpath = function_exists('curl_file_create') ? curl_file_create(realpath($fname)) : '@'.realpath($fname);
46 50
         
@@ -105,7 +109,9 @@  discard block
 block discarded – undo
105 109
         }
106 110
          
107 111
         if (isset($options['HTTPHEADERS'])) {
108
-            foreach ($options['HTTPHEADERS'] As $header) $headers[]=$header;
112
+            foreach ($options['HTTPHEADERS'] As $header) {
113
+            	$headers[]=$header;
114
+            }
109 115
         }
110 116
 
111 117
         $ch = curl_init();
@@ -158,7 +164,9 @@  discard block
 block discarded – undo
158 164
            if (isset($body)) {
159 165
                 $bodyData = json_encode($body);
160 166
                if (isset($options['HTTPHEADER'])) {
161
-                  if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) $bodyData = $body;
167
+                  if (strpos($options['HTTPHEADER'], "multipart/form-data")>0) {
168
+                  	$bodyData = $body;
169
+                  }
162 170
                }
163 171
                
164 172
                curl_setopt($ch, CURLOPT_POSTFIELDS, $bodyData); 
@@ -186,14 +194,16 @@  discard block
 block discarded – undo
186 194
         if (200 == $code) {
187 195
             if ($isxml) {
188 196
                 $json = $jxml;
189
-            } else $json = json_decode($result, true);
197
+            } else {
198
+            	$json = json_decode($result, true);
199
+            }
190 200
             
191 201
             if (isset($json['errors'])) {
192 202
                 throw new ApiError(implode(', ', $json['errors']));
193 203
             } else {
194 204
                 return $json;
195 205
             }
196
-        }  elseif (409 == $code) {
206
+        } elseif (409 == $code) {
197 207
             throw new ApiError('Wrong API key');
198 208
         } else {
199 209
             throw new ApiError('Something wrong');
@@ -278,7 +288,9 @@  discard block
 block discarded – undo
278 288
         
279 289
         if ($isxml) {
280 290
             $json = $jxml;
281
-        } else $json = json_decode($result, true);
291
+        } else {
292
+        	$json = json_decode($result, true);
293
+        }
282 294
         
283 295
         if (200 == $code) {
284 296
             return $json;
@@ -319,7 +331,9 @@  discard block
 block discarded – undo
319 331
                                         echo $key1." --> "."Object <br>";
320 332
                                     } 
321 333
                                 } else {
322
-                                    if (!is_null($result1)) echo $key1." --> ".$result1."<br>";    
334
+                                    if (!is_null($result1)) {
335
+                                    	echo $key1." --> ".$result1."<br>";
336
+                                    }
323 337
                                 }
324 338
                             }
325 339
                         }
@@ -334,7 +348,9 @@  discard block
 block discarded – undo
334 348
                                 echo $key." --> "."Object <br>";
335 349
                             } 
336 350
                         } else {
337
-                            if (!is_null($result)) echo $key." --> ".$result."<br>";
351
+                            if (!is_null($result)) {
352
+                            	echo $key." --> ".$result."<br>";
353
+                            }
338 354
                         }
339 355
                         
340 356
                     }
Please login to merge, or discard this patch.
examples/Activities/SearchActivities.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@
 block discarded – undo
17 17
 
18 18
 // Itereate through all the existing activity types
19 19
 foreach ($activityTypes->getConstants() as $prop => $value) {
20
-    $activityParameters = ActivityParameters::fromArray(array(
21
-        "activity_type" => $value,
22
-        "limit"         => 2,
23
-        "offset"        => 0
24
-    ));
20
+	$activityParameters = ActivityParameters::fromArray(array(
21
+		"activity_type" => $value,
22
+		"limit"         => 2,
23
+		"offset"        => 0
24
+	));
25 25
     
26
-    $activities = new ActivityParameters();
27
-    $results = $activities->searcActivities($activityParameters);
26
+	$activities = new ActivityParameters();
27
+	$results = $activities->searcActivities($activityParameters);
28 28
     
29
-    foreach ($results as $key => $activity) {
30
-        Route4Me::simplePrint($activity);
31
-        echo "<br>";
32
-    }
29
+	foreach ($results as $key => $activity) {
30
+		Route4Me::simplePrint($activity);
31
+		echo "<br>";
32
+	}
33 33
     
34
-    echo "------------------- <br><br>";
34
+	echo "------------------- <br><br>";
35 35
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
examples/Activities/GetActivities.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
 Route4Me::setApiKey('11111111111111111111111111111111');
15 15
 
16 16
 $activityParameters = ActivityParameters::fromArray(array(
17
-    "limit" => 10,
18
-    "offset" => 0
17
+	"limit" => 10,
18
+	"offset" => 0
19 19
 ));
20 20
 
21 21
 $activities = new ActivityParameters();
@@ -23,6 +23,6 @@  discard block
 block discarded – undo
23 23
 $results = $activities->getValue($actresults, "results");
24 24
 
25 25
 foreach ($results as $result) {
26
-    Route4Me::simplePrint($result);
27
-    echo "<br>";
26
+	Route4Me::simplePrint($result);
27
+	echo "<br>";
28 28
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@
 block discarded – undo
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\Route;
Please login to merge, or discard this patch.