You are here

public function AcquiaLiftAPI::getAPICallsForPeriod in Acquia Lift Connector 7

Returns the number or runtime API calls that were made during the specified period.

Parameters

$date_start: The start date in the format YYYY-MM-DD.

$date_end: The end date in the format YYYY-MM-DD.

Return value

int

2 calls to AcquiaLiftAPI::getAPICallsForPeriod()
AcquiaLiftAPI::getCallsForMonthToDate in includes/acquia_lift.classes.inc
Returns counts of API calls from the 1st to the date provided.
AcquiaLiftAPI::getCallsForPreviousMonth in includes/acquia_lift.classes.inc
Returns the counts of API calls for the month prior to the date provided.

File

includes/acquia_lift.classes.inc, line 1248
Provides an agent type for Acquia Lift

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

public function getAPICallsForPeriod($date_start, $date_end) {
  $date_str = $this
    ->getDateString($date_start, $date_end);
  $url = $this
    ->generateEndpoint("/-/report/system-usage{$date_str}");
  $headers = array(
    'Accept' => 'application/json',
  );
  $response = $this
    ->httpClient()
    ->get($url, $headers);
  if ($response->code != 200) {
    $this
      ->handleBadResponse($response->code, 'Problem retrieving API call counts.');
    return array();
  }
  $result = json_decode($response->data, TRUE);
  if (!isset($result['data']) || !isset($result['data'][0]) || !isset($result['data'][0]['calls'])) {
    return array();
  }
  return $result['data'][0]['calls'];
}