class PactBroker::Api::Resources::Verifications

Public Instance Methods

allowed_methods() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 24
def allowed_methods
  ["POST", "OPTIONS"]
end
content_types_accepted() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 16
def content_types_accepted
  [["application/json", :from_json]]
end
content_types_provided() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 20
def content_types_provided
  [["application/hal+json", :to_json]]
end
create_path() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 48
def create_path
  new_verification_url(pact, next_verification_number, base_url)
end
from_json() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 52
def from_json
  handle_webhook_events do
    verified_pacts = pact_service.find_for_verification_publication(pact_params, event_context[:consumer_version_selectors])
    verification = verification_service.create(next_verification_number, verification_params, verified_pacts, event_context)
    response.body = decorator_for(verification).to_json(decorator_options)
  end
  true
end
malformed_request?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 36
def malformed_request?
  if request.post?
    return true if invalid_json?
    errors = verification_service.errors(params)
    if !errors.empty?
      set_json_validation_error_messages(errors.messages)
      return true
    end
  end
  false
end
policy_name() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 61
def policy_name
  :'verifications::verifications'
end
policy_pacticipant() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 65
def policy_pacticipant
  provider
end
post_is_create?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 28
def post_is_create?
  true
end
resource_exists?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 32
def resource_exists?
  !!pact
end

Private Instance Methods

decorator_for(model) click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 79
def decorator_for model
  decorator_class(:verification_decorator).new(model)
end
event_context() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 91
def event_context
  metadata
end
next_verification_number() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 75
def next_verification_number
  @next_verification_number ||= verification_service.next_number
end
pact() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 71
def pact
  @pact ||= pact_service.find_pact(pact_params)
end
pending?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 87
def pending?
  metadata[:pending]
end
verification_params() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 95
def verification_params
  params(symbolize_names: false).merge("wip" => wip?, "pending" => pending?)
end
wip?() click to toggle source
# File lib/pact_broker/api/resources/verifications.rb, line 83
def wip?
  metadata[:wip] == "true"
end