Sha256: 928537aa6f512226e8343059cb15b5b43d4370031828b351340b97be91a21ff4

Contents?: true

Size: 1.06 KB

Versions: 3

Compression:

Stored size: 1.06 KB

Contents

module Balanced
  # A card represents a source of funds for an Account. You may Hold or Debit
  # funds from the account associated with the Card.
  #
  class Card
    include Balanced::Resource

    def initialize attributes = {}
      Balanced::Utils.stringify_keys! attributes
      unless attributes.has_key? 'uri'
        attributes['uri'] = Balanced::Marketplace.my_marketplace.send(self.class.collection_name + '_uri')
      end
      super attributes
    end

    # Creates a Debit of funds from this Card to your Marketplace.
    #
    # If +appears_on_statement_as+ is nil, then Balanced will use the
    # +domain_name+ property from your Marketplace.
    #
    # @return [Debit]
    def debit amount=nil, appears_on_statement_as=nil, holds_uri=nil, meta={}, description=nil
      self.account.debit(amount, appears_on_statement_as, holds_uri, meta, description, self.uri)
    end

    # Creates a Hold of funds from this Card to your Marketplace.
    #
    # @return [Hold]
    def hold amount=nil, meta=nil
      self.account.hold(amount, meta, self.uri)
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
balanced-0.3.2 lib/balanced/resources/card.rb
balanced-0.3.1 lib/balanced/resources/card.rb
balanced-0.3.0 lib/balanced/resources/card.rb