Class: Zazu::Resources::WebhookEndpoints

Inherits:
Base
  • Object
show all
Defined in:
lib/zazu/resources/webhook_endpoints.rb

Overview

Webhook endpoint configuration.

Constant Summary

Constants inherited from Base

Base::MAX_PER_PAGE

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Zazu::Resources::Base

Instance Method Details

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

POST /api/webhook_endpoints

Parameters:

  • url (String)

    the URL to deliver events to

  • events (Array<String>)

    event names to subscribe to

  • description (String, nil) (defaults to: nil)


22
23
24
25
26
27
# File 'lib/zazu/resources/webhook_endpoints.rb', line 22

def create(url:, events:, description: nil)
  http_post(
    "api/webhook_endpoints",
    body: { url: url, events: events, description: description }.compact
  )
end

#delete(id) ⇒ Object

DELETE /api/webhook_endpoints/:id



35
36
37
# File 'lib/zazu/resources/webhook_endpoints.rb', line 35

def delete(id)
  http_delete(encode_path("api/webhook_endpoints", id))
end

#disable(id) ⇒ Object

POST /api/webhook_endpoints/:id/disable



55
56
57
# File 'lib/zazu/resources/webhook_endpoints.rb', line 55

def disable(id)
  http_post(encode_path("api/webhook_endpoints", id, "disable"))
end

#enable(id) ⇒ Object

POST /api/webhook_endpoints/:id/enable



50
51
52
# File 'lib/zazu/resources/webhook_endpoints.rb', line 50

def enable(id)
  http_post(encode_path("api/webhook_endpoints", id, "enable"))
end

#get(id) ⇒ Object

GET /api/webhook_endpoints/:id



13
14
15
# File 'lib/zazu/resources/webhook_endpoints.rb', line 13

def get(id)
  http_get(encode_path("api/webhook_endpoints", id))
end

#list(limit: MAX_PER_PAGE, cursor: nil) ⇒ Object

GET /api/webhook_endpoints



8
9
10
# File 'lib/zazu/resources/webhook_endpoints.rb', line 8

def list(limit: MAX_PER_PAGE, cursor: nil)
  list_page("api/webhook_endpoints", limit: limit, cursor: cursor)
end

#regenerate_secret(id) ⇒ Object

POST /api/webhook_endpoints/:id/regenerate_secret



45
46
47
# File 'lib/zazu/resources/webhook_endpoints.rb', line 45

def regenerate_secret(id)
  http_post(encode_path("api/webhook_endpoints", id, "regenerate_secret"))
end

#test_endpoint(id) ⇒ Object

POST /api/webhook_endpoints/:id/test



40
41
42
# File 'lib/zazu/resources/webhook_endpoints.rb', line 40

def test_endpoint(id)
  http_post(encode_path("api/webhook_endpoints", id, "test"))
end

#update(id, **attributes) ⇒ Object

PATCH /api/webhook_endpoints/:id



30
31
32
# File 'lib/zazu/resources/webhook_endpoints.rb', line 30

def update(id, **attributes)
  http_patch(encode_path("api/webhook_endpoints", id), body: attributes)
end