@@ -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 | } |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | protected function configureData($data){ |
| 26 | 26 | if (is_array($data)){ |
| 27 | 27 | $data['grant_type'] = 'password'; |
| 28 | - }elseif (is_object($data)){ |
|
| 28 | + } elseif (is_object($data)){ |
|
| 29 | 29 | $data->grant_type = 'password'; |
| 30 | 30 | } |
| 31 | 31 | return $data; |
@@ -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); |
@@ -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; |
@@ -98,7 +98,7 @@ |
||
| 98 | 98 | $response = $EP->data($this->authOptions)->execute()->getResponse(); |
| 99 | 99 | if ($response->getStatus()=='200'){ |
| 100 | 100 | $this->authToken = $response->getBody(); |
| 101 | - } else{ |
|
| 101 | + }else{ |
|
| 102 | 102 | throw new AuthenticationException($response->getBody()); |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -81,12 +81,12 @@ |
||
| 81 | 81 | if ($EntryPoint->authRequired()){ |
| 82 | 82 | if (isset($this->authToken)){ |
| 83 | 83 | $EntryPoint->configureAuth($this->authToken->access_token); |
| 84 | - }else{ |
|
| 84 | + } else{ |
|
| 85 | 85 | throw new AuthenticationException('no_auth'); |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | return $EntryPoint; |
| 89 | - }else{ |
|
| 89 | + } else{ |
|
| 90 | 90 | throw new SDKException('Method '.$name.', is not a registered method of the SugarAPI SDK'); |
| 91 | 91 | } |
| 92 | 92 | } |