Sha256: fdc4e09fce45093a223df42a4efa6b4adf9cc1e9ea674e3944ea3d41788a4032

Contents?: true

Size: 686 Bytes

Versions: 2

Compression:

Stored size: 686 Bytes

Contents

# frozen_string_literal: true

# https://upstash.com/docs/qstash/api/publish
module Qstash
  module Message
    class Publish
      include Qstash::Callable
      attr_reader :destination, :body, :headers

      def initialize(destination:, body:, headers: {})
        @destination = destination
        @body = body
        @headers = headers
      end

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

      private

      def endpoint
        [
          Qstash.config.url.sub(/\/$/, ""),
          Endpoints::PUBLISH_ENDPOINT,
          destination
        ].join("/")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qstash-rb-0.1.3 lib/qstash/message/publish.rb
qstash-rb-0.1.2 lib/qstash/message/publish.rb