public function Client::nspiCall in Acquia Connector 3.x
Same name and namespace in other branches
- 8.2 src/Client.php \Drupal\acquia_connector\Client::nspiCall()
- 8 src/Client.php \Drupal\acquia_connector\Client::nspiCall()
Prepare and send a REST request to Acquia with an authenticator.
Parameters
string $method: HTTP method.
array $params: Parameters to pass to the NSPI.
string $key: Acquia Key or NULL.
Return value
array NSPI response.
Throws
2 calls to Client::nspiCall()
- Client::getSubscription in src/
Client.php - Get Acquia subscription from Acquia.
- Client::sendNspi in src/
Client.php - Get Acquia subscription from Acquia.
File
- src/
Client.php, line 431
Class
- Client
- Acquia connector client.
Namespace
Drupal\acquia_connectorCode
public function nspiCall($method, array $params, $key = NULL) {
if (empty($key)) {
$storage = new Storage();
$key = $storage
->getKey();
}
// Used in HMAC validation.
$params['rpc_version'] = ACQUIA_CONNECTOR_ACQUIA_SPI_DATA_VERSION;
$ip = \Drupal::request()->server
->get('SERVER_ADDR', '');
$host = \Drupal::request()->server
->get('HTTP_HOST', '');
$ssl = \Drupal::request()
->isSecure();
$data = [
'authenticator' => $this
->buildAuthenticator($key, \Drupal::time()
->getRequestTime(), $params),
'ip' => $ip,
'host' => $host,
'ssl' => $ssl,
'body' => $params,
];
$data['result'] = $this
->request('POST', $method, $data);
return $data;
}