Class: Nombaone::Resources::WebhookEndpoints

Inherits:
BaseResource show all
Defined in:
lib/nombaone/resources/webhook_endpoints.rb,
sig/nombaone/resources.rbs

Overview

Webhook endpoints — register and manage the URLs that receive signed events. To verify incoming deliveries in your handler, use Nombaone.webhooks / Webhooks#construct_event — the crypto helper, not this REST resource.

Instance Method Summary collapse

Methods inherited from BaseResource

#encode, #initialize, #request, #request_page

Constructor Details

This class inherits a constructor from Nombaone::Resources::BaseResource

Instance Method Details

#create(url:, enabled_events: OMIT, request_options: {}) ⇒ NombaObject

Register an endpoint. The response includes the full signing_secret exactly once — store it in your secret manager immediately.

Examples:

endpoint = nombaone.webhook_endpoints.create(
  url: "https://example.com/nombaone/webhooks",
  enabled_events: ["invoice.paid", "invoice.payment_failed"]
)
store_secret(endpoint.signing_secret)

Parameters:

  • url (String)
  • enabled_events (Array<String>) (defaults to: OMIT)

    event types to fan out; defaults to ["*"] (all events) server-side.

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

Returns:

  • (NombaObject)

    the endpoint plus its one-time signing_secret.



82
83
84
85
# File 'lib/nombaone/resources/webhook_endpoints.rb', line 82

def create(url:, enabled_events: OMIT, request_options: {})
  request(:post, "/webhooks",
          body: { url: url, enabled_events: enabled_events }, options: request_options)
end

#delete(id, request_options: {}) ⇒ NombaObject

Delete an endpoint. Pending deliveries to it are retired.

Parameters:

  • id (String)

    nbo…whk

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

Returns:



124
125
126
# File 'lib/nombaone/resources/webhook_endpoints.rb', line 124

def delete(id, request_options: {})
  request(:delete, "/webhooks/#{encode(id)}", options: request_options)
end

#deliveriesWebhookEndpointDeliveries

Deliveries under an endpoint.



63
64
65
# File 'lib/nombaone/resources/webhook_endpoints.rb', line 63

def deliveries
  @deliveries ||= WebhookEndpointDeliveries.new(@client)
end

#list(request_options: {}) ⇒ Page<NombaObject>

List your endpoints.

Parameters:

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

Returns:



115
116
117
# File 'lib/nombaone/resources/webhook_endpoints.rb', line 115

def list(request_options: {})
  request_page("/webhooks", options: request_options)
end

#retrieve(id, request_options: {}) ⇒ NombaObject

Retrieve an endpoint by id.

Parameters:

  • id (String)

    nbo…whk

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

Returns:

Raises:



93
94
95
# File 'lib/nombaone/resources/webhook_endpoints.rb', line 93

def retrieve(id, request_options: {})
  request(:get, "/webhooks/#{encode(id)}", options: request_options)
end

#rotate_secret(id, request_options: {}) ⇒ NombaObject

Rotate the signing secret. The new secret is returned exactly once; the old one is briefly honored so you can roll without dropping in-flight deliveries.

Parameters:

  • id (String)

    nbo…whk

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

Returns:

  • (NombaObject)

    with the new one-time signing_secret.



135
136
137
# File 'lib/nombaone/resources/webhook_endpoints.rb', line 135

def rotate_secret(id, request_options: {})
  request(:post, "/webhooks/#{encode(id)}/rotate-secret", body: {}, options: request_options)
end

#update(id, url: OMIT, enabled_events: OMIT, disabled: OMIT, request_options: {}) ⇒ NombaObject

Update url, event subscription, or enabled state.

Parameters:

  • id (String)

    nbo…whk

  • url (String) (defaults to: OMIT)
  • enabled_events (Array<String>) (defaults to: OMIT)
  • disabled (Boolean) (defaults to: OMIT)

    true pauses deliveries; false re-enables.

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

Returns:



105
106
107
108
109
# File 'lib/nombaone/resources/webhook_endpoints.rb', line 105

def update(id, url: OMIT, enabled_events: OMIT, disabled: OMIT, request_options: {})
  request(:patch, "/webhooks/#{encode(id)}",
          body: { url: url, enabled_events: enabled_events, disabled: disabled },
          options: request_options)
end