Sha256: 1f45222721148f1a206f42c5f9b8a9486a9c266e076a26c3ff52d8f28acde291

Contents?: true

Size: 991 Bytes

Versions: 4

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

module Yoti
  module DocScan
    module Session
      module Retrieve
        class ResourceResponse
          # @return [String]
          attr_reader :id

          # @return [Array<TaskResponse>]
          attr_reader :tasks

          #
          # @param [Hash] resource
          #
          def initialize(resource)
            Validation.assert_is_a(String, resource['id'], 'id', true)
            @id = resource['id']

            if resource['tasks'].nil?
              @tasks = []
            else
              Validation.assert_is_a(Array, resource['tasks'], 'tasks')
              @tasks = resource['tasks'].map do |task|
                case task['type']
                when Constants::ID_DOCUMENT_TEXT_DATA_EXTRACTION
                  TextExtractionTaskResponse.new(task)
                else
                  TaskResponse.new(task)
                end
              end
            end
          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_response.rb
yoti-1.8.0 lib/yoti/doc_scan/session/retrieve/resource_response.rb
yoti-1.7.1 lib/yoti/doc_scan/session/retrieve/resource_response.rb
yoti-1.7.0 lib/yoti/doc_scan/session/retrieve/resource_response.rb