Sha256: 63c38aa2ca1d213891093719d7b0468092aa648039d9f21dd27215a5d5a7c24b

Contents?: true

Size: 909 Bytes

Versions: 2

Compression:

Stored size: 909 Bytes

Contents

# frozen_string_literal: true

module PurlFetcher
  class Client
    # Delete an item from the purl-fetcher cache
    class Unpublish
      # @param [String] druid the identifier of the item
      # @raise [Purl::Fetcher::Client::AlreadyDeletedResponseError] if the item is already deleted
      def self.unpublish(druid:)
        new(druid:).unpublish
      end

      # @param [String] druid the identifier of the item
      def initialize(druid:)
        @druid = druid
      end

      def unpublish
        logger.debug("Starting a unpublish request for: #{druid}")
        response = client.delete(path:)
        logger.debug("Unpublish request complete")
        response
      end

      private

      attr_reader :druid

      def logger
        Client.config.logger
      end

      def client
        Client.instance
      end

      def path
        "/purls/#{druid}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
purl_fetcher-client-1.5.4 lib/purl_fetcher/client/unpublish.rb
purl_fetcher-client-1.5.3 lib/purl_fetcher/client/unpublish.rb