Sha256: 19c126f48d0b84ee6c78e9b7a09d6eede554da1c2d1c9e5373a4e7226e5b99da

Contents?: true

Size: 1.31 KB

Versions: 27

Compression:

Stored size: 1.31 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 400
                              BadRequestError
                            when 401
                              UnauthorizedResponse
                            when 404
                              NotFoundResponse
                            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

27 entries across 27 versions & 1 rubygems

Version Path
dor-services-client-8.9.0 lib/dor/services/client/versioned_service.rb
dor-services-client-8.8.0 lib/dor/services/client/versioned_service.rb
dor-services-client-8.7.0 lib/dor/services/client/versioned_service.rb
dor-services-client-8.6.0 lib/dor/services/client/versioned_service.rb
dor-services-client-8.5.0 lib/dor/services/client/versioned_service.rb
dor-services-client-8.4.0 lib/dor/services/client/versioned_service.rb
dor-services-client-8.3.0 lib/dor/services/client/versioned_service.rb
dor-services-client-8.2.0 lib/dor/services/client/versioned_service.rb
dor-services-client-8.1.1 lib/dor/services/client/versioned_service.rb
dor-services-client-8.1.0 lib/dor/services/client/versioned_service.rb
dor-services-client-8.0.0 lib/dor/services/client/versioned_service.rb
dor-services-client-7.12.0 lib/dor/services/client/versioned_service.rb
dor-services-client-7.11.0 lib/dor/services/client/versioned_service.rb
dor-services-client-7.10.0 lib/dor/services/client/versioned_service.rb
dor-services-client-7.9.0 lib/dor/services/client/versioned_service.rb
dor-services-client-7.8.0 lib/dor/services/client/versioned_service.rb
dor-services-client-7.7.1 lib/dor/services/client/versioned_service.rb
dor-services-client-7.7.0 lib/dor/services/client/versioned_service.rb
dor-services-client-7.6.0 lib/dor/services/client/versioned_service.rb
dor-services-client-7.5.0 lib/dor/services/client/versioned_service.rb