Class: Bct::Apigm
- Inherits:
-
Object
- Object
- Bct::Apigm
- Defined in:
- lib/bct/apigm.rb
Overview
classe para acesso dados blockchain EOS
Instance Attribute Summary collapse
-
#url ⇒ String
readonly
Base URL to use as a prefix for all requests.
Instance Method Summary collapse
-
#account(**arg) ⇒ Hash
Dados & saldo duma carteira EOS.
-
#adapter ⇒ <Symbol>
Adapter for the connection - default :net_http.
-
#all_tx(add, **arg) ⇒ Array<Hash>
Devolve lista de transacoes.
-
#conn ⇒ <Faraday::Connection>
Connection object with an URL & adapter.
-
#initialize(www: 'https://eos.greymass.com') ⇒ Apigm
constructor
Acesso dados blockchain EOS.
-
#ledger(pos = 0, ary = [], **arg) ⇒ Array<Hash>
Lista das transacoes ligadas a uma carteira EOS.
Constructor Details
#initialize(www: 'https://eos.greymass.com') ⇒ Apigm
Returns acesso dados blockchain EOS.
14 15 16 |
# File 'lib/bct/apigm.rb', line 14 def initialize(www: 'https://eos.greymass.com') @url = www end |
Instance Attribute Details
#url ⇒ String (readonly)
Returns base URL to use as a prefix for all requests.
10 11 12 |
# File 'lib/bct/apigm.rb', line 10 def url @url end |
Instance Method Details
#account(**arg) ⇒ Hash
Returns dados & saldo duma carteira EOS.
83 84 85 86 87 |
# File 'lib/bct/apigm.rb', line 83 def account(**arg) raise(Erro, 'endereco tem de ser definido') if arg[:account_name].nil? || arg[:account_name].empty? get('/v1/chain/get_account', **arg) end |
#adapter ⇒ <Symbol>
Returns adapter for the connection - default :net_http.
19 20 21 |
# File 'lib/bct/apigm.rb', line 19 def adapter @adapter ||= Faraday.default_adapter end |
#all_tx(add, **arg) ⇒ Array<Hash>
Returns devolve lista de transacoes.
147 148 149 150 151 |
# File 'lib/bct/apigm.rb', line 147 def all_tx(add, **arg) raise(Erro, 'endereco tem de ser definido') if add.nil? || add.empty? ledger(**arg.merge(account_name: add)) end |
#conn ⇒ <Faraday::Connection>
Returns connection object with an URL & adapter.
24 25 26 27 28 29 30 |
# File 'lib/bct/apigm.rb', line 24 def conn @conn ||= Faraday.new(url: url) do |c| c.request(:url_encoded) c.adapter(adapter) end end |
#ledger(pos = 0, ary = [], **arg) ⇒ Array<Hash>
Returns lista das transacoes ligadas a uma carteira EOS.
158 159 160 161 162 163 164 |
# File 'lib/bct/apigm.rb', line 158 def ledger(pos = 0, ary = [], **arg) r = get('/v1/history/get_actions', **arg.merge(pos: pos, offset: 100))[:actions] ary += r r.count < 100 ? ary : ledger(pos + r.count, ary, **arg) rescue StandardError ary end |