Class: Dinie::Resources::WebhookEndpoints

Inherits:
Object
  • Object
show all
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 =

Returns:

  • (String)

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ WebhookEndpoints

Returns a new instance of WebhookEndpoints.

Parameters:



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.

Parameters:

  • request_options: (request_opts) (defaults to: {})
  • fields (Object)

Returns:



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).

Parameters:

  • id (String)
  • request_options: (request_opts) (defaults to: {})

Returns:

  • (nil)


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

Parameters:

  • id (String)

Returns:

  • (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.

Parameters:

  • limit: (Integer) (defaults to: Internal::OMIT)
  • starting_after: (String) (defaults to: Internal::OMIT)
  • request_options: (request_opts) (defaults to: {})

Returns:



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}).

Parameters:

  • id (String)
  • request_options: (request_opts) (defaults to: {})

Returns:



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).

Parameters:

  • id (String)
  • expire_current_in: (Integer)
  • request_options: (request_opts) (defaults to: {})

Returns:



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}).

Parameters:

  • id (String)
  • request_options: (request_opts) (defaults to: {})
  • fields (Object)

Returns:



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