Class: PagerTree::Integrations::Integration
- Inherits:
-
Object
- Object
- PagerTree::Integrations::Integration
- Extended by:
- BooleanStoreAccessor
- Defined in:
- app/models/pager_tree/integrations/integration.rb
Constant Summary collapse
- GENERIC_OPTIONS =
[ {key: :title_template, type: :string, default: nil}, {key: :title_template_enabled, type: :boolean, default: false}, {key: :description_template, type: :string, default: nil}, {key: :description_template_enabled, type: :boolean, default: false} ]
Instance Method Summary collapse
-
#adapter_action ⇒ Object
Returns :create, :resolve, or :other.
- #adapter_incoming_can_defer? ⇒ Boolean
- #adapter_outgoing_interest?(event_name) ⇒ Boolean
- #adapter_process_create ⇒ Object
- #adapter_process_other ⇒ Object
- #adapter_process_outgoing ⇒ Object
- #adapter_response_blocked ⇒ Object
- #adapter_response_deferred ⇒ Object
- #adapter_response_disabled ⇒ Object
- #adapter_response_inactive_subscription ⇒ Object
- #adapter_response_incoming ⇒ Object
- #adapter_response_maintenance_mode ⇒ Object
-
#adapter_response_rate_limit ⇒ Object
END basic show functions.
- #adapter_response_upgrade ⇒ Object
-
#adapter_should_block_incoming?(request) ⇒ Boolean
a function to determine if we should block the incoming request (e.g. if the payload doesn’t match a signature).
-
#adapter_show_alerts? ⇒ Boolean
START basic show functions.
- #adapter_show_logs? ⇒ Boolean
- #adapter_show_outgoing_webhook_delivery? ⇒ Boolean
-
#adapter_supports_cnames? ⇒ Boolean
END template functions.
- #adapter_supports_description_template? ⇒ Boolean
-
#adapter_supports_incoming? ⇒ Boolean
START basic incoming functions.
-
#adapter_supports_outgoing? ⇒ Boolean
START basic outgoing functions.
-
#adapter_supports_title_template? ⇒ Boolean
START template functions.
-
#adapter_thirdparty_id ⇒ Object
A unique identifier for this integration/alert.
- #adapter_will_route_alert? ⇒ Boolean
- #cast_types ⇒ Object
Methods included from BooleanStoreAccessor
Instance Method Details
#adapter_action ⇒ Object
Returns :create, :resolve, or :other
52 53 54 |
# File 'app/models/pager_tree/integrations/integration.rb', line 52 def adapter_action :other end |
#adapter_incoming_can_defer? ⇒ Boolean
47 48 49 |
# File 'app/models/pager_tree/integrations/integration.rb', line 47 def adapter_incoming_can_defer? true end |
#adapter_outgoing_interest?(event_name) ⇒ Boolean
72 73 74 |
# File 'app/models/pager_tree/integrations/integration.rb', line 72 def adapter_outgoing_interest?(event_name) false end |
#adapter_process_create ⇒ Object
56 57 |
# File 'app/models/pager_tree/integrations/integration.rb', line 56 def adapter_process_create end |
#adapter_process_other ⇒ Object
59 60 |
# File 'app/models/pager_tree/integrations/integration.rb', line 59 def adapter_process_other end |
#adapter_process_outgoing ⇒ Object
76 77 |
# File 'app/models/pager_tree/integrations/integration.rb', line 76 def adapter_process_outgoing end |
#adapter_response_blocked ⇒ Object
128 129 130 |
# File 'app/models/pager_tree/integrations/integration.rb', line 128 def adapter_response_blocked adapter_controller&.head(:forbidden) end |
#adapter_response_deferred ⇒ Object
132 133 134 |
# File 'app/models/pager_tree/integrations/integration.rb', line 132 def adapter_response_deferred adapter_controller&.head(:ok) end |
#adapter_response_disabled ⇒ Object
112 113 114 |
# File 'app/models/pager_tree/integrations/integration.rb', line 112 def adapter_response_disabled adapter_controller&.head(:method_not_allowed) end |
#adapter_response_inactive_subscription ⇒ Object
116 117 118 |
# File 'app/models/pager_tree/integrations/integration.rb', line 116 def adapter_response_inactive_subscription adapter_controller&.head(:payment_required) end |
#adapter_response_incoming ⇒ Object
136 137 138 |
# File 'app/models/pager_tree/integrations/integration.rb', line 136 def adapter_response_incoming adapter_controller&.head(:ok) end |
#adapter_response_maintenance_mode ⇒ Object
124 125 126 |
# File 'app/models/pager_tree/integrations/integration.rb', line 124 def adapter_response_maintenance_mode adapter_controller&.head(:ok) end |
#adapter_response_rate_limit ⇒ Object
END basic show functions
108 109 110 |
# File 'app/models/pager_tree/integrations/integration.rb', line 108 def adapter_response_rate_limit adapter_controller&.head(:too_many_requests) end |
#adapter_response_upgrade ⇒ Object
120 121 122 |
# File 'app/models/pager_tree/integrations/integration.rb', line 120 def adapter_response_upgrade adapter_controller&.head(:payment_required) end |
#adapter_should_block_incoming?(request) ⇒ Boolean
a function to determine if we should block the incoming request (e.g. if the payload doesn’t match a signature)
38 39 40 |
# File 'app/models/pager_tree/integrations/integration.rb', line 38 def adapter_should_block_incoming?(request) false end |
#adapter_show_alerts? ⇒ Boolean
START basic show functions
95 96 97 |
# File 'app/models/pager_tree/integrations/integration.rb', line 95 def adapter_show_alerts? adapter_supports_incoming? end |
#adapter_show_logs? ⇒ Boolean
99 100 101 |
# File 'app/models/pager_tree/integrations/integration.rb', line 99 def adapter_show_logs? true end |
#adapter_show_outgoing_webhook_delivery? ⇒ Boolean
103 104 105 |
# File 'app/models/pager_tree/integrations/integration.rb', line 103 def adapter_show_outgoing_webhook_delivery? false end |
#adapter_supports_cnames? ⇒ Boolean
END template functions
90 91 92 |
# File 'app/models/pager_tree/integrations/integration.rb', line 90 def adapter_supports_cnames? false end |
#adapter_supports_description_template? ⇒ Boolean
85 86 87 |
# File 'app/models/pager_tree/integrations/integration.rb', line 85 def adapter_supports_description_template? true end |
#adapter_supports_incoming? ⇒ Boolean
START basic incoming functions
33 34 35 |
# File 'app/models/pager_tree/integrations/integration.rb', line 33 def adapter_supports_incoming? false end |
#adapter_supports_outgoing? ⇒ Boolean
START basic outgoing functions
68 69 70 |
# File 'app/models/pager_tree/integrations/integration.rb', line 68 def adapter_supports_outgoing? false end |
#adapter_supports_title_template? ⇒ Boolean
START template functions
81 82 83 |
# File 'app/models/pager_tree/integrations/integration.rb', line 81 def adapter_supports_title_template? true end |
#adapter_thirdparty_id ⇒ Object
A unique identifier for this integration/alert
43 44 45 |
# File 'app/models/pager_tree/integrations/integration.rb', line 43 def adapter_thirdparty_id ULID.generate end |
#adapter_will_route_alert? ⇒ Boolean
62 63 64 |
# File 'app/models/pager_tree/integrations/integration.rb', line 62 def adapter_will_route_alert? false end |
#cast_types ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'app/models/pager_tree/integrations/integration.rb', line 140 def cast_types (self.class.const_get(:GENERIC_OPTIONS) + self.class.const_get(:OPTIONS)).each do |option| key = option[:key] value = send("option_#{key}") type = option[:type] value = ActiveModel::Type::Boolean.new.cast(value) if type == :boolean value = ActiveModel::Type::String.new.cast(value) if type == :string value = ActiveModel::Type::Integer.new.cast(value) if type == :integer value = option[:default] if value.nil? && option.has_key?(:default) send("option_#{key}=", value) end end |