Class: RailsWebhookOutbox::Sender

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_webhook_outbox/sender.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delivery) ⇒ Sender

Returns a new instance of Sender.



12
13
14
# File 'lib/rails_webhook_outbox/sender.rb', line 12

def initialize(delivery)
  @delivery = delivery
end

Class Method Details

.call(delivery) ⇒ Object



8
9
10
# File 'lib/rails_webhook_outbox/sender.rb', line 8

def self.call(delivery)
  new(delivery).call
end

Instance Method Details

#callObject

Raises:



16
17
18
19
20
21
22
23
# File 'lib/rails_webhook_outbox/sender.rb', line 16

def call
  uri = URI.parse(@delivery.subscription.url)
  body = build_body
  request = build_request(uri, body)
  response = execute(uri, request)
  raise DeliveryError.new(response) unless response.is_a?(Net::HTTPSuccess)
  response
end