Class: Certynix::Resources::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/certynix/resources/webhooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Webhooks

Returns a new instance of Webhooks.



6
7
8
# File 'lib/certynix/resources/webhooks.rb', line 6

def initialize(http)
  @http = http
end

Instance Method Details

#create(url:, events: nil) ⇒ Object



10
11
12
13
14
# File 'lib/certynix/resources/webhooks.rb', line 10

def create(url:, events: nil)
  body = { url: url }
  body[:events] = events if events
  @http.post('/v1/webhooks', body)
end

#delete(id) ⇒ Object



28
29
30
# File 'lib/certynix/resources/webhooks.rb', line 28

def delete(id)
  @http.delete("/v1/webhooks/#{URI.encode_www_form_component(id)}")
end

#list(**params) ⇒ Object



16
17
18
# File 'lib/certynix/resources/webhooks.rb', line 16

def list(**params)
  Models::Paginator.new(http: @http, path: '/v1/webhooks', params: params)
end

#list_deliveries(id, **params) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/certynix/resources/webhooks.rb', line 32

def list_deliveries(id, **params)
  Models::Paginator.new(
    http: @http,
    path: "/v1/webhooks/#{URI.encode_www_form_component(id)}/deliveries",
    params: params
  )
end

#update(id, url: nil, events: nil, active: nil) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/certynix/resources/webhooks.rb', line 20

def update(id, url: nil, events: nil, active: nil)
  body = {}
  body[:url]    = url    if url
  body[:events] = events if events
  body[:active] = active unless active.nil?
  @http.put("/v1/webhooks/#{URI.encode_www_form_component(id)}", body)
end