houdini/app/models/object_event_hook_config.rb

23 lines
734 B
Ruby
Raw Normal View History

2021-02-09 01:37:47 +00:00
# frozen_string_literal: true
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
class ObjectEventHookConfig < ApplicationRecord
# :webhook_service, #str, webhook service to be called
# :configuration, #jsonb, configuration needed to connect to the webhook
# :object_event_types, #text (array), a set of object event types
belongs_to :nonprofit
validates :webhook_service, presence: true
validates :configuration, presence: true
validates :object_event_types, presence: true
serialize :object_event_types, Array
def webhook
2021-02-09 23:46:19 +00:00
Houdini::WebhookAdapter.build(webhook_service, configuration.symbolize_keys)
2021-02-09 01:37:47 +00:00
end
end