当前位置: 首页>>代码示例>>Python>>正文


Python APIHelper.APIHelper类代码示例

本文整理汇总了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) 
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:57,代码来源:DefcoinController.py

示例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) 
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:53,代码来源:DefcoinController.py

示例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)
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:31,代码来源:Transaction.py

示例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)
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:25,代码来源:Vin.py

示例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)
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:26,代码来源:Txoutsetinfo.py

示例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)
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:27,代码来源:UTXO.py

示例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)
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:34,代码来源:Info.py

示例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)
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:18,代码来源:GetAddressTotalReceivedResponse.py

示例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) 
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:44,代码来源:EthereumController.py

示例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)
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:22,代码来源:Vout.py

示例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)
开发者ID:synrg-labs,项目名称:Ribbit-API-docs,代码行数:37,代码来源:GetBlockByHashResponse.py


注:本文中的RibbitRewardsWalletAndBlockchainAPILib.APIHelper.APIHelper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。