You are here

public function AcquiaLiftAPI::getReportForDateRange in Acquia Lift Connector 7.2

Implements AcquiaLiftLearnReportDataSourceInterface::getReportForDateRange().

Overrides AcquiaLiftLearnReportDataSourceInterface::getReportForDateRange

File

includes/AcquiaLiftAPI.inc, line 453

Class

AcquiaLiftAPI

Code

public function getReportForDateRange($name, $from, $to) {
  if ($from != $to && ($interval = date_diff(date_create($from), date_create($to)))) {
    $days = $interval
      ->format('%d');
  }
  else {
    $days = 1;
  }
  $date = new DateTime($from, new DateTimeZone("UTC"));
  $from = $date
    ->format("Y-m-d\\TH:i:s\\Z");
  $path = "report?campaign_id={$name}&from={$from}&days={$days}";
  $url = $this
    ->generateEndpoint($path);
  $vars = array(
    'name' => $name,
  );
  $fail_msg = 'Could not retrieve report from Acquia Lift';
  return $this
    ->makeGetRequest($url, $this
    ->getStandardHeaders(), $fail_msg, $vars);
}