Class: PactBroker::Api::Resources::WebhookExecution

Inherits:
BaseResource
  • Object
show all
Includes:
WebhookExecutionMethods, WebhookResourceMethods
Defined in:
lib/pact_broker/api/resources/webhook_execution.rb

Instance Method Summary collapse

Methods included from WebhookExecutionMethods

#finish_request, #handle_webhook_events, #schedule_triggered_webhooks

Methods included from WebhookResourceMethods

#webhook_validation_errors?

Instance Method Details

#actionObject



55
56
57
# File 'lib/pact_broker/api/resources/webhook_execution.rb', line 55

def action
  :execute
end

#allowed_methodsObject



24
25
26
# File 'lib/pact_broker/api/resources/webhook_execution.rb', line 24

def allowed_methods
  ["POST", "OPTIONS"]
end

#content_types_acceptedObject



16
17
18
# File 'lib/pact_broker/api/resources/webhook_execution.rb', line 16

def content_types_accepted
  [["application/json"]]
end

#content_types_providedObject



20
21
22
# File 'lib/pact_broker/api/resources/webhook_execution.rb', line 20

def content_types_provided
  [["application/hal+json"]]
end

#malformed_request?Boolean

Returns:

  • (Boolean)


39
40
41
42
43
44
45
46
47
48
49
# File 'lib/pact_broker/api/resources/webhook_execution.rb', line 39

def malformed_request?
  if request.post?
    if uuid
      false
    else
      webhook_validation_errors?(webhook)
    end
  else
    super
  end
end

#policy_nameObject



51
52
53
# File 'lib/pact_broker/api/resources/webhook_execution.rb', line 51

def policy_name
  :'webhooks::webhook'
end

#policy_recordObject



59
60
61
# File 'lib/pact_broker/api/resources/webhook_execution.rb', line 59

def policy_record
  webhook
end

#process_postObject



28
29
30
31
32
33
# File 'lib/pact_broker/api/resources/webhook_execution.rb', line 28

def process_post
  webhook_execution_result = webhook_trigger_service.test_execution(webhook, webhook_execution_configuration.webhook_context, webhook_execution_configuration)
  response.headers["Content-Type"] = "application/hal+json;charset=utf-8"
  response.body = post_response_body(webhook_execution_result)
  true
end

#resource_exists?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/pact_broker/api/resources/webhook_execution.rb', line 35

def resource_exists?
  !!webhook
end