Class: Braintree::Disbursement

Inherits:
Object
  • Object
show all
Includes:
BaseModule
Defined in:
lib/braintree/disbursement.rb

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from BaseModule

included

Methods included from BaseModule::Methods

#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class

Constructor Details

#initialize(gateway, attributes) ⇒ Disbursement

Returns a new instance of Disbursement.



23
24
25
26
27
28
29
# File 'lib/braintree/disbursement.rb', line 23

def initialize(gateway, attributes)
  @gateway = gateway
  set_instance_variables_from_hash(attributes)
  @amount = Util.to_big_decimal(amount)
  @disbursement_date = Date.parse(disbursement_date)
  @merchant_account = MerchantAccount._new(gateway, @merchant_account)
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



10
11
12
# File 'lib/braintree/disbursement.rb', line 10

def amount
  @amount
end

#disbursement_dateObject (readonly)

Returns the value of attribute disbursement_date.



11
12
13
# File 'lib/braintree/disbursement.rb', line 11

def disbursement_date
  @disbursement_date
end

#disbursement_typeObject (readonly)

Returns the value of attribute disbursement_type.



12
13
14
# File 'lib/braintree/disbursement.rb', line 12

def disbursement_type
  @disbursement_type
end

#exception_messageObject (readonly)

Returns the value of attribute exception_message.



13
14
15
# File 'lib/braintree/disbursement.rb', line 13

def exception_message
  @exception_message
end

#follow_up_actionObject (readonly)

Returns the value of attribute follow_up_action.



14
15
16
# File 'lib/braintree/disbursement.rb', line 14

def follow_up_action
  @follow_up_action
end

#idObject (readonly)

Returns the value of attribute id.



15
16
17
# File 'lib/braintree/disbursement.rb', line 15

def id
  @id
end

#merchant_accountObject (readonly)

Returns the value of attribute merchant_account.



16
17
18
# File 'lib/braintree/disbursement.rb', line 16

def 
  @merchant_account
end

#retryObject (readonly)

Returns the value of attribute retry.



17
18
19
# File 'lib/braintree/disbursement.rb', line 17

def retry
  @retry
end

#successObject (readonly) Also known as: success?

Returns the value of attribute success.



18
19
20
# File 'lib/braintree/disbursement.rb', line 18

def success
  @success
end

#transaction_idsObject (readonly)

Returns the value of attribute transaction_ids.



19
20
21
# File 'lib/braintree/disbursement.rb', line 19

def transaction_ids
  @transaction_ids
end

Class Method Details

._inspect_attributesObject



59
60
61
# File 'lib/braintree/disbursement.rb', line 59

def self._inspect_attributes
  [:id, :exception_message, :follow_up_action, :merchant_account, :transaction_ids, :retry, :success]
end

._new(*args) ⇒ Object



54
55
56
# File 'lib/braintree/disbursement.rb', line 54

def _new(*args)
  self.new(*args)
end

Instance Method Details

#credit?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/braintree/disbursement.rb', line 48

def credit?
  disbursement_type == Types::Credit
end

#debit?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/braintree/disbursement.rb', line 44

def debit?
  disbursement_type == Types::Debit
end

#inspectObject



37
38
39
40
41
42
# File 'lib/braintree/disbursement.rb', line 37

def inspect
  nice_attributes = self.class._inspect_attributes.map { |attr| "#{attr}: #{send(attr).inspect}" }
  nice_attributes << "amount: #{self.amount.to_s("F").inspect}"
  nice_attributes << "disbursement_date: #{self.disbursement_date}"
  "#<#{self.class} #{nice_attributes.join(', ')}>"
end

#transactionsObject



31
32
33
34
35
# File 'lib/braintree/disbursement.rb', line 31

def transactions
  @gateway.transaction.search do |search|
    search.ids.in transaction_ids
  end
end