Class: Dinie::Resources::WebhookEndpoints
- Inherits:
-
Object
- Object
- Dinie::Resources::WebhookEndpoints
- Defined in:
- lib/dinie/generated/resources/webhook_endpoints.rb
Overview
Operations on the webhook endpoints resource.
Instance Method Summary collapse
-
#create(request_options: {}, **fields) ⇒ Object
Create a webhook endpoint.
-
#delete(id, request_options: {}) ⇒ Object
Delete a webhook endpoint.
-
#initialize(http) ⇒ WebhookEndpoints
constructor
A new instance of WebhookEndpoints.
-
#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}) ⇒ Object
List webhook endpoints.
-
#retrieve(id, request_options: {}) ⇒ Object
Retrieve a webhook endpoint.
-
#rotate_secret(id, request_options: {}, **fields) ⇒ Object
Rotate the signing secret.
-
#update(id, request_options: {}, **fields) ⇒ Object
Update a webhook endpoint.
Constructor Details
#initialize(http) ⇒ WebhookEndpoints
Returns a new instance of WebhookEndpoints.
11 12 13 |
# File 'lib/dinie/generated/resources/webhook_endpoints.rb', line 11 def initialize(http) @http = http end |
Instance Method Details
#create(request_options: {}, **fields) ⇒ Object
Create a webhook endpoint
Create a webhook endpoint; the HMAC signing ‘secret` is returned only in this response
22 23 24 25 26 |
# File 'lib/dinie/generated/resources/webhook_endpoints.rb', line 22 def create(request_options: {}, **fields) body = WebhookEndpoint.serialize_create(**fields) raw = @http.request(method: :post, path: "/webhooks/endpoints", body:, request_options:) WebhookEndpointWithSecret.deserialize(raw) end |
#delete(id, request_options: {}) ⇒ Object
Delete a webhook endpoint
Delete a webhook endpoint and stop all deliveries
35 36 37 38 |
# File 'lib/dinie/generated/resources/webhook_endpoints.rb', line 35 def delete(id, request_options: {}) @http.request(method: :delete, path: "/webhooks/endpoints/#{id}", request_options:) nil end |
#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}) ⇒ Object
List webhook endpoints
List all configured webhook endpoints with URL, subscribed events, and status
46 47 48 49 50 51 52 53 54 |
# File 'lib/dinie/generated/resources/webhook_endpoints.rb', line 46 def list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}) fetch_page = lambda do |cursor| query = { limit:, starting_after: cursor || starting_after } .reject { |_key, value| Internal.omitted?(value) } body = @http.request(method: :get, path: "/webhooks/endpoints", query:, request_options:) { data: body[:data].map { |raw| WebhookEndpoint.deserialize(raw) }, has_more: body[:has_more] } end Dinie::Page.from_fetch(fetch_page) end |
#retrieve(id, request_options: {}) ⇒ Object
Retrieve a webhook endpoint
Return details of a specific webhook endpoint including URL, events, and status
63 64 65 66 |
# File 'lib/dinie/generated/resources/webhook_endpoints.rb', line 63 def retrieve(id, request_options: {}) raw = @http.request(method: :get, path: "/webhooks/endpoints/#{id}", request_options:) WebhookEndpoint.deserialize(raw) end |
#rotate_secret(id, request_options: {}, **fields) ⇒ Object
Rotate the signing secret
Rotate the HMAC signing secret; the previous secret remains valid for the grace period
76 77 78 79 80 |
# File 'lib/dinie/generated/resources/webhook_endpoints.rb', line 76 def rotate_secret(id, request_options: {}, **fields) body = fields raw = @http.request(method: :post, path: "/webhooks/endpoints/#{id}/rotate-secret", body:, request_options:) WebhookSecretRotation.deserialize(raw) end |
#update(id, request_options: {}, **fields) ⇒ Object
Update a webhook endpoint
Update URL, events, description, or status of a webhook endpoint
90 91 92 93 94 |
# File 'lib/dinie/generated/resources/webhook_endpoints.rb', line 90 def update(id, request_options: {}, **fields) body = WebhookEndpoint.serialize_update(**fields) raw = @http.request(method: :patch, path: "/webhooks/endpoints/#{id}", body:, request_options:) WebhookEndpoint.deserialize(raw) end |