Sha256: ac56be28ee5a8ab1a9fdcac865f9f9d2c6893724ad6a764e2d18742756e06992

Contents?: true

Size: 1.7 KB

Versions: 3

Compression:

Stored size: 1.7 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

          # @return [DocumentIdPhotoResponse]
          attr_reader :document_id_photo

          #
          # @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?

            @document_id_photo = DocumentIdPhotoResponse.new(resource['document_id_photo']) unless resource['document_id_photo'].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

3 entries across 3 versions & 1 rubygems

Version Path
yoti-1.10.0 lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb
yoti-1.9.0 lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb
yoti-1.8.0 lib/yoti/doc_scan/session/retrieve/id_document_resource_response.rb