Пример #1
0
    def _make_request(self,
                      method,
                      host: urlparse,
                      params: dict = None,
                      data: dict = None,
                      **kwargs) -> dict:
        """
        Create a server request and parse the response for validation
        :param method: Request method
        :param host: endpoint to send the request
        :param params: query params for the request
        :param data: form data for the requests
        :param kwargs: Any other that a server accepts
        :return: json response of the server
        """
        tmp = self.__dict__.copy()
        for _type, _obj in tmp.items():
            if _type not in ("api_key", "_session"):
                self.__delattr__(_type)

        host = host if not host.startswith("http") else host.split("/")[2]
        url = urlparse.urlunparse(('https', host, '', '', '', ''))
        self.ServerResponse = self._session.request(method,
                                                    url,
                                                    params=params,
                                                    data=data,
                                                    **kwargs)
        ValidateResponse(resp=self.ServerResponse, show_warn=self._WARNINGS)

        return self.ServerResponse.json()
Пример #2
0
 def _make_request(self, method, host: urlparse, params: dict = None, data: dict = None, **kwargs) -> dict:
     """
     Create a server request and parse the response for validation
     :param method: Request method
     :param host: endpoint to send the request
     :param params: query params for the request
     :param data: form data for the requests
     :param kwargs: Any other that a server accepts
     :return: json response of the server
     """
     host = host if not host.startswith("http") else host.split("/")[2]
     url = urlparse.urlunparse(('https', host, '', '', '', ''))
     self.ServerResponse = self._session.request(method, url, params=params, data=data, **kwargs)
     ResponseParser(resp=self.ServerResponse, show_warn=self._WARNINGS)
     return self.ServerResponse.json()