Class: Balanced::Credit
- Inherits:
-
Object
- Object
- Balanced::Credit
- Includes:
- Resource
- Defined in:
- lib/balanced/resources/credit.rb
Overview
A Credit represents a transfer of funds from your Marketplace’s escrow account to a Merchant’s Account within your Marketplace.
By default, a Credit is sent to the most recently added funding destination associated with an Account. You may specify a specific funding source.
Instance Attribute Summary
Attributes included from Resource
Instance Method Summary collapse
-
#initialize(*args) ⇒ Credit
constructor
A new instance of Credit.
Methods included from Resource
#copy_from, #destroy, #find, included, #method_missing, #reload, #save, #warn_on_positional
Constructor Details
#initialize(*args) ⇒ Credit
Returns a new instance of Credit.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/balanced/resources/credit.rb', line 20 def initialize *args = args.last.is_a?(Hash) ? args.pop : {} uri = .fetch(:uri) { self.class.uri } bank_account = .fetch(:bank_account) {} amount = args[0] || .fetch(:amount) { } description = args[1] || .fetch(:description) { nil } unless bank_account.nil? # Accountless bank account attributes = { uri: uri, amount: amount, description: description, bank_account: bank_account, meta: nil } else = args[2] || .fetch(:meta) { nil } destination_uri = args[3] || .fetch(:destination_uri) { nil } appears_on_statement_as = args[4] || .fetch(:appears_on_statement_as) { nil } attributes = { uri: uri, amount: amount, meta: , description: description, destination_uri: destination_uri, appears_on_statement_as: appears_on_statement_as } end Balanced::Utils.stringify_keys! attributes super attributes end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Balanced::Resource