Class: Dinie::Resources::WebhookEndpoints
- Inherits:
-
Object
- Object
- Dinie::Resources::WebhookEndpoints
- Defined in:
- lib/dinie/generated/resources/webhook_endpoints.rb,
sig/dinie/generated/resources/webhook_endpoints.rbs
Overview
Operations on the webhook endpoints resource.
Constant Summary collapse
- WEBHOOK_ENDPOINTS_PATH =
Instance Method Summary collapse
-
#create(request_options: {}, **fields) ⇒ Dinie::WebhookEndpointWithSecret
Create a webhook endpoint (
POST /webhooks/endpoints) → the secret-bearing response. -
#delete(id, request_options: {}) ⇒ nil
Delete a webhook endpoint (
DELETE /webhooks/endpoints/{id}→ 204). - #endpoint_path ⇒ String
-
#initialize(http) ⇒ WebhookEndpoints
constructor
A new instance of WebhookEndpoints.
-
#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}) ⇒ Dinie::Page[Dinie::WebhookEndpoint]
List webhook endpoints (
GET /webhooks/endpoints), auto-paginating bystarting_after. -
#retrieve(id, request_options: {}) ⇒ Dinie::WebhookEndpoint
Retrieve a webhook endpoint by id (
GET /webhooks/endpoints/{id}). -
#rotate_secret(id, request_options: {}, **fields) ⇒ Dinie::WebhookSecretRotation
Rotate the HMAC signing secret (
POST /webhooks/endpoints/{id}/rotate-secret). -
#update(id, request_options: {}, **fields) ⇒ Dinie::WebhookEndpoint
Update a webhook endpoint (
PATCH /webhooks/endpoints/{id}).
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) ⇒ Dinie::WebhookEndpointWithSecret
Create a webhook endpoint (POST /webhooks/endpoints) → the secret-bearing 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: {}) ⇒ nil
Delete a webhook endpoint (DELETE /webhooks/endpoints/{id} → 204).
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 |
#endpoint_path ⇒ String
32 |
# File 'sig/dinie/generated/resources/webhook_endpoints.rbs', line 32 def endpoint_path: (String id) -> String |
#list(limit: Internal::OMIT, starting_after: Internal::OMIT, request_options: {}) ⇒ Dinie::Page[Dinie::WebhookEndpoint]
List webhook endpoints (GET /webhooks/endpoints), auto-paginating by starting_after.
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: {}) ⇒ Dinie::WebhookEndpoint
Retrieve a webhook endpoint by id (GET /webhooks/endpoints/{id}).
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) ⇒ Dinie::WebhookSecretRotation
Rotate the HMAC signing secret (POST /webhooks/endpoints/{id}/rotate-secret).
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) ⇒ Dinie::WebhookEndpoint
Update a webhook endpoint (PATCH /webhooks/endpoints/{id}).
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 |