Class: PactBroker::Webhooks::TriggeredWebhook

Inherits:
Object
  • Object
show all
Defined in:
lib/pact_broker/webhooks/triggered_webhook.rb

Direct Known Subclasses

LatestTriggeredWebhook

Constant Summary collapse

TRIGGER_TYPE_RESOURCE_CREATION =
"resource_creation"
TRIGGER_TYPE_USER =
"user"
STATUS_NOT_RUN =
"not_run".freeze
STATUS_RETRYING =
"retrying".freeze
STATUS_SUCCESS =
"success".freeze
STATUS_FAILURE =
"failure".freeze

Instance Method Summary collapse

Instance Method Details

#consumer_nameObject



76
77
78
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 76

def consumer_name
  consumer && consumer.name
end

#execute(options) ⇒ Object



69
70
71
72
73
74
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 69

def execute options
  # getting a random 'no method to_domain for null' error
  # not sure on which object, so splitting this out into two lines
  pact = pact_publication.with_version_branches_and_tags.to_domain
  webhook.to_domain.execute(pact, verification, event_context.symbolize_keys, options)
end

#failure?Boolean

Returns:

  • (Boolean)


88
89
90
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 88

def failure?
  status == STATUS_FAILURE
end

#finished?Boolean

Returns:

  • (Boolean)


104
105
106
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 104

def finished?
  success? || failure?
end

#not_run?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 96

def not_run?
  status == STATUS_NOT_RUN
end

#number_of_attempts_madeObject



100
101
102
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 100

def number_of_attempts_made
  webhook_executions.size
end

#number_of_attempts_remainingObject



108
109
110
111
112
113
114
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 108

def number_of_attempts_remaining
  if finished?
    0
  else
    (PactBroker.configuration.webhook_retry_schedule.size + 1) - number_of_attempts_made
  end
end

#provider_nameObject



80
81
82
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 80

def provider_name
  provider && provider.name
end

#request_descriptionObject



64
65
66
67
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 64

def request_description
  # webhook could be deleted
  webhook&.to_domain&.request_description
end

#retrying?Boolean

Returns:

  • (Boolean)


92
93
94
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 92

def retrying?
  status == STATUS_RETRYING
end

#success?Boolean

Returns:

  • (Boolean)


84
85
86
# File 'lib/pact_broker/webhooks/triggered_webhook.rb', line 84

def success?
  status == STATUS_SUCCESS
end