@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | protected $Request; |
| 22 | 22 | protected $Response; |
| 23 | 23 | |
| 24 | - public function __construct($url,$options = array()){ |
|
| 24 | + public function __construct($url, $options = array()) { |
|
| 25 | 25 | $this->url = $url; |
| 26 | 26 | $this->Module = $this->_MODULE; |
| 27 | 27 | |
| 28 | 28 | if (!empty($options)) { |
| 29 | 29 | if (empty($this->Module)) { |
| 30 | - if (strpos($this->_URL, '$module') !== FALSE) { |
|
| 30 | + if (strpos($this->_URL, '$module')!==FALSE) { |
|
| 31 | 31 | $this->module($options[0]); |
| 32 | 32 | array_shift($options); |
| 33 | 33 | } |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | /** |
| 41 | 41 | * @inheritdoc |
| 42 | 42 | */ |
| 43 | - public function module($module){ |
|
| 43 | + public function module($module) { |
|
| 44 | 44 | $this->Module = $module; |
| 45 | 45 | return $this; |
| 46 | 46 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | /** |
| 49 | 49 | * @inheritdoc |
| 50 | 50 | */ |
| 51 | - public function options(array $options){ |
|
| 51 | + public function options(array $options) { |
|
| 52 | 52 | $this->Options = $options; |
| 53 | 53 | return $this; |
| 54 | 54 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | /** |
| 57 | 57 | * @inheritdoc |
| 58 | 58 | */ |
| 59 | - public function data(array $data){ |
|
| 59 | + public function data(array $data) { |
|
| 60 | 60 | $this->Data = $data; |
| 61 | 61 | $this->Request->setBody($this->Data); |
| 62 | 62 | return $this; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | /** |
| 66 | 66 | * @inheritdoc |
| 67 | 67 | */ |
| 68 | - public function execute(){ |
|
| 68 | + public function execute() { |
|
| 69 | 69 | if ($this->verifyURL() && $this->validateData()) { |
| 70 | 70 | $this->configureURL(); |
| 71 | 71 | $this->Request->setURL($this->url); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | /** |
| 79 | 79 | * @inheritdoc |
| 80 | 80 | */ |
| 81 | - public function status(){ |
|
| 81 | + public function status() { |
|
| 82 | 82 | $this->Request->getStatus(); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -99,28 +99,28 @@ discard block |
||
| 99 | 99 | /** |
| 100 | 100 | * |
| 101 | 101 | */ |
| 102 | - public function getData(){ |
|
| 102 | + public function getData() { |
|
| 103 | 103 | return $this->Data; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * @inheritdoc |
| 108 | 108 | */ |
| 109 | - public function getURL(){ |
|
| 109 | + public function getURL() { |
|
| 110 | 110 | return $this->url; |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * @inheritdoc |
| 115 | 115 | */ |
| 116 | - public function getResponse(){ |
|
| 116 | + public function getResponse() { |
|
| 117 | 117 | return $this->Response; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
| 121 | 121 | * @inheritdoc |
| 122 | 122 | */ |
| 123 | - public function getRequest(){ |
|
| 123 | + public function getRequest() { |
|
| 124 | 124 | return $this->Request; |
| 125 | 125 | } |
| 126 | 126 | |
@@ -129,32 +129,32 @@ discard block |
||
| 129 | 129 | * - Replaces $module with $this->Module |
| 130 | 130 | * - Replcaes all other variables starting with $, with options in the order they were given |
| 131 | 131 | */ |
| 132 | - protected function configureURL(){ |
|
| 132 | + protected function configureURL() { |
|
| 133 | 133 | $url = $this->_URL; |
| 134 | - if (strpos($this->_URL,"$")!==FALSE) { |
|
| 135 | - if (count($this->Options) > 0 || !empty($this->Module)) { |
|
| 134 | + if (strpos($this->_URL, "$")!==FALSE) { |
|
| 135 | + if (count($this->Options)>0 || !empty($this->Module)) { |
|
| 136 | 136 | $urlParts = explode("/", $this->_URL); |
| 137 | 137 | $o = 0; |
| 138 | 138 | foreach ($urlParts as $key => $part) { |
| 139 | - if (strpos($part, '$module') !== FALSE) { |
|
| 139 | + if (strpos($part, '$module')!==FALSE) { |
|
| 140 | 140 | if (isset($this->Module)) { |
| 141 | 141 | $urlParts[$key] = $this->Module; |
| 142 | 142 | continue; |
| 143 | - } else { |
|
| 143 | + }else { |
|
| 144 | 144 | if (isset($this->Options[$o])) { |
| 145 | 145 | $this->Module = $this->Options[$o]; |
| 146 | 146 | array_shift($this->Options); |
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | - if (strpos($part, "$") !== FALSE) { |
|
| 150 | + if (strpos($part, "$")!==FALSE) { |
|
| 151 | 151 | if (isset($this->Options[$o])) { |
| 152 | 152 | $urlParts[$key] = $this->Options[$o]; |
| 153 | 153 | $o++; |
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | } |
| 157 | - $url = implode($urlParts,"/"); |
|
| 157 | + $url = implode($urlParts, "/"); |
|
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | $this->url = $this->url.$url; |
@@ -163,15 +163,15 @@ discard block |
||
| 163 | 163 | /** |
| 164 | 164 | * Setup the Request Object property, setup on initial Construct of EntryPoint |
| 165 | 165 | */ |
| 166 | - protected function setupRequest(){ |
|
| 166 | + protected function setupRequest() { |
|
| 167 | 167 | $this->Request = new POST(); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
| 171 | 171 | * Setup the Response Object Property, not called until after Request Execution |
| 172 | 172 | */ |
| 173 | - protected function setupResponse(){ |
|
| 174 | - $this->Response = new StandardResponse($this->Request->getResponse(),$this->Request->getCurlObject()); |
|
| 173 | + protected function setupResponse() { |
|
| 174 | + $this->Response = new StandardResponse($this->Request->getResponse(), $this->Request->getCurlObject()); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | /** |
@@ -179,20 +179,20 @@ discard block |
||
| 179 | 179 | * @return bool |
| 180 | 180 | * @throws EntryPointExecutionFailure |
| 181 | 181 | */ |
| 182 | - protected function verifyURL(){ |
|
| 183 | - $urlVarCount = substr_count($this->_URL,"$"); |
|
| 182 | + protected function verifyURL() { |
|
| 183 | + $urlVarCount = substr_count($this->_URL, "$"); |
|
| 184 | 184 | $optionCount = 0; |
| 185 | - if (!empty($this->Module)){ |
|
| 185 | + if (!empty($this->Module)) { |
|
| 186 | 186 | $optionCount++; |
| 187 | 187 | } |
| 188 | 188 | $optionCount += count($this->Options); |
| 189 | - if ($urlVarCount!==$optionCount){ |
|
| 190 | - if (empty($this->Module)){ |
|
| 189 | + if ($urlVarCount!==$optionCount) { |
|
| 190 | + if (empty($this->Module)) { |
|
| 191 | 191 | throw new EntryPointExecutionFailure('missing_module'); |
| 192 | - }else{ |
|
| 192 | + }else { |
|
| 193 | 193 | throw new EntryPointExecutionFailure('missing_options'); |
| 194 | 194 | } |
| 195 | - }else{ |
|
| 195 | + }else { |
|
| 196 | 196 | return true; |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -200,21 +200,21 @@ discard block |
||
| 200 | 200 | /** |
| 201 | 201 | * @return bool |
| 202 | 202 | */ |
| 203 | - protected function validateData(){ |
|
| 204 | - if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){ |
|
| 203 | + protected function validateData() { |
|
| 204 | + if (empty($this->_REQUIRED_DATA) || count($this->_REQUIRED_DATA)==0) { |
|
| 205 | 205 | return true; |
| 206 | - }else{ |
|
| 206 | + }else { |
|
| 207 | 207 | $errors = array(); |
| 208 | - foreach($this->_REQUIRED_DATA as $property){ |
|
| 209 | - if (isset($this->Data[$property]) || $this->Data[$property]!==null){ |
|
| 208 | + foreach ($this->_REQUIRED_DATA as $property) { |
|
| 209 | + if (isset($this->Data[$property]) || $this->Data[$property]!==null) { |
|
| 210 | 210 | continue; |
| 211 | - }else{ |
|
| 211 | + }else { |
|
| 212 | 212 | $errors[] = $property; |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | - if (count($errors)>0){ |
|
| 215 | + if (count($errors)>0) { |
|
| 216 | 216 | throw new EntryPointExecutionFailure('missing_data'); |
| 217 | - }else{ |
|
| 217 | + }else { |
|
| 218 | 218 | return true; |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -189,10 +189,10 @@ discard block |
||
| 189 | 189 | if ($urlVarCount!==$optionCount){ |
| 190 | 190 | if (empty($this->Module)){ |
| 191 | 191 | throw new EntryPointExecutionFailure('missing_module'); |
| 192 | - }else{ |
|
| 192 | + } else{ |
|
| 193 | 193 | throw new EntryPointExecutionFailure('missing_options'); |
| 194 | 194 | } |
| 195 | - }else{ |
|
| 195 | + } else{ |
|
| 196 | 196 | return true; |
| 197 | 197 | } |
| 198 | 198 | } |
@@ -203,18 +203,18 @@ discard block |
||
| 203 | 203 | protected function validateData(){ |
| 204 | 204 | if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){ |
| 205 | 205 | return true; |
| 206 | - }else{ |
|
| 206 | + } else{ |
|
| 207 | 207 | $errors = array(); |
| 208 | 208 | foreach($this->_REQUIRED_DATA as $property){ |
| 209 | 209 | if (isset($this->Data[$property]) || $this->Data[$property]!==null){ |
| 210 | 210 | continue; |
| 211 | - }else{ |
|
| 211 | + } else{ |
|
| 212 | 212 | $errors[] = $property; |
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | if (count($errors)>0){ |
| 216 | 216 | throw new EntryPointExecutionFailure('missing_data'); |
| 217 | - }else{ |
|
| 217 | + } else{ |
|
| 218 | 218 | return true; |
| 219 | 219 | } |
| 220 | 220 | } |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | 'platform' |
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | - public function data(array $data){ |
|
| 20 | + public function data(array $data) { |
|
| 21 | 21 | $data['grant_type'] = 'password'; |
| 22 | 22 | return parent::data($data); |
| 23 | 23 | } |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | use SugarAPI\SDK\EntryPoint\Abstracts\Abstract_POST_EntryPoint; |
| 6 | 6 | |
| 7 | -class CreateRecord extends Abstract_POST_EntryPoint{ |
|
| 7 | +class CreateRecord extends Abstract_POST_EntryPoint { |
|
| 8 | 8 | |
| 9 | 9 | protected $_URL = '$module'; |
| 10 | 10 | |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | |
| 6 | 6 | use SugarAPI\SDK\Exception\Abstracts\AbstractException; |
| 7 | 7 | |
| 8 | -class InvalidEntryPoint extends AbstractException{ |
|
| 8 | +class InvalidEntryPoint extends AbstractException { |
|
| 9 | 9 | |
| 10 | 10 | protected $defaultMessage = 'The method you called is not a valid EntryPoint in the SDK.'; |
| 11 | 11 | protected $failureCodes = array( |
@@ -5,7 +5,7 @@ |
||
| 5 | 5 | |
| 6 | 6 | use SugarAPI\SDK\Exception\Abstracts\AbstractException; |
| 7 | 7 | |
| 8 | -class AuthenticationError extends AbstractException{ |
|
| 8 | +class AuthenticationError extends AbstractException { |
|
| 9 | 9 | |
| 10 | 10 | protected $defaultMessage = 'Unknown error occurred, when SDK attempted to Authenticate to SugarCRM instance.'; |
| 11 | 11 | protected $failureCodes = array( |
@@ -1,7 +1,7 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 3 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 4 | 4 | |
| 5 | -$SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7621/',array('username' => 'admin','password'=>'asdf')); |
|
| 5 | +$SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7621/', array('username' => 'admin', 'password'=>'asdf')); |
|
| 6 | 6 | $SugarAPI->login(); |
| 7 | 7 | print_r($SugarAPI->getToken()); |
| 8 | 8 | \ No newline at end of file |
@@ -1,19 +1,19 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 4 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
| 5 | 5 | |
| 6 | -try{ |
|
| 7 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/',array('username' => 'admin','password'=>'asdf')); |
|
| 6 | +try { |
|
| 7 | + $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/', array('username' => 'admin', 'password'=>'asdf')); |
|
| 8 | 8 | $SugarAPI->login(); |
| 9 | 9 | $EP = $SugarAPI->filterRecords('Accounts'); |
| 10 | 10 | $response = $EP->execute()->getResponse(); |
| 11 | - if ($response->getStatus()=='200'){ |
|
| 11 | + if ($response->getStatus()=='200') { |
|
| 12 | 12 | print_r($response->getBody()); |
| 13 | - }else{ |
|
| 13 | + }else { |
|
| 14 | 14 | print_r($EP); |
| 15 | 15 | print_r($response->getBody()); |
| 16 | 16 | } |
| 17 | -}catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ |
|
| 17 | +}catch (\SugarAPI\SDK\Exception\AuthenticationError $ex) { |
|
| 18 | 18 | print $ex->getMessage(); |
| 19 | 19 | } |
@@ -10,10 +10,10 @@ |
||
| 10 | 10 | $response = $EP->execute()->getResponse(); |
| 11 | 11 | if ($response->getStatus()=='200'){ |
| 12 | 12 | print_r($response->getBody()); |
| 13 | - }else{ |
|
| 13 | + } else{ |
|
| 14 | 14 | print_r($EP); |
| 15 | 15 | print_r($response->getBody()); |
| 16 | 16 | } |
| 17 | -}catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ |
|
| 17 | +} catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ |
|
| 18 | 18 | print $ex->getMessage(); |
| 19 | 19 | } |
@@ -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 | -try{ |
|
| 8 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/',array('username' => 'admin','password'=>'asdf')); |
|
| 7 | +try { |
|
| 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\AuthenticationError $ex){ |
|
| 18 | +}catch (\SugarAPI\SDK\Exception\AuthenticationError $ex) { |
|
| 19 | 19 | print $ex->getMessage(); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | ))->execute()->getResponse()->getBody(); |
| 16 | 16 | echo "Updated Record: ".$record->id; |
| 17 | 17 | |
| 18 | -}catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ |
|
| 18 | +} catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ |
|
| 19 | 19 | print $ex->getMessage(); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -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 | -try{ |
|
| 6 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Pro/7621/',array('username' => 'admin','password'=>'asdf')); |
|
| 5 | +try { |
|
| 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( |
@@ -11,14 +11,14 @@ discard block |
||
| 11 | 11 | 'email1' => '[email protected]' |
| 12 | 12 | )); |
| 13 | 13 | $response = $EP->execute()->getResponse(); |
| 14 | - if ($response->getStatus()=='200'){ |
|
| 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\AuthenticationError $ex){ |
|
| 22 | +}catch (\SugarAPI\SDK\Exception\AuthenticationError $ex) { |
|
| 23 | 23 | print $ex->getMessage(); |
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -19,6 +19,6 @@ |
||
| 19 | 19 | print_r($getResponse->getBody()); |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | -}catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ |
|
| 22 | +} catch(\SugarAPI\SDK\Exception\AuthenticationError $ex){ |
|
| 23 | 23 | print $ex->getMessage(); |
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |