Sha256: 160a710cdd0c158ded5d153f6ea3e17f253b0615204ee3616a91cab9e2bb6f08

Contents?: true

Size: 854 Bytes

Versions: 8

Compression:

Stored size: 854 Bytes

Contents

# frozen_string_literal: true

require 'logger'

module SdrClient
  class RedesignedClient
    # Find an object
    class Find
      def self.run(...)
        new(...).run
      end

      # @param [String] object_id an ID for an object
      def initialize(object_id:)
        @object_id = object_id
      end

      # @raise [Failed] if the find operation fails
      # @return [String] JSON for the given Cocina object or an error
      def run
        logger.info("Retrieving metadata from: #{path}")
        client.get(path: path)
      end

      private

      attr_reader :object_id

      def logger
        SdrClient::RedesignedClient.config.logger
      end

      def client
        SdrClient::RedesignedClient.instance
      end

      def path
        format('/v1/resources/%<object_id>s', object_id: object_id)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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