Class: Mondo::Transaction
Instance Attribute Summary collapse
Attributes inherited from Resource
#client, #raw_data
Instance Method Summary
collapse
Methods inherited from Resource
boolean_accessor, boolean_reader, date_accessor, date_writer, #initialize, #inspect, #to_s
Instance Attribute Details
#category ⇒ Object
Returns the value of attribute category.
4
5
6
|
# File 'lib/mondo/transaction.rb', line 4
def category
@category
end
|
#decline_reason ⇒ Object
Returns the value of attribute decline_reason.
4
5
6
|
# File 'lib/mondo/transaction.rb', line 4
def decline_reason
@decline_reason
end
|
#description ⇒ Object
Returns the value of attribute description.
4
5
6
|
# File 'lib/mondo/transaction.rb', line 4
def description
@description
end
|
#id ⇒ Object
Returns the value of attribute id.
4
5
6
|
# File 'lib/mondo/transaction.rb', line 4
def id
@id
end
|
#is_load ⇒ Object
Returns the value of attribute is_load.
4
5
6
|
# File 'lib/mondo/transaction.rb', line 4
def is_load
@is_load
end
|
Returns the value of attribute metadata.
4
5
6
|
# File 'lib/mondo/transaction.rb', line 4
def metadata
@metadata
end
|
#notes ⇒ Object
Returns the value of attribute notes.
4
5
6
|
# File 'lib/mondo/transaction.rb', line 4
def notes
@notes
end
|
#settled ⇒ Object
Returns the value of attribute settled.
4
5
6
|
# File 'lib/mondo/transaction.rb', line 4
def settled
@settled
end
|
Instance Method Details
#account_balance ⇒ Object
28
29
30
|
# File 'lib/mondo/transaction.rb', line 28
def account_balance
Money.new(raw_data['account_balance'], currency)
end
|
#amount ⇒ Object
20
21
22
|
# File 'lib/mondo/transaction.rb', line 20
def amount
Money.new(raw_data['amount'], currency)
end
|
#attachments ⇒ Object
57
58
59
60
61
|
# File 'lib/mondo/transaction.rb', line 57
def attachments
@transactions ||= begin
raw_data['attachments'].map { |tx| Attachment.new(tx, self.client) }
end
end
|
#currency ⇒ Object
32
33
34
|
# File 'lib/mondo/transaction.rb', line 32
def currency
Money::Currency.new(raw_data['currency'])
end
|
#declined? ⇒ Boolean
16
17
18
|
# File 'lib/mondo/transaction.rb', line 16
def declined?
raw_data['decline_reason'].present?
end
|
#local_amount ⇒ Object
24
25
26
|
# File 'lib/mondo/transaction.rb', line 24
def local_amount
Money.new(raw_data['local_amount'], local_currency)
end
|
#local_currency ⇒ Object
36
37
38
|
# File 'lib/mondo/transaction.rb', line 36
def local_currency
Money::Currency.new(raw_data['local_currency'])
end
|
#merchant(opts = {}) ⇒ Object
63
64
65
66
67
68
69
70
|
# File 'lib/mondo/transaction.rb', line 63
def merchant(opts={})
unless raw_data['merchant'].kind_of?(Hash)
self.raw_data['merchant'] = self.client.transaction(self.id, expand: [:merchant]).raw_data['merchant']
end
::Mondo::Merchant.new(raw_data['merchant'], client) unless raw_data['merchant'].nil?
end
|
#register_attachment(args = {}) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/mondo/transaction.rb', line 44
def register_attachment(args={})
attachment = Attachment.new(
{
external_id: self.id,
file_url: args.fetch(:file_url),
file_type: args.fetch(:file_type)
},
self.client
)
self.attachments << attachment if attachment.register
end
|
40
41
42
|
# File 'lib/mondo/transaction.rb', line 40
def save_metadata
self.client.api_patch("/transactions/#{self.id}", metadata: self.metadata)
end
|
72
73
74
|
# File 'lib/mondo/transaction.rb', line 72
def tags
metadata["tags"]
end
|
76
77
78
|
# File 'lib/mondo/transaction.rb', line 76
def tags=(t)
metadata["tags"] = t
end
|