Class: SepaClearer::PaymentProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/sepa_clearer/payment_provider.rb

Constant Summary collapse

SERVICES =
[:sct, :core, :cor1, :b2b]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ PaymentProvider

Returns a new instance of PaymentProvider.



7
8
9
10
11
12
13
14
# File 'lib/sepa_clearer/payment_provider.rb', line 7

def initialize(options = {})
  self.name = options[:name]
  self.bic = options[:bic]
  self.sct = options[:sct] || false
  self.core = options[:core] || false
  self.cor1 = options[:cor1] || false
  self.b2b = options[:b2b] || false
end

Instance Attribute Details

#b2bObject

Returns the value of attribute b2b.



5
6
7
# File 'lib/sepa_clearer/payment_provider.rb', line 5

def b2b
  @b2b
end

#bicObject

Returns the value of attribute bic.



5
6
7
# File 'lib/sepa_clearer/payment_provider.rb', line 5

def bic
  @bic
end

#cor1Object

Returns the value of attribute cor1.



5
6
7
# File 'lib/sepa_clearer/payment_provider.rb', line 5

def cor1
  @cor1
end

#coreObject

Returns the value of attribute core.



5
6
7
# File 'lib/sepa_clearer/payment_provider.rb', line 5

def core
  @core
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/sepa_clearer/payment_provider.rb', line 5

def name
  @name
end

#sctObject

Returns the value of attribute sct.



5
6
7
# File 'lib/sepa_clearer/payment_provider.rb', line 5

def sct
  @sct
end

Instance Method Details

#capabilitiesObject



16
17
18
# File 'lib/sepa_clearer/payment_provider.rb', line 16

def capabilities
  SERVICES.map { |s| [s, send(s)] }.select { |_,v| v }.map { |k,v| k }
end

#direct_debit_instrumentsObject

Returns a list of provided direct debit methods sorted by there speed :cor1 => 2 business days :core => 3 business days (recurring) & 6 business days for first



23
24
25
# File 'lib/sepa_clearer/payment_provider.rb', line 23

def direct_debit_instruments
  (capabilities & [:core, :cor1]).sort
end

#to_aObject



31
32
33
# File 'lib/sepa_clearer/payment_provider.rb', line 31

def to_a
  to_hash.values
end

#to_hashObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/sepa_clearer/payment_provider.rb', line 35

def to_hash
  {
    name: name,
    bic: bic,
    sct: sct,
    core: core,
    cor1: cor1,
    b2b: b2b,
  }
end