Skip to content

Commit 428230c

Browse files
authoredFeb 20, 2025
Feat inhouse outgoing webhooks (#131)
1 parent 7afa467 commit 428230c

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed
 

‎app/models/pager_tree/integrations/outgoing_webhook_delivery.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module PagerTree::Integrations
2-
class OutgoingWebhookDelivery < PagerTree::Integrations.outgoing_webhook_delivery_parent_class.constantize
2+
class OutgoingWebhookDelivery < ApplicationRecord
33
self.table_name = PagerTree::Integrations.outgoing_webhook_delivery_table_name
44

55
serialize :data, JSON
@@ -16,7 +16,8 @@ class OutgoingWebhookDelivery < PagerTree::Integrations.outgoing_webhook_deliver
1616
enum status: {queued: 0, sent: 1, success: 2, failure: 3, retrying: 4, cancelled: 5, stored: 6, insufficent_funds: 7}
1717

1818
def self.factory(**params)
19-
PagerTree::Integrations.outgoing_webhook_delivery_factory_class.constantize.new(**params)
19+
klass = PagerTree::Integrations.outgoing_webhook_delivery_factory_class
20+
(klass.is_a?(Proc) ? klass.call : klass.to_s).constantize.new(**params)
2021
end
2122
end
2223
end

‎app/models/pager_tree/integrations/outgoing_webhook_delivery/hook_relay.rb

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ class OutgoingWebhookDelivery::HookRelay < OutgoingWebhookDelivery
44

55
define_model_callbacks :deliver
66

7+
def self.factory(**params)
8+
new(**params)
9+
end
10+
711
def self.hook_relay_account_id
812
find_value_by_name(:hook_relay, :account_id)
913
end

‎lib/pager_tree/integrations.rb

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ module Integrations
1111
mattr_accessor :integration_parent_class
1212
@@integration_parent_class = "ApplicationRecord"
1313

14-
mattr_accessor :outgoing_webhook_delivery_parent_class
15-
@@outgoing_webhook_delivery_parent_class = "ApplicationRecord"
16-
1714
mattr_accessor :outgoing_webhook_delivery_factory_class
1815
@@outgoing_webhook_delivery_factory_class = "PagerTree::Integrations::OutgoingWebhookDelivery::HookRelay"
1916

0 commit comments

Comments
 (0)