Class: Balanced::Card
- Inherits:
-
DebitableFundingInstrument
- Object
- FundingInstrument
- DebitableFundingInstrument
- Balanced::Card
- Includes:
- HypermediaRegistry, Resource
- Defined in:
- lib/balanced/resources/card.rb
Overview
A card represents a source of funds for an Account. You may Hold or Debit funds from the account associated with the Card.
Instance Attribute Summary
Attributes included from Resource
#attributes, #href, #hyperlinks, #id, #links
Instance Method Summary collapse
- #associate_to_customer(customer) ⇒ Object
-
#credit(options = {}) ⇒ Credit
Creates a Credit of funds to this Card.
-
#debit(options = {}) ⇒ Debit
Creates a Debit of funds from this Card.
-
#hold(options = {}) ⇒ Hold
Creates a Hold of funds from this Card to your Marketplace.
Methods included from HypermediaRegistry
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
#associate_to_customer(customer) ⇒ Object
44 45 46 47 |
# File 'lib/balanced/resources/card.rb', line 44 def associate_to_customer(customer) self.links['customer'] = Balanced::Utils.extract_href_from_object(customer) save end |
#credit(options = {}) ⇒ Credit
Creates a Credit of funds to this Card.
25 26 27 28 29 30 31 32 33 |
# File 'lib/balanced/resources/card.rb', line 25 def credit(={}) if ! self.respond_to?(:credits) raise Balanced::FundingInstrumentNotCreditable end [:href] = self.credits.href credit = Balanced::Credit.new() credit.save end |