@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | { |
9 | 9 | static public $apiUrl = '/api.v4/territory.php'; |
10 | 10 | |
11 | - public $territory_id; // Territory id |
|
11 | + public $territory_id; // Territory id |
|
12 | 12 | public $territory_name; |
13 | 13 | public $territory_color; |
14 | 14 | public $addresses; |
15 | 15 | public $member_id; |
16 | 16 | public $territory; // Territory parameters |
17 | 17 | |
18 | - public function __construct () { |
|
18 | + public function __construct() { |
|
19 | 19 | |
20 | 20 | } |
21 | 21 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | $territoryparameters = new Territory(); |
36 | - foreach($params as $key => $value) { |
|
36 | + foreach ($params as $key => $value) { |
|
37 | 37 | if (property_exists($territoryparameters, $key)) { |
38 | 38 | $territoryparameters->{$key} = $value; |
39 | 39 | } |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | 'url' => self::$apiUrl, |
49 | 49 | 'method' => 'GET', |
50 | 50 | 'query' => array( |
51 | - 'territory_id' => isset($params['territory_id']) ? $params['territory_id']: null, |
|
52 | - 'addresses' => isset($params['addresses']) ? $params['addresses']: null, |
|
51 | + 'territory_id' => isset($params['territory_id']) ? $params['territory_id'] : null, |
|
52 | + 'addresses' => isset($params['addresses']) ? $params['addresses'] : null, |
|
53 | 53 | ) |
54 | 54 | )); |
55 | 55 | |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | 'url' => self::$apiUrl, |
63 | 63 | 'method' => 'GET', |
64 | 64 | 'query' => array( |
65 | - 'offset' => isset($params->offset) ? $params->offset: null, |
|
66 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
65 | + 'offset' => isset($params->offset) ? $params->offset : null, |
|
66 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
67 | 67 | ) |
68 | 68 | )); |
69 | 69 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | 'url' => self::$apiUrl, |
77 | 77 | 'method' => 'ADD', |
78 | 78 | 'query' => array( |
79 | - 'territory_name' => isset($params->territory_name) ? $params->territory_name: null, |
|
79 | + 'territory_name' => isset($params->territory_name) ? $params->territory_name : null, |
|
80 | 80 | 'territory_color' => isset($params->territory_color) ? $params->territory_color : null, |
81 | 81 | 'territory' => isset($params->territory) ? $params->territory : null, |
82 | 82 | ) |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | public $activity_type; |
20 | 20 | public $activity_message; |
21 | 21 | |
22 | - public function __construct () { |
|
22 | + public function __construct() { |
|
23 | 23 | |
24 | 24 | } |
25 | 25 | |
26 | 26 | public static function fromArray(array $params) { |
27 | 27 | $activityparameters = new ActivityParameters(); |
28 | - foreach($params as $key => $value) { |
|
28 | + foreach ($params as $key => $value) { |
|
29 | 29 | if (property_exists($activityparameters, $key)) { |
30 | 30 | $activityparameters->{$key} = $value; |
31 | 31 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | 'method' => 'GET', |
42 | 42 | 'query' => array( |
43 | 43 | 'route_id' => isset($params->route_id) ? $params->route_id : null, |
44 | - 'team' => isset($params->team) ? $params->team: null, |
|
45 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
44 | + 'team' => isset($params->team) ? $params->team : null, |
|
45 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
46 | 46 | 'offset' => isset($params->offset) ? $params->offset : null, |
47 | 47 | ) |
48 | 48 | )); |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | 'method' => 'GET', |
58 | 58 | 'query' => array( |
59 | 59 | 'route_id' => isset($params->route_id) ? $params->route_id : null, |
60 | - 'limit' => isset($params->limit) ? $params->limit: null, |
|
60 | + 'limit' => isset($params->limit) ? $params->limit : null, |
|
61 | 61 | 'offset' => isset($params->offset) ? $params->offset : null, |
62 | 62 | 'activity_type' => isset($params->activity_type) ? $params->activity_type : null, |
63 | 63 | ) |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | 'method' => 'POST', |
74 | 74 | 'body' => array( |
75 | 75 | 'activity_type' => isset($postParameters->activity_type) ? $postParameters->activity_type : null, |
76 | - 'activity_message' => isset($postParameters->activity_message) ? $postParameters->activity_message: null, |
|
76 | + 'activity_message' => isset($postParameters->activity_message) ? $postParameters->activity_message : null, |
|
77 | 77 | 'route_id' => isset($postParameters->route_id) ? $postParameters->route_id : null, |
78 | 78 | ) |
79 | 79 | )); |
@@ -48,7 +48,7 @@ |
||
48 | 48 | public static function fromArray(array $params) |
49 | 49 | { |
50 | 50 | $routeParams = new RouteParameters(); |
51 | - foreach($params as $key => $value) { |
|
51 | + foreach ($params as $key => $value) { |
|
52 | 52 | if (property_exists($routeParams, $key)) { |
53 | 53 | $routeParams->{$key} = $value; |
54 | 54 | } |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return MyQ |
45 | 45 | */ |
46 | - public function __construct ($params = array()) { |
|
46 | + public function __construct($params = array()) { |
|
47 | 47 | // Overwrite class variables |
48 | 48 | foreach ($params as $k => $v) { |
49 | 49 | $this->$k = $v; |
50 | 50 | } |
51 | 51 | // Initialize cURL request headers |
52 | - if (sizeof($this->_headers) == 0) { |
|
53 | - $this->_headers = array ( |
|
52 | + if (sizeof($this->_headers)==0) { |
|
53 | + $this->_headers = array( |
|
54 | 54 | 'MyQApplicationId' => $this->appId, |
55 | 55 | 'Culture' => $this->culture, |
56 | 56 | 'Content-Type' => $this->contentType, |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return MyQ |
71 | 71 | */ |
72 | - public function login ($username = null, $password = null) { |
|
72 | + public function login($username = null, $password = null) { |
|
73 | 73 | // Set username/password if not null |
74 | 74 | if (!is_null($username)) { |
75 | 75 | $this->username = $username; |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | if (is_null($this->password)) { |
86 | 86 | $error[] = 'password'; |
87 | 87 | } |
88 | - if (sizeof($error) > 0) { |
|
89 | - throw new MyQException('Missing required auth credential: ' . implode(',', $error)); |
|
88 | + if (sizeof($error)>0) { |
|
89 | + throw new MyQException('Missing required auth credential: '.implode(',', $error)); |
|
90 | 90 | } |
91 | 91 | $this->_login(); |
92 | 92 | } |
93 | - public function getState () { |
|
93 | + public function getState() { |
|
94 | 94 | $this->_getDetails(); |
95 | 95 | $timeInState = time() - $this->_doorStateTime; |
96 | - echo implode(',', array ( |
|
96 | + echo implode(',', array( |
|
97 | 97 | $this->_locationName, |
98 | 98 | $this->_doorName, |
99 | 99 | $this->_doorState, |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | return $this->_getDetails(); |
106 | 106 | } |
107 | 107 | |
108 | - private function _init () { |
|
108 | + private function _init() { |
|
109 | 109 | if (!isset($this->_conn)) { |
110 | 110 | $this->_conn = curl_init(); |
111 | - curl_setopt_array($this->_conn, array ( |
|
111 | + curl_setopt_array($this->_conn, array( |
|
112 | 112 | CURLOPT_RETURNTRANSFER => true, |
113 | 113 | CURLOPT_ENCODING => "", |
114 | 114 | CURLOPT_MAXREDIRS => 10, |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | } |
124 | 124 | $this->_setHeaders(); |
125 | 125 | } |
126 | - private function _setHeaders () { |
|
126 | + private function _setHeaders() { |
|
127 | 127 | $headers = array(); |
128 | 128 | foreach ($this->_headers as $k => $v) { |
129 | 129 | $headers[] = "$k: $v"; |
130 | 130 | } |
131 | 131 | curl_setopt($this->_conn, CURLOPT_HTTPHEADER, $headers); |
132 | 132 | } |
133 | - private function _login () { |
|
133 | + private function _login() { |
|
134 | 134 | $this->_init(); |
135 | 135 | curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'POST'); |
136 | 136 | curl_setopt($this->_conn, CURLOPT_URL, $this->_loginUrl); |
@@ -138,27 +138,27 @@ discard block |
||
138 | 138 | curl_setopt($this->_conn, CURLOPT_POSTFIELDS, $post); |
139 | 139 | $output = curl_exec($this->_conn); |
140 | 140 | $data = json_decode($output); |
141 | - if ($data == false || !isset($data->SecurityToken)) { |
|
141 | + if ($data==false || !isset($data->SecurityToken)) { |
|
142 | 142 | throw new MyQException("Error processing login request: $output"); |
143 | 143 | } |
144 | 144 | $this->_headers['SecurityToken'] = $data->SecurityToken; |
145 | 145 | return $this; |
146 | 146 | } |
147 | - private function _getDetails () { |
|
147 | + private function _getDetails() { |
|
148 | 148 | $this->_init(); |
149 | 149 | curl_setopt($this->_conn, CURLOPT_CUSTOMREQUEST, 'GET'); |
150 | 150 | curl_setopt($this->_conn, CURLOPT_URL, $this->_getDeviceDetailUrl); |
151 | 151 | $output = curl_exec($this->_conn); |
152 | 152 | $data = json_decode($output); |
153 | - if ($data == false || !isset($data->Devices)) { |
|
153 | + if ($data==false || !isset($data->Devices)) { |
|
154 | 154 | throw new MyQException("Error fetching device details: $output"); |
155 | 155 | } |
156 | 156 | // Find our door device ID |
157 | 157 | foreach ($data->Devices as $device) { |
158 | - if (stripos($device->MyQDeviceTypeName, "Gateway") !== false) { |
|
158 | + if (stripos($device->MyQDeviceTypeName, "Gateway")!==false) { |
|
159 | 159 | // Find location name |
160 | 160 | foreach ($device->Attributes as $attr) { |
161 | - if ($attr->AttributeDisplayName == 'desc') { |
|
161 | + if ($attr->AttributeDisplayName=='desc') { |
|
162 | 162 | $this->_locationName = $attr->Value; |
163 | 163 | } |
164 | 164 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 | //require __DIR__.'/../vendor/autoload.php';; |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Route4Me; |
3 | 3 | |
4 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
4 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
5 | 5 | |
6 | 6 | require $vdir.'/../vendor/autoload.php'; |
7 | 7 | |
@@ -13,23 +13,23 @@ discard block |
||
13 | 13 | // Add Avoidance Zone and get territory_id |
14 | 14 | //--------------------------------------------------------- |
15 | 15 | $territory = new Territory(); |
16 | - $territory->type = TerritoryTypes::CIRCLE; |
|
17 | - $territory->data = array ( |
|
16 | + $territory->type = TerritoryTypes::CIRCLE; |
|
17 | + $territory->data = array( |
|
18 | 18 | "37.569752822786455,-77.47833251953125", |
19 | 19 | "5000" |
20 | 20 | ); |
21 | 21 | |
22 | - $AvoisanceZoneParameters=AvoidanceZone::fromArray(array( |
|
23 | - "territory_name" => "Test Territory ".strval(rand(10000,99999)), |
|
22 | + $AvoisanceZoneParameters = AvoidanceZone::fromArray(array( |
|
23 | + "territory_name" => "Test Territory ".strval(rand(10000, 99999)), |
|
24 | 24 | "territory_color" => "ff7700", |
25 | 25 | "territory" => $territory |
26 | 26 | )); |
27 | 27 | |
28 | - $avoidancezone=new AvoidanceZone(); |
|
28 | + $avoidancezone = new AvoidanceZone(); |
|
29 | 29 | |
30 | 30 | $result = (array)$avoidancezone->addAvoidanceZone($AvoisanceZoneParameters); |
31 | 31 | |
32 | - $territory_id=""; |
|
32 | + $territory_id = ""; |
|
33 | 33 | if (isset($result)) { |
34 | 34 | $territory_id = $result["territory_id"]; |
35 | 35 | } else { |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | - $vdir=$_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
2 | + $vdir = $_SERVER['DOCUMENT_ROOT'].'/route4me/examples/'; |
|
3 | 3 | require $vdir.'/../vendor/autoload.php'; |
4 | 4 | |
5 | 5 | use Route4Me\MyQ; |