You are here

public function ALProfilesAPI::deleteEvent in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 acquia_lift_profiles/includes/acquia_lift_profiles.classes.inc \ALProfilesAPI::deleteEvent()

Deletes an event from Acquia Lift Profiles

Parameters

$event_name: The name of the event.

Throws

ALProfilesException

File

acquia_lift_profiles/includes/acquia_lift_profiles.classes.inc, line 377
Provides an agent type for Acquia Lift Profiles

Class

ALProfilesAPI
@file Provides an agent type for Acquia Lift Profiles

Code

public function deleteEvent($event_name) {

  // First get our Authorization header.
  $url = $this
    ->generateEndpoint('events/' . $event_name);
  $params = array();
  $querystring = '';
  if (!empty($this->customerSite)) {
    $params['customerSite'] = $this->customerSite;
    $querystring = '?customerSite=' . $this->customerSite;
  }
  $auth_header = $this
    ->getAuthHeader('DELETE', $url, $params);
  $response = $this
    ->httpClient()
    ->delete($url . $querystring, array(
    'Authorization' => $auth_header,
  ));
  $vars = array(
    'eventname' => $event_name,
  );
  $success_msg = 'The event {eventname} was deleted from Acquia Lift Profiles';
  $fail_msg = 'Could not delete event {eventname} from Acquia Lift Profiles';
  if ($response->code == 200) {
    $this
      ->logger()
      ->log(PersonalizeLogLevel::INFO, $success_msg, $vars);
  }
  else {
    $this
      ->logger()
      ->log(PersonalizeLogLevel::ERROR, $fail_msg, $vars);
    throw new ALProfilesException($fail_msg);
  }
}