You are here

protected function RestClient::updateApiUsage in Salesforce Suite 5.0.x

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

Helper to extract API Usage info from response header and write to state.

Parameters

\Drupal\salesforce\Rest\RestResponse $response: A REST API response.

1 call to RestClient::updateApiUsage()
RestClient::apiCall in src/Rest/RestClient.php
Make a call to the Salesforce REST API.

File

src/Rest/RestClient.php, line 405

Class

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

Namespace

Drupal\salesforce\Rest

Code

protected function updateApiUsage(RestResponse $response) {
  if ($limit_info = $response
    ->getHeader('Sforce-Limit-Info')) {
    if (is_array($limit_info)) {
      $limit_info = reset($limit_info);
    }
    $this->state
      ->set('salesforce.usage', $limit_info);
  }
}