You are here

public function RestClient::objectDescribe in Salesforce Suite 5.0.x

Same name and namespace in other branches
  1. 8.4 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::objectDescribe()
  2. 8.3 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::objectDescribe()

Retrieve all the metadata for an object.

Parameters

string $name: Object type name, E.g., Contact, Account, etc.

bool $reset: Whether to reset the cache and retrieve a fresh version from Salesforce.

Return value

\Drupal\salesforce\Rest\RestResponseDescribe The describe result.

Overrides RestClientInterface::objectDescribe

1 method overrides RestClient::objectDescribe()
TestRestClient::objectDescribe in src/Tests/TestRestClient.php
Hard-code the object descriptions for testing.

File

src/Rest/RestClient.php, line 486

Class

RestClient
Objects, properties, and methods to communicate with the Salesforce REST API.

Namespace

Drupal\salesforce\Rest

Code

public function objectDescribe($name, $reset = FALSE) {
  if (empty($name)) {
    throw new \Exception($this
      ->t('No name provided to describe'));
  }
  if (!$reset && ($cache = $this->cache
    ->get('salesforce:object:' . $name))) {
    return $cache->data;
  }
  else {
    $response = new RestResponseDescribe($this
      ->apiCall("sobjects/{$name}/describe", [], 'GET', TRUE));
    $this->cache
      ->set('salesforce:object:' . $name, $response, $this
      ->getRequestTime() + $this
      ->getShortTermCacheLifetime(), [
      'salesforce',
    ]);
    return $response;
  }
}