@@ -2,9 +2,9 @@ |
||
2 | 2 | |
3 | 3 | namespace SugarAPI\SDK\Exception; |
4 | 4 | |
5 | -class SDKException extends \Exception{ |
|
5 | +class SDKException extends \Exception { |
|
6 | 6 | |
7 | - public function __construct($message = 'Unknown SugarAPI SDK Exception Occurred.') { |
|
7 | + public function __construct($message = 'Unknown SugarAPI SDK Exception Occurred.'){ |
|
8 | 8 | parent::__construct($message); |
9 | 9 | } |
10 | 10 |
@@ -2,11 +2,11 @@ |
||
2 | 2 | |
3 | 3 | namespace SugarAPI\SDK\Exception; |
4 | 4 | |
5 | -class AuthenticationException extends SDKException{ |
|
5 | +class AuthenticationException extends SDKException { |
|
6 | 6 | |
7 | 7 | protected $message = 'Authentication Exception occurred when attempting to Login to SugarCRM instance. Message: %s'; |
8 | 8 | |
9 | - public function __construct($message) { |
|
9 | + public function __construct($message){ |
|
10 | 10 | $message = sprintf($this->message,$message); |
11 | 11 | parent::__construct($message); |
12 | 12 | } |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | $this->url = $url; |
90 | 90 | $this->Module = $this->_MODULE; |
91 | 91 | |
92 | - if (!empty($options)) { |
|
93 | - if (empty($this->Module)) { |
|
94 | - if (strpos($this->_URL, '$module') !== FALSE) { |
|
92 | + if (!empty($options)){ |
|
93 | + if (empty($this->Module)){ |
|
94 | + if (strpos($this->_URL, '$module') !== FALSE){ |
|
95 | 95 | $this->module($options[0]); |
96 | 96 | array_shift($options); |
97 | 97 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @inheritdoc |
131 | 131 | */ |
132 | 132 | public function execute(){ |
133 | - if ($this->verifyURL() && $this->validateData()) { |
|
133 | + if ($this->verifyURL() && $this->validateData()){ |
|
134 | 134 | $this->configureURL(); |
135 | 135 | $this->Request->setURL($this->url); |
136 | 136 | $this->Request->send(); |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | /** |
145 | 145 | * @inheritdoc |
146 | 146 | */ |
147 | - public function authRequired() { |
|
147 | + public function authRequired(){ |
|
148 | 148 | return $this->_AUTH_REQUIRED; |
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
152 | 152 | * @inheritdoc |
153 | 153 | */ |
154 | - public function configureAuth($accessToken) { |
|
154 | + public function configureAuth($accessToken){ |
|
155 | 155 | if ($this->authRequired()){ |
156 | 156 | $this->accessToken = $accessToken; |
157 | 157 | $this->Request->addHeader('OAuth-Token', $accessToken); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * @inheritdoc |
164 | 164 | */ |
165 | - public function getModule() { |
|
165 | + public function getModule(){ |
|
166 | 166 | return $this->Module; |
167 | 167 | } |
168 | 168 | |
@@ -201,24 +201,24 @@ discard block |
||
201 | 201 | */ |
202 | 202 | protected function configureURL(){ |
203 | 203 | $url = $this->_URL; |
204 | - if (strpos($this->_URL,"$")!==FALSE) { |
|
205 | - if (count($this->Options) > 0 || !empty($this->Module)) { |
|
204 | + if (strpos($this->_URL,"$")!==FALSE){ |
|
205 | + if (count($this->Options) > 0 || !empty($this->Module)){ |
|
206 | 206 | $urlParts = explode("/", $this->_URL); |
207 | 207 | $o = 0; |
208 | - foreach ($urlParts as $key => $part) { |
|
209 | - if (strpos($part, '$module') !== FALSE) { |
|
210 | - if (isset($this->Module)) { |
|
208 | + foreach ($urlParts as $key => $part){ |
|
209 | + if (strpos($part, '$module') !== FALSE){ |
|
210 | + if (isset($this->Module)){ |
|
211 | 211 | $urlParts[$key] = $this->Module; |
212 | 212 | continue; |
213 | - } else { |
|
214 | - if (isset($this->Options[$o])) { |
|
213 | + } else{ |
|
214 | + if (isset($this->Options[$o])){ |
|
215 | 215 | $this->Module = $this->Options[$o]; |
216 | 216 | array_shift($this->Options); |
217 | 217 | } |
218 | 218 | } |
219 | 219 | } |
220 | - if (strpos($part, "$") !== FALSE) { |
|
221 | - if (isset($this->Options[$o])) { |
|
220 | + if (strpos($part, "$") !== FALSE){ |
|
221 | + if (isset($this->Options[$o])){ |
|
222 | 222 | $urlParts[$key] = $this->Options[$o]; |
223 | 223 | $o++; |
224 | 224 | } |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | if ($urlVarCount!==$optionCount){ |
260 | 260 | if (empty($this->Module) && strpos($this->_URL,'$module')){ |
261 | 261 | throw new EntryPointException('Module is required for EntryPoint '.get_called_class()); |
262 | - }else{ |
|
262 | + } else{ |
|
263 | 263 | throw new EntryPointException('EntryPoint URL ('.$this->_URL.') requires more parameters than passed.'); |
264 | 264 | } |
265 | - }else{ |
|
265 | + } else{ |
|
266 | 266 | return true; |
267 | 267 | } |
268 | 268 | } |
@@ -275,18 +275,18 @@ discard block |
||
275 | 275 | protected function validateData(){ |
276 | 276 | if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){ |
277 | 277 | return true; |
278 | - }else{ |
|
278 | + } else{ |
|
279 | 279 | $errors = array(); |
280 | 280 | foreach($this->_REQUIRED_DATA as $property){ |
281 | 281 | if (isset($this->Data[$property]) || $this->Data[$property]!==null){ |
282 | 282 | continue; |
283 | - }else{ |
|
283 | + } else{ |
|
284 | 284 | $errors[] = $property; |
285 | 285 | } |
286 | 286 | } |
287 | 287 | if (count($errors)>0){ |
288 | 288 | throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors,",")); |
289 | - }else{ |
|
289 | + } else{ |
|
290 | 290 | return true; |
291 | 291 | } |
292 | 292 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @inheritdoc |
19 | 19 | */ |
20 | - protected function setupRequest() { |
|
20 | + protected function setupRequest(){ |
|
21 | 21 | $this->Request = new GETFile(); |
22 | 22 | } |
23 | 23 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @inheritdoc |
26 | 26 | * File Response Object has option File Destination parameter, which is passed using DownloadDir property |
27 | 27 | */ |
28 | - protected function setupResponse() { |
|
28 | + protected function setupResponse(){ |
|
29 | 29 | $this->Response = new FileResponse($this->Request->getResponse(),$this->Request->getCurlObject(),$this->downloadDir); |
30 | 30 | } |
31 | 31 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | /** |
11 | 11 | * @inheritdoc |
12 | 12 | */ |
13 | - protected function setupRequest() { |
|
13 | + protected function setupRequest(){ |
|
14 | 14 | $this->Request = new POSTFile(); |
15 | 15 | } |
16 | 16 |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use SugarAPI\SDK\EntryPoint\Abstracts\GET\FileEntryPoint as GETFileEntryPoint; |
6 | 6 | |
7 | -class RecordFileField extends GETFileEntryPoint{ |
|
7 | +class RecordFileField extends GETFileEntryPoint { |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * @inheritdoc |
@@ -4,7 +4,7 @@ |
||
4 | 4 | |
5 | 5 | use SugarAPI\SDK\EntryPoint\Abstracts\POST\JSONEntryPoint as POSTEntryPoint; |
6 | 6 | |
7 | -class CreateRecord extends POSTEntryPoint{ |
|
7 | +class CreateRecord extends POSTEntryPoint { |
|
8 | 8 | |
9 | 9 | protected $_URL = '$module'; |
10 | 10 |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | protected function loadDefaults(){ |
43 | 43 | include __DIR__ .DIRECTORY_SEPARATOR.'defaults.php'; |
44 | - if (isset($defaults)) { |
|
44 | + if (isset($defaults)){ |
|
45 | 45 | static::$_DEFAULTS = $defaults; |
46 | 46 | if (isset($defaults['instance'])){ |
47 | 47 | $this->setInstance($defaults['instance']); |
@@ -81,14 +81,14 @@ discard block |
||
81 | 81 | $EntryPoint = new $Class($this->url,$params); |
82 | 82 | |
83 | 83 | if ($EntryPoint->authRequired()){ |
84 | - if (isset($this->authToken)) { |
|
84 | + if (isset($this->authToken)){ |
|
85 | 85 | $EntryPoint->configureAuth($this->authToken->access_token); |
86 | - }else{ |
|
86 | + } else{ |
|
87 | 87 | throw new AuthenticationException('no_auth'); |
88 | 88 | } |
89 | 89 | } |
90 | 90 | return $EntryPoint; |
91 | - }else{ |
|
91 | + } else{ |
|
92 | 92 | throw new SDKException('Method '.$name.', is not a registered method of the SugarAPI SDK'); |
93 | 93 | } |
94 | 94 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $response = $EP->data($this->authOptions)->execute()->getResponse(); |
101 | 101 | if ($response->getStatus()=='200'){ |
102 | 102 | $this->authToken = $response->getBody(); |
103 | - }else{ |
|
103 | + } else{ |
|
104 | 104 | throw new AuthenticationException($response->getBody()); |
105 | 105 | } |
106 | 106 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | print_r($response); |
14 | 14 | |
15 | -}catch(\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
15 | +} catch(\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
16 | 16 | print $ex->getMessage(); |
17 | 17 | } |
18 | 18 |