def create_get_unspent_transaction_outputs_for_multiple_addresses(self, addrs): """Does a POST request to /api/defcoin/api/utxo. TODO: type endpoint description here. Args: addrs (string): TODO: type description here. Returns: list of UTXO: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # The base uri for api requests query_builder = Configuration.BASE_URI # Prepare query string for API call query_builder += "/api/defcoin/api/utxo" # Process optional query parameters query_builder = APIHelper.append_url_with_query_parameters(query_builder, { "addrs": addrs }) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "user-agent": "APIMATIC 2.0", "accept": "application/json" } # Prepare and invoke the API call request to fetch the response response = unirest.post(query_url, headers=headers) # Error handling using HTTP status codes if response.code < 200 or response.code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.code, response.body) #try to cast response to list of desired type if isinstance(response.body, list): # Response is already in a list, return the list of objects value = list() for item in response.body: value.append(UTXO(**item)) return value # If we got here then an error occured while trying to parse the response raise APIException("Invalid JSON returned", response.code, response.body)
def get_address_total_sent(self, address): """Does a GET request to /api/defcoin/api/addr. TODO: type endpoint description here. Args: address (string): TODO: type description here. Returns: GetAddressTotalSentResponse: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # The base uri for api requests query_builder = Configuration.BASE_URI # Prepare query string for API call query_builder += "/api/defcoin/api/addr" # Process optional query parameters query_builder = APIHelper.append_url_with_query_parameters(query_builder, { "address": address }) # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "user-agent": "APIMATIC 2.0", "accept": "application/json" } # Prepare and invoke the API call request to fetch the response response = unirest.get(query_url, headers=headers) # Error handling using HTTP status codes if response.code < 200 or response.code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.code, response.body) # Try to cast response to desired type if isinstance(response.body, dict): # Response is already in a dictionary, return the object return GetAddressTotalSentResponse(**response.body) # If we got here then an error occured while trying to parse the response raise APIException("Invalid JSON returned", response.code, response.body)
def get_stats_for_specified_chain(self): """Does a GET request to /api/ethereum/api/. TODO: type endpoint description here. Returns: GetStatsForSpecifiedChainResponse366: Response from the API. Raises: APIException: When an error occurs while fetching the data from the remote API. This exception includes the HTTP Response code, an error message, and the HTTP body that was received in the request. """ # The base uri for api requests query_builder = Configuration.BASE_URI # Prepare query string for API call query_builder += "/api/ethereum/api/" # Validate and preprocess url query_url = APIHelper.clean_url(query_builder) # Prepare headers headers = { "user-agent": "APIMATIC 2.0", "accept": "application/json" } # Prepare and invoke the API call request to fetch the response response = unirest.get(query_url, headers=headers) # Error handling using HTTP status codes if response.code < 200 or response.code > 206: # 200 = HTTP OK raise APIException("HTTP Response Not OK", response.code, response.body) # Try to cast response to desired type if isinstance(response.body, dict): # Response is already in a dictionary, return the object return GetStatsForSpecifiedChainResponse366(**response.body) # If we got here then an error occured while trying to parse the response raise APIException("Invalid JSON returned", response.code, response.body)