class PactBroker::Api::Resources::PactWebhooks
Public Instance Methods
allowed_methods()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 11 def allowed_methods ["POST", "GET", "OPTIONS"] end
content_types_accepted()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 19 def content_types_accepted [["application/json", :from_json]] end
content_types_provided()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 15 def content_types_provided [["application/hal+json", :to_json]] end
create_path()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 45 def create_path webhook_url next_uuid, base_url end
from_json()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 53 def from_json saved_webhook = webhook_service.create next_uuid, webhook, consumer, provider response.body = decorator_class(:webhook_decorator).new(saved_webhook).to_json(decorator_options) end
malformed_request?()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 27 def malformed_request? if request.post? return invalid_json? || validation_errors?(webhook) end false end
policy_name()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 62 def policy_name :"integrations::integration" end
post_is_create?()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 49 def post_is_create? true end
resource_exists?()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 23 def resource_exists? (!consumer_specified? || consumer) && (!provider_specified? || provider) end
to_json()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 58 def to_json decorator_class(:webhooks_decorator).new(webhooks).to_json(decorator_options(resource_title: "Pact webhooks")) end
validation_errors?(webhook)
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 34 def validation_errors? webhook errors = webhook_service.errors(webhook) unless errors.empty? response.headers["Content-Type"] = "application/hal+json;charset=utf-8" response.body = { errors: errors.messages }.to_json end !errors.empty? end
Private Instance Methods
next_uuid()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 76 def next_uuid @next_uuid ||= webhook_service.next_uuid end
webhook()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 72 def webhook @webhook ||= decorator_class(:webhook_decorator).new(PactBroker::Domain::Webhook.new).from_json(request_body) end
webhooks()
click to toggle source
# File lib/pact_broker/api/resources/pact_webhooks.rb, line 68 def webhooks @webhooks ||= webhook_service.find_by_consumer_and_provider consumer, provider end