Class: Dinie::Resources::WebhookEndpoints

Inherits:
Object
  • Object
show all
Defined in:
lib/dinie/generated/resources/webhook_endpoints.rb

Overview

Operations on the webhook endpoints resource.

Instance Method Summary collapse

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

Parameters:

  • fields (Hash)

    Request body fields.

  • request_options (Hash) (defaults to: {})

    Request options.

Returns:

  • (Object)


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

Parameters:

  • id (String)

    Identificador único do endpoint de webhook

  • request_options (Hash) (defaults to: {})

    Request options.

Returns:

  • (Object)


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

Parameters:

  • request_options (Hash) (defaults to: {})

    Request options.

Returns:

  • (Object)


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

Parameters:

  • id (String)

    Identificador único do endpoint de webhook

  • request_options (Hash) (defaults to: {})

    Request options.

Returns:

  • (Object)


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

Parameters:

  • id (String)

    Identificador único do endpoint de webhook

  • fields (Hash)

    Request body fields.

  • request_options (Hash) (defaults to: {})

    Request options.

Returns:

  • (Object)


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

Parameters:

  • id (String)

    Identificador único do endpoint de webhook

  • fields (Hash)

    Request body fields.

  • request_options (Hash) (defaults to: {})

    Request options.

Returns:

  • (Object)


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