Class: Aviate::Wallet

Inherits:
Object
  • Object
show all
Defined in:
app/services/aviate/wallet.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Wallet

Returns a new instance of Wallet.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/aviate/wallet.rb', line 9

def initialize(attributes = {})
  @wallet_id = attributes[:wallet_id]
  @kb_account_id = attributes[:kb_account_id]
  @currency = attributes[:currency]
  @balance = attributes[:balance]
  @live_balance = attributes[:live_balance]
  @credit_type = attributes[:credit_type]
  @amount = attributes[:amount]
  @exp_date = attributes[:exp_date]
  @top_off_type = attributes[:top_off_type]
  @low_watermark = attributes[:low_watermark]
  @top_off_amount = attributes[:top_off_amount]
  @exp_duration_unit = attributes[:exp_duration_unit]
  @exp_duration_length = attributes[:exp_duration_length]
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def amount
  @amount
end

#balanceObject

Returns the value of attribute balance.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def balance
  @balance
end

#credit_typeObject

Returns the value of attribute credit_type.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def credit_type
  @credit_type
end

#currencyObject

Returns the value of attribute currency.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def currency
  @currency
end

#exp_dateObject

Returns the value of attribute exp_date.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def exp_date
  @exp_date
end

#exp_duration_lengthObject

Returns the value of attribute exp_duration_length.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def exp_duration_length
  @exp_duration_length
end

#exp_duration_unitObject

Returns the value of attribute exp_duration_unit.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def exp_duration_unit
  @exp_duration_unit
end

#kb_account_idObject

Returns the value of attribute kb_account_id.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def 
  @kb_account_id
end

#live_balanceObject

Returns the value of attribute live_balance.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def live_balance
  @live_balance
end

#low_watermarkObject

Returns the value of attribute low_watermark.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def low_watermark
  @low_watermark
end

#top_off_amountObject

Returns the value of attribute top_off_amount.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def top_off_amount
  @top_off_amount
end

#top_off_typeObject

Returns the value of attribute top_off_type.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def top_off_type
  @top_off_type
end

#wallet_idObject

Returns the value of attribute wallet_id.



5
6
7
# File 'app/services/aviate/wallet.rb', line 5

def wallet_id
  @wallet_id
end

Class Method Details

.from_api_response(response) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/services/aviate/wallet.rb', line 25

def self.from_api_response(response)
  {
    wallet_id: response['walletId'],
    kb_account_id: response['kbAccountId'],
    currency: response['currency'],
    balance: response['balance'],
    live_balance: response['liveBalance'],
    credit_type: response['creditType'],
    amount: response['amount'],
    exp_date: response['expDate'],
    top_off_type: response['topOff']['topOffType'],
    low_watermark: response['topOff']['lowWatermark'],
    top_off_amount: response['topOff']['amount'],
    exp_duration_unit: response['topOff']['expDurationUnit'],
    exp_duration_length: response['topOff']['expDurationLength']
  }
end

Instance Method Details

#to_api_paramsObject



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/services/aviate/wallet.rb', line 43

def to_api_params
  {
    currency: @currency,
    credit_type: @credit_type,
    amount: @amount,
    exp_date: @exp_date,
    top_off_type: @top_off_type,
    low_watermark: @low_watermark,
    top_off_amount: @top_off_amount,
    exp_duration_unit: @exp_duration_unit,
    exp_duration_length: @exp_duration_length
  }.compact
end