Sha256: db2be265209fce34ed9876f5643714dc53d2f84c23e54439db157a2ec2ef60c7

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

# https://upstash.com/docs/qstash/api/dlq/deleteMessage
module Qstash
  module DLQ
    class Delete
      include Qstash::Callable
      attr_reader :dlq_ids, :headers

      def initialize(dlq_ids, headers: {})
        @dlq_ids = Array(dlq_ids)
        @headers = headers
      end

      def call
        uri = URI(endpoint)
        client = Qstash::HttpClient.new(uri)
        client.delete(body, headers)
      end

      private

      def base_url
        Qstash.config.url.sub(/\/$/, "")
      end

      def body
        (dlq_ids.length > 1) ? {dlqIds: dlq_ids} : {}
      end

      def endpoint
        [
          base_url,
          (dlq_ids.length > 1) ? Endpoints::DLQ_ENDPOINT : "#{Endpoints::DLQ_ENDPOINT}/#{dlq_ids.first}"
        ].join("/")
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qstash-rb-0.1.3 lib/qstash/dlq/delete.rb