Sha256: a1b28e3d791702a9bcc0216d036e6611c6dea37a1c64be28c8976fb8dbfe8422

Contents?: true

Size: 1.66 KB

Versions: 7

Compression:

Stored size: 1.66 KB

Contents

module Balanced
  # A BankAccount is both a source, and a destination of, funds. You may
  # create Debits and Credits to and from, this funding source.
  #
  # *NOTE:* The BankAccount resource does not support creating a Hold.
  #
  class BankAccount < Balanced::DebitableFundingInstrument
    include Balanced::Resource
    include Balanced::HypermediaRegistry

    define_hypermedia_types [:bank_accounts]

    # Creates a Debit of funds from this BankAccount to your Marketplace's escrow account.
    #
    # @return [Debit]
    def debit(options = {})
      options[:href] = self.debits.href
      debit = Balanced::Debit.new(options)
      debit.save
    end

    # Creates a Credit of funds from your Marketplace's escrow account to this
    # Account.
    #
    # @return [Credit]
    def credit(options = {})
      options[:href] = self.credits.href
      credit = Balanced::Credit.new(options)
      credit.save
    end

    def verify
      options = {:href => self.bank_account_verifications.href}
      vf = BankAccountVerification.new(options)
      vf.save
    end

    def associate_to_customer(customer)
      self.links['customer'] = Balanced::Utils.extract_href_from_object(customer)
      save
    end
  end

  class BankAccountVerification
    include Balanced::Resource
    include Balanced::HypermediaRegistry

    define_hypermedia_types [:bank_account_verification,
                             :bank_account_verifications,
                             :verification,
                             :verifications
                            ]

    def confirm(amount_1, amount_2)
      self.amount_1 = amount_1
      self.amount_2 = amount_2
      save
    end
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
balanced-1.2.1 lib/balanced/resources/bank_account.rb
balanced-1.1.1 lib/balanced/resources/bank_account.rb
balanced-1.1.0 lib/balanced/resources/bank_account.rb
balanced-1.0.2 lib/balanced/resources/bank_account.rb
balanced-1.0.1 lib/balanced/resources/bank_account.rb
balanced-1.0 lib/balanced/resources/bank_account.rb
balanced-1.0.beta1 lib/balanced/resources/bank_account.rb