Class: AfterbanksPSD2::Bank
Class Method Summary
collapse
Methods inherited from Resource
fields_information, #fields_information, has_fields, #initialize
Class Method Details
.bank_id_for(bank_information:) ⇒ Object
69
70
71
|
# File 'lib/afterbanks_psd2/resources/bank.rb', line 69
def self.bank_id_for(bank_information:)
bank_information['service'].split("_").first
end
|
.bank_name_for(bank_information:) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/afterbanks_psd2/resources/bank.rb', line 52
def self.bank_name_for(bank_information:)
service = bank_information['service']
return "Caixa d'Enginyers" if service == 'cajaingenieros'
return "Caixa Guissona" if service == 'caixaguissona'
return "Caixa Burriana" if service == 'caixaruralburriana'
bank_information['fullname']
end
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/afterbanks_psd2/resources/bank.rb', line 31
def self.banks_information_for(response:, ordered:, country_codes:)
country_codes = country_codes.map(&:upcase) unless country_codes.nil?
banks_information = []
response.each do |bank_information|
next if country_codes && !country_codes.include?(bank_information['countryCode'])
bank_information['fullname'] = bank_name_for(bank_information: bank_information)
banks_information << bank_information
end
if ordered
banks_information.sort! do |bank_information1, bank_information2|
bank_information1['fullname'].downcase <=> bank_information2['fullname'].downcase
end
end
banks_information
end
|
.list(ordered: false, country_codes: nil) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/afterbanks_psd2/resources/bank.rb', line 11
def self.list(ordered: false, country_codes: nil)
response, debug_id = AfterbanksPSD2.api_call(
method: :get,
path: '/listOfSupportedBanks/'
)
Response.new(
result: Collection.new(
banks_information_for(
response: response,
ordered: ordered,
country_codes: country_codes
),
self
),
body: response,
debug_id: debug_id
)
end
|