Class: PactBroker::Services::WebhookService
- Inherits:
-
Object
- Object
- PactBroker::Services::WebhookService
show all
- Extended by:
- Repositories
- Includes:
- Logging
- Defined in:
- lib/pact_broker/services/webhook_service.rb
Constant Summary
Constants included
from Logging
Logging::LOG_DIR, Logging::LOG_FILE_NAME
Class Method Summary
collapse
pact_repository, pacticipant_repository, tag_repository, version_repository, webhook_repository
Methods included from Logging
included, #logger, #logger=
Class Method Details
.create(uuid, webhook, consumer, provider) ⇒ Object
23
24
25
|
# File 'lib/pact_broker/services/webhook_service.rb', line 23
def self.create uuid, webhook, consumer, provider
webhook_repository.create uuid, webhook, consumer, provider
end
|
.delete_by_pacticipant(pacticipant) ⇒ Object
35
36
37
|
# File 'lib/pact_broker/services/webhook_service.rb', line 35
def self.delete_by_pacticipant pacticipant
webhook_repository.delete_by_pacticipant pacticipant
end
|
.delete_by_uuid(uuid) ⇒ Object
31
32
33
|
# File 'lib/pact_broker/services/webhook_service.rb', line 31
def self.delete_by_uuid uuid
webhook_repository.delete_by_uuid uuid
end
|
.errors(webhook) ⇒ Object
17
18
19
20
21
|
# File 'lib/pact_broker/services/webhook_service.rb', line 17
def self.errors webhook
contract = PactBroker::Api::Contracts::WebhookContract.new(webhook)
contract.validate
contract.errors
end
|
.execute_webhook_now(webhook) ⇒ Object
43
44
45
|
# File 'lib/pact_broker/services/webhook_service.rb', line 43
def self.execute_webhook_now webhook
webhook.execute
end
|
.execute_webhooks(pact) ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/pact_broker/services/webhook_service.rb', line 51
def self.execute_webhooks pact
webhooks = webhook_repository.find_by_consumer_and_provider pact.consumer, pact.provider
if webhooks.any?
run_later(webhooks)
else
logger.debug "No webhook found for consumer \"#{pact.consumer.name}\" and provider \"#{pact.provider.name}\""
end
end
|
.find_all ⇒ Object
39
40
41
|
# File 'lib/pact_broker/services/webhook_service.rb', line 39
def self.find_all
webhook_repository.find_all
end
|
.find_by_consumer_and_provider(consumer, provider) ⇒ Object
47
48
49
|
# File 'lib/pact_broker/services/webhook_service.rb', line 47
def self.find_by_consumer_and_provider consumer, provider
webhook_repository.find_by_consumer_and_provider consumer, provider
end
|
.find_by_uuid(uuid) ⇒ Object
27
28
29
|
# File 'lib/pact_broker/services/webhook_service.rb', line 27
def self.find_by_uuid uuid
webhook_repository.find_by_uuid uuid
end
|
.next_uuid ⇒ Object
13
14
15
|
# File 'lib/pact_broker/services/webhook_service.rb', line 13
def self.next_uuid
SecureRandom.urlsafe_base64
end
|
.run_later(webhooks) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/pact_broker/services/webhook_service.rb', line 61
def self.run_later webhooks
Thread.new do
webhooks.each do | webhook |
begin
webhook.execute
rescue StandardError => e
end
end
end
end
|