Class: OmiseGO::Wallet

Inherits:
Base
  • Object
show all
Defined in:
lib/omisego/wallet.rb

Instance Attribute Summary

Attributes inherited from Base

#client, #original_payload

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attributes, #error?, global_client, #initialize, #inspect, request, #success?

Constructor Details

This class inherits a constructor from OmiseGO::Base

Class Method Details

.all(provider_user_id:, client: nil) ⇒ Object



8
9
10
# File 'lib/omisego/wallet.rb', line 8

def all(provider_user_id:, client: nil)
  request(client).send('user.get_wallets', provider_user_id: provider_user_id).data
end

.all_for_account(account_id:, client: nil) ⇒ Object



12
13
14
# File 'lib/omisego/wallet.rb', line 12

def (account_id:, client: nil)
  request(client).send('account.get_wallets', id: ).data
end

.credit(provider_user_id:, token_id:, amount:, metadata: {}, user_address: nil, encrypted_metadata: {}, idempotency_token:, account_id:, account_address: nil, client: nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/omisego/wallet.rb', line 16

def credit(provider_user_id:, token_id:, amount:, metadata: {}, user_address: nil,
           encrypted_metadata: {}, idempotency_token:, account_id:, account_address: nil,
           client: nil)
  params = { to_provider_user_id: provider_user_id,
             to_address: user_address,
             from_account_id: ,
             from_address: ,
             token_id: token_id,
             amount: amount,
             metadata: ,
             encrypted_metadata: ,
             account_address: ,
             idempotency_token: idempotency_token }
  request(client).send('transaction.create', params).data
end

.debit(provider_user_id:, user_address: nil, token_id:, amount:, metadata: {}, encrypted_metadata: {}, idempotency_token:, account_id:, account_address: nil, client: nil) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/omisego/wallet.rb', line 32

def debit(provider_user_id:, user_address: nil, token_id:, amount:, metadata: {},
          encrypted_metadata: {}, idempotency_token:, account_id:, account_address: nil,
          client: nil)
  params = { from_provider_user_id: provider_user_id,
             from_address: user_address,
             to_account_id: ,
             to_address: ,
             token_id: token_id,
             amount: amount,
             metadata: ,
             encrypted_metadata: ,
             account_address: ,
             idempotency_token: idempotency_token }
  request(client).send('transaction.create', params).data
end

Instance Method Details

#accountObject



53
54
55
# File 'lib/omisego/wallet.rb', line 53

def 
   ||= .new(@account)
end

#balancesObject



57
58
59
60
61
# File 'lib/omisego/wallet.rb', line 57

def balances
  @_balances ||= @balances.map do |balance|
    Balance.new(balance)
  end
end

#userObject



49
50
51
# File 'lib/omisego/wallet.rb', line 49

def user
  @_user ||= User.new(@user)
end