Class: GoCardlessPro::Resources::Balance

Inherits:
Object
  • Object
show all
Defined in:
lib/gocardless_pro/resources/balance.rb

Overview

Returns the balances for a creditor. These balances are the same as what’s shown in the dashboard with one exception (mentioned below under balance_type).

These balances will typically be 3-5 minutes old. The balance amounts likely won’t match what’s shown in the dashboard as the dashboard balances are updated much less frequently (once per day).

Defined Under Namespace

Classes: Links

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, response = nil) ⇒ Balance

Initialize a balance resource instance

Parameters:

  • object (Hash)

    an object returned from the API



25
26
27
28
29
30
31
32
33
34
# File 'lib/gocardless_pro/resources/balance.rb', line 25

def initialize(object, response = nil)
  @object = object

  @amount = object['amount']
  @balance_type = object['balance_type']
  @currency = object['currency']
  @last_updated_at = object['last_updated_at']
  @links = object['links']
  @response = response
end

Instance Attribute Details

#amountObject (readonly)

Returns the value of attribute amount.



21
22
23
# File 'lib/gocardless_pro/resources/balance.rb', line 21

def amount
  @amount
end

#balance_typeObject (readonly)

Returns the value of attribute balance_type.



21
22
23
# File 'lib/gocardless_pro/resources/balance.rb', line 21

def balance_type
  @balance_type
end

#currencyObject (readonly)

Returns the value of attribute currency.



21
22
23
# File 'lib/gocardless_pro/resources/balance.rb', line 21

def currency
  @currency
end

#last_updated_atObject (readonly)

Returns the value of attribute last_updated_at.



21
22
23
# File 'lib/gocardless_pro/resources/balance.rb', line 21

def last_updated_at
  @last_updated_at
end

Instance Method Details

#api_responseObject



36
37
38
# File 'lib/gocardless_pro/resources/balance.rb', line 36

def api_response
  ApiResponse.new(@response)
end

Return the links that the resource has



41
42
43
# File 'lib/gocardless_pro/resources/balance.rb', line 41

def links
  @balance_links ||= Links.new(@links)
end

#to_hObject

Provides the balance resource as a hash of all its readable attributes



46
47
48
# File 'lib/gocardless_pro/resources/balance.rb', line 46

def to_h
  @object
end