Module: Integrations::HasWebHook

Extended by:
ActiveSupport::Concern
Included in:
Buildkite, Datadog, DroneCi, Jenkins, Packagist, SquashTm
Defined in:
app/models/concerns/integrations/has_web_hook.rb

Instance Method Summary collapse

Instance Method Details

#execute_web_hook!Object

Execute the webhook, creating it if necessary.



45
46
47
48
# File 'app/models/concerns/integrations/has_web_hook.rb', line 45

def execute_web_hook!(...)
  update_web_hook!
  service_hook.execute(...)
end

#hook_ssl_verificationObject

Return whether the webhook should use SSL verification.



23
24
25
26
27
28
29
# File 'app/models/concerns/integrations/has_web_hook.rb', line 23

def hook_ssl_verification
  if respond_to?(:enable_ssl_verification)
    enable_ssl_verification
  else
    true
  end
end

#hook_urlObject

Return the URL to be used for the webhook.

Raises:

  • (NotImplementedError)


13
14
15
# File 'app/models/concerns/integrations/has_web_hook.rb', line 13

def hook_url
  raise NotImplementedError
end

#update_web_hook!Object

Create or update the webhook, raising an exception if it cannot be saved.



32
33
34
35
36
37
38
39
40
41
42
# File 'app/models/concerns/integrations/has_web_hook.rb', line 32

def update_web_hook!
  hook = service_hook || build_service_hook

  # Avoid reencryption
  hook.url = hook_url if hook.url != hook_url
  hook.url_variables = url_variables if hook.url_variables != url_variables

  hook.enable_ssl_verification = hook_ssl_verification
  hook.save! if hook.changed?
  hook
end

#url_variablesObject

Return the url variables to be used for the webhook.

Raises:

  • (NotImplementedError)


18
19
20
# File 'app/models/concerns/integrations/has_web_hook.rb', line 18

def url_variables
  raise NotImplementedError
end