Sha256: 0819fb894616c38a7592b2bbf08297d650e81cf4b9bb9b6cbcdabe4ee25dae7e

Contents?: true

Size: 1.48 KB

Versions: 2

Compression:

Stored size: 1.48 KB

Contents

# frozen_string_literal: true

module Yoti
  module DocScan
    module Session
      module Retrieve
        class IdDocumentResourceResponse < ResourceResponse
          # @return [String]
          attr_reader :document_type

          # @return [String]
          attr_reader :issuing_country

          # @return [Array<PageResponse>]
          attr_reader :pages

          # @return [DocumentFieldsResponse]
          attr_reader :document_fields

          #
          # @param [Hash] resource
          #
          def initialize(resource)
            super(resource)

            Validation.assert_is_a(String, resource['document_type'], 'document_type', true)
            @document_type = resource['document_type']

            Validation.assert_is_a(String, resource['issuing_country'], 'issuing_country', true)
            @issuing_country = resource['issuing_country']

            if resource['pages'].nil?
              @pages = []
            else
              Validation.assert_is_a(Array, resource['pages'], 'pages')
              @pages = resource['pages'].map { |page| PageResponse.new(page) }
            end

            @document_fields = DocumentFieldsResponse.new(resource['document_fields']) unless resource['document_fields'].nil?
          end

          #
          # @return [Array<TextExtractionTaskResponse>]
          #
          def text_extraction_tasks
            @tasks.select { |task| task.is_a?(TextExtractionTaskResponse) }
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yoti-1.7.1 lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb
yoti-1.7.0 lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb