Class: PactBroker::Api::Resources::Verifications

Inherits:
BaseResource
  • Object
show all
Includes:
MetadataResourceMethods, WebhookExecutionMethods
Defined in:
lib/pact_broker/api/resources/verifications.rb

Instance Method Summary collapse

Methods included from MetadataResourceMethods

#maybe_params_with_consumer_version_number, #metadata, #pact_params

Methods included from WebhookExecutionMethods

#webhook_execution_configuration

Instance Method Details

#allowed_methodsObject



24
25
26
# File 'lib/pact_broker/api/resources/verifications.rb', line 24

def allowed_methods
  ["POST", "OPTIONS"]
end

#content_types_acceptedObject



16
17
18
# File 'lib/pact_broker/api/resources/verifications.rb', line 16

def content_types_accepted
  [["application/json", :from_json]]
end

#content_types_providedObject



20
21
22
# File 'lib/pact_broker/api/resources/verifications.rb', line 20

def content_types_provided
  [["application/hal+json", :to_json]]
end

#create_pathObject



48
49
50
# File 'lib/pact_broker/api/resources/verifications.rb', line 48

def create_path
  new_verification_url(pact, next_verification_number, base_url)
end

#from_jsonObject



52
53
54
55
56
# File 'lib/pact_broker/api/resources/verifications.rb', line 52

def from_json
  verification = verification_service.create(next_verification_number, verification_params, pact, event_context, webhook_options)
  response.body = decorator_for(verification).to_json(decorator_options)
  true
end

#malformed_request?Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
45
46
# 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_nameObject



58
59
60
# File 'lib/pact_broker/api/resources/verifications.rb', line 58

def policy_name
  :'verifications::verifications'
end

#policy_pacticipantObject



62
63
64
# File 'lib/pact_broker/api/resources/verifications.rb', line 62

def policy_pacticipant
  provider
end

#post_is_create?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/pact_broker/api/resources/verifications.rb', line 28

def post_is_create?
  true
end

#resource_exists?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/pact_broker/api/resources/verifications.rb', line 32

def resource_exists?
  !!pact
end