Sha256: fe922a045cf4463229314d750d39f5d004d74095338b5a0a13e2d8de62ef4e7b

Contents?: true

Size: 1.76 KB

Versions: 4

Compression:

Stored size: 1.76 KB

Contents

# frozen_string_literal: true

module Yoti
  module Sandbox
    module DocScan
      #
      # Client for the Doc Scan sandbox service
      #
      class Client
        #
        # @param [String] base_url
        #
        def initialize(base_url: nil)
          @base_url = base_url || "#{Yoti.configuration.api_url}/sandbox/idverify/v1"
        end

        #
        # @param [String] session_id
        # @param [Yoti::SandboxDocScan::Request::ResponseConfig] response_config
        #
        def configure_session_response(session_id, response_config)
          request = Yoti::Request
                    .builder
                    .with_http_method('PUT')
                    .with_base_url(@base_url)
                    .with_endpoint("sessions/#{session_id}/response-config")
                    .with_query_param('sdkId', Yoti.configuration.client_sdk_id)
                    .with_payload(response_config)
                    .build

          begin
            request.execute
          rescue Yoti::RequestError => e
            raise Yoti::Sandbox::DocScan::Error.wrap(e)
          end
        end

        #
        # @param [Yoti::SandboxDocScan::Request::ResponseConfig] response_config
        #
        def configure_application_response(response_config)
          request = Yoti::Request
                    .builder
                    .with_http_method('PUT')
                    .with_base_url(@base_url)
                    .with_endpoint("apps/#{Yoti.configuration.client_sdk_id}/response-config")
                    .with_payload(response_config)
                    .build

          begin
            request.execute
          rescue Yoti::RequestError => e
            raise Yoti::Sandbox::DocScan::Error.wrap(e)
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yoti_sandbox-1.4.0 lib/yoti_sandbox/doc_scan/client.rb
yoti_sandbox-1.3.0 lib/yoti_sandbox/doc_scan/client.rb
yoti_sandbox-1.2.1 lib/yoti_sandbox/doc_scan/client.rb
yoti_sandbox-1.2.0 lib/yoti_sandbox/doc_scan/client.rb