Skip to content
Snippets Groups Projects
Commit 1b148dc5 authored by Aaron Bauman's avatar Aaron Bauman
Browse files

isReady / isInit

parent 9b04fdfd
No related branches found
No related tags found
No related merge requests found
...@@ -95,7 +95,7 @@ abstract class SalesforceMappingFormBase extends EntityForm { ...@@ -95,7 +95,7 @@ abstract class SalesforceMappingFormBase extends EntityForm {
*/ */
protected function ensureConnection($method = 'objects', $arg = []) { protected function ensureConnection($method = 'objects', $arg = []) {
$message = ''; $message = '';
if ($this->client->isReady()) { if ($this->client->isInit()) {
try { try {
$this->client->{$method}($arg); $this->client->{$method}($arg);
return TRUE; return TRUE;
......
...@@ -145,8 +145,11 @@ class RestClient implements RestClientInterface { ...@@ -145,8 +145,11 @@ class RestClient implements RestClientInterface {
return $this; return $this;
} }
public function isReady() { /**
if (!$this->authProvider || !$this->authToken) { * {@inheritdoc}
*/
public function isInit() {
if (!$this->authProvider || !$this->authToken || !$this->authManager) {
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
...@@ -156,6 +159,9 @@ class RestClient implements RestClientInterface { ...@@ -156,6 +159,9 @@ class RestClient implements RestClientInterface {
* {@inheritdoc} * {@inheritdoc}
*/ */
public function apiCall($path, array $params = [], $method = 'GET', $returnObject = FALSE) { public function apiCall($path, array $params = [], $method = 'GET', $returnObject = FALSE) {
if (!$this->isInit()) {
throw new RestException(NULL, 'RestClient is not initialized.');
}
if (!$this->authToken) { if (!$this->authToken) {
$this->authManager->refreshToken(); $this->authManager->refreshToken();
} }
......
...@@ -14,10 +14,14 @@ interface RestClientInterface { ...@@ -14,10 +14,14 @@ interface RestClientInterface {
/** /**
* Check if the client is ready to perform API calls. * Check if the client is ready to perform API calls.
* *
* TRUE indicates that the various dependencies are in place to initiate an
* API call. It does NOT indicate that the API call will be successful, or
* return a 200 status.
*
* @return bool * @return bool
* TRUE if the client is ready to perform API calls. Otherwise FALSE. * FALSE if the client is not initialized. TRUE otherwise.
*/ */
public function isReady(); public function isInit();
/** /**
* Make a call to the Salesforce REST API. * Make a call to the Salesforce REST API.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment