Class: Rerout::Resources::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/rerout/webhooks_resource.rb

Overview

Webhook endpoint management namespace — create, list, delete endpoints for the project that owns the API key.

This is distinct from Webhooks, which verifies inbound delivery signatures. Reach it via ‘client.webhooks`.

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Webhooks

Returns a new instance of Webhooks.

Parameters:



14
15
16
# File 'lib/rerout/webhooks_resource.rb', line 14

def initialize(client)
  @client = client
end

Instance Method Details

#create(input) ⇒ Rerout::Models::CreatedWebhook

Create a webhook endpoint. The returned ‘signing_secret` (`whsec_…`) is shown once — persist it to verify future deliveries.

Parameters:

Returns:



23
24
25
26
27
# File 'lib/rerout/webhooks_resource.rb', line 23

def create(input)
  body = coerce_input(input)
  response = @client.request(method: :post, path: '/v1/projects/me/webhooks', body: body)
  Models::CreatedWebhook.from_hash(response)
end

#delete(endpoint_id) ⇒ Hash

Soft-delete an endpoint and abandon its pending deliveries. Idempotent.

Parameters:

  • endpoint_id (String)

    the endpoint id (‘wh_…`).

Returns:

  • (Hash)

    ‘{ “deleted” => true }`



41
42
43
# File 'lib/rerout/webhooks_resource.rb', line 41

def delete(endpoint_id)
  @client.request(method: :delete, path: webhook_path(endpoint_id))
end

#listRerout::Models::ListWebhooksResult

List webhook endpoints and the event types the server can deliver.



32
33
34
35
# File 'lib/rerout/webhooks_resource.rb', line 32

def list
  response = @client.request(method: :get, path: '/v1/projects/me/webhooks')
  Models::ListWebhooksResult.from_hash(response)
end