class SalesforceIdentity in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 src/Rest/SalesforceIdentity.php \Drupal\salesforce\Rest\SalesforceIdentity
Hierarchy
- class \Drupal\salesforce\Rest\SalesforceIdentity implements SalesforceIdentityInterface
Expanded class hierarchy of SalesforceIdentity
2 files declare their use of SalesforceIdentity
File
- src/
Rest/ SalesforceIdentity.php, line 7
Namespace
Drupal\salesforce\RestView source
class SalesforceIdentity implements SalesforceIdentityInterface {
protected $data;
/**
* Handle the identity response from Salesforce.
*
* @param string $responseBody
* JSON identity response from Salesforce.
*
* @throws \OAuth\Common\Http\Exception\TokenResponseException
* If responseBody cannot be parsed, or contains an error.
*/
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;
}
/**
* Static creation method.
*
* @param array $data
* Data array.
*
* @return \Drupal\salesforce\Rest\SalesforceIdentity
* New identity.
*
* @throws \OAuth\Common\Http\Exception\TokenResponseException
*/
public static function create(array $data) {
return new static(json_encode($data));
}
/**
* {@inheritdoc}
*/
public function getUrl($api_type, $api_version = NULL) {
if (empty($this->data['urls'][$api_type])) {
return '';
}
$url = $this->data['urls'][$api_type];
return $api_version ? str_replace('{version}', $api_version, $url) : $url;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SalesforceIdentity:: |
protected | property | ||
SalesforceIdentity:: |
public static | function | Static creation method. | |
SalesforceIdentity:: |
public | function |
Given API type and optional API version, return the API url. Overrides SalesforceIdentityInterface:: |
|
SalesforceIdentity:: |
public | function | Handle the identity response from Salesforce. |