public static function request($method, $params = null)
    {
        $url = self::getUrl($method);

        $request_method = self::getRequestMethodName();
        $response_body = self::$request_method($url, $params);
        $response = json_decode($response_body);

        if (!is_object($response))
            throw new Error("Invalid server response: $response_body");

        if (isset($response->error))
            throw new Error($response->error->message);

        return $response;
    }