You are here

public function AcquiaLiftAPI::deleteGoal in Acquia Lift Connector 7

Deletes a goal from an agent.

Parameters

$agent_name: The agent to delete the goal from.

$goal_name: The name of the goal.

File

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

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

public function deleteGoal($agent_name, $goal_name) {
  $url = $this
    ->generateEndpoint("/agent-api/{$agent_name}/goals/{$goal_name}");
  $response = $this
    ->httpClient()
    ->delete($url);
  $vars = array(
    'agent' => $agent_name,
    'goalname' => $goal_name,
  );
  $success_msg = 'The goal {goalname} was deleted from the Acquia Lift campaign {agent}';
  $fail_msg = 'Could not delete the goal {goalname} from the Acquia Lift campaign {agent}';
  if ($response->code == 200) {
    $this
      ->logger()
      ->log(PersonalizeLogLevel::INFO, $success_msg, $vars);
  }
  else {
    $this
      ->handleBadResponse($response->code, $fail_msg, $vars);
  }
}