Class: Cex::Apimt
- Inherits:
-
Object
- Object
- Cex::Apimt
- Defined in:
- lib/cex/apimt.rb
Overview
classe para processar dados no therock
Instance Attribute Summary collapse
-
#aky ⇒ String
readonly
API key.
-
#asc ⇒ String
readonly
API secret.
-
#urb ⇒ String
readonly
API url base.
Instance Method Summary collapse
-
#account ⇒ Hash
Saldos no therock.
-
#initialize(pky: ENV['THEROCK_API_KEY'], psc: ENV['THEROCK_API_SECRET'], ops: { www: 'https://api.therocktrading.com', ver: 1 }) ⇒ Apius
constructor
API therock base.
-
#ledger(pag = 1, ary = []) ⇒ Hash
Ledger no therock.
Constructor Details
#initialize(pky: ENV['THEROCK_API_KEY'], psc: ENV['THEROCK_API_SECRET'], ops: { www: 'https://api.therocktrading.com', ver: 1 }) ⇒ Apius
Returns API therock base.
25 26 27 28 29 30 31 32 33 |
# File 'lib/cex/apimt.rb', line 25 def initialize( pky: ENV['THEROCK_API_KEY'], psc: ENV['THEROCK_API_SECRET'], ops: { www: 'https://api.therocktrading.com', ver: 1 } ) @aky = pky @asc = psc @urb = "#{ops[:www]}/v#{ops[:ver]}" end |
Instance Attribute Details
#aky ⇒ String (readonly)
Returns API key.
15 16 17 |
# File 'lib/cex/apimt.rb', line 15 def aky @aky end |
#asc ⇒ String (readonly)
Returns API secret.
17 18 19 |
# File 'lib/cex/apimt.rb', line 17 def asc @asc end |
#urb ⇒ String (readonly)
Returns API url base.
19 20 21 |
# File 'lib/cex/apimt.rb', line 19 def urb @urb end |
Instance Method Details
#account ⇒ Hash
Returns saldos no therock.
45 46 47 48 |
# File 'lib/cex/apimt.rb', line 45 def account api_get('balances')[:balances].delete_if { |e| DC.include?(e[:currency]) } .sort { |a, b| a[:currency] <=> b[:currency] } end |
#ledger(pag = 1, ary = []) ⇒ Hash
Returns ledger no therock.
77 78 79 80 81 82 |
# File 'lib/cex/apimt.rb', line 77 def ledger(pag = 1, ary = []) r = api_get('transactions', page: pag)[:transactions] r.empty? ? ary : ledger(pag + r.size, ary + r) rescue StandardError ary end |