You are here

public function AcquiaLiftAPI::deleteChoice in Acquia Lift Connector 7

Deletes a choice from a decision.

Parameters

$agent_name: The name of the agent to delete the choice from.

$point: The name of the decision point containing the decision from which the choice is to be deleted.

$decision_name: The name of the decision that the choice belongs to.

$choice: The name of the choice to delete.

File

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

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

public function deleteChoice($agent_name, $point_name, $decision_name, $choice) {
  $url = $this
    ->generateEndpoint("/agent-api/{$agent_name}/points/{$point_name}/decisions/{$decision_name}/choices/{$choice}");
  $response = $this
    ->httpClient()
    ->delete($url);
  $data = json_decode($response->data, TRUE);
  $vars = array(
    'agent' => $agent_name,
    'decpoint' => $point_name,
    'choicename' => $decision_name . ': ' . $choice,
  );
  $success_msg = 'The decision choice {choicename} for point {decpoint} was deleted from the Acquia Lift campaign {agent}';
  $fail_msg = 'Could not delete decision choice {choicename} for point {decpoint} from the Acquia Lift campaign {agent}';
  if ($response->code == 200 && $data['status'] == 'ok') {
    $this
      ->logger()
      ->log(PersonalizeLogLevel::INFO, $success_msg, $vars);
  }
  else {
    $this
      ->logger()
      ->log(PersonalizeLogLevel::ERROR, $fail_msg, $vars);
    throw new AcquiaLiftException($fail_msg);
  }
}