Class: Musoni::Transaction

Inherits:
Endpoint show all
Defined in:
lib/musoni_ruby/endpoints/transaction.rb

Instance Attribute Summary

Attributes inherited from Endpoint

#attributes, #config, #endpoint, #id, #pagination, #response

Class Method Summary collapse

Methods inherited from Endpoint

#fail?, #initialize, #success?

Constructor Details

This class inherits a constructor from Musoni::Endpoint

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Musoni::Endpoint

Class Method Details

.transfer(options = {}) ⇒ Object

move to own endpoint from_account = 1,fromClientId: 1,fromAccountType: 2,fromAccountId: 1 to_account = 1,toClientId: 1,toAccountType: 1,toAccountId: 9 Musoni::SavingsAccount.transfer(from_account.merge!(to_account).merge!(transferAmount:100,transferDescription:“transfering”)



20
21
22
23
24
25
26
# File 'lib/musoni_ruby/endpoints/transaction.rb', line 20

def transfer(options={})
  options = transfer_options(options)
  url = "/accounttransfers"
  options[:transferDate] ||= Time.zone.now
  response = Musoni::Fetch.post(url,options)
  new(options.merge!(id:response.resourceId ,response:response)) rescue response
end

.transfer_options(options) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/musoni_ruby/endpoints/transaction.rb', line 7

def transfer_options(options)
  # TODO Have actual object as inputs like account1 and account2
  options.merge!(options[:to] || {}).merge!(options[:from] || {})
  options[:transferAmount] ||= options[:amount]
  options[:transferDescription] ||= options[:description]
  [:to,:from,:amount,:description].each { |k| options.delete k }
  options
end