You are here

public function AcquiaLiftAPI::deleteAutoTargetingRule in Acquia Lift Connector 7

Deletes the auto targeting rule for the specified agent.

Parameters

$agent_name: The name of the agent whose targeting rule is to be deleted.

File

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

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

public function deleteAutoTargetingRule($agent_name) {
  $rule_name = $agent_name . '-auto-targeting';
  $url = $this
    ->generateEndpoint("/transform-rule/{$rule_name}");
  $response = $this
    ->httpClient()
    ->delete($url, array(
    'Content-Type' => 'application/json; charset=utf-8',
    'Accept' => 'application/json',
  ));
  $vars = array(
    'agent' => $agent_name,
  );
  $success_msg = 'The targeting rule for campaign {agent} was deleted successfully';
  $fail_msg = 'The targeting rule could not be deleted for campaign {agent}';
  if ($response->code == 200) {
    $this
      ->logger()
      ->log(PersonalizeLogLevel::INFO, $success_msg, $vars);
  }
  else {
    $this
      ->handleBadResponse($response->code, $fail_msg, $vars);
  }
}