private function decodeResponse(Response $response)
    {
        $data = json_decode($response->getBody()->read($response->getBody()->getSize()), true);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new ClientException('Unable to parse response body into JSON: ' . json_last_error());
        }

        return $data === null ? array() : $data;
    }