Sha256: cce5a7fe207b03fa4de7af28e4c77a47f5c7d9fe2338e1e556e5f9e848ad04d1

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

# frozen_string_literal: true

module Yoti
  module Sandbox
    module DocScan
      module Request
        class TaskResults
          #
          # @param [Array<DocumentTextDataExtractionTask>] document_text_data_extraction_tasks
          #
          def initialize(document_text_data_extraction_tasks)
            Validation.assert_is_a(
              Array,
              document_text_data_extraction_tasks,
              'document_text_data_extraction_tasks'
            )
            @document_text_data_extraction_tasks = document_text_data_extraction_tasks
          end

          def self.builder
            TaskResultsBuilder.new
          end

          def to_json(*_args)
            as_json.to_json
          end

          def as_json(*_args)
            {
              Yoti::DocScan::Constants::ID_DOCUMENT_TEXT_DATA_EXTRACTION => @document_text_data_extraction_tasks
            }
          end
        end

        class TaskResultsBuilder
          def initialize
            @document_text_data_extraction_tasks = []
          end

          #
          # @param [DocumentTextDataExtractionTask] document_text_data_extraction_task
          #
          # @return [self]
          #
          def with_document_text_data_extraction_task(document_text_data_extraction_task)
            Validation.assert_is_a(
              DocumentTextDataExtractionTask,
              document_text_data_extraction_task,
              'document_text_data_extraction_task'
            )
            @document_text_data_extraction_tasks << document_text_data_extraction_task
            self
          end

          #
          # @return [TaskResults]
          #
          def build
            TaskResults.new(@document_text_data_extraction_tasks)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoti_sandbox-1.3.0 lib/yoti_sandbox/doc_scan/request/task_results.rb
yoti_sandbox-1.2.1 lib/yoti_sandbox/doc_scan/request/task_results.rb
yoti_sandbox-1.2.0 lib/yoti_sandbox/doc_scan/request/task_results.rb
yoti_sandbox-1.1.0 lib/yoti_sandbox/doc_scan/request/task_results.rb