def request(self, method, path, **options):
        """
        Dispatches a request to the Razorpay HTTP API
        """
        options = self._update_user_agent_header(options)

        url = "{}{}".format(self.base_url, path)

        response = getattr(self.session, method)(url, auth=self.auth,
                                                 verify=self.cert_path,
                                                 **options)
        if ((response.status_code >= HTTP_STATUS_CODE.OK) and
                (response.status_code < HTTP_STATUS_CODE.REDIRECT)):
            return response.json()
        else:
            msg = ""
            code = ""
            json_response = response.json()
            if 'error' in json_response:
                if 'description' in json_response['error']:
                    msg = json_response['error']['description']
                if 'code' in json_response['error']:
                    code = str(json_response['error']['code'])

            if str.upper(code) == ERROR_CODE.BAD_REQUEST_ERROR:
                raise BadRequestError(msg)
            elif str.upper(code) == ERROR_CODE.GATEWAY_ERROR:
                raise GatewayError(msg)
            elif str.upper(code) == ERROR_CODE.SERVER_ERROR:
                raise ServerError(msg)
            else:
                raise ServerError(msg)
def request ( self , method , path , ** options ) : options = self . _update_user_agent_header ( options ) url = "{}{}" . format ( self . base_url , path ) response = getattr ( self . session , method ) ( url , auth = self . auth , verify = self . cert_path , ** options ) if ( ( response . status_code >= HTTP_STATUS_CODE . OK ) and ( response . status_code < HTTP_STATUS_CODE . REDIRECT ) ) : return response . json ( ) else : msg = "" code = "" json_response = response . json ( ) if 'error' in json_response : if 'description' in json_response [ 'error' ] : msg = json_response [ 'error' ] [ 'description' ] if 'code' in json_response [ 'error' ] : code = str ( json_response [ 'error' ] [ 'code' ] ) if str . upper ( code ) == ERROR_CODE . BAD_REQUEST_ERROR : raise BadRequestError ( msg ) elif str . upper ( code ) == ERROR_CODE . GATEWAY_ERROR : raise GatewayError ( msg ) elif str . upper ( code ) == ERROR_CODE . SERVER_ERROR : raise ServerError ( msg ) else : raise ServerError ( msg )
Dispatches a request to the Razorpay HTTP API