Class: Docdata::Ideal

Inherits:
Object
  • Object
show all
Defined in:
lib/docdata/ideal.rb

Overview

This class bundles all the needed logic and methods for IDEAL specific stuff.

Class Method Summary collapse

Class Method Details

.banksArray<Docdata::Ideal>

List of supported banks.

For the lack of an available list of banks by Docdata, this gem uses the list provided by competitor Mollie.

Examples:

Docdata.banks

Returns:



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/docdata/ideal.rb', line 19

def self.banks
  begin
    @source ||= open('https://secure.mollie.nl/xml/ideal?a=banklist')
  rescue 
    # in case the mollie API isn't available
    # use the cached version (august 2014) of the XML file
    @source = open("#{File.dirname(__FILE__)}/xml/bank-list.xml")
  end
  @response ||= Nokogiri::XML(@source)
  @list = []
  @response.xpath("//bank").each do |b|
    bank = Docdata::Bank.new(
      id: b.xpath("bank_id").first.content,
      name: b.xpath("bank_name").first.content
    )
    @list << bank
  end
  return @list
end