Class: PactBroker::Api::Resources::Pact
Constant Summary
Constants included
from Logging
Logging::LOG_DIR, Logging::LOG_FILE_NAME
Instance Method Summary
collapse
#potential_duplicate_pacticipants?
#base_url, #consumer_name, #decorator_context, #handle_exception, #identifier_from_path, #invalid_json?, #params, #provider_name, #request_body, #resource_url, #set_json_error_message, #set_json_validation_error_messages, #validation_errors?
Methods included from Logging
included, #logger, #logger=
#hal_browser_url, #latest_pact_url, #latest_pacts_url, #latest_version_url, #pact_url, #pact_versions_url, #pacticipant_url, #pacticipants_url, #tag_url, #tags_url, #url_encode, #version_url, #versions_url, #webhook_execution_url, #webhook_url, #webhooks_for_pact_url, #webhooks_url
Methods included from Services
#group_service, #pact_service, #pacticipant_service, #tag_service, #webhook_service
Instance Method Details
#allowed_methods ⇒ Object
24
25
26
|
# File 'lib/pact_broker/api/resources/pact.rb', line 24
def allowed_methods
["GET", "PUT"]
end
|
#content_types_accepted ⇒ Object
20
21
22
|
# File 'lib/pact_broker/api/resources/pact.rb', line 20
def content_types_accepted
[["application/json", :from_json]]
end
|
#content_types_provided ⇒ Object
16
17
18
|
# File 'lib/pact_broker/api/resources/pact.rb', line 16
def content_types_provided
[["application/json", :to_json]]
end
|
#from_json ⇒ Object
41
42
43
44
45
46
|
# File 'lib/pact_broker/api/resources/pact.rb', line 41
def from_json
response_code = pact ? 200 : 201
@pact = pact_service.create_or_update_pact(identifier_from_path.merge(:json_content => request_body))
response.body = to_json
response_code
end
|
28
29
30
31
32
33
34
35
|
# File 'lib/pact_broker/api/resources/pact.rb', line 28
def malformed_request?
if request.put?
return invalid_json? ||
potential_duplicate_pacticipants?([identifier_from_path[:consumer_name], identifier_from_path[:provider_name]])
else
false
end
end
|
#pact ⇒ Object
52
53
54
|
# File 'lib/pact_broker/api/resources/pact.rb', line 52
def pact
@pact ||= pact_service.find_pact(identifier_from_path)
end
|
#resource_exists? ⇒ Boolean
37
38
39
|
# File 'lib/pact_broker/api/resources/pact.rb', line 37
def resource_exists?
pact
end
|