Class: Sentdm::Resources::Webhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/sentdm/resources/webhooks.rb

Overview

Configure webhook endpoints for real-time event delivery

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Webhooks

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Webhooks.

Parameters:



355
356
357
# File 'lib/sentdm/resources/webhooks.rb', line 355

def initialize(client:)
  @client = client
end

Instance Method Details

#create(display_name: nil, endpoint_url: nil, event_filters: nil, event_types: nil, retry_count: nil, sandbox: nil, timeout_seconds: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseWebhook

Some parameter documentations has been truncated, see Models::WebhookCreateParams for more details.

Creates a new webhook endpoint for the authenticated customer.

Parameters:

  • display_name (String)

    Body param

  • endpoint_url (String)

    Body param

  • event_filters (Hash{Symbol=>Array<String>}, nil)

    Body param

  • event_types (Array<String>)

    Body param

  • retry_count (Integer)

    Body param

  • sandbox (Boolean)

    Body param: Sandbox flag - when true, the operation is simulated without side ef

  • timeout_seconds (Integer)

    Body param

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/sentdm/resources/webhooks.rb', line 37

def create(params = {})
  parsed, options = Sentdm::WebhookCreateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
  @client.request(
    method: :post,
    path: "v3/webhooks",
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::APIResponseWebhook,
    options: options
  )
end

#delete(id, x_profile_id: nil, request_options: {}) ⇒ nil

Some parameter documentations has been truncated, see Models::WebhookDeleteParams for more details.

Deletes a webhook for the authenticated customer.

Parameters:

  • id (String)
  • x_profile_id (String)

    Profile UUID to scope the request to a child profile. Only organization API keys

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

  • (nil)

See Also:



174
175
176
177
178
179
180
181
182
183
# File 'lib/sentdm/resources/webhooks.rb', line 174

def delete(id, params = {})
  parsed, options = Sentdm::WebhookDeleteParams.dump_request(params)
  @client.request(
    method: :delete,
    path: ["v3/webhooks/%1$s", id],
    headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
    model: NilClass,
    options: options
  )
end

#list(page:, page_size:, is_active: nil, search: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::WebhookListResponse

Some parameter documentations has been truncated, see Models::WebhookListParams for more details.

Retrieves a paginated list of webhooks for the authenticated customer.

Parameters:

  • page (Integer)

    Query param

  • page_size (Integer)

    Query param

  • is_active (Boolean, nil)

    Query param

  • search (String, nil)

    Query param

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/sentdm/resources/webhooks.rb', line 144

def list(params)
  query_params = [:page, :page_size, :is_active, :search]
  parsed, options = Sentdm::WebhookListParams.dump_request(params)
  query = Sentdm::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: "v3/webhooks",
    query: query,
    headers: parsed.except(*query_params).transform_keys(x_profile_id: "x-profile-id"),
    model: Sentdm::Models::WebhookListResponse,
    options: options
  )
end

#list_event_types(x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::WebhookListEventTypesResponse

Some parameter documentations has been truncated, see Models::WebhookListEventTypesParams for more details.

Retrieves all available webhook event types that can be subscribed to.

Parameters:

  • x_profile_id (String)

    Profile UUID to scope the request to a child profile. Only organization API keys

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



199
200
201
202
203
204
205
206
207
208
# File 'lib/sentdm/resources/webhooks.rb', line 199

def list_event_types(params = {})
  parsed, options = Sentdm::WebhookListEventTypesParams.dump_request(params)
  @client.request(
    method: :get,
    path: "v3/webhooks/event-types",
    headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
    model: Sentdm::Models::WebhookListEventTypesResponse,
    options: options
  )
end

#list_events(id, page:, page_size:, search: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::WebhookListEventsResponse

Some parameter documentations has been truncated, see Models::WebhookListEventsParams for more details.

Retrieves a paginated list of delivery events for the specified webhook.

Parameters:

  • id (String)

    Path param

  • page (Integer)

    Query param

  • page_size (Integer)

    Query param

  • search (String, nil)

    Query param

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/sentdm/resources/webhooks.rb', line 232

def list_events(id, params)
  query_params = [:page, :page_size, :search]
  parsed, options = Sentdm::WebhookListEventsParams.dump_request(params)
  query = Sentdm::Internal::Util.encode_query_params(parsed.slice(*query_params))
  @client.request(
    method: :get,
    path: ["v3/webhooks/%1$s/events", id],
    query: query,
    headers: parsed.except(*query_params).transform_keys(x_profile_id: "x-profile-id"),
    model: Sentdm::Models::WebhookListEventsResponse,
    options: options
  )
end

#retrieve(id, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseWebhook

