You are here

public function NewRelicApiClient::buildUrl in New Relic 8

Same name and namespace in other branches
  1. 2.x src/Client/NewRelicApiClient.php \Drupal\new_relic_rpm\Client\NewRelicApiClient::buildUrl()
  2. 2.0.x src/Client/NewRelicApiClient.php \Drupal\new_relic_rpm\Client\NewRelicApiClient::buildUrl()

Build the URL for the API.

Parameters

string $uri: The base path.

array $filters: Request filters.

Return value

string The full URL.

1 call to NewRelicApiClient::buildUrl()
NewRelicApiClient::request in src/Client/NewRelicApiClient.php
Make the request to newrelic.

File

src/Client/NewRelicApiClient.php, line 229

Class

NewRelicApiClient
Controls the interaction between us and newrelic rest API v2.

Namespace

Drupal\new_relic_rpm\Client

Code

public function buildUrl($uri, array $filters = []) {
  $url = static::API_URL . $uri . '.json';
  if (empty($filters)) {
    return $url;
  }
  $params = [];
  foreach ($filters as $name => $value) {
    $params['filter[' . $name . ']'] = $value;
  }
  return $url . '?' . http_build_query($params);
}