@@ -1,21 +1,21 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
3 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
4 | 4 | |
5 | 5 | $record_id = '436dcb0b-14a9-c0d4-3046-5706b186b9b8'; |
6 | 6 | |
7 | 7 | try{ |
8 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/',array('username' => 'admin','password'=>'asdf')); |
|
8 | + $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/', array('username' => 'admin', 'password'=>'asdf')); |
|
9 | 9 | $SugarAPI->login(); |
10 | - $EP = $SugarAPI->updateRecord('Accounts',$record_id); |
|
10 | + $EP = $SugarAPI->updateRecord('Accounts', $record_id); |
|
11 | 11 | $EP->getRequest()->setOption(); |
12 | - $record = $SugarAPI->updateRecord('Accounts',$record_id)->data(array( |
|
12 | + $record = $SugarAPI->updateRecord('Accounts', $record_id)->data(array( |
|
13 | 13 | 'name' => 'Test Record 5', |
14 | 14 | 'email1' => '[email protected]' |
15 | 15 | ))->execute()->getResponse()->getBody(); |
16 | 16 | echo "Updated Record: ".$record->id; |
17 | 17 | |
18 | -}catch(\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
18 | +}catch (\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
19 | 19 | print $ex->getMessage(); |
20 | 20 | } |
21 | 21 |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
3 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
4 | 4 | |
5 | 5 | $recordID = 'ac096703-67fd-8dd2-980a-57097932f07a'; |
6 | 6 | |
7 | 7 | try{ |
8 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/',array('username' => 'admin','password'=>'asdf')); |
|
8 | + $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/', array('username' => 'admin', 'password'=>'asdf')); |
|
9 | 9 | $SugarAPI->login(); |
10 | - $EP = $SugarAPI->getAttachment('Notes',$recordID,'filename')->downloadTo(__DIR__)->execute(); |
|
10 | + $EP = $SugarAPI->getAttachment('Notes', $recordID, 'filename')->downloadTo(__DIR__)->execute(); |
|
11 | 11 | $response = $EP->getResponse(); |
12 | 12 | if ($response->getStatus()=='200'){ |
13 | 13 | if (file_exists($response->file())){ |
@@ -20,6 +20,6 @@ discard block |
||
20 | 20 | print_r($response->getBody()); |
21 | 21 | } |
22 | 22 | |
23 | -}catch(\SugarAPI\SDK\Exception\SDKException $ex){ |
|
23 | +}catch (\SugarAPI\SDK\Exception\SDKException $ex){ |
|
24 | 24 | print $ex->getMessage(); |
25 | 25 | } |
26 | 26 | \ No newline at end of file |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
3 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
4 | 4 | |
5 | 5 | try{ |
6 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/',array('username' => 'admin','password'=>'asdf')); |
|
6 | + $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/', array('username' => 'admin', 'password'=>'asdf')); |
|
7 | 7 | $SugarAPI->login(); |
8 | 8 | $EP = $SugarAPI->createRecord('Accounts'); |
9 | 9 | $EP->data(array( |
@@ -13,12 +13,12 @@ discard block |
||
13 | 13 | $response = $EP->execute()->getResponse(); |
14 | 14 | if ($response->getStatus()=='200'){ |
15 | 15 | $record = $response->getBody(); |
16 | - $EP2 = $SugarAPI->getRecord('Accounts',$record->id)->data(array('fields' => 'name,email1')); |
|
16 | + $EP2 = $SugarAPI->getRecord('Accounts', $record->id)->data(array('fields' => 'name,email1')); |
|
17 | 17 | $getResponse = $EP2->execute()->getResponse(); |
18 | 18 | print $EP2->getUrl(); |
19 | 19 | print_r($getResponse->getBody()); |
20 | 20 | } |
21 | 21 | |
22 | -}catch(\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
22 | +}catch (\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
23 | 23 | print $ex->getMessage(); |
24 | 24 | } |
25 | 25 | \ No newline at end of file |
@@ -1,22 +1,22 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
4 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
5 | 5 | |
6 | 6 | try{ |
7 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7700/',array('username' => 'admin','password'=>'asdf')); |
|
7 | + $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7700/', array('username' => 'admin', 'password'=>'asdf')); |
|
8 | 8 | $SugarAPI->login(); |
9 | 9 | $EP = $SugarAPI->filterRecords('Accounts'); |
10 | 10 | $response = $EP->execute()->getResponse(); |
11 | 11 | if ($response->getStatus()=='200'){ |
12 | 12 | $recordList = $response->getBody(); |
13 | - $max=count($recordList->records); |
|
13 | + $max = count($recordList->records); |
|
14 | 14 | echo "found $max records from Filter Records request. <br>"; |
15 | - $number = rand(0,$max); |
|
15 | + $number = rand(0, $max); |
|
16 | 16 | $randomRecord = $recordList->records[$number]; |
17 | 17 | echo "Choose random record #$number, with ID: ".$randomRecord->id." <br>"; |
18 | 18 | |
19 | - $getRecord = $SugarAPI->getRecord('Accounts',$randomRecord->id)->data(array( |
|
19 | + $getRecord = $SugarAPI->getRecord('Accounts', $randomRecord->id)->data(array( |
|
20 | 20 | 'fields' => 'name' |
21 | 21 | ))->execute(); |
22 | 22 | $response = $getRecord->getResponse(); |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * Configure the static property $_DEFAULTS with settings from defaults.php |
85 | 85 | */ |
86 | 86 | protected function loadDefaults(){ |
87 | - if (empty(static::$_DEFAULTS)) { |
|
88 | - include __DIR__ . DIRECTORY_SEPARATOR . 'defaults.php'; |
|
89 | - if (isset($defaults)) { |
|
87 | + if (empty(static::$_DEFAULTS)){ |
|
88 | + include __DIR__.DIRECTORY_SEPARATOR.'defaults.php'; |
|
89 | + if (isset($defaults)){ |
|
90 | 90 | static::$_DEFAULTS = $defaults; |
91 | 91 | } |
92 | 92 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $response = $this->oauth2Token()->data($this->authOptions)->execute()->getResponse(); |
177 | 177 | if ($response->getStatus()=='200'){ |
178 | 178 | $this->setAuthToken($response->getBody()); |
179 | - } else{ |
|
179 | + }else{ |
|
180 | 180 | throw new AuthenticationException($response->getBody()); |
181 | 181 | } |
182 | 182 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $response = $this->oauth2Refresh()->data($refreshOptions)->execute()->getResponse(); |
203 | 203 | if ($response->getStatus()=='200'){ |
204 | 204 | $this->setAuthToken($response->getBody()); |
205 | - } else{ |
|
205 | + }else{ |
|
206 | 206 | throw new AuthenticationException($response->getBody()); |
207 | 207 | } |
208 | 208 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * @return bool |
213 | 213 | */ |
214 | 214 | public function authExpired(){ |
215 | - return time() >= $this->authExpiration; |
|
215 | + return time()>=$this->authExpiration; |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |