Class: PactBroker::Domain::Webhook
- Inherits:
-
Object
- Object
- PactBroker::Domain::Webhook
- Defined in:
- lib/pact_broker/domain/webhook.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#consumer ⇒ Object
request is actually a request_template.
-
#created_at ⇒ Object
request is actually a request_template.
-
#description ⇒ Object
request is actually a request_template.
-
#enabled ⇒ Object
request is actually a request_template.
-
#events ⇒ Object
request is actually a request_template.
-
#provider ⇒ Object
request is actually a request_template.
-
#request ⇒ Object
request is actually a request_template.
-
#updated_at ⇒ Object
request is actually a request_template.
-
#uuid ⇒ Object
request is actually a request_template.
Instance Method Summary collapse
- #consumer_name ⇒ Object
- #display_description ⇒ Object
- #execute(pact, verification, event_context, options) ⇒ Object
- #expand_currently_deployed_provider_versions? ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Webhook
constructor
A new instance of Webhook.
- #provider_name ⇒ Object
- #request_description ⇒ Object
- #scope_description ⇒ Object
- #to_s ⇒ Object
- #trigger_on_contract_content_changed? ⇒ Boolean
- #trigger_on_contract_requiring_verification_published? ⇒ Boolean
- #trigger_on_provider_verification_failed? ⇒ Boolean
- #trigger_on_provider_verification_published? ⇒ Boolean
- #trigger_on_provider_verification_succeeded? ⇒ Boolean
Methods included from Logging
included, #log_error, #log_with_tag, #measure_info
Methods included from Messages
#message, #pluralize, #validation_message, #validation_message_at_index
Constructor Details
#initialize(attributes = {}) ⇒ Webhook
Returns a new instance of Webhook.
19 20 21 22 23 24 |
# File 'lib/pact_broker/domain/webhook.rb', line 19 def initialize attributes = {} @attributes = attributes attributes.each do | (name, value) | instance_variable_set("@#{name}", value) if respond_to?(name) end end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
17 18 19 |
# File 'lib/pact_broker/domain/webhook.rb', line 17 def attributes @attributes end |
#consumer ⇒ Object
request is actually a request_template
16 17 18 |
# File 'lib/pact_broker/domain/webhook.rb', line 16 def consumer @consumer end |
#created_at ⇒ Object
request is actually a request_template
16 17 18 |
# File 'lib/pact_broker/domain/webhook.rb', line 16 def created_at @created_at end |
#description ⇒ Object
request is actually a request_template
16 17 18 |
# File 'lib/pact_broker/domain/webhook.rb', line 16 def description @description end |
#enabled ⇒ Object
request is actually a request_template
16 17 18 |
# File 'lib/pact_broker/domain/webhook.rb', line 16 def enabled @enabled end |
#events ⇒ Object
request is actually a request_template
16 17 18 |
# File 'lib/pact_broker/domain/webhook.rb', line 16 def events @events end |
#provider ⇒ Object
request is actually a request_template
16 17 18 |
# File 'lib/pact_broker/domain/webhook.rb', line 16 def provider @provider end |
#request ⇒ Object
request is actually a request_template
16 17 18 |
# File 'lib/pact_broker/domain/webhook.rb', line 16 def request @request end |
#updated_at ⇒ Object
request is actually a request_template
16 17 18 |
# File 'lib/pact_broker/domain/webhook.rb', line 16 def updated_at @updated_at end |
#uuid ⇒ Object
request is actually a request_template
16 17 18 |
# File 'lib/pact_broker/domain/webhook.rb', line 16 def uuid @uuid end |
Instance Method Details
#consumer_name ⇒ Object
65 66 67 |
# File 'lib/pact_broker/domain/webhook.rb', line 65 def consumer_name consumer && (consumer.name || (consumer.label && "#{provider ? 'consumers ' : ''}labeled '#{consumer.label}'")) end |
#display_description ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/pact_broker/domain/webhook.rb', line 26 def display_description if description && description.strip.size > 0 description else request_description end end |
#execute(pact, verification, event_context, options) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/pact_broker/domain/webhook.rb', line 50 def execute pact, verification, event_context, logger.info "Executing #{self} event_context=#{event_context}" template_params = template_parameters(pact, verification, event_context, ) webhook_request = request.build(template_params, **.slice(:user_agent, :disable_ssl_verification, :cert_store)) http_response, error = execute_request(webhook_request) success = success?(http_response, ) http_request = webhook_request.http_request logs = generate_logs(webhook_request, http_response, success, error, event_context, .fetch(:logging_options)) result(http_request, http_response, success, logs, error) end |
#expand_currently_deployed_provider_versions? ⇒ Boolean
93 94 95 |
# File 'lib/pact_broker/domain/webhook.rb', line 93 def request.uses_parameter?(PactBroker::Webhooks::PactAndVerificationParameters::CURRENTLY_DEPLOYED_PROVIDER_VERSION_NUMBER) end |
#provider_name ⇒ Object
69 70 71 |
# File 'lib/pact_broker/domain/webhook.rb', line 69 def provider_name provider && (provider.name || (provider.label && "#{consumer ? 'providers ' : ''}labeled '#{provider.label}'")) end |
#request_description ⇒ Object
46 47 48 |
# File 'lib/pact_broker/domain/webhook.rb', line 46 def request_description request && request.description end |
#scope_description ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pact_broker/domain/webhook.rb', line 34 def scope_description if consumer && provider "A webhook for the pact between #{consumer_name} and #{provider_name}" elsif provider "A webhook for all pacts with provider #{provider_name}" elsif consumer "A webhook for all pacts with consumer #{consumer_name}" else "A webhook for all pacts" end end |
#to_s ⇒ Object
61 62 63 |
# File 'lib/pact_broker/domain/webhook.rb', line 61 def to_s "webhook for consumer=#{consumer_name} provider=#{provider_name} uuid=#{uuid}" end |
#trigger_on_contract_content_changed? ⇒ Boolean
73 74 75 |
# File 'lib/pact_broker/domain/webhook.rb', line 73 def trigger_on_contract_content_changed? events.any?(&:contract_content_changed?) end |
#trigger_on_contract_requiring_verification_published? ⇒ Boolean
89 90 91 |
# File 'lib/pact_broker/domain/webhook.rb', line 89 def trigger_on_contract_requiring_verification_published? events.any?(&:contract_requiring_verification_published?) end |
#trigger_on_provider_verification_failed? ⇒ Boolean
85 86 87 |
# File 'lib/pact_broker/domain/webhook.rb', line 85 def trigger_on_provider_verification_failed? events.any?(&:provider_verification_failed?) end |
#trigger_on_provider_verification_published? ⇒ Boolean
77 78 79 |
# File 'lib/pact_broker/domain/webhook.rb', line 77 def trigger_on_provider_verification_published? events.any?(&:provider_verification_published?) end |
#trigger_on_provider_verification_succeeded? ⇒ Boolean
81 82 83 |
# File 'lib/pact_broker/domain/webhook.rb', line 81 def trigger_on_provider_verification_succeeded? events.any?(&:provider_verification_succeeded?) end |