Class: BloomRemit2::Credit

Inherits:
Object
  • Object
show all
Defined in:
lib/bloom_remit2/credit.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount_in_php, balance, consumed, created_at, id, item_id, item_type, rate, source_amount, source_currency, target_amount, target_currency, updated_at) ⇒ Credit

Returns a new instance of Credit.



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
# File 'lib/bloom_remit2/credit.rb', line 39

def initialize(
  amount_in_php,
  balance,
  consumed,
  created_at,
  id,
  item_id,
  item_type,
  rate,
  source_amount,
  source_currency,
  target_amount,
  target_currency,
  updated_at
)
  @amount_in_php = amount_in_php
  @balance = balance
  @consumed = consumed
  @created_at = created_at
  @id = id
  @item_id = item_id
  @item_type = item_type
  @rate = rate
  @source_amount = source_amount
  @source_currency = source_currency
  @target_amount = target_amount
  @target_currency = target_currency
  @updated_at = updated_at
end

Instance Attribute Details

#amount_in_phpObject (readonly)

Returns the value of attribute amount_in_php.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def amount_in_php
  @amount_in_php
end

#balanceObject (readonly)

Returns the value of attribute balance.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def balance
  @balance
end

#consumedObject (readonly)

Returns the value of attribute consumed.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def consumed
  @consumed
end

#created_atObject (readonly)

Returns the value of attribute created_at.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def created_at
  @created_at
end

#idObject (readonly)

Returns the value of attribute id.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def id
  @id
end

#item_idObject (readonly)

Returns the value of attribute item_id.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def item_id
  @item_id
end

#item_typeObject (readonly)

Returns the value of attribute item_type.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def item_type
  @item_type
end

#rateObject (readonly)

Returns the value of attribute rate.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def rate
  @rate
end

#source_amountObject (readonly)

Returns the value of attribute source_amount.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def source_amount
  @source_amount
end

#source_currencyObject (readonly)

Returns the value of attribute source_currency.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def source_currency
  @source_currency
end

#target_amountObject (readonly)

Returns the value of attribute target_amount.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def target_amount
  @target_amount
end

#target_currencyObject (readonly)

Returns the value of attribute target_currency.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def target_currency
  @target_currency
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



37
38
39
# File 'lib/bloom_remit2/credit.rb', line 37

def updated_at
  @updated_at
end

Class Method Details

.historyObject

Show a list of credit transactions

Grabs a list of the most recent 100 credit transactions associated with this vendor account. Transactions that add to your credit will have the boolean ‘consumed’ set to ‘false’, and transactions that use up your credit (i.e., to pay for remittances) will have it set to ‘true’.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bloom_remit2/credit.rb', line 9

def history
  credits = Client.get("#{path}/history")
  credits.map do |credit|
    new(
      credit['amount_in_php'],
      credit['balance'],
      credit['consumed'],
      credit['created_at'],
      credit['id'],
      credit['item_id'],
      credit['item_type'],
      credit['rate'],
      credit['source_amount'],
      credit['source_currency'],
      credit['target_amount'],
      credit['target_currency'],
      credit['updated_at']
    )
  end
end