protected function responseToArray(ResponseInterface $response): array
    {
        if ($response->getHeaderLine('Content-Type') &&
            0 === strpos($response->getHeaderLine('Content-Type'), 'application/json')) {
            try {
                return (array) $this->jsonDecoder()->decode((string) $response->getBody(), 'json');
            } catch (\UnexpectedValueException $e) {
                throw new InvalidJsonException(
                    $e->getMessage(),
                    $response,
                    $this->getClient()->getJournal()->getLastRequest()
                );
            }
        }
        throw new ApiResponseException(
            $response,
            $this->getClient()->getJournal()->getLastRequest(),
            sprintf('Unable to parse response with %s type. Response body: %s', $response->getHeaderLine('Content-Type') ?: 'unknown', (string) $response->getBody())
        );
    }