Sha256: 8af28b0af8c4cd5a4e4bde2b11da205f7506bd12fd8c8825ba4b65b716e05929

Contents?: true

Size: 705 Bytes

Versions: 10

Compression:

Stored size: 705 Bytes

Contents

# frozen_string_literal: true

module SdrClient
  # The namespace for the "get" command
  module Find
    DRO_PATH = '/v1/resources/%<id>s'

    # @raise [Failed] if the find operation fails
    # @return [String] JSON for the given Cocina object or an error
    def self.run(druid, url:, logger: Logger.new($stdout))
      connection = Connection.new(url: url)
      path = format(DRO_PATH, id: druid)
      logger.info("Retrieving metadata from: #{path}")
      response = connection.get(path)
      return response.body if response.success?

      logger.error("There was an HTTP #{response.status} error making the request: #{response.body}")
      UnexpectedResponse.call(response)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
sdr-client-2.18.0 lib/sdr_client/find.rb
sdr-client-2.17.0 lib/sdr_client/find.rb
sdr-client-2.16.0 lib/sdr_client/find.rb
sdr-client-2.13.2 lib/sdr_client/find.rb
sdr-client-2.13.1 lib/sdr_client/find.rb
sdr-client-2.13.0 lib/sdr_client/find.rb
sdr-client-2.13.0.beta2 lib/sdr_client/find.rb
sdr-client-2.13.0.beta1 lib/sdr_client/find.rb
sdr-client-2.12.0 lib/sdr_client/find.rb
sdr-client-2.11.1 lib/sdr_client/find.rb