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

- old
+ new

@@ -1,16 +1,16 @@ -require 'cgi' -require 'pact_broker/api/resources/base_resource' -require 'pact_broker/api/resources/pacticipant_resource_methods' -require 'pact_broker/api/decorators/pact_decorator' -require 'pact_broker/api/decorators/extended_pact_decorator' -require 'pact_broker/json' -require 'pact_broker/pacts/pact_params' -require 'pact_broker/api/contracts/put_pact_params_contract' -require 'pact_broker/webhooks/execution_configuration' -require 'pact_broker/api/resources/webhook_execution_methods' -require 'pact_broker/api/resources/pact_resource_methods' +require "cgi" +require "pact_broker/api/resources/base_resource" +require "pact_broker/api/resources/pacticipant_resource_methods" +require "pact_broker/api/decorators/pact_decorator" +require "pact_broker/api/decorators/extended_pact_decorator" +require "pact_broker/json" +require "pact_broker/pacts/pact_params" +require "pact_broker/api/contracts/put_pact_params_contract" +require "pact_broker/webhooks/execution_configuration" +require "pact_broker/api/resources/webhook_execution_methods" +require "pact_broker/api/resources/pact_resource_methods" module PactBroker module Api module Resources class Pact < BaseResource @@ -56,16 +56,17 @@ end def from_json response_code = pact ? 200 : 201 - if request.patch? && resource_exists? - @pact = pact_service.merge_pact(pact_params, webhook_options) - else - @pact = pact_service.create_or_update_pact(pact_params, webhook_options) + handle_webhook_events do + if request.patch? && resource_exists? + @pact = pact_service.merge_pact(pact_params) + else + @pact = pact_service.create_or_update_pact(pact_params) + end end - response.body = to_json response_code end def to_json @@ -104,20 +105,9 @@ private def pact @pact ||= pact_service.find_pact(pact_params) - end - - def pact_params - @pact_params ||= PactBroker::Pacts::PactParams.from_request request, path_info - end - - def webhook_options - { - database_connector: database_connector, - webhook_execution_configuration: webhook_execution_configuration - } end end end end end