Class: Cex::Apifr

Inherits:
Object
  • Object
show all
Defined in:
lib/cex/apifr.rb

Overview

classe para processar dados no paymium

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pky: ENV['PAYMIUM_API_KEY'], psc: ENV['PAYMIUM_API_SECRET'], ops: { www: 'https://paymium.com', ver: 1 }) ⇒ Apius

Returns API paymium base.

Parameters:

  • pky (String) (defaults to: ENV['PAYMIUM_API_KEY'])

    API key

  • psc (String) (defaults to: ENV['PAYMIUM_API_SECRET'])

    API secret

  • ops (Hash) (defaults to: { www: 'https://paymium.com', ver: 1 })

    parametrizacao base da API



23
24
25
26
27
28
29
30
31
# File 'lib/cex/apifr.rb', line 23

def initialize(
  pky: ENV['PAYMIUM_API_KEY'],
  psc: ENV['PAYMIUM_API_SECRET'],
  ops: { www: 'https://paymium.com', ver: 1 }
)
  @aky = pky
  @asc = psc
  @urb = "#{ops[:www]}/api/v#{ops[:ver]}"
end

Instance Attribute Details

#akyString (readonly)

Returns API key.

Returns:

  • (String)

    API key



13
14
15
# File 'lib/cex/apifr.rb', line 13

def aky
  @aky
end

#ascString (readonly)

Returns API secret.

Returns:

  • (String)

    API secret



15
16
17
# File 'lib/cex/apifr.rb', line 15

def asc
  @asc
end

#urbString (readonly)

Returns API url base.

Returns:

  • (String)

    API url base



17
18
19
# File 'lib/cex/apifr.rb', line 17

def urb
  @urb
end

Instance Method Details

#accountHash

Returns saldos no paymium.

Examples:

{
  name: '...',
  email: '...',
  locale: 'en',
  channel_id: '...',
  meta_state: 'approved',
  balance_eur: '0.0',
  locked_eur: '0.0',
  balance_btc: '0.0',
  locked_btc: '0.0',
  balance_lbtc: '0.0',
  locked_lbtc: '0.0'
}

Returns:

  • (Hash)

    saldos no paymium



48
49
50
# File 'lib/cex/apifr.rb', line 48

def 
  api_get('user')
end

#ledger(pag = 0, ary = []) ⇒ Hash

Returns ledger no paymium.

Examples:

[
  {
    uuid: '50551e61-4e74-4ae7-85fd-9c2040542818',
    currency_amount: nil,
    state: 'executed',
    btc_fee: '0.0',
    currency_fee: '0.0',
    created_at: '2014-03-04T09:00Z',
    updated_at: '2014-03-04T09:00Z',
    currency: 'EUR',
    comment: '5723',
    amount: '100.0',
    type: 'WireDeposit',
    account_operations: [{
      uuid: 'b5058a68-cf99-4438-86d3-e773eba418ec',
      name: 'wire_deposit',
      amount: '100.0',
      currency: 'EUR',
      created_at: '2014-03-04T09:00Z',
      created_at_int: 1_393_923_644,
      is_trading_account: false
    }, {}]
  }, {}
]

Returns:

  • (Hash)

    ledger no paymium



78
79
80
81
82
83
# File 'lib/cex/apifr.rb', line 78

def ledger(pag = 0, ary = [])
  r = api_get('user/orders', offset: pag)
  r.empty? ? ary : ledger(pag + r.size, ary + r)
rescue StandardError
  ary
end