protected function AcquiaLiftAPI::makePutRequest in Acquia Lift Connector 7.2
Makes an Acquia Authenticated PUT request to an API endpoint.
Parameters
string $url: The fully-qualified URL to make the request to.
array $headers: Any headers that need to be added.
array $body: The request body.
string $success_msg: The error message to provide if the request fails.
string $fail_msg: The error message to provide if the request fails.
Throws
File
- includes/
AcquiaLiftAPI.inc, line 838
Class
Code
protected function makePutRequest($url, $headers = array(), $body = NULL, $success_msg = '', $fail_msg = '', $vars = array()) {
// Our authentication needs the JSON string before our HTTP converts the
// array of items. To avoid double work, we encode it here and send it along to both.
$payload = $this
->encodeBody($body);
$nonce = self::nonce();
$timestamp = time();
$this
->prepareRequest('PUT', $url, $headers, $payload, $nonce, $timestamp);
$response = $this
->httpClient()
->put($url, $headers, $payload);
if ($response->code == 200) {
$this
->logger()
->log(PersonalizeLogLevel::INFO, $success_msg, $vars);
}
else {
$this
->handleBadResponse($response->code, $fail_msg, $vars);
}
$this
->authenticateResponse($nonce, $timestamp, $response);
return json_decode($response->data, TRUE);
}