Class: GoCardlessPro::Resources::CustomerBankAccount

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

Overview

Customer Bank Accounts hold the bank details of a [customer](#core-endpoints-customers). They always belong to a [customer](#core-endpoints-customers), and may be linked to several Direct Debit [mandates](#core-endpoints-mandates).

Note that customer bank accounts must be unique, and so you will encounter a ‘bank_account_exists` error if you try to create a duplicate bank account. You may wish to handle this by updating the existing record instead, the ID of which will be provided as `links` in the error response.

Note: To ensure the customer’s bank accounts are valid, verify them first using

[bank_details_lookups](#bank-details-lookups-perform-a-bank-details-lookup), before proceeding with creating the accounts

Defined Under Namespace

Classes: Links

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object, response = nil) ⇒ CustomerBankAccount

Initialize a customer_bank_account resource instance

Parameters:

  • object (Hash)

    an object returned from the API



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 36

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

  @account_holder_name = object['account_holder_name']
  @account_number_ending = object['account_number_ending']
  @account_type = object['account_type']
  @bank_account_token = object['bank_account_token']
  @bank_name = object['bank_name']
  @country_code = object['country_code']
  @created_at = object['created_at']
  @currency = object['currency']
  @enabled = object['enabled']
  @id = object['id']
  @links = object['links']
  @metadata = object['metadata']
  @response = response
end

Instance Attribute Details

#account_holder_nameObject (readonly)

Returns the value of attribute account_holder_name.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def 
  @account_holder_name
end

#account_number_endingObject (readonly)

Returns the value of attribute account_number_ending.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def 
  @account_number_ending
end

#account_typeObject (readonly)

Returns the value of attribute account_type.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def 
  @account_type
end

#bank_account_tokenObject (readonly)

Returns the value of attribute bank_account_token.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def 
  @bank_account_token
end

#bank_nameObject (readonly)

Returns the value of attribute bank_name.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def bank_name
  @bank_name
end

#country_codeObject (readonly)

Returns the value of attribute country_code.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def country_code
  @country_code
end

#created_atObject (readonly)

Returns the value of attribute created_at.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def created_at
  @created_at
end

#currencyObject (readonly)

Returns the value of attribute currency.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def currency
  @currency
end

#enabledObject (readonly)

Returns the value of attribute enabled.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def enabled
  @enabled
end

#idObject (readonly)

Returns the value of attribute id.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def id
  @id
end

#metadataObject (readonly)

Returns the value of attribute metadata.



31
32
33
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 31

def 
  @metadata
end

Instance Method Details

#api_responseObject



54
55
56
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 54

def api_response
  ApiResponse.new(@response)
end

Return the links that the resource has



59
60
61
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 59

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

#to_hObject

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



64
65
66
# File 'lib/gocardless_pro/resources/customer_bank_account.rb', line 64

def to_h
  @object
end