public function RestClient::getVersions in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::getVersions()
- 8.3 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::getVersions()
Wrapper for "Versions" resource to list information about API releases.
Parameters
bool $reset: Whether to reset cache.
Return value
array Array of all available Salesforce versions, or empty array if version info is not available.
Throws
\GuzzleHttp\Exception\RequestException
Overrides RestClientInterface::getVersions
File
- src/
Rest/ RestClient.php, line 367
Class
- RestClient
- Objects, properties, and methods to communicate with the Salesforce REST API.
Namespace
Drupal\salesforce\RestCode
public function getVersions($reset = FALSE) {
if (!$reset && ($cache = $this->cache
->get('salesforce:versions'))) {
return $cache->data;
}
$versions = [];
if (!$this->authProvider) {
return [];
}
try {
$id = $this->authProvider
->getIdentity();
} catch (IdentityNotFoundException $e) {
return [];
}
$url = str_replace('v{version}/', '', $id
->getUrl('rest'));
$response = new RestResponse($this
->httpRequest($url));
foreach ($response->data as $version) {
$versions[$version['version']] = $version;
}
$this->cache
->set('salesforce:versions', $versions, $this
->getRequestTime() + $this
->getLongTermCacheLifetime(), [
'salesforce',
]);
return $versions;
}