Exemple #1
0
    def _service_request_without_rate_limits(
        self,
        request_args: RequestArgs,
        required_sid: bool,
    ) -> requests.Response:
        """Post data to url.

        :param request_args: request args
        :param required_sid: is this method required sid
        :return: response
        """
        if required_sid is True:
            request_data = request_args.data or {}
            request_data['sid'] = self.sid
            request_args.data = request_data  # NOQA:WPS110
        logger.info(
            'Service post: %s. Params: %s',
            request_args.url,
            str(clear_params(request_args.data)),
        )
        return self.service_session.request(
            method=request_args.method,
            url=request_args.full_url,
            **request_args.dict_optional_args(
                self._autocast_arguments,
            ),
        )
Exemple #2
0
 def request_args(self):
     """Request args."""
     yield RequestArgs(
         method='GET',
         url='/some/url',
         full_url='/some/full/url',
         data={
             'd1': 1,
             'd2': 2,
         },
     )
Exemple #3
0
    def __init__(self, api: 'Api', *args, **kwargs):
        """Init.

        :param api: api
        :param args: args
        :param kwargs: kwargs
        """
        super().__init__(api, *args, **kwargs)
        self.request_args = RequestArgs(
            method='POST',
            url=self.url,
            full_url=self._api.service_full_url(self.url),
            data=self.request_data,
        )
Exemple #4
0
    def service_post(
        self,
        url: str,
        required_sid: bool,
        **kwargs,
    ) -> requests.Response:
        """Post data to url.

        :param url: method url
        :param required_sid: is this method required sid
        :param kwargs: request arguments
        :return: response
        """
        full_url = self.service_full_url(url)
        request_args = RequestArgs(
            method='POST',
            url=url,
            full_url=full_url,
            **kwargs,
        )
        return self.service_request(
            request_args=request_args,
            required_sid=required_sid,
        )
Exemple #5
0
 def __init__(self):
     self.request_args = RequestArgs(
         method='POST',
         url='/some/url',
         full_url='/some/url',
     )