Class: Ibancom::Resources::SCAN::Validation

Inherits:
Base
  • Object
show all
Defined in:
lib/ibancom/resources/scan/validation.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#response

Instance Method Summary collapse

Methods inherited from Base

map

Constructor Details

#initialize(response, attributes = {}) ⇒ Validation

Returns a new instance of Validation.



12
13
14
15
16
17
18
# File 'lib/ibancom/resources/scan/validation.rb', line 12

def initialize(response, attributes = {})
  super(response, attributes)
  @bank = Bank.new(response, attributes[:bank_data])
  @account = Account.new(response, attributes[:account_data])
  @checks = Checks.new(response, attributes[:validations])
  @schemes = Schemes.new(response, attributes[:payment_schemes])
end

Instance Attribute Details

#accountObject (readonly)

Returns the value of attribute account.



7
8
9
# File 'lib/ibancom/resources/scan/validation.rb', line 7

def 
  @account
end

#bankObject (readonly)

Returns the value of attribute bank.



7
8
9
# File 'lib/ibancom/resources/scan/validation.rb', line 7

def bank
  @bank
end

#checksObject (readonly)

Returns the value of attribute checks.



7
8
9
# File 'lib/ibancom/resources/scan/validation.rb', line 7

def checks
  @checks
end

#schemesObject (readonly)

Returns the value of attribute schemes.



7
8
9
# File 'lib/ibancom/resources/scan/validation.rb', line 7

def schemes
  @schemes
end

Instance Method Details

#failed_checksObject



24
25
26
# File 'lib/ibancom/resources/scan/validation.rb', line 24

def failed_checks
  checks.select(&:failed?)
end

#supported_scheme?(code) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
# File 'lib/ibancom/resources/scan/validation.rb', line 32

def supported_scheme?(code)
  scheme = supported_schemes.find { |supported| supported.code == code }

  return false if scheme.nil?

  scheme.supported?
end

#supported_schemesObject



28
29
30
# File 'lib/ibancom/resources/scan/validation.rb', line 28

def supported_schemes
  schemes.select(&:supported?)
end

#valid?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ibancom/resources/scan/validation.rb', line 20

def valid?
  checks.all?(&:passed?)
end