Class: PreventGo::Base

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_front, file_back = nil, **params) ⇒ Base

Returns a new instance of Base.



5
6
7
8
# File 'lib/prevent_go/base.rb', line 5

def initialize(file_front, file_back=nil, **params)
  @params = PreventGo.concat_params([file_front, file_back], params)
  @request = PreventGo.request(endpoint, @params)
end

Instance Attribute Details

#paramsObject

Returns the value of attribute params.



3
4
5
# File 'lib/prevent_go/base.rb', line 3

def params
  @params
end

#requestObject

Returns the value of attribute request.



3
4
5
# File 'lib/prevent_go/base.rb', line 3

def request
  @request
end

Instance Method Details

#document_controlsObject



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

def document_controls
  @_document_controls ||= @request.dig('controlsGroups', 'document') || {}
end

#document_detailsObject



14
15
16
# File 'lib/prevent_go/base.rb', line 14

def document_details
  @_document_details ||= @request['documentDetails'] || {}
end

#document_typeObject



10
11
12
# File 'lib/prevent_go/base.rb', line 10

def document_type
  @request["documentType"]
end

#holder_controlsObject



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

def holder_controls
  @_holder_controls ||= @request.dig('controlsGroups', 'holder')
end

#quality_validated?Boolean

Returns:

  • (Boolean)


26
27
28
29
30
31
# File 'lib/prevent_go/base.rb', line 26

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