static function decodeBody(\Psr\Http\Message\ResponseInterface $response) {
        $body = (string) $response->getBody();
        
        $type = $response->getHeader('Content-Type')[0];
        if(\stripos($type, 'text/html') !== false) {
            throw new \RuntimeException('Invalid API response: HTML response body received');
        }
        
        $json = \json_decode($body, true, 512, self::$jsonOptions);
        if($json === null && \json_last_error() !== \JSON_ERROR_NONE) {
            throw new \RuntimeException('Invalid API response: '.\json_last_error_msg());
        }
        
        return $json;
    }