Sha256: 8cf24c13a97a614bd25f508653a2e7ddba471e8c29e43e391c8da8fe1d623376

Contents?: true

Size: 1.54 KB

Versions: 4

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module Yoti
  module DocScan
    module Session
      module Retrieve
        class ResourceContainer
          # @return [Array<IdDocumentResourceResponse>]
          attr_reader :id_documents

          # @return [Array<LivenessResourceResponse>]
          attr_reader :liveness_capture

          #
          # @param [Hash] resources
          #
          def initialize(resources)
            if resources['id_documents'].nil?
              @id_documents = []
            else
              Validation.assert_is_a(Array, resources['id_documents'], 'id_documents')
              @id_documents = resources['id_documents'].map { |resource| IdDocumentResourceResponse.new(resource) }
            end

            if resources['liveness_capture'].nil?
              @liveness_capture = []
            else
              Validation.assert_is_a(Array, resources['liveness_capture'], 'liveness_capture')
              @liveness_capture = resources['liveness_capture'].map do |resource|
                case resource['liveness_type']
                when Constants::ZOOM
                  ZoomLivenessResourceResponse.new(resource)
                else
                  LivenessResourceResponse.new(resource)
                end
              end
            end
          end

          #
          # @return [Array<ZoomLivenessResourceResponse>]
          #
          def zoom_liveness_resources
            @liveness_capture.select { |resource| resource.is_a?(ZoomLivenessResourceResponse) }
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoti-1.9.0 lib/yoti/doc_scan/session/retrieve/resource_container.rb
yoti-1.8.0 lib/yoti/doc_scan/session/retrieve/resource_container.rb
yoti-1.7.1 lib/yoti/doc_scan/session/retrieve/resource_container.rb
yoti-1.7.0 lib/yoti/doc_scan/session/retrieve/resource_container.rb