Some parameter documentations has been truncated, see Models::WebhookRetrieveParams for more details.

Retrieves a single webhook by ID for the authenticated customer.

Parameters:

  • id (String)
  • x_profile_id (String)

    Profile UUID to scope the request to a child profile. Only organization API keys

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



66
67
68
69
70
71
72
73
74
75
# File 'lib/sentdm/resources/webhooks.rb', line 66

def retrieve(id, params = {})
  parsed, options = Sentdm::WebhookRetrieveParams.dump_request(params)
  @client.request(
    method: :get,
    path: ["v3/webhooks/%1$s", id],
    headers: parsed.transform_keys(x_profile_id: "x-profile-id"),
    model: Sentdm::APIResponseWebhook,
    options: options
  )
end

#rotate_secret(id, body:, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::WebhookRotateSecretResponse

Some parameter documentations has been truncated, see Models::WebhookRotateSecretParams for more details.

Generates a new signing secret for the specified webhook. The old secret is immediately invalidated.

Parameters:

  • id (String)

    Path param

  • body (Sentdm::Models::WebhookRotateSecretParams::Body)

    Body param

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



267
268
269
270
271
272
273
274
275
276
277
278
279
280
# File 'lib/sentdm/resources/webhooks.rb', line 267

def rotate_secret(id, params)
  parsed, options = Sentdm::WebhookRotateSecretParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v3/webhooks/%1$s/rotate-secret", id],
    headers: parsed.except(:body).transform_keys(
      idempotency_key: "idempotency-key",
      x_profile_id: "x-profile-id"
    ),
    body: parsed[:body],
    model: Sentdm::Models::WebhookRotateSecretResponse,
    options: options
  )
end

#test_(id, event_type: nil, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::WebhookTestResponse

Some parameter documentations has been truncated, see Models::WebhookTestParams for more details.

Sends a test event to the specified webhook endpoint to verify connectivity.

Parameters:

  • id (String)

    Path param

  • event_type (String)

    Body param

  • sandbox (Boolean)

    Body param: Sandbox flag - when true, the operation is simulated without side ef

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/sentdm/resources/webhooks.rb', line 304

def test_(id, params = {})
  parsed, options = Sentdm::WebhookTestParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
  @client.request(
    method: :post,
    path: ["v3/webhooks/%1$s/test", id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::Models::WebhookTestResponse,
    options: options
  )
end

#toggle_status(id, is_active: nil, sandbox: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseWebhook

Some parameter documentations has been truncated, see Models::WebhookToggleStatusParams for more details.

Activates or deactivates a webhook for the authenticated customer.

Parameters:

  • id (String)

    Path param

  • is_active (Boolean)

    Body param

  • sandbox (Boolean)

    Body param: Sandbox flag - when true, the operation is simulated without side ef

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



339
340
341
342
343
344
345
346
347
348
349
350
# File 'lib/sentdm/resources/webhooks.rb', line 339

def toggle_status(id, params = {})
  parsed, options = Sentdm::WebhookToggleStatusParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
  @client.request(
    method: :patch,
    path: ["v3/webhooks/%1$s/toggle-status", id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::APIResponseWebhook,
    options: options
  )
end

#update(id, display_name: nil, endpoint_url: nil, event_filters: nil, event_types: nil, retry_count: nil, sandbox: nil, timeout_seconds: nil, idempotency_key: nil, x_profile_id: nil, request_options: {}) ⇒ Sentdm::Models::APIResponseWebhook

Some parameter documentations has been truncated, see Models::WebhookUpdateParams for more details.

Updates an existing webhook for the authenticated customer.

Parameters:

  • id (String)

    Path param

  • display_name (String)

    Body param

  • endpoint_url (String)

    Body param

  • event_filters (Hash{Symbol=>Array<String>}, nil)

    Body param

  • event_types (Array<String>)

    Body param

  • retry_count (Integer)

    Body param

  • sandbox (Boolean)

    Body param: Sandbox flag - when true, the operation is simulated without side ef

  • timeout_seconds (Integer)

    Body param

  • idempotency_key (String)

    Header param: Unique key to ensure idempotent request processing. Must be 1-255

  • x_profile_id (String)

    Header param: Profile UUID to scope the request to a child profile. Only organiz

  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/sentdm/resources/webhooks.rb', line 109

def update(id, params = {})
  parsed, options = Sentdm::WebhookUpdateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key", x_profile_id: "x-profile-id"}
  @client.request(
    method: :put,
    path: ["v3/webhooks/%1$s", id],
    headers: parsed.slice(*header_params.keys).transform_keys(header_params),
    body: parsed.except(*header_params.keys),
    model: Sentdm::APIResponseWebhook,
    options: options
  )
end