Class: Balanced::Account

Inherits:
FundingInstrument show all
Includes:
HypermediaRegistry, Resource
Defined in:
lib/balanced/resources/account.rb

Overview

An Account is a way to pool funds from across multiple Orders

Instance Attribute Summary

Attributes included from Resource

#attributes, #href, #hyperlinks, #id, #links

Instance Method Summary collapse

Methods included from HypermediaRegistry

included

Methods included from Resource

#copy_from, #does_resource_respond_to?, #fetch, #hydrate, included, #initialize, #method_missing, #reload, #respond_to?, #respond_to_missing?, #sanitize, #save, #unstore

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Balanced::Resource

Instance Method Details

#credit(options = {}) ⇒ Credit

Creates a Credit of funds from to this Account.

Returns:



13
14
15
16
17
# File 'lib/balanced/resources/account.rb', line 13

def credit(options = {})
  options[:href] = self.credits.href
  credit = Balanced::Credit.new(options)
  credit.save
end

#settle(options = {}) ⇒ Credit

Creates a Settlement from to this Account.

Returns:



22
23
24
25
26
27
28
29
30
# File 'lib/balanced/resources/account.rb', line 22

def settle(options = {})
  Balanced::Utils.assert_required_keys(
      options,
      :required => [:funding_instrument]
  )
  options[:href] = self.settlements.href
  settlement = Balanced::Settlement.new(options)
  settlement.save
end