Class: Blueticks::Resources::WebhooksResource
Instance Attribute Summary
Attributes inherited from BaseResource
#client
Instance Method Summary
collapse
#initialize
Instance Method Details
#create(url:, events:, description: nil) ⇒ Object
10
11
12
13
14
15
|
# File 'lib/blueticks/resources/webhooks.rb', line 10
def create(url:, events:, description: nil)
body = { "url" => url, "events" => events }
body["description"] = description unless description.nil?
data = client.request("POST", "/v1/webhooks", body: body)
Types::WebhookCreateResult.from_hash(data)
end
|
#delete(webhook_id) ⇒ Object
41
42
43
44
|
# File 'lib/blueticks/resources/webhooks.rb', line 41
def delete(webhook_id)
client.request("DELETE", "/v1/webhooks/#{webhook_id}")
nil
end
|
#get(webhook_id) ⇒ Object
26
27
28
29
|
# File 'lib/blueticks/resources/webhooks.rb', line 26
def get(webhook_id)
data = client.request("GET", "/v1/webhooks/#{webhook_id}")
Types::Webhook.from_hash(data)
end
|
#list(limit: nil, cursor: nil) ⇒ Object
List webhooks, newest first. Cursor-paginated.
18
19
20
21
22
23
24
|
# File 'lib/blueticks/resources/webhooks.rb', line 18
def list(limit: nil, cursor: nil)
params = {}
params["limit"] = limit unless limit.nil?
params["cursor"] = cursor unless cursor.nil?
data = client.request("GET", "/v1/webhooks", params: params.empty? ? nil : params)
Types::Page.from_hash(data, item_type: Types::Webhook)
end
|
#rotate_secret(webhook_id) ⇒ Object
46
47
48
49
|
# File 'lib/blueticks/resources/webhooks.rb', line 46
def rotate_secret(webhook_id)
data = client.request("POST", "/v1/webhooks/#{webhook_id}/rotate-secret")
Types::WebhookCreateResult.from_hash(data)
end
|
#update(webhook_id, url: nil, events: nil, description: nil, status: nil) ⇒ Object
31
32
33
34
35
36
37
38
39
|
# File 'lib/blueticks/resources/webhooks.rb', line 31
def update(webhook_id, url: nil, events: nil, description: nil, status: nil)
body = {}
body["url"] = url unless url.nil?
body["events"] = events unless events.nil?
body["description"] = description unless description.nil?
body["status"] = status unless status.nil?
data = client.request("PATCH", "/v1/webhooks/#{webhook_id}", body: body)
Types::Webhook.from_hash(data)
end
|