You are here

protected function ContentHubConnectionManager::handleResponse in Acquia Content Hub 8.2

Handles incoming response.

A response can either contain a json body which has the data, or a reason phrase containing the error message. In some cases the latter one can also come in an array structure.

Parameters

\Psr\Http\Message\ResponseInterface $response: The response object.

Return value

array The response decoded into array.

1 call to ContentHubConnectionManager::handleResponse()
ContentHubConnectionManager::updateWebhook in src/ContentHubConnectionManager.php
Updates the specified webhook on Content Hub.

File

src/ContentHubConnectionManager.php, line 503

Class

ContentHubConnectionManager
Responsible for connection management actions.

Namespace

Drupal\acquia_contenthub

Code

protected function handleResponse(ResponseInterface $response) : array {
  $body = json_decode((string) $response
    ->getBody(), TRUE);
  if (empty($body)) {
    return [
      'success' => FALSE,
      'error' => [
        'message' => $response
          ->getReasonPhrase(),
      ],
    ];
  }
  return $body;
}