Class: Blueticks::Resources::WebhooksResource
- Inherits:
-
BaseResource
- Object
- BaseResource
- Blueticks::Resources::WebhooksResource
- Defined in:
- lib/blueticks/resources/webhooks.rb
Instance Attribute Summary
Attributes inherited from BaseResource
Instance Method Summary collapse
-
#create(url:, events:, description: nil) ⇒ Object
Create a webhook subscription.
-
#delete(webhook_id) ⇒ Object
Delete a webhook.
-
#list(order: nil, skip: nil, limit: nil) ⇒ Object
List webhooks, newest first.
-
#retrieve(webhook_id) ⇒ Object
Retrieve a webhook by id.
-
#update(webhook_id, url: nil, events: nil, description: nil, status: nil) ⇒ Object
Update a webhook's url, events, description and/or status.
Methods inherited from BaseResource
Constructor Details
This class inherits a constructor from Blueticks::BaseResource
Instance Method Details
#create(url:, events:, description: nil) ⇒ Object
Create a webhook subscription.
12 13 14 15 16 17 |
# File 'lib/blueticks/resources/webhooks.rb', line 12 def create(url:, events:, description: nil) body = { "url" => url, "events" => events } body["description"] = description unless description.nil? env = client.request("POST", "/v1/webhooks", body: body) Types::Webhook.from_hash(env && env["data"]) end |
#delete(webhook_id) ⇒ Object
Delete a webhook.
47 48 49 50 |
# File 'lib/blueticks/resources/webhooks.rb', line 47 def delete(webhook_id) env = client.request("DELETE", "/v1/webhooks/#{webhook_id}") Types::DeletedResource.from_hash(env && env["data"]) end |
#list(order: nil, skip: nil, limit: nil) ⇒ Object
List webhooks, newest first. Offset-paginated.
20 21 22 23 24 25 26 27 |
# File 'lib/blueticks/resources/webhooks.rb', line 20 def list(order: nil, skip: nil, limit: nil) params = {} params["order"] = order unless order.nil? params["skip"] = skip unless skip.nil? params["limit"] = limit unless limit.nil? env = client.request("GET", "/v1/webhooks", params: params.empty? ? nil : params) Types::PaginatedPage.from_hash(env, item_type: Types::Webhook) end |
#retrieve(webhook_id) ⇒ Object
Retrieve a webhook by id.
30 31 32 33 |
# File 'lib/blueticks/resources/webhooks.rb', line 30 def retrieve(webhook_id) env = client.request("GET", "/v1/webhooks/#{webhook_id}") Types::Webhook.from_hash(env && env["data"]) end |
#update(webhook_id, url: nil, events: nil, description: nil, status: nil) ⇒ Object
Update a webhook's url, events, description and/or status.
36 37 38 39 40 41 42 43 44 |
# File 'lib/blueticks/resources/webhooks.rb', line 36 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? env = client.request("PATCH", "/v1/webhooks/#{webhook_id}", body: body) Types::Webhook.from_hash(env && env["data"]) end |