Class: Cex::Apide
- Inherits:
-
Object
- Object
- Cex::Apide
- Defined in:
- lib/cex/apide.rb
Overview
classe para processar dados no bitcoinde
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 bitcoinde.
-
#deposit_hash(hde) ⇒ Hash
Deposit uniformizado.
-
#deposits(pag = 0, ary = []) ⇒ Array<Hash>
Lista depositos no bitcoinde.
-
#initialize(pky: ENV['BITCOINDE_API_KEY'], psc: ENV['BITCOINDE_API_SECRET'], ops: { www: 'https://api.bitcoin.de', ver: 4 }) ⇒ Apide
constructor
API bitcoinde base.
-
#trades(pag = 0, ary = []) ⇒ Array<Hash>
Lista trades no bitcoinde.
-
#withdrawal_hash(hwi) ⇒ Hash
Withdrawal unifirmizada.
-
#withdrawals(pag = 0, ary = []) ⇒ Array<Hash>
Lista withdrawals no bitcoinde.
Constructor Details
#initialize(pky: ENV['BITCOINDE_API_KEY'], psc: ENV['BITCOINDE_API_SECRET'], ops: { www: 'https://api.bitcoin.de', ver: 4 }) ⇒ Apide
Returns API bitcoinde base.
23 24 25 26 27 28 29 30 31 |
# File 'lib/cex/apide.rb', line 23 def initialize( pky: ENV['BITCOINDE_API_KEY'], psc: ENV['BITCOINDE_API_SECRET'], ops: { www: 'https://api.bitcoin.de', ver: 4 } ) @aky = pky @asc = psc @urb = "#{ops[:www]}/v#{ops[:ver]}" end |
Instance Attribute Details
#aky ⇒ String (readonly)
Returns API key.
13 14 15 |
# File 'lib/cex/apide.rb', line 13 def aky @aky end |
#asc ⇒ String (readonly)
Returns API secret.
15 16 17 |
# File 'lib/cex/apide.rb', line 15 def asc @asc end |
#urb ⇒ String (readonly)
Returns API url base.
17 18 19 |
# File 'lib/cex/apide.rb', line 17 def urb @urb end |
Instance Method Details
#account ⇒ Hash
Returns saldos no bitcoinde.
50 51 52 |
# File 'lib/cex/apide.rb', line 50 def account api_get('account')[:data][:balances] end |
#deposit_hash(hde) ⇒ Hash
Returns deposit uniformizado.
173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/cex/apide.rb', line 173 def deposit_hash(hde) { id: hde[:address], tp: 'deposit', qtxt: 'btc', fee: '0', time: Time.parse(hde[:created_at]), qt: hde[:amount], lgid: Integer(hde[:deposit_id]) } end |
#deposits(pag = 0, ary = []) ⇒ Array<Hash>
Returns lista depositos no bitcoinde.
110 111 112 113 114 115 116 |
# File 'lib/cex/apide.rb', line 110 def deposits(pag = 0, ary = []) r = api_get('btc/deposits', state: 2, page: pag + 1) ary += r[:deposits].map { |h| deposit_hash(h) } r[:page][:current] < r[:page][:last] ? deposits(pag + 1, ary) : ary rescue StandardError ary end |
#trades(pag = 0, ary = []) ⇒ Array<Hash>
Returns lista trades no bitcoinde.
93 94 95 96 97 98 99 |
# File 'lib/cex/apide.rb', line 93 def trades(pag = 0, ary = []) r = api_get('trades', state: 1, page: pag + 1) ary += r[:trades] r[:page][:current] < r[:page][:last] ? trades(pag + 1, ary) : ary rescue StandardError ary end |
#withdrawal_hash(hwi) ⇒ Hash
Returns withdrawal unifirmizada.
149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/cex/apide.rb', line 149 def withdrawal_hash(hwi) { id: hwi[:address], tp: 'out', qtxt: 'btc', fee: hwi[:network_fee], time: Time.parse(hwi[:transferred_at]), qt: hwi[:amount], lgid: Integer(hwi[:withdrawal_id]) } end |
#withdrawals(pag = 0, ary = []) ⇒ Array<Hash>
Returns lista withdrawals no bitcoinde.
127 128 129 130 131 132 133 |
# File 'lib/cex/apide.rb', line 127 def withdrawals(pag = 0, ary = []) r = api_get('btc/withdrawals', state: 1, page: pag + 1) ary += r[:withdrawals].map { |h| withdrawal_hash(h) } r[:page][:current] < r[:page][:last] ? withdrawals(pag + 1, ary) : ary rescue StandardError ary end |