Sha256: a660761f77224e0607177685f82c7ad3beecb1a267ecabd00001da56de656bc9

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module PurlFetcher
  class Client
    # Publish (metadata-only). This will be replaced with a single publish operation
    class LegacyPublish
      # @param [Cocina::Models::DRO,Cocina::Models::Collection] cocina the Cocina data object
      def self.publish(cocina:)
        new(cocina:).publish
      end

      # @param [Cocina::Models::DRO,Cocina::Models::Collection] cocina the Cocina data object
      def initialize(cocina:)
        @cocina = cocina
      end

      def publish
        logger.debug("Starting a legacy publish request for: #{druid}")
        response = client.post(path:, body:)
        logger.debug("Legacy publish request complete")
      end

      private

      attr_reader :cocina

      def druid
        cocina.externalIdentifier
      end

      def body
        cocina.to_json
      end

      def logger
        Client.config.logger
      end

      def client
        Client.instance
      end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
purl_fetcher-client-2.0.0 lib/purl_fetcher/client/legacy_publish.rb
purl_fetcher-client-1.5.4 lib/purl_fetcher/client/legacy_publish.rb
purl_fetcher-client-1.5.3 lib/purl_fetcher/client/legacy_publish.rb
purl_fetcher-client-1.5.2 lib/purl_fetcher/client/legacy_publish.rb
purl_fetcher-client-1.5.1 lib/purl_fetcher/client/legacy_publish.rb
purl_fetcher-client-1.5.0 lib/purl_fetcher/client/legacy_publish.rb
purl_fetcher-client-1.4.1 lib/purl_fetcher/client/legacy_publish.rb
purl_fetcher-client-1.4.0 lib/purl_fetcher/client/legacy_publish.rb
purl_fetcher-client-1.2.1 lib/purl_fetcher/client/legacy_publish.rb
purl_fetcher-client-1.2.0 lib/purl_fetcher/client/legacy_publish.rb