@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | */ |
| 86 | 86 | protected $accessToken; |
| 87 | 87 | |
| 88 | - public function __construct($url,$options = array()){ |
|
| 88 | + public function __construct($url, $options = array()){ |
|
| 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,30 +201,30 @@ 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 | } |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | - $url = implode($urlParts,"/"); |
|
| 227 | + $url = implode($urlParts, "/"); |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | $this->url = $this->url.$url; |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | * Setup the Response Object Property, not called until after Request Execution |
| 242 | 242 | */ |
| 243 | 243 | protected function setupResponse(){ |
| 244 | - $this->Response = new JSONResponse($this->Request->getResponse(),$this->Request->getCurlObject()); |
|
| 244 | + $this->Response = new JSONResponse($this->Request->getResponse(), $this->Request->getCurlObject()); |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | /** |
@@ -250,14 +250,14 @@ discard block |
||
| 250 | 250 | * @throws EntryPointException |
| 251 | 251 | */ |
| 252 | 252 | protected function verifyURL(){ |
| 253 | - $urlVarCount = substr_count($this->_URL,"$"); |
|
| 253 | + $urlVarCount = substr_count($this->_URL, "$"); |
|
| 254 | 254 | $optionCount = 0; |
| 255 | 255 | if (!empty($this->Module)){ |
| 256 | 256 | $optionCount++; |
| 257 | 257 | } |
| 258 | 258 | $optionCount += count($this->Options); |
| 259 | 259 | if ($urlVarCount!==$optionCount){ |
| 260 | - if (empty($this->Module) && strpos($this->_URL,'$module')){ |
|
| 260 | + if (empty($this->Module) && strpos($this->_URL, '$module')){ |
|
| 261 | 261 | throw new EntryPointException('Module is required for EntryPoint '.get_called_class()); |
| 262 | 262 | }else{ |
| 263 | 263 | throw new EntryPointException('EntryPoint URL ('.$this->_URL.') requires more parameters than passed.'); |
@@ -273,11 +273,11 @@ discard block |
||
| 273 | 273 | * @throws EntryPointException |
| 274 | 274 | */ |
| 275 | 275 | protected function validateData(){ |
| 276 | - if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){ |
|
| 276 | + if (empty($this->_REQUIRED_DATA) || count($this->_REQUIRED_DATA)==0){ |
|
| 277 | 277 | return true; |
| 278 | 278 | }else{ |
| 279 | 279 | $errors = array(); |
| 280 | - foreach($this->_REQUIRED_DATA as $property){ |
|
| 280 | + foreach ($this->_REQUIRED_DATA as $property){ |
|
| 281 | 281 | if (isset($this->Data[$property]) || $this->Data[$property]!==null){ |
| 282 | 282 | continue; |
| 283 | 283 | }else{ |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | if (count($errors)>0){ |
| 288 | - throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors,",")); |
|
| 288 | + throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors, ",")); |
|
| 289 | 289 | }else{ |
| 290 | 290 | return true; |
| 291 | 291 | } |
@@ -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 | } |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | * Whether or not Authentication is Required |
| 15 | 15 | * @var bool |
| 16 | 16 | */ |
| 17 | - protected $_AUTH_REQUIRED = true; |
|
| 17 | + protected $_AUTH_REQUIRED = TRUE; |
|
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | 20 | * The default Module for the EntryPoint |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | throw new EntryPointException('EntryPoint URL ('.$this->_URL.') requires more parameters than passed.'); |
| 264 | 264 | } |
| 265 | 265 | }else{ |
| 266 | - return true; |
|
| 266 | + return TRUE; |
|
| 267 | 267 | } |
| 268 | 268 | } |
| 269 | 269 | |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | */ |
| 275 | 275 | protected function validateData(){ |
| 276 | 276 | if (empty($this->_REQUIRED_DATA)||count($this->_REQUIRED_DATA)==0){ |
| 277 | - return true; |
|
| 277 | + return TRUE; |
|
| 278 | 278 | }else{ |
| 279 | 279 | $errors = array(); |
| 280 | 280 | foreach($this->_REQUIRED_DATA as $property){ |
| 281 | - if (isset($this->Data[$property]) || $this->Data[$property]!==null){ |
|
| 281 | + if (isset($this->Data[$property]) || $this->Data[$property]!==NULL){ |
|
| 282 | 282 | continue; |
| 283 | 283 | }else{ |
| 284 | 284 | $errors[] = $property; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | if (count($errors)>0){ |
| 288 | 288 | throw new EntryPointException('EntryPoint requires specific properties in Request data. Missing the following '.implode($errors,",")); |
| 289 | 289 | }else{ |
| 290 | - return true; |
|
| 290 | + return TRUE; |
|
| 291 | 291 | } |
| 292 | 292 | } |
| 293 | 293 | } |
@@ -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,8 +25,8 @@ 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() { |
|
| 29 | - $this->Response = new FileResponse($this->Request->getResponse(),$this->Request->getCurlObject(),$this->downloadDir); |
|
| 28 | + protected function setupResponse(){ |
|
| 29 | + $this->Response = new FileResponse($this->Request->getResponse(), $this->Request->getCurlObject(), $this->downloadDir); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -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 | |
@@ -12,7 +12,7 @@ |
||
| 12 | 12 | * The directory in which to download the File |
| 13 | 13 | * @var string |
| 14 | 14 | */ |
| 15 | - protected $downloadDir = null; |
|
| 15 | + protected $downloadDir = NULL; |
|
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | 18 | * @inheritdoc |
@@ -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 | |
@@ -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 | |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Oauth2Token extends POSTEntryPoint { |
| 8 | 8 | |
| 9 | - protected $_AUTH_REQUIRED = false; |
|
| 9 | + protected $_AUTH_REQUIRED = FALSE; |
|
| 10 | 10 | protected $_URL = 'oauth2/token'; |
| 11 | 11 | protected $_REQUIRED_DATA = array( |
| 12 | 12 | 'username', |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | protected function configureData($data){ |
| 23 | 23 | if (is_array($data)){ |
| 24 | 24 | $data['grant_type'] = 'refresh_token'; |
| 25 | - }elseif (is_object($data)){ |
|
| 25 | + } elseif (is_object($data)){ |
|
| 26 | 26 | $data->grant_type = 'refresh_token'; |
| 27 | 27 | } |
| 28 | 28 | return $data; |
@@ -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 | |
@@ -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 | |
@@ -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 | |
@@ -15,18 +15,18 @@ |
||
| 15 | 15 | if ($response->getStatus()=='200'){ |
| 16 | 16 | $record = $response->getBody(); |
| 17 | 17 | print_r($record); |
| 18 | - }else{ |
|
| 18 | + } else{ |
|
| 19 | 19 | print_r($upload->getRequest()); |
| 20 | 20 | echo "Failed to Update Note with File<br>"; |
| 21 | 21 | echo "Response: ".$response->getStatus()."<br>"; |
| 22 | 22 | print_r($response->getBody()); |
| 23 | 23 | } |
| 24 | - }else{ |
|
| 24 | + } else{ |
|
| 25 | 25 | echo "Failed to create Note<br>"; |
| 26 | 26 | echo "Response: ".$response->getStatus()."<br>"; |
| 27 | 27 | print_r($response->getBody()); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | -}catch (\SugarAPI\SDK\Exception\SDKException $ex){ |
|
| 30 | +} catch (\SugarAPI\SDK\Exception\SDKException $ex){ |
|
| 31 | 31 | print $ex->getMessage(); |
| 32 | 32 | } |
| 33 | 33 | \ 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(); |
@@ -37,31 +37,31 @@ |
||
| 37 | 37 | $response = $deleteRecord->getResponse()->getBody(); |
| 38 | 38 | echo "Deleted Record <br>"; |
| 39 | 39 | print_r($response); |
| 40 | - }else{ |
|
| 40 | + } else{ |
|
| 41 | 41 | echo "Failed to Delete record<br>"; |
| 42 | 42 | echo "Response: ".$response->getStatus()."<br>"; |
| 43 | 43 | print_r($response->getBody()); |
| 44 | 44 | } |
| 45 | - }else{ |
|
| 45 | + } else{ |
|
| 46 | 46 | print_r($updateRecord->getRequest()); |
| 47 | 47 | echo "Failed to Update record<br>"; |
| 48 | 48 | echo "Response: ".$response->getStatus()."<br>"; |
| 49 | 49 | print_r($response->getBody()); |
| 50 | 50 | } |
| 51 | - }else{ |
|
| 51 | + } else{ |
|
| 52 | 52 | echo "Failed to retrieve record<br>"; |
| 53 | 53 | echo "Response: ".$response->getStatus()."<br>"; |
| 54 | 54 | print_r($response->getBody()); |
| 55 | 55 | } |
| 56 | - }else{ |
|
| 56 | + } else{ |
|
| 57 | 57 | echo "Response: ".$response->getStatus(); |
| 58 | 58 | print_r($response->getBody()); |
| 59 | 59 | } |
| 60 | -}catch (\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
| 60 | +} catch (\SugarAPI\SDK\Exception\AuthenticationException $ex){ |
|
| 61 | 61 | echo "Auth Options:<pre>"; |
| 62 | 62 | print_r($SugarAPI->getAuthOptions()); |
| 63 | 63 | echo "</pre> Error Message: "; |
| 64 | 64 | print $ex->getMessage(); |
| 65 | -}catch (\SugarAPI\SDK\Exception\SDKException $ex){ |
|
| 65 | +} catch (\SugarAPI\SDK\Exception\SDKException $ex){ |
|
| 66 | 66 | echo $ex->__toString(); |
| 67 | 67 | } |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | if (is_array($data)){ |
| 36 | 36 | if (isset($fileField)){ |
| 37 | 37 | $data[$fileField] = $this->setFileFieldValue($data[$fileField]); |
| 38 | - }else{ |
|
| 38 | + } else{ |
|
| 39 | 39 | foreach ($data as $key => $value){ |
| 40 | 40 | if (strtolower($key)!=='oauth_token' || strtolower($key)!=='delete_if_fails' || strtolower($key)!=='format'){ |
| 41 | 41 | $data[$key] = $this->setFileFieldValue($value); |