Class: Mondo::Transaction
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#notes ⇒ Object
Returns the value of attribute notes.
Attributes inherited from Resource
Instance Method Summary collapse
-
#amount_with_currency ⇒ Object
TODO - proper currency library.
- #attachments ⇒ Object
- #merchant(opts = {}) ⇒ Object
- #register_attachment(args = {}) ⇒ Object
- #save_metadata ⇒ Object
- #tags ⇒ Object
- #tags=(t) ⇒ Object
Methods inherited from Resource
date_accessor, date_writer, #initialize, #inspect, #to_s
Constructor Details
This class inherits a constructor from Mondo::Resource
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
4 5 6 |
# File 'lib/mondo/transaction.rb', line 4 def amount @amount end |
#currency ⇒ Object
Returns the value of attribute currency.
4 5 6 |
# File 'lib/mondo/transaction.rb', line 4 def currency @currency 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 |
#metadata ⇒ Object
Returns the value of attribute metadata.
4 5 6 |
# File 'lib/mondo/transaction.rb', line 4 def @metadata end |
#notes ⇒ Object
Returns the value of attribute notes.
4 5 6 |
# File 'lib/mondo/transaction.rb', line 4 def notes @notes end |
Instance Method Details
#amount_with_currency ⇒ Object
TODO - proper currency library
14 15 16 |
# File 'lib/mondo/transaction.rb', line 14 def amount_with_currency "#{amount/100}#{currency}" end |
#attachments ⇒ Object
35 36 37 38 39 |
# File 'lib/mondo/transaction.rb', line 35 def @transactions ||= begin raw_data['attachments'].map { |tx| Attachment.new(tx, self.client) } end end |
#merchant(opts = {}) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/mondo/transaction.rb', line 41 def merchant(opts={}) unless raw_data['merchant'].kind_of?(Hash) # Go and refetch the transaction with merchant info expanded 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
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/mondo/transaction.rb', line 22 def (args={}) = Attachment.new( { external_id: self.id, file_url: args.fetch(:file_url), file_type: args.fetch(:file_type) }, self.client ) self. << if .register end |
#save_metadata ⇒ Object
18 19 20 |
# File 'lib/mondo/transaction.rb', line 18 def self.client.api_patch("/transactions/#{self.id}", metadata: self.) end |
#tags ⇒ Object
50 51 52 |
# File 'lib/mondo/transaction.rb', line 50 def ["tags"] end |
#tags=(t) ⇒ Object
54 55 56 |
# File 'lib/mondo/transaction.rb', line 54 def (t) ["tags"] = t end |