Sha256: ac4cb4733a51a21cd9dc4adedb075181d60c845b0417f340e285fec9e6e51efa

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 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(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

9 entries across 9 versions & 1 rubygems

Version Path
pact_broker-1.14.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.13.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.12.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.11.2 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.11.1 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.11.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.10.0 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.9.3 lib/pact_broker/api/resources/webhook_execution.rb
pact_broker-1.9.2 lib/pact_broker/api/resources/webhook_execution.rb