@@ -2,8 +2,6 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace SugarAPI\SDK; |
| 4 | 4 | |
| 5 | -use SugarAPI\SDK\Exception\InitializationFailure; |
|
| 6 | -use SugarAPI\SDK\Exception\InvalidEntryPoint; |
|
| 7 | 5 | use SugarAPI\SDK\Exception\AuthenticationException; |
| 8 | 6 | use SugarAPI\SDK\Exception\SDKException; |
| 9 | 7 | |
@@ -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 | |
@@ -21,18 +21,18 @@ |
||
| 21 | 21 | if ($response->getStatus()=='200'){ |
| 22 | 22 | $record = $response->getBody(); |
| 23 | 23 | print_r($response); |
| 24 | - }else{ |
|
| 24 | + } else{ |
|
| 25 | 25 | print_r($upload->getRequest()); |
| 26 | 26 | echo "Failed to Update Note with File<br>"; |
| 27 | 27 | echo "Response: ".$response->getStatus()."<br>"; |
| 28 | 28 | print_r($response->getBody()); |
| 29 | 29 | } |
| 30 | - }else{ |
|
| 30 | + } else{ |
|
| 31 | 31 | echo "Failed to create Note<br>"; |
| 32 | 32 | echo "Response: ".$response->getStatus()."<br>"; |
| 33 | 33 | print_r($response->getBody()); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | -}catch(\SugarAPI\SDK\Exception\SDKException $ex){ |
|
| 36 | +} catch(\SugarAPI\SDK\Exception\SDKException $ex){ |
|
| 37 | 37 | print $ex->getMessage(); |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -39,31 +39,31 @@ |
||
| 39 | 39 | $response = $deleteRecord->getResponse()->getBody(); |
| 40 | 40 | echo "Deleted Record <br>"; |
| 41 | 41 | print_r($response); |
| 42 | - }else{ |
|
| 42 | + } else{ |
|
| 43 | 43 | echo "Failed to Delete record<br>"; |
| 44 | 44 | echo "Response: ".$response->getStatus()."<br>"; |
| 45 | 45 | print_r($response->getBody()); |
| 46 | 46 | } |
| 47 | - }else{ |
|
| 47 | + } else{ |
|
| 48 | 48 | print_r($updateRecord->getRequest()); |
| 49 | 49 | echo "Failed to Update record<br>"; |
| 50 | 50 | echo "Response: ".$response->getStatus()."<br>"; |
| 51 | 51 | print_r($response->getBody()); |
| 52 | 52 | } |
| 53 | - }else{ |
|
| 53 | + } else{ |
|
| 54 | 54 | echo "Failed to retrieve record<br>"; |
| 55 | 55 | echo "Response: ".$response->getStatus()."<br>"; |
| 56 | 56 | print_r($response->getBody()); |
| 57 | 57 | } |
| 58 | - }else{ |
|
| 58 | + } else{ |
|
| 59 | 59 | echo "Response: ".$response->getStatus(); |
| 60 | 60 | print_r($response->getBody()); |
| 61 | 61 | } |
| 62 | -}catch(\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
| 62 | +} catch(\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
| 63 | 63 | echo "Auth Options:<pre>"; |
| 64 | 64 | print_r($SugarAPI->getAuthOptions()); |
| 65 | 65 | echo "</pre> Error Message: "; |
| 66 | 66 | print $ex->getMessage(); |
| 67 | -}catch(\SugarAPI\SDK\Exception\SDKException $ex){ |
|
| 67 | +} catch(\SugarAPI\SDK\Exception\SDKException $ex){ |
|
| 68 | 68 | echo $ex->__toString(); |
| 69 | 69 | } |
@@ -19,6 +19,6 @@ |
||
| 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 |
@@ -14,12 +14,12 @@ |
||
| 14 | 14 | echo "File downloaded to ".$response->file(); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - }else{ |
|
| 17 | + } else{ |
|
| 18 | 18 | echo "Failed to retrieve Note<br>"; |
| 19 | 19 | echo "Response: ".$response->getStatus()."<br>"; |
| 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 |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Request\Abstracts\AbstractRequest; |
| 6 | 6 | |
| 7 | -class POST extends AbstractRequest{ |
|
| 7 | +class POST extends AbstractRequest { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * @inheritdoc |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * JSON Encode Body |
| 33 | 33 | * @inheritdoc |
| 34 | 34 | */ |
| 35 | - public function setBody($body) { |
|
| 35 | + public function setBody($body){ |
|
| 36 | 36 | return parent::setBody(json_encode($body)); |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\Response\Interfaces\ResponseInterface; |
| 6 | 6 | |
| 7 | -abstract class AbstractResponse implements ResponseInterface{ |
|
| 7 | +abstract class AbstractResponse implements ResponseInterface { |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Full Curl Response |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function __construct($curlResponse,$curlRequest){ |
| 40 | 40 | $this->CurlResponse = $curlResponse; |
| 41 | - if ($this->checkErrors($curlRequest)) { |
|
| 41 | + if ($this->checkErrors($curlRequest)){ |
|
| 42 | 42 | $this->extractResponse($curlRequest); |
| 43 | 43 | } |
| 44 | 44 | $this->setStatus($curlRequest); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return bool |
| 69 | 69 | */ |
| 70 | 70 | protected function checkErrors($curlRequest){ |
| 71 | - if (curl_errno($curlRequest) !== CURLE_OK) { |
|
| 71 | + if (curl_errno($curlRequest) !== CURLE_OK){ |
|
| 72 | 72 | $this->error = curl_error($curlRequest); |
| 73 | 73 | return false; |
| 74 | 74 | } |
@@ -85,14 +85,14 @@ discard block |
||
| 85 | 85 | /** |
| 86 | 86 | * @inheritdoc |
| 87 | 87 | */ |
| 88 | - public function getBody() { |
|
| 88 | + public function getBody(){ |
|
| 89 | 89 | return $this->body; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | /** |
| 93 | 93 | * @inheritdoc |
| 94 | 94 | */ |
| 95 | - public function getHeaders() { |
|
| 95 | + public function getHeaders(){ |
|
| 96 | 96 | return $this->headers; |
| 97 | 97 | } |
| 98 | 98 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @inheritdoc |
| 19 | 19 | */ |
| 20 | - public function getBody() { |
|
| 20 | + public function getBody(){ |
|
| 21 | 21 | return json_decode($this->body); |
| 22 | 22 | } |
| 23 | 23 | |