async def pre_process(self, request: RESTRequest) -> RESTRequest: if request.headers is None: request.headers = {} # Generates generic headers required by AscendEx headers_generic = {} headers_generic["Accept"] = "application/json" headers_generic["Content-Type"] = "application/json" # Headers signature to identify user as an HB liquidity provider. request.headers = dict( list(headers_generic.items()) + list(request.headers.items()) + list(get_hb_id_headers().items())) return request
async def pre_process(self, request: RESTRequest) -> RESTRequest: if request.headers is None: request.headers = {} request.headers["Content-Type"] = ("application/json" if request.method == RESTMethod.POST else "application/x-www-form-urlencoded") return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: headers = {} if request.headers is not None: headers.update(request.headers) headers.update(self._get_auth_headers(request)) request.headers = headers return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: if request.method == RESTMethod.POST: request.data = self.add_auth_to_params(request.data) else: request.params = self.add_auth_to_params(request.params) request.headers = {"X-MBX-APIKEY": self._api_key} return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: """ Adds the server time and the signature to the request, required for authenticated interactions. It also adds the required parameter in the request header. :param request: the request to be configured for authenticated interaction """ request.params = self.add_auth_to_params(params=request.params) headers = {} if request.headers is not None: headers.update(request.headers) request.headers = headers return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: payload: Optional[str] = None if request.params is not None: payload = urlencode(dict(request.params.items())) request.params["signature"] = self.generate_signature_from_payload(payload=payload) if request.data is not None: payload = urlencode(dict(request.data.items())) request.data["signature"] = self.generate_signature_from_payload(payload=payload) request.headers = {"X-MBX-APIKEY": self._api_key} return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: """ Adds the server time and the signature to the request, required for authenticated interactions. It also adds the required parameter in the request header. :param request: the request to be configured for authenticated interaction """ # Generates auth headers headers_auth = self.get_auth_headers(request.endpoint_url) headers = {} if request.headers is not None: headers.update(request.headers) headers.update(headers_auth) request.headers = headers return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: """ Adds the server time and the signature to the request, required for authenticated interactions. It also adds the required parameter in the request header. :param request: the request to be configured for authenticated interaction :return: The RESTRequest with auth information included """ headers = {} if request.headers is not None: headers.update(request.headers) headers.update(self.authentication_headers(request=request)) request.headers = headers return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: verb = str(request.method) expires = str(int(time.time()) + EXPIRATION) data = json.dumps(request.data) if request.data is not None else '' parsed_url = urlparse(request.url) path = parsed_url.path query = urlencode(request.params) if request.params is not None else '' if not (query == ''): query = '?' + query payload = verb + path + query + expires + data signature = self.generate_signature_from_payload(payload) request.headers = { "api-expires": expires, "api-key": self._api_key, "api-signature": signature, } return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: """ Adds the server time and the signature to the request, required for authenticated interactions. It also adds the required parameter in the request header. :param request: the request to be configured for authenticated interaction """ if request.method == RESTMethod.POST: request.data = self.add_auth_to_params( params=json.loads(request.data)) else: request.params = self.add_auth_to_params(params=request.params) headers = {} if request.headers is not None: headers.update(request.headers) headers.update(self.header_for_authentication()) request.headers = headers return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: request_params = self.add_auth_to_params(params=request.params) if request.method == RESTMethod.POST: request.data = payload.JsonPayload(dict(request_params), dumps=ujson.dumps) request.params = None else: request.params = request_params headers = {} if request.headers is not None: headers.update(request.headers) endpoint = str(urlsplit(request.url).path) signature = self._generate_signature(method=request.method.name, endpoint=endpoint, params=request_params) headers.update(self.header_for_authentication(signature)) request.headers = headers return request
async def rest_authenticate(self, request: RESTRequest) -> RESTRequest: request.headers = auth_header return request