You are here

protected function AcquiaLiftAPI::generateEndpoint in Acquia Lift Connector 7

Same name and namespace in other branches
  1. 7.2 includes/AcquiaLiftAPI.inc \AcquiaLiftAPI::generateEndpoint()

Returns the fully qualified URL to use to connect to API.

This function handles personalizing the endpoint to the client by handling owner code and API keys.

Parameters

$path: The $path to the endpoint at the API base url.

$admin: Boolean indicating whether to use admin key (true) or runtime (false).

30 calls to AcquiaLiftAPI::generateEndpoint()
AcquiaLiftAPI::deleteAgent in includes/acquia_lift.classes.inc
Deletes an agent.
AcquiaLiftAPI::deleteAutoTargetingRule in includes/acquia_lift.classes.inc
Deletes the auto targeting rule for the specified agent.
AcquiaLiftAPI::deleteChoice in includes/acquia_lift.classes.inc
Deletes a choice from a decision.
AcquiaLiftAPI::deleteDecision in includes/acquia_lift.classes.inc
Deletes a decision from an agent.
AcquiaLiftAPI::deleteGoal in includes/acquia_lift.classes.inc
Deletes a goal from an agent.

... See full list

File

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

Class

AcquiaLiftAPI
@file Provides an agent type for Acquia Lift

Code

protected function generateEndpoint($path, $admin = TRUE) {
  $endpoint = $this->api_url . '/';
  $endpoint .= $this->owner_code;
  if (substr($path, 0, 1) !== '/') {
    $endpoint .= '/';
  }
  $endpoint .= $path;

  // Append api key.
  if (strpos($endpoint, '?')) {
    $endpoint .= '&';
  }
  else {
    $endpoint .= '?';
  }
  $key = $admin ? $this
    ->getAdminKey() : $this
    ->getApiKey();
  $endpoint .= "apikey={$key}";
  return $endpoint;
}