Class: PreventGo::TaxNotice

Inherits:
Base
  • Object
show all
Defined in:
lib/prevent_go/tax_notice.rb

Instance Attribute Summary

Attributes inherited from Base

#params, #request

Instance Method Summary collapse

Methods inherited from Base

#document_controls, #document_details, #document_type, #holder_controls, #initialize

Constructor Details

This class inherits a constructor from PreventGo::Base

Instance Method Details

#default_holders_keysObject



40
41
42
# File 'lib/prevent_go/tax_notice.rb', line 40

def default_holders_keys
  %w[firstName lastName birthName birthDate]
end

#endpointObject



18
19
20
# File 'lib/prevent_go/tax_notice.rb', line 18

def endpoint
  '/tax-notice'
end

#fetch_holders_infos(*keys) ⇒ Object



35
36
37
38
# File 'lib/prevent_go/tax_notice.rb', line 35

def fetch_holders_infos(*keys)
  keys = default_holders_keys if keys.empty?
  holders_data.map { |holder| holder.compact.slice(*keys).values }
end

#holders_dataObject



22
23
24
25
# File 'lib/prevent_go/tax_notice.rb', line 22

def holders_data
  @_holders_data ||=
    [@request.dig('taxNoticeDetails', 'holder1'), @request.dig('taxNoticeDetails', 'holder2')].compact
end

#quality_validated?Boolean

Returns:

  • (Boolean)


27
28
29
30
31
32
33
# File 'lib/prevent_go/tax_notice.rb', line 27

def quality_validated?
  [
    document_controls['typeRecognized'],
    document_controls.dig('quality', 'aboveMinimumThreshold'),
    document_controls['fiscalNumberFound']
  ].all? { |entry| entry == 'OK' }
end