lib/pact_broker/api/resources/webhooks.rb in pact_broker-2.58.0 vs lib/pact_broker/api/resources/webhooks.rb in pact_broker-2.58.2

- old
+ new

@@ -21,12 +21,11 @@ def content_types_accepted [["application/json", :from_json]] end def resource_exists? - (identifier_from_path[:consumer_name].nil? || consumer) && - (identifier_from_path[:provider_name].nil? || provider) + (!consumer_specified? || consumer) && (!provider_specified? || provider) end def malformed_request? if request.post? return invalid_json? || webhook_validation_errors?(webhook) @@ -42,15 +41,15 @@ true end def from_json saved_webhook = webhook_service.create next_uuid, webhook, consumer, provider - response.body = Decorators::WebhookDecorator.new(saved_webhook).to_json(user_options: { base_url: base_url }) + response.body = Decorators::WebhookDecorator.new(saved_webhook).to_json(decorator_options) end def to_json - Decorators::WebhooksDecorator.new(webhooks).to_json(user_options: decorator_context(resource_title: 'Pact webhooks')) + Decorators::WebhooksDecorator.new(webhooks).to_json(decorator_options(resource_title: 'Pact webhooks')) end private def webhooks @@ -61,23 +60,9 @@ @webhook ||= Decorators::WebhookDecorator.new(PactBroker::Domain::Webhook.new).from_json(request_body) end def next_uuid @next_uuid ||= webhook_service.next_uuid - end - - def consumer - @consumer ||= identifier_from_path[:consumer_name] && find_pacticipant(identifier_from_path[:consumer_name], "consumer") - end - - def provider - @provider ||= identifier_from_path[:provider_name] && find_pacticipant(identifier_from_path[:provider_name], "provider") - end - - def find_pacticipant name, role - pacticipant_service.find_pacticipant_by_name(name).tap do | pacticipant | - set_json_error_message("No #{role} with name '#{name}' found") if pacticipant.nil? - end end end end end end