public static function decode(ResponseInterface $response): array
    {
        $contents = $response->getBody()->getContents();
        $decoded = json_decode($contents, true);
        $response->getBody()->rewind();

        if (json_last_error() !== JSON_ERROR_NONE || ! is_array($decoded)) {
            throw new JsonException(json_last_error_msg());
        }

        return $decoded;
    }