Class: Dor::Services::Client::VersionedService Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/services/client/versioned_service.rb

Overview

This class is abstract.

API calls to a versioned endpoint

Constant Summary collapse

EXCEPTION_CLASS =
{
  400 => BadRequestError,
  401 => UnauthorizedResponse,
  404 => NotFoundResponse,
  409 => ConflictResponse,
  412 => PreconditionFailedResponse
}.freeze
JSON_API_MIME_TYPE =
'application/vnd.api+json'

Instance Method Summary collapse

Constructor Details

#initialize(connection:, version:) ⇒ VersionedService

Returns a new instance of VersionedService.



18
19
20
21
# File 'lib/dor/services/client/versioned_service.rb', line 18

def initialize(connection:, version:)
  @connection = connection
  @api_version = version
end

Instance Method Details

#async_result(url:) ⇒ Object

Common interface for handling asynchronous results



24
25
26
# File 'lib/dor/services/client/versioned_service.rb', line 24

def async_result(url:)
  AsyncResult.new(url: url)
end

#with_querystring(url:, params:) ⇒ Object



28
29
30
31
32
# File 'lib/dor/services/client/versioned_service.rb', line 28

def with_querystring(url:, params:)
  return url if params.blank?

  "#{url}?#{params.to_query}"
end