Class: OmiseGO::Transaction

Inherits:
Base
  • Object
show all
Defined in:
lib/omisego/transaction.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(params: {}, client: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/omisego/transaction.rb', line 14

def all(params: {}, client: nil)
  if params[:provider_user_id]
    all_for_user(
      provider_user_id: params[:provider_user_id],
      address: params[:address],
      params: params,
      client: client
    )
  else
    request(client).send('transaction.all', {}, params: params).data
  end
end

.all_for_user(provider_user_id:, address: nil, params: {}, client: nil) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/omisego/transaction.rb', line 27

def all_for_user(provider_user_id:, address: nil, params: {}, client: nil)
  body = {
    provider_user_id: provider_user_id,
    address:          address
  }

  request(client).send('user.get_transactions', body, params: params).data
end

.create(from_account_id: nil, from_provider_user_id: nil, from_address: nil, to_account_id: nil, to_provider_user_id: nil, to_address: nil, from_token_id: nil, to_token_id: nil, token_id: nil, from_amount: nil, to_amount: nil, amount: nil, exchange_account_id: nil, exchange_wallet_address: nil, metadata: {}, encrypted_metadata: {}, idempotency_token:, client: nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/omisego/transaction.rb', line 36

def create(from_account_id: nil,
           from_provider_user_id: nil,
           from_address: nil,
           to_account_id: nil,
           to_provider_user_id: nil,
           to_address: nil,
           from_token_id: nil,
           to_token_id: nil,
           token_id: nil,
           from_amount: nil,
           to_amount: nil,
           amount: nil,
           exchange_account_id: nil,
           exchange_wallet_address: nil,
           metadata: {},
           encrypted_metadata: {},
           idempotency_token:,
           client: nil)
  request(client).send('transaction.create', from_account_id: ,
                                             from_provider_user_id: from_provider_user_id,
                                             from_address: from_address,
                                             to_account_id: ,
                                             to_provider_user_id: to_provider_user_id,
                                             to_address: to_address,
                                             from_token_id: from_token_id,
                                             to_token_id: to_token_id,
                                             token_id: token_id,
                                             from_amount: from_amount,
                                             to_amount: to_amount,
                                             amount: amount,
                                             exchange_account_id: ,
                                             exchange_wallet_address: exchange_wallet_address,
                                             metadata: ,
                                             encrypted_metadata: ,
                                             idempotency_token: idempotency_token).data
end

Instance Method Details

#exchangeObject



82
83
84
# File 'lib/omisego/transaction.rb', line 82

def exchange
  @_exchange ||= Exchange.new(@exchange)
end

#fromObject



74
75
76
# File 'lib/omisego/transaction.rb', line 74

def from
  @_from ||= TransactionSource.new(@from)
end

#toObject



78
79
80
# File 'lib/omisego/transaction.rb', line 78

def to
  @_to ||= TransactionSource.new(@to)
end