lib/pact_broker/api/resources/webhook.rb in pact_broker-2.79.1 vs lib/pact_broker/api/resources/webhook.rb in pact_broker-2.80.0

- old
+ new

@@ -1,9 +1,9 @@ -require 'pact_broker/api/resources/base_resource' -require 'pact_broker/services' -require 'pact_broker/api/decorators/webhook_decorator' -require 'pact_broker/api/resources/webhook_resource_methods' +require "pact_broker/api/resources/base_resource" +require "pact_broker/services" +require "pact_broker/api/decorators/webhook_decorator" +require "pact_broker/api/resources/webhook_resource_methods" module PactBroker module Api module Resources class Webhook < BaseResource @@ -21,17 +21,13 @@ def allowed_methods ["GET", "PUT", "DELETE", "OPTIONS"] end def resource_exists? - !!resource_object + !!webhook end - def resource_object - webhook - end - def malformed_request? if request.put? return invalid_json? || webhook_validation_errors?(parsed_webhook, uuid) end false @@ -57,9 +53,21 @@ true end def policy_name :'webhooks::webhook' + end + + def action + if request.put? + webhook ? :update : :create + else + super + end + end + + def policy_record + webhook || parsed_webhook end private def webhook