Sha256: 508106853fe1db0f27b7c89a1746ccab3b6c5fcde643f62714aac6f11800f5ee

Contents?: true

Size: 1.23 KB

Versions: 38

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

module Dor
  module Services
    class Client
      # @abstract API calls to a versioned endpoint
      class VersionedService
        def initialize(connection:, version:)
          @connection = connection
          @api_version = version
        end

        # Common interface for handling asynchronous results
        def async_result(url:)
          AsyncResult.new(url: url)
        end

        private

        attr_reader :connection, :api_version

        # rubocop:disable Metrics/MethodLength
        def raise_exception_based_on_response!(response, object_identifier = nil)
          exception_class = case response.status
                            when 404
                              NotFoundResponse
                            when 401
                              UnauthorizedResponse
                            when 409
                              ConflictResponse
                            else
                              UnexpectedResponse
                            end
          raise exception_class,
                ResponseErrorFormatter.format(response: response, object_identifier: object_identifier)
        end
        # rubocop:enable Metrics/MethodLength
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
dor-services-client-6.35.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.34.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.33.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.32.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.31.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.30.1 lib/dor/services/client/versioned_service.rb
dor-services-client-6.30.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.29.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.28.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.27.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.26.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.26.0.beta.1 lib/dor/services/client/versioned_service.rb
dor-services-client-6.25.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.24.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.23.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.22.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.21.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.20.0 lib/dor/services/client/versioned_service.rb
dor-services-client-6.19.2 lib/dor/services/client/versioned_service.rb
dor-services-client-6.19.1 lib/dor/services/client/versioned_service.rb