Sha256: 6c9f9343eacd23f5d38ae4f6621b7c18b059a33464c6016967995f8881ae5aeb

Contents?: true

Size: 1.3 KB

Versions: 40

Compression:

Stored size: 1.3 KB

Contents

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

module PactBroker
  module Api
    module Resources
      module WebhookExecutionMethods
        def handle_webhook_events(event_context = {})
          @webhook_event_listener = PactBroker::Webhooks::EventListener.new(webhook_options(event_context))
          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


        def webhook_options(event_context = {})
          {
            database_connector: database_connector,
            webhook_execution_configuration: webhook_execution_configuration.with_webhook_context(event_context)
          }
        end
        private :webhook_options

        def webhook_execution_configuration
          application_context.webhook_execution_configuration_creator.call(self)
        end
        private :webhook_execution_configuration

        def webhook_event_listener
          @webhook_event_listener
        end

        private :webhook_event_listener
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
pact_broker-2.114.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.113.2 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.113.1 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.113.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.112.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.111.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.109.1 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.109.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.108.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.107.1 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.107.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.107.0.beta.1 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.106.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.105.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.104.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.103.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.102.2 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.102.1 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.102.0 lib/pact_broker/api/resources/webhook_execution_methods.rb
pact_broker-2.101.0 lib/pact_broker/api/resources/webhook_execution_methods.rb