Class: PactBroker::Api::Resources::PacticipantWebhooks
Instance Method Summary
collapse
#webhook_validation_errors?
Instance Method Details
#allowed_methods ⇒ Object
13
14
15
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 13
def allowed_methods
["POST", "GET", "OPTIONS"]
end
|
#content_types_accepted ⇒ Object
21
22
23
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 21
def content_types_accepted
[["application/json", :from_json]]
end
|
#content_types_provided ⇒ Object
17
18
19
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 17
def content_types_provided
[["application/hal+json", :to_json]]
end
|
#create_path ⇒ Object
36
37
38
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 36
def create_path
webhook_url next_uuid, base_url
end
|
#from_json ⇒ Object
44
45
46
47
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 44
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
|
29
30
31
32
33
34
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 29
def malformed_request?
if request.post?
return invalid_json? || webhook_validation_errors?(webhook)
end
false
end
|
#policy_name ⇒ Object
53
54
55
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 53
def policy_name
:'webhooks::webhooks'
end
|
#policy_record ⇒ Object
57
58
59
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 57
def policy_record
request.post? ? webhook : nil
end
|
#post_is_create? ⇒ Boolean
40
41
42
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 40
def post_is_create?
true
end
|
#resource_exists? ⇒ Boolean
25
26
27
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 25
def resource_exists?
(!consumer_specified? || consumer) && (!provider_specified? || provider)
end
|
#to_json ⇒ Object
49
50
51
|
# File 'lib/pact_broker/api/resources/pacticipant_webhooks.rb', line 49
def to_json
decorator_class(:webhooks_decorator).new(webhooks).to_json(decorator_options(resource_title: "Webhooks"))
end
|