Sha256: 6e5c33ae7debb32155c12ab69318eec25dda7879a24c1c09c780cda2793f73ee
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
# # Counterparty APIs # module Katapaty class Party class << self def get_running_info request(__method__.to_s) end def address_token_balance(address, token_name) rs = request('get_balances', {"filters": [{ "field": 'address', "op": '==', "value": address }, { "field": 'asset', "op": '==', "value": token_name }]}) return 0 if rs.blank? rs.first['quantity'].to_i end def get_asset_info(assets) request(__method__.to_s, { assets: assets }) end def get_blocks(block_indexes) request(__method__.to_s, { block_indexes: block_indexes }) end def getrawtransaction(tx_hash) request(__method__.to_s, { tx_hash: tx_hash }) end def create_send(payload) request(__method__.to_s, payload) end def request(method_name, payload={}) client = RestClient::Resource.new Katapaty.configuration.counterparty_url request = { method: method_name, params: payload, jsonrpc: '2.0', id: '0' }.to_json response = JSON.parse client.post(request, accept: 'json', content_type: 'json' ) raise JsonResponseError.new response if response.has_key? 'code' raise ResponseError.new response['error'] if response.has_key? 'error' response['result'] end def method_missing(name, *args) args = args.nil? ? {} : args.first request(name, args) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
katapaty-0.4.1 | lib/katapaty/party.rb |