Sha256: 15f17440e4bac6e4159d4d4abf132c18af6ea4ce72869abfe026b5c9d3b6d9e4

Contents?: true

Size: 1.65 KB

Versions: 15

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: tru

module Dor
  module Services
    class Client
      # API calls that are about retrieving metadata
      class Metadata < VersionedService
        # @param object_identifier [String] the pid for the object
        def initialize(connection:, version:, object_identifier:)
          super(connection: connection, version: version)
          @object_identifier = object_identifier
        end

        # @return [String, NilClass] The Dublin Core XML representation of the object or nil if response is 404
        # @raise [UnexpectedResponse] on an unsuccessful response from the server
        def dublin_core
          resp = connection.get do |req|
            req.url "#{base_path}/dublin_core"
          end
          return resp.body if resp.success?
          return if resp.status == 404

          raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
        end

        # @return [String, NilClass] The descriptive metadata XML representation of the object or nil if response is 404
        # @raise [UnexpectedResponse] on an unsuccessful response from the server
        def descriptive
          resp = connection.get do |req|
            req.url "#{base_path}/descriptive"
          end
          return resp.body if resp.success?
          return if resp.status == 404

          raise UnexpectedResponse, ResponseErrorFormatter.format(response: resp, object_identifier: object_identifier)
        end

        private

        attr_reader :object_identifier

        def base_path
          "#{api_version}/objects/#{object_identifier}/metadata"
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
dor-services-client-3.7.0 lib/dor/services/client/metadata.rb
dor-services-client-3.6.0 lib/dor/services/client/metadata.rb
dor-services-client-3.5.0 lib/dor/services/client/metadata.rb
dor-services-client-3.4.0 lib/dor/services/client/metadata.rb
dor-services-client-3.3.0 lib/dor/services/client/metadata.rb
dor-services-client-3.2.0 lib/dor/services/client/metadata.rb
dor-services-client-3.1.1 lib/dor/services/client/metadata.rb
dor-services-client-3.1.0 lib/dor/services/client/metadata.rb
dor-services-client-3.0.0 lib/dor/services/client/metadata.rb
dor-services-client-2.6.2 lib/dor/services/client/metadata.rb
dor-services-client-2.6.1 lib/dor/services/client/metadata.rb
dor-services-client-2.6.0 lib/dor/services/client/metadata.rb
dor-services-client-2.5.1 lib/dor/services/client/metadata.rb
dor-services-client-2.5.0 lib/dor/services/client/metadata.rb
dor-services-client-2.4.0 lib/dor/services/client/metadata.rb