Sha256: e1832df38b0a4d3360f9911c5acc640349ac56c72104592600fd87c8049def3e

Contents?: true

Size: 1.04 KB

Versions: 27

Compression:

Stored size: 1.04 KB

Contents

require 'pact_broker/services'
require 'pact_broker/api/decorators/webhook_execution_result_decorator'

module PactBroker
  module Api
    module Resources

      class WebhookExecution < BaseResource

        def allowed_methods
          ["POST"]
        end

        def process_post
          webhook_execution_result = webhook_service.execute_webhook_now webhook
          response.headers['Content-Type'] = 'application/hal+json;charset=utf-8'
          response.body = post_response_body webhook_execution_result
          webhook_execution_result.success? ? true : 500
        end

        def resource_exists?
          webhook
        end

        private

        def post_response_body webhook_execution_result
          Decorators::WebhookExecutionResultDecorator.new(webhook_execution_result).to_json(user_options: { base_url: base_url, webhook: webhook })
        end

        def webhook
          @webhook ||= webhook_service.find_by_uuid uuid
        end

        def uuid
          identifier_from_path[:uuid]
        end
      end
    end
  end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
pact_broker-2.4.1 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.4.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.3.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.2.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.1.1 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.1.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.5 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.4 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.3 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.2 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.1 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.0.beta.8 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.0.beta.7 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.0.beta.6 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.18.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-2.0.0.beta.5 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.18.0.beta.1 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.17.2 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.17.1 lib/pact_broker/api/resources/webhook_execution.rb