def _postVoidOutput(self, input1): self.query_parameters['output'] = 'void' responseJson = self.client.postJsonHelper(self.url, input1, **self.query_parameters) if 'error' in responseJson: raise ApiError(responseJson['error']['message']) else: return AsyncResponse(responseJson)
def create_algo_response(response): # Check if request is async if 'async_protocol' in response and 'request_id' in response: return AsyncResponse(response) # Parse response JSON, if it's indeed JSON elif 'error' in response or 'metadata' not in response: # Failure raise raiseAlgoApiError(response) else: metadata = Metadata(response['metadata']) # Success, check content_type if response['metadata']['content_type'] == 'binary': # Decode Base64 encoded binary file return AlgoResponse(base64.b64decode(response['result']), metadata) elif response['metadata']['content_type'] == 'void': return AlgoResponse(None, metadata) else: return AlgoResponse(response['result'], metadata)