You are here

public function SalesforceIdentity::__construct in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 5.0.x src/Rest/SalesforceIdentity.php \Drupal\salesforce\Rest\SalesforceIdentity::__construct()

Handle the identity response from Salesforce.

Parameters

string $responseBody: JSON identity response from Salesforce.

Throws

\OAuth\Common\Http\Exception\TokenResponseException If responseBody cannot be parsed, or contains an error.

File

src/Rest/SalesforceIdentity.php, line 20

Class

SalesforceIdentity

Namespace

Drupal\salesforce\Rest

Code

public function __construct($responseBody) {
  $data = json_decode($responseBody, TRUE);
  if (NULL === $data || !is_array($data)) {
    throw new TokenResponseException('Unable to parse response.');
  }
  elseif (isset($data['error'])) {
    throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
  }
  $this->data = $data;
}