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



28
29
30
31
32
33
34
35
36
37
# File 'lib/gocardless_pro/resources/balance.rb', line 28

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.



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

def balance_type
  @balance_type
end

#currencyObject (readonly)

Returns the value of attribute currency.



23
24
25
# File 'lib/gocardless_pro/resources/balance.rb', line 23

def currency
  @currency
end

#last_updated_atObject (readonly)

Returns the value of attribute last_updated_at.



24
25
26
# File 'lib/gocardless_pro/resources/balance.rb', line 24

def last_updated_at
  @last_updated_at
end

Instance Method Details

#api_responseObject



39
40
41
# File 'lib/gocardless_pro/resources/balance.rb', line 39

def api_response
  ApiResponse.new(@response)
end

Return the links that the resource has



44
45
46
# File 'lib/gocardless_pro/resources/balance.rb', line 44

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

#to_hObject

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



49
50
51
# File 'lib/gocardless_pro/resources/balance.rb', line 49

def to_h
  @object
end