You are here

public function AcquiaLiftAPI::saveFixedTargetingMapping in Acquia Lift Connector 7

Saves a mapping of targeting features to options for explicit targeting.

Parameters

$agent_name: The name of the agent this mapping is for.

$point_name: The decision point this mapping is for.

$map: An array of associative arrays with teh following keys:

  • feature A string corresponding to a feature name
  • decision A string in the form decision_name:option_id

Return value

array An array containing the response from Acquia Lift.

Throws

AcquiaLiftException

File

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

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

public function saveFixedTargetingMapping($agent_name, $point_name, $map) {
  $url = $this
    ->generateEndpoint("/agent-api/{$agent_name}/points/{$point_name}/fixed-targeting");
  $response = $this
    ->httpClient()
    ->put($url, array(
    'Content-Type' => 'application/json; charset=utf-8',
    'Accept' => 'application/json',
  ), $map);
  $data = json_decode($response->data, TRUE);
  $vars = array(
    'agent' => $agent_name,
    'decpoint' => $point_name,
  );
  $success_msg = 'The fixed targeting mapping for point {decpoint} was successfully saved for campaign {agent}';
  $fail_msg = 'The fixed targeting mapping for point {decpoint} could not be saved for campaign {agent}';
  if ($response->code == 200 && $data['status'] == 'ok') {
    $this
      ->logger()
      ->log(PersonalizeLogLevel::INFO, $success_msg, $vars);
  }
  else {
    $this
      ->handleBadResponse($response->code, $fail_msg, $vars);
  }
}