class PactBroker::Api::Resources::PacticipantWebhooks

Public Instance Methods

allowed_methods() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_webhooks.rb, line 11
def allowed_methods
  ["POST", "GET", "OPTIONS"]
end
content_types_accepted() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_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/pacticipant_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/pacticipant_webhooks.rb, line 31
def create_path
  webhook_url next_uuid, base_url
end
from_json() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_webhooks.rb, line 39
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/pacticipant_webhooks.rb, line 27
def malformed_request?
  super || (request.post? && validation_errors_for_schema?)
end
policy_name() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_webhooks.rb, line 48
def policy_name
  :'webhooks::webhooks'
end
policy_record() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_webhooks.rb, line 52
def policy_record
  request.post? ? webhook : nil
end
post_is_create?() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_webhooks.rb, line 35
def post_is_create?
  true
end
resource_exists?() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_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/pacticipant_webhooks.rb, line 44
def to_json
  decorator_class(:webhooks_decorator).new(webhooks).to_json(**decorator_options(resource_title: "Webhooks"))
end

Private Instance Methods

next_uuid() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_webhooks.rb, line 70
def next_uuid
  @next_uuid ||= webhook_service.next_uuid
end
schema() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_webhooks.rb, line 58
def schema
  api_contract_class(:webhook_contract)
end
webhook() click to toggle source
# File lib/pact_broker/api/resources/pacticipant_webhooks.rb, line 66
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/pacticipant_webhooks.rb, line 62
def webhooks
  webhook_service.find_by_consumer_and_provider(consumer, provider)
end