Module: PactBroker::Webhooks::Service
Constant Summary
Constants included
from Services
Services::FACTORIES
Instance Method Summary
collapse
branch_version_repository, integration_repository, label_repository, matrix_repository, pact_repository, pacticipant_repository, tag_repository, verification_repository, version_repository, webhook_repository
Methods included from Services
badge_service, branch_service, certificate_service, contract_service, deployed_version_service, environment_service, get, group_service, index_service, integration_service, label_service, matrix_service, metrics_service, pact_service, pacticipant_service, register_default_services, register_service, released_version_service, tag_service, verification_service, version_service, webhook_service, webhook_trigger_service
Methods included from Messages
message, pluralize, potential_duplicate_pacticipant_message, validation_message
Methods included from Logging
included, #log_error, #log_with_tag
Instance Method Details
#create(uuid, webhook, consumer, provider) ⇒ Object
64
65
66
|
# File 'lib/pact_broker/webhooks/service.rb', line 64
def create uuid, webhook, consumer, provider
webhook_repository.create uuid, webhook, consumer, provider
end
|
79
80
81
|
# File 'lib/pact_broker/webhooks/service.rb', line 79
def delete_all_webhhook_related_objects_by_pacticipant pacticipant
webhook_repository.delete_by_pacticipant(pacticipant)
end
|
83
84
85
|
# File 'lib/pact_broker/webhooks/service.rb', line 83
def delete_all_webhook_related_objects_by_pact_publication_ids pact_publication_ids
webhook_repository.delete_triggered_webhooks_by_pact_publication_ids pact_publication_ids
end
|
87
88
89
|
# File 'lib/pact_broker/webhooks/service.rb', line 87
def delete_all_webhook_related_objects_by_verification_ids verification_ids
webhook_repository.delete_triggered_webhooks_by_verification_ids verification_ids
end
|
#delete_by_uuid(uuid) ⇒ Object
75
76
77
|
# File 'lib/pact_broker/webhooks/service.rb', line 75
def delete_by_uuid uuid
webhook_repository.delete_by_uuid uuid
end
|
#errors(webhook, uuid = nil) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/pact_broker/webhooks/service.rb', line 52
def errors webhook, uuid = nil
contract = PactBroker::Api::Contracts::WebhookContract.new(webhook)
contract.validate(webhook.attributes)
messages = contract.errors.messages
if uuid && !valid_uuid_format?(uuid)
messages["uuid"] = [message("errors.validation.invalid_webhook_uuid")]
end
OpenStruct.new(messages: messages, empty?: messages.empty?, any?: messages.any?)
end
|
#next_uuid ⇒ Object
48
49
50
|
# File 'lib/pact_broker/webhooks/service.rb', line 48
def next_uuid
SecureRandom.urlsafe_base64
end
|
#parameters ⇒ Object
91
92
93
94
95
96
97
98
|
# File 'lib/pact_broker/webhooks/service.rb', line 91
def parameters
PactAndVerificationParameters::ALL.collect do | parameter |
OpenStruct.new(
name: parameter,
description: message("messages.webhooks.parameters.#{parameter}")
)
end
end
|
#update_by_uuid(uuid, params) ⇒ Object
68
69
70
71
72
73
|
# File 'lib/pact_broker/webhooks/service.rb', line 68
def update_by_uuid uuid, params
webhook = webhook_repository.find_by_uuid(uuid)
maintain_redacted_params(webhook, params)
PactBroker::Api::Decorators::WebhookDecorator.new(webhook).from_hash(params)
webhook_repository.update_by_uuid uuid, webhook
end
|
Not actually a UUID. Ah well.
44
45
46
|
# File 'lib/pact_broker/webhooks/service.rb', line 44
def valid_uuid_format?(uuid)
!!(uuid =~ /^[A-Za-z0-9_\-]{16,}$/)
end
|