Loading src/EntityNotFoundException.php +8 −3 Changes for src/EntityNotFoundException.php: 8 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\salesforce; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Component\Render\FormattableMarkup; use Throwable; /** * EntityNotFoundException extends Drupal\salesforce\Exception Loading @@ -18,7 +19,11 @@ class EntityNotFoundException extends \RuntimeException { protected $entity_type_id; /** * EntityNotFoundException constructor. * * @param $entity_properties * @param $entity_type_id * @param Throwable|NULL $previous */ public function __construct($entity_properties, $entity_type_id, Throwable $previous = NULL) { parent::__construct($this->t('Entity not found. type: %type properties: %props', ['%type' => $entity_type_id, '%props' => var_export($entity_properties, TRUE)]), 0, $previous); Loading @@ -27,21 +32,21 @@ class EntityNotFoundException extends \RuntimeException { } /** * * @return mixed */ public function getEntityProperties() { return $this->entity_properties; } /** * * @return mixed */ public function getEntityTypeId() { return $this->entity_type_id; } /** * * @return \Drupal\Component\Render\FormattableMarkup */ public function getFormattableMessage() { return new FormattableMarkup('Entity not found. type: %type properties: %props', ['%type' => $this->entity_type_id, '%props' => var_export($this->entity_properties, TRUE)]); Loading src/Exception.php +2 −0 Changes for src/Exception.php: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ namespace Drupal\salesforce; use Symfony\Component\Serializer\Exception\ExceptionInterface; /** * Class Exception. * * @package Drupal\salesforce */ class Exception extends \RuntimeException implements ExceptionInterface { Loading src/Rest/RestClient.php +48 −20 Changes for src/Rest/RestClient.php: 48 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ use Drupal\Component\Datetime\TimeInterface; class RestClient implements RestClientInterface { /** * Reponse object. * Response object. * * @var \GuzzleHttp\Psr7\Response */ Loading @@ -48,7 +48,7 @@ class RestClient implements RestClientInterface { /** * Salesforce API URL. * * @var Drupal\Core\Url * @var \Drupal\Core\Url */ protected $url; Loading @@ -69,7 +69,7 @@ class RestClient implements RestClientInterface { /** * The cache service. * * @var Drupal\Core\Cache\CacheBackendInterface * @var \Drupal\Core\Cache\CacheBackendInterface */ protected $cache; Loading Loading @@ -186,8 +186,11 @@ class RestClient implements RestClientInterface { * @param string $method * Method to initiate the call, such as GET or POST. Defaults to GET. * * @return GuzzleHttp\Psr7\Response * @return \GuzzleHttp\Psr7\Response * Response object. * * @throws \Exception * @throws \GuzzleHttp\Exception\RequestException */ protected function apiHttpRequest($url, array $params, $method) { if (!$this->getAccessToken()) { Loading @@ -211,6 +214,7 @@ class RestClient implements RestClientInterface { * * @param string $url * @return mixed * @throws \Exception */ public function httpRequestRaw($url) { if (!$this->getAccessToken()) { Loading @@ -236,11 +240,11 @@ class RestClient implements RestClientInterface { * @param string $method * Method to initiate the call, such as GET or POST. Defaults to GET. * * @throws RequestException * Request exception. * * @return GuzzleHttp\Psr7\Response * @return \GuzzleHttp\Psr7\Response * Response object. * * @throws \GuzzleHttp\Exception\RequestException * Request exception. */ protected function httpRequest($url, $data = NULL, array $headers = [], $method = 'GET') { // Build the request, including path and headers. Internal use. Loading Loading @@ -344,6 +348,9 @@ class RestClient implements RestClientInterface { * * @param bool $use_latest * @param int $version * * @throws \Exception * @throws \GuzzleHttp\Exception\RequestException */ public function setApiVersion($use_latest = TRUE, $version = NULL) { if ($use_latest) { Loading @@ -352,7 +359,7 @@ class RestClient implements RestClientInterface { else { $versions = $this->getVersions(); if (empty($versions[$version])) { throw new Exception("Version $version is not available."); throw new \Exception("Version $version is not available."); } $version = $versions[$version]; $this->config->set('rest_api_version', $version); Loading Loading @@ -415,6 +422,8 @@ class RestClient implements RestClientInterface { * * @param string $url * URL to set. * * @return $this */ public function setInstanceUrl($url) { $this->state->set('salesforce.instance_url', $url); Loading @@ -434,6 +443,8 @@ class RestClient implements RestClientInterface { * * @param string $token * Access token from Salesforce. * * @return $this */ public function setAccessToken($token) { $this->state->set('salesforce.access_token', $token); Loading @@ -452,6 +463,8 @@ class RestClient implements RestClientInterface { * * @param string $token * Refresh token from Salesforce. * * @return $this */ public function setRefreshToken($token) { $this->state->set('salesforce.refresh_token', $token); Loading Loading @@ -488,9 +501,13 @@ class RestClient implements RestClientInterface { /** * Helper callback for OAuth handshake, and refreshToken() * * @param GuzzleHttp\Psr7\Response $response * @param \GuzzleHttp\Psr7\Response $response * Response object from refreshToken or authToken endpoints. * * @return $this * * @throws \Exception * * @see SalesforceController::oauthCallback() * @see self::refreshToken() */ Loading Loading @@ -519,7 +536,10 @@ class RestClient implements RestClientInterface { * @param string $id * Identity URL. * * @throws Exception * @return $this * * @throws \Exception * @throws \GuzzleHttp\Exception\RequestException */ public function initializeIdentity($id) { $headers = [ Loading Loading @@ -563,7 +583,7 @@ class RestClient implements RestClientInterface { * @return string * Redirect URL. * * @see Drupal\salesforce\Controller\SalesforceController * @see \Drupal\salesforce\Controller\SalesforceController */ public function getAuthCallbackUrl() { return Url::fromRoute('salesforce.oauth_callback', [], [ Loading Loading @@ -595,12 +615,14 @@ class RestClient implements RestClientInterface { /** * Wrapper for "Versions" resource to list information about API releases. * * @param $reset * @param bool $reset * Whether to reset cache. * * @return array * Array of all available Salesforce versions, or empty array if version * info is not available. * * @throws \GuzzleHttp\Exception\RequestException */ public function getVersions($reset = FALSE) { if (!$reset && ($cache = $this->cache->get('salesforce:versions'))) { Loading Loading @@ -726,9 +748,11 @@ class RestClient implements RestClientInterface { * @param bool $reset * Whether to reset the cache and retrieve a fresh version from Salesforce. * * @return RestResponse_Describe * @return \Drupal\salesforce\Rest\RestResponse_Describe * Salesforce object description object. * * @throws \Exception * * @addtogroup salesforce_apicalls */ public function objectDescribe($name, $reset = FALSE) { Loading @@ -754,7 +778,7 @@ class RestClient implements RestClientInterface { * @param array $params * Values of the fields to set for the object. * * @return Drupal\salesforce\SFID * @return \Drupal\salesforce\SFID * Salesforce ID object. * * @addtogroup salesforce_apicalls Loading @@ -781,8 +805,7 @@ class RestClient implements RestClientInterface { * @param array $params * Values of the fields to set for the object. * * @return mixed * Drupal\salesforce\SFID or NULL. * @return \Drupal\salesforce\SFID|null * * @addtogroup salesforce_apicalls */ Loading Loading @@ -876,6 +899,8 @@ class RestClient implements RestClientInterface { * (optional) If TRUE, 404 response code will cause RequestException to be * thrown. Otherwise, hide those errors. Default is FALSE. * * @throws \Exception * * @addtogroup salesforce_apicalls */ public function objectDelete($name, $id, $throw_exception = FALSE) { Loading Loading @@ -909,7 +934,7 @@ class RestClient implements RestClientInterface { /** * Return a list of available resources for the configured API version. * * @return Drupal\salesforce\Rest\RestResponse_Resources * @return \Drupal\salesforce\Rest\RestResponse_Resources * * @addtogroup salesforce_apicalls */ Loading Loading @@ -965,6 +990,8 @@ class RestClient implements RestClientInterface { * @return array * If $name is given, an array of record types indexed by developer name. * Otherwise, an array of record type arrays, indexed by object type name. * * @throws \Exception */ public function getRecordTypes($name = NULL, $reset = FALSE) { if (!$reset && ($cache = $this->cache->get('salesforce:record_types'))) { Loading Loading @@ -999,11 +1026,12 @@ class RestClient implements RestClientInterface { * Object type name, E.g., Contact, Account. * @param string $devname * RecordType DeveloperName, e.g. Donation, Membership, etc. * @param bool $reset * * @return \Drupal\salesforce\SFID * The Salesforce ID of the given Record Type, or null. * * @throws Exception if record type not found * @throws \Exception if record type not found */ public function getRecordTypeIdByDeveloperName($name, $devname, $reset = FALSE) { $record_types = $this->getRecordTypes(); Loading @@ -1022,7 +1050,7 @@ class RestClient implements RestClientInterface { * @return string * Object type's name. * * @throws Exception * @throws \Exception * If SFID doesn't match any object type. */ public function getObjectTypeName(SFID $id) { Loading src/Rest/RestClientInterface.php +15 −18 Changes for src/Rest/RestClientInterface.php: 15 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -42,9 +42,9 @@ interface RestClientInterface { * Defaults to FALSE for backwards compatibility. * * @return mixed * Reponce object or response data. * Response object or response data. * * @throws GuzzleHttp\Exception\RequestException * @throws \GuzzleHttp\Exception\RequestException */ public function apiCall($path, array $params = [], $method = 'GET', $returnObject = FALSE); Loading Loading @@ -171,14 +171,14 @@ interface RestClientInterface { /** * Refresh access token based on the refresh token. * * @throws Exception * @throws \Exception */ public function refreshToken(); /** * Helper callback for OAuth handshake, and refreshToken() * * @param GuzzleHttp\Psr7\Response $response * @param \GuzzleHttp\Psr7\Response $response * Response object from refreshToken or authToken endpoints. * * @see SalesforceController::oauthCallback() Loading @@ -192,7 +192,7 @@ interface RestClientInterface { * @param string $id * Identity URL. * * @throws Exception * @throws \Exception */ public function initializeIdentity($id); Loading @@ -215,7 +215,7 @@ interface RestClientInterface { * @return string * Redirect URL. * * @see Drupal\salesforce\Controller\SalesforceController * @see \Drupal\salesforce\Controller\SalesforceController */ public function getAuthCallbackUrl(); Loading Loading @@ -291,14 +291,14 @@ interface RestClientInterface { public function queryMore(SelectQueryResult $results); /** * Retreieve all the metadata for an object. * Retrieve all the metadata for an object. * * @param string $name * Object type name, E.g., Contact, Account, etc. * @param bool $reset * Whether to reset the cache and retrieve a fresh version from Salesforce. * * @return RestResponse_Describe * @return \Drupal\salesforce\Rest\RestResponse_Describe * * @addtogroup salesforce_apicalls */ Loading @@ -312,7 +312,7 @@ interface RestClientInterface { * @param array $params * Values of the fields to set for the object. * * @return Drupal\salesforce\SFID * @return \Drupal\salesforce\SFID * * @addtogroup salesforce_apicalls */ Loading @@ -334,7 +334,7 @@ interface RestClientInterface { * @param array $params * Values of the fields to set for the object. * * @return Drupal\salesforce\SFID or NULL * @return \Drupal\salesforce\SFID|null * * @addtogroup salesforce_apicalls */ Loading Loading @@ -365,7 +365,7 @@ interface RestClientInterface { * @param string $id * Salesforce id of the object. * * @return SObject * @return \Drupal\salesforce\SObject * Object of the requested Salesforce object. * * @addtogroup salesforce_apicalls Loading @@ -382,7 +382,7 @@ interface RestClientInterface { * @param string $value * Value of external id. * * @return SObject * @return \Drupal\salesforce\SObject * Object of the requested Salesforce object. * * @addtogroup salesforce_apicalls Loading @@ -397,7 +397,6 @@ interface RestClientInterface { * Object type name, E.g., Contact, Account. * @param string $id * Salesforce id of the object. * * @pararm bool $throw_exception * (optional) If TRUE, 404 response code will cause RequestException to be * thrown. Otherwise, hide those errors. Default is FALSE. Loading Loading @@ -427,7 +426,7 @@ interface RestClientInterface { /** * Return a list of available resources for the configured API version. * * @return Drupal\salesforce\Rest\RestResponse_Resources * @return \Drupal\salesforce\Rest\RestResponse_Resources * * @addtogroup salesforce_apicalls */ Loading @@ -439,11 +438,9 @@ interface RestClientInterface { * * @param string $name * Object type name, E.g., Contact, Account. * * @param int $start * Unix timestamp for older timeframe for updates. * Defaults to "-29 days" if empty. * * @param int $end * unix timestamp for end of timeframe for updates. * Defaults to now if empty. Loading Loading @@ -488,7 +485,7 @@ interface RestClientInterface { * @return \Drupal\salesforce\SFID * The Salesforce ID of the given Record Type, or null. * * @throws Exception if record type not found * @throws \Exception if record type not found */ public function getRecordTypeIdByDeveloperName($name, $devname, $reset = FALSE); Loading @@ -499,7 +496,7 @@ interface RestClientInterface { * * @return string * * @throws Exception if SFID doesn't match any object type * @throws \Exception if SFID doesn't match any object type */ public function getObjectTypeName(SFID $id); Loading src/Rest/RestException.php +10 −3 Changes for src/Rest/RestException.php: 10 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,14 +6,21 @@ use Symfony\Component\Serializer\Exception\ExceptionInterface; use Psr\Http\Message\ResponseInterface; /** * Class RestException. * * @package Drupal\salesforce\Rest */ class RestException extends \RuntimeException implements ExceptionInterface { protected $response; /** * RestException constructor. * * @param \Psr\Http\Message\ResponseInterface|NULL $response * @param string $message * @param int $code * @param \Exception|NULL $previous */ public function __construct(ResponseInterface $response = NULL, $message = "", $code = 0, \Exception $previous = NULL) { $this->response = $response; Loading @@ -22,18 +29,18 @@ class RestException extends \RuntimeException implements ExceptionInterface { } /** * * @return NULL|\Psr\Http\Message\ResponseInterface */ public function getResponse() { return $this->response; } /** * * @return string|null */ public function getResponseBody() { if (!$this->response) { return; return NULL; } $body = $this->response->getBody(); if ($body) { Loading Loading
src/EntityNotFoundException.php +8 −3 Changes for src/EntityNotFoundException.php: 8 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\salesforce; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Component\Render\FormattableMarkup; use Throwable; /** * EntityNotFoundException extends Drupal\salesforce\Exception Loading @@ -18,7 +19,11 @@ class EntityNotFoundException extends \RuntimeException { protected $entity_type_id; /** * EntityNotFoundException constructor. * * @param $entity_properties * @param $entity_type_id * @param Throwable|NULL $previous */ public function __construct($entity_properties, $entity_type_id, Throwable $previous = NULL) { parent::__construct($this->t('Entity not found. type: %type properties: %props', ['%type' => $entity_type_id, '%props' => var_export($entity_properties, TRUE)]), 0, $previous); Loading @@ -27,21 +32,21 @@ class EntityNotFoundException extends \RuntimeException { } /** * * @return mixed */ public function getEntityProperties() { return $this->entity_properties; } /** * * @return mixed */ public function getEntityTypeId() { return $this->entity_type_id; } /** * * @return \Drupal\Component\Render\FormattableMarkup */ public function getFormattableMessage() { return new FormattableMarkup('Entity not found. type: %type properties: %props', ['%type' => $this->entity_type_id, '%props' => var_export($this->entity_properties, TRUE)]); Loading
src/Exception.php +2 −0 Changes for src/Exception.php: 2 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ namespace Drupal\salesforce; use Symfony\Component\Serializer\Exception\ExceptionInterface; /** * Class Exception. * * @package Drupal\salesforce */ class Exception extends \RuntimeException implements ExceptionInterface { Loading
src/Rest/RestClient.php +48 −20 Changes for src/Rest/RestClient.php: 48 added lines, 20 removed lines. Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ use Drupal\Component\Datetime\TimeInterface; class RestClient implements RestClientInterface { /** * Reponse object. * Response object. * * @var \GuzzleHttp\Psr7\Response */ Loading @@ -48,7 +48,7 @@ class RestClient implements RestClientInterface { /** * Salesforce API URL. * * @var Drupal\Core\Url * @var \Drupal\Core\Url */ protected $url; Loading @@ -69,7 +69,7 @@ class RestClient implements RestClientInterface { /** * The cache service. * * @var Drupal\Core\Cache\CacheBackendInterface * @var \Drupal\Core\Cache\CacheBackendInterface */ protected $cache; Loading Loading @@ -186,8 +186,11 @@ class RestClient implements RestClientInterface { * @param string $method * Method to initiate the call, such as GET or POST. Defaults to GET. * * @return GuzzleHttp\Psr7\Response * @return \GuzzleHttp\Psr7\Response * Response object. * * @throws \Exception * @throws \GuzzleHttp\Exception\RequestException */ protected function apiHttpRequest($url, array $params, $method) { if (!$this->getAccessToken()) { Loading @@ -211,6 +214,7 @@ class RestClient implements RestClientInterface { * * @param string $url * @return mixed * @throws \Exception */ public function httpRequestRaw($url) { if (!$this->getAccessToken()) { Loading @@ -236,11 +240,11 @@ class RestClient implements RestClientInterface { * @param string $method * Method to initiate the call, such as GET or POST. Defaults to GET. * * @throws RequestException * Request exception. * * @return GuzzleHttp\Psr7\Response * @return \GuzzleHttp\Psr7\Response * Response object. * * @throws \GuzzleHttp\Exception\RequestException * Request exception. */ protected function httpRequest($url, $data = NULL, array $headers = [], $method = 'GET') { // Build the request, including path and headers. Internal use. Loading Loading @@ -344,6 +348,9 @@ class RestClient implements RestClientInterface { * * @param bool $use_latest * @param int $version * * @throws \Exception * @throws \GuzzleHttp\Exception\RequestException */ public function setApiVersion($use_latest = TRUE, $version = NULL) { if ($use_latest) { Loading @@ -352,7 +359,7 @@ class RestClient implements RestClientInterface { else { $versions = $this->getVersions(); if (empty($versions[$version])) { throw new Exception("Version $version is not available."); throw new \Exception("Version $version is not available."); } $version = $versions[$version]; $this->config->set('rest_api_version', $version); Loading Loading @@ -415,6 +422,8 @@ class RestClient implements RestClientInterface { * * @param string $url * URL to set. * * @return $this */ public function setInstanceUrl($url) { $this->state->set('salesforce.instance_url', $url); Loading @@ -434,6 +443,8 @@ class RestClient implements RestClientInterface { * * @param string $token * Access token from Salesforce. * * @return $this */ public function setAccessToken($token) { $this->state->set('salesforce.access_token', $token); Loading @@ -452,6 +463,8 @@ class RestClient implements RestClientInterface { * * @param string $token * Refresh token from Salesforce. * * @return $this */ public function setRefreshToken($token) { $this->state->set('salesforce.refresh_token', $token); Loading Loading @@ -488,9 +501,13 @@ class RestClient implements RestClientInterface { /** * Helper callback for OAuth handshake, and refreshToken() * * @param GuzzleHttp\Psr7\Response $response * @param \GuzzleHttp\Psr7\Response $response * Response object from refreshToken or authToken endpoints. * * @return $this * * @throws \Exception * * @see SalesforceController::oauthCallback() * @see self::refreshToken() */ Loading Loading @@ -519,7 +536,10 @@ class RestClient implements RestClientInterface { * @param string $id * Identity URL. * * @throws Exception * @return $this * * @throws \Exception * @throws \GuzzleHttp\Exception\RequestException */ public function initializeIdentity($id) { $headers = [ Loading Loading @@ -563,7 +583,7 @@ class RestClient implements RestClientInterface { * @return string * Redirect URL. * * @see Drupal\salesforce\Controller\SalesforceController * @see \Drupal\salesforce\Controller\SalesforceController */ public function getAuthCallbackUrl() { return Url::fromRoute('salesforce.oauth_callback', [], [ Loading Loading @@ -595,12 +615,14 @@ class RestClient implements RestClientInterface { /** * Wrapper for "Versions" resource to list information about API releases. * * @param $reset * @param bool $reset * Whether to reset cache. * * @return array * Array of all available Salesforce versions, or empty array if version * info is not available. * * @throws \GuzzleHttp\Exception\RequestException */ public function getVersions($reset = FALSE) { if (!$reset && ($cache = $this->cache->get('salesforce:versions'))) { Loading Loading @@ -726,9 +748,11 @@ class RestClient implements RestClientInterface { * @param bool $reset * Whether to reset the cache and retrieve a fresh version from Salesforce. * * @return RestResponse_Describe * @return \Drupal\salesforce\Rest\RestResponse_Describe * Salesforce object description object. * * @throws \Exception * * @addtogroup salesforce_apicalls */ public function objectDescribe($name, $reset = FALSE) { Loading @@ -754,7 +778,7 @@ class RestClient implements RestClientInterface { * @param array $params * Values of the fields to set for the object. * * @return Drupal\salesforce\SFID * @return \Drupal\salesforce\SFID * Salesforce ID object. * * @addtogroup salesforce_apicalls Loading @@ -781,8 +805,7 @@ class RestClient implements RestClientInterface { * @param array $params * Values of the fields to set for the object. * * @return mixed * Drupal\salesforce\SFID or NULL. * @return \Drupal\salesforce\SFID|null * * @addtogroup salesforce_apicalls */ Loading Loading @@ -876,6 +899,8 @@ class RestClient implements RestClientInterface { * (optional) If TRUE, 404 response code will cause RequestException to be * thrown. Otherwise, hide those errors. Default is FALSE. * * @throws \Exception * * @addtogroup salesforce_apicalls */ public function objectDelete($name, $id, $throw_exception = FALSE) { Loading Loading @@ -909,7 +934,7 @@ class RestClient implements RestClientInterface { /** * Return a list of available resources for the configured API version. * * @return Drupal\salesforce\Rest\RestResponse_Resources * @return \Drupal\salesforce\Rest\RestResponse_Resources * * @addtogroup salesforce_apicalls */ Loading Loading @@ -965,6 +990,8 @@ class RestClient implements RestClientInterface { * @return array * If $name is given, an array of record types indexed by developer name. * Otherwise, an array of record type arrays, indexed by object type name. * * @throws \Exception */ public function getRecordTypes($name = NULL, $reset = FALSE) { if (!$reset && ($cache = $this->cache->get('salesforce:record_types'))) { Loading Loading @@ -999,11 +1026,12 @@ class RestClient implements RestClientInterface { * Object type name, E.g., Contact, Account. * @param string $devname * RecordType DeveloperName, e.g. Donation, Membership, etc. * @param bool $reset * * @return \Drupal\salesforce\SFID * The Salesforce ID of the given Record Type, or null. * * @throws Exception if record type not found * @throws \Exception if record type not found */ public function getRecordTypeIdByDeveloperName($name, $devname, $reset = FALSE) { $record_types = $this->getRecordTypes(); Loading @@ -1022,7 +1050,7 @@ class RestClient implements RestClientInterface { * @return string * Object type's name. * * @throws Exception * @throws \Exception * If SFID doesn't match any object type. */ public function getObjectTypeName(SFID $id) { Loading
src/Rest/RestClientInterface.php +15 −18 Changes for src/Rest/RestClientInterface.php: 15 added lines, 18 removed lines. Original line number Diff line number Diff line Loading @@ -42,9 +42,9 @@ interface RestClientInterface { * Defaults to FALSE for backwards compatibility. * * @return mixed * Reponce object or response data. * Response object or response data. * * @throws GuzzleHttp\Exception\RequestException * @throws \GuzzleHttp\Exception\RequestException */ public function apiCall($path, array $params = [], $method = 'GET', $returnObject = FALSE); Loading Loading @@ -171,14 +171,14 @@ interface RestClientInterface { /** * Refresh access token based on the refresh token. * * @throws Exception * @throws \Exception */ public function refreshToken(); /** * Helper callback for OAuth handshake, and refreshToken() * * @param GuzzleHttp\Psr7\Response $response * @param \GuzzleHttp\Psr7\Response $response * Response object from refreshToken or authToken endpoints. * * @see SalesforceController::oauthCallback() Loading @@ -192,7 +192,7 @@ interface RestClientInterface { * @param string $id * Identity URL. * * @throws Exception * @throws \Exception */ public function initializeIdentity($id); Loading @@ -215,7 +215,7 @@ interface RestClientInterface { * @return string * Redirect URL. * * @see Drupal\salesforce\Controller\SalesforceController * @see \Drupal\salesforce\Controller\SalesforceController */ public function getAuthCallbackUrl(); Loading Loading @@ -291,14 +291,14 @@ interface RestClientInterface { public function queryMore(SelectQueryResult $results); /** * Retreieve all the metadata for an object. * Retrieve all the metadata for an object. * * @param string $name * Object type name, E.g., Contact, Account, etc. * @param bool $reset * Whether to reset the cache and retrieve a fresh version from Salesforce. * * @return RestResponse_Describe * @return \Drupal\salesforce\Rest\RestResponse_Describe * * @addtogroup salesforce_apicalls */ Loading @@ -312,7 +312,7 @@ interface RestClientInterface { * @param array $params * Values of the fields to set for the object. * * @return Drupal\salesforce\SFID * @return \Drupal\salesforce\SFID * * @addtogroup salesforce_apicalls */ Loading @@ -334,7 +334,7 @@ interface RestClientInterface { * @param array $params * Values of the fields to set for the object. * * @return Drupal\salesforce\SFID or NULL * @return \Drupal\salesforce\SFID|null * * @addtogroup salesforce_apicalls */ Loading Loading @@ -365,7 +365,7 @@ interface RestClientInterface { * @param string $id * Salesforce id of the object. * * @return SObject * @return \Drupal\salesforce\SObject * Object of the requested Salesforce object. * * @addtogroup salesforce_apicalls Loading @@ -382,7 +382,7 @@ interface RestClientInterface { * @param string $value * Value of external id. * * @return SObject * @return \Drupal\salesforce\SObject * Object of the requested Salesforce object. * * @addtogroup salesforce_apicalls Loading @@ -397,7 +397,6 @@ interface RestClientInterface { * Object type name, E.g., Contact, Account. * @param string $id * Salesforce id of the object. * * @pararm bool $throw_exception * (optional) If TRUE, 404 response code will cause RequestException to be * thrown. Otherwise, hide those errors. Default is FALSE. Loading Loading @@ -427,7 +426,7 @@ interface RestClientInterface { /** * Return a list of available resources for the configured API version. * * @return Drupal\salesforce\Rest\RestResponse_Resources * @return \Drupal\salesforce\Rest\RestResponse_Resources * * @addtogroup salesforce_apicalls */ Loading @@ -439,11 +438,9 @@ interface RestClientInterface { * * @param string $name * Object type name, E.g., Contact, Account. * * @param int $start * Unix timestamp for older timeframe for updates. * Defaults to "-29 days" if empty. * * @param int $end * unix timestamp for end of timeframe for updates. * Defaults to now if empty. Loading Loading @@ -488,7 +485,7 @@ interface RestClientInterface { * @return \Drupal\salesforce\SFID * The Salesforce ID of the given Record Type, or null. * * @throws Exception if record type not found * @throws \Exception if record type not found */ public function getRecordTypeIdByDeveloperName($name, $devname, $reset = FALSE); Loading @@ -499,7 +496,7 @@ interface RestClientInterface { * * @return string * * @throws Exception if SFID doesn't match any object type * @throws \Exception if SFID doesn't match any object type */ public function getObjectTypeName(SFID $id); Loading
src/Rest/RestException.php +10 −3 Changes for src/Rest/RestException.php: 10 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -6,14 +6,21 @@ use Symfony\Component\Serializer\Exception\ExceptionInterface; use Psr\Http\Message\ResponseInterface; /** * Class RestException. * * @package Drupal\salesforce\Rest */ class RestException extends \RuntimeException implements ExceptionInterface { protected $response; /** * RestException constructor. * * @param \Psr\Http\Message\ResponseInterface|NULL $response * @param string $message * @param int $code * @param \Exception|NULL $previous */ public function __construct(ResponseInterface $response = NULL, $message = "", $code = 0, \Exception $previous = NULL) { $this->response = $response; Loading @@ -22,18 +29,18 @@ class RestException extends \RuntimeException implements ExceptionInterface { } /** * * @return NULL|\Psr\Http\Message\ResponseInterface */ public function getResponse() { return $this->response; } /** * * @return string|null */ public function getResponseBody() { if (!$this->response) { return; return NULL; } $body = $this->response->getBody(); if ($body) { Loading