本文整理汇总了Python中RibbitRewardsWalletAndBlockchainAPILib.APIHelper.APIHelper类的典型用法代码示例。如果您正苦于以下问题:Python APIHelper类的具体用法?Python APIHelper怎么用?Python APIHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了APIHelper类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_get_unspent_transaction_outputs_for_multiple_addresses
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)
示例2: get_address_total_sent
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)
示例3: resolve_names
def resolve_names(self):
"""Creates a dictionary representation of this object.
This method converts an object to a dictionary that represents the
format that the model should be in when passed into an API Request.
Because of this, the generated dictionary may have different
property names to that of the model itself.
Returns:
dict: The dictionary representing the object.
"""
# Create a mapping from Model property names to API property names
replace_names = {
"blockhash": "blockhash",
"blocktime": "blocktime",
"confirmations": "confirmations",
"is_coin_base": "isCoinBase",
"locktime": "locktime",
"size": "size",
"time": "time",
"txid": "txid",
"value_out": "valueOut",
"version": "version",
"vin": "vin",
"vout": "vout",
}
retval = dict()
return APIHelper.resolve_names(self, replace_names, retval)
示例4: resolve_names
def resolve_names(self):
"""Creates a dictionary representation of this object.
This method converts an object to a dictionary that represents the
format that the model should be in when passed into an API Request.
Because of this, the generated dictionary may have different
property names to that of the model itself.
Returns:
dict: The dictionary representing the object.
"""
# Create a mapping from Model property names to API property names
replace_names = {
"coinbase": "coinbase",
"confirmations": "confirmations",
"is_confirmed": "isConfirmed",
"n": "n",
"sequence": "sequence",
"unconfirmed_input": "unconfirmedInput",
}
retval = dict()
return APIHelper.resolve_names(self, replace_names, retval)
示例5: resolve_names
def resolve_names(self):
"""Creates a dictionary representation of this object.
This method converts an object to a dictionary that represents the
format that the model should be in when passed into an API Request.
Because of this, the generated dictionary may have different
property names to that of the model itself.
Returns:
dict: The dictionary representing the object.
"""
# Create a mapping from Model property names to API property names
replace_names = {
"bestblock": "bestblock",
"bytes_serialized": "bytes_serialized",
"hash_serialized": "hash_serialized",
"height": "height",
"total_amount": "total_amount",
"transactions": "transactions",
"txouts": "txouts",
}
retval = dict()
return APIHelper.resolve_names(self, replace_names, retval)
示例6: resolve_names
def resolve_names(self):
"""Creates a dictionary representation of this object.
This method converts an object to a dictionary that represents the
format that the model should be in when passed into an API Request.
Because of this, the generated dictionary may have different
property names to that of the model itself.
Returns:
dict: The dictionary representing the object.
"""
# Create a mapping from Model property names to API property names
replace_names = {
"address": "address",
"amount": "amount",
"confirmation": "confirmation",
"confirmations_from_cache": "confirmationsFromCache",
"script_pub_key": "scriptPubKey",
"ts": "ts",
"txid": "txid",
"vout": "vout",
}
retval = dict()
return APIHelper.resolve_names(self, replace_names, retval)
示例7: resolve_names
def resolve_names(self):
"""Creates a dictionary representation of this object.
This method converts an object to a dictionary that represents the
format that the model should be in when passed into an API Request.
Because of this, the generated dictionary may have different
property names to that of the model itself.
Returns:
dict: The dictionary representing the object.
"""
# Create a mapping from Model property names to API property names
replace_names = {
"balance": "balance",
"blocks": "blocks",
"connections": "connections",
"difficulty": "difficulty",
"errors": "errors",
"keypoololdest": "keypoololdest",
"keypoolsize": "keypoolsize",
"paytxfee": "paytxfee",
"protocolversion": "protocolversion",
"proxy": "proxy",
"relayfee": "relayfee",
"testnet": "testnet",
"timeoffset": "timeoffset",
"version": "version",
"walletversion": "walletversion",
}
retval = dict()
return APIHelper.resolve_names(self, replace_names, retval)
示例8: resolve_names
def resolve_names(self):
"""Creates a dictionary representation of this object.
This method converts an object to a dictionary that represents the
format that the model should be in when passed into an API Request.
Because of this, the generated dictionary may have different
property names to that of the model itself.
Returns:
dict: The dictionary representing the object.
"""
# Create a mapping from Model property names to API property names
replace_names = {"total_received": "totalReceived"}
retval = dict()
return APIHelper.resolve_names(self, replace_names, retval)
示例9: get_stats_for_specified_chain
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)
示例10: resolve_names
def resolve_names(self):
"""Creates a dictionary representation of this object.
This method converts an object to a dictionary that represents the
format that the model should be in when passed into an API Request.
Because of this, the generated dictionary may have different
property names to that of the model itself.
Returns:
dict: The dictionary representing the object.
"""
# Create a mapping from Model property names to API property names
replace_names = {
"n": "n",
"script_pub_key": "scriptPubKey",
"value_24_34567111": "value 24.34567111",
}
retval = dict()
return APIHelper.resolve_names(self, replace_names, retval)
示例11: resolve_names
def resolve_names(self):
"""Creates a dictionary representation of this object.
This method converts an object to a dictionary that represents the
format that the model should be in when passed into an API Request.
Because of this, the generated dictionary may have different
property names to that of the model itself.
Returns:
dict: The dictionary representing the object.
"""
# Create a mapping from Model property names to API property names
replace_names = {
"bits": "bits",
"chainwork": "chainwork",
"confirmations": "confirmations",
"difficulty": "difficulty",
"hash": "hash",
"height": "height",
"is_main_chain": "isMainChain",
"merkleroot": "merkleroot",
"nextblockhash": "nextblockhash",
"nonce": "nonce",
"previousblockhash": "previousblockhash",
"reward": "reward",
"size": "size",
"time": "time",
"tx": "tx",
"version": "version",
"pool_info": "poolInfo",
}
# Start from the base class
retval = super(GetBlockByHashResponse, self).resolve_names()
return APIHelper.resolve_names(self, replace_names, retval)