Sha256: d1452e71415b97c479f27b40b5469a9415020c5b8e2d4c17bf281e14620fabdd

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require "pact_broker/webhooks/event_listener"
require "pact_broker/events/subscriber"

module PactBroker
  module Api
    module Resources
      module WebhookExecutionMethods
        def webhook_execution_configuration
          application_context.webhook_execution_configuration_creator.call(self)
        end

        def webhook_options
          {
            database_connector: database_connector,
            webhook_execution_configuration: webhook_execution_configuration
          }
        end

        def webhook_event_listener
          @webhook_event_listener ||= PactBroker::Webhooks::EventListener.new(webhook_options)
        end

        def handle_webhook_events
          PactBroker::Events.subscribe(webhook_event_listener) do
            yield
          end
        end

        def schedule_triggered_webhooks
          webhook_event_listener.schedule_triggered_webhooks
        end

        def finish_request
          if response.code < 400
            schedule_triggered_webhooks
          end
          super
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pact_broker-2.86.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.85.1 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.85.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.84.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.83.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.82.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.81.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.80.0 lib/pact_broker/api/resources/webhook_execution_methods.rb