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:



293
294
295
# File 'lib/sentdm/resources/webhooks.rb', line 293

def initialize(client:)
  @client = client
end

Instance Method Details

#create(display_name: nil, endpoint_url: nil, event_types: nil, retry_count: nil, test_mode: nil, timeout_seconds: nil, idempotency_key: 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_types (Array<String>)

    Body param

  • retry_count (Integer)

    Body param

  • test_mode (Boolean)

    Body param: Test mode flag - when true, the operation is simulated without side

  • timeout_seconds (Integer)

    Body param

  • idempotency_key (String)

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

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

Returns:

See Also:



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sentdm/resources/webhooks.rb', line 33

def create(params = {})
  parsed, options = Sentdm::WebhookCreateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @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, request_options: {}) ⇒ nil

Deletes a webhook for the authenticated customer.

Parameters:

Returns:

  • (nil)

See Also:



141
142
143
144
145
146
147
148
# File 'lib/sentdm/resources/webhooks.rb', line 141

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["v3/webhooks/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

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

Retrieves a paginated list of webhooks for the authenticated customer.

Parameters:

  • page (Integer)
  • page_size (Integer)
  • is_active (Boolean, nil)
  • search (String, nil)
  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



119
120
121
122
123
124
125
126
127
128
129
# File 'lib/sentdm/resources/webhooks.rb', line 119

def list(params)
  parsed, options = Sentdm::WebhookListParams.dump_request(params)
  query = Sentdm::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v3/webhooks",
    query: query.transform_keys(page_size: "pageSize", is_active: "isActive"),
    model: Sentdm::Models::WebhookListResponse,
    options: options
  )
end

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

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

Parameters:

Returns:

See Also:



159
160
161
162
163
164
165
166
# File 'lib/sentdm/resources/webhooks.rb', line 159

def list_event_types(params = {})
  @client.request(
    method: :get,
    path: "v3/webhooks/event-types",
    model: Sentdm::Models::WebhookListEventTypesResponse,
    options: params[:request_options]
  )
end

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

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

Parameters:

  • id (String)
  • page (Integer)
  • page_size (Integer)
  • search (String, nil)
  • request_options (Sentdm::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



181
182
183
184
185
186
187
188
189
190
191
# File 'lib/sentdm/resources/webhooks.rb', line 181

def list_events(id, params)
  parsed, options = Sentdm::WebhookListEventsParams.dump_request(params)
  query = Sentdm::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["v3/webhooks/%1$s/events", id],
    query: query.transform_keys(page_size: "pageSize"),
    model: Sentdm::Models::WebhookListEventsResponse,
    options: options
  )
end

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

Retrieves a single webhook by ID for the authenticated customer.

Parameters:

Returns:

See Also:



56
57
58
59
60
61
62
63
# File 'lib/sentdm/resources/webhooks.rb', line 56

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["v3/webhooks/%1$s", id],
    model: Sentdm::APIResponseWebhook,
    options: params[:request_options]
  )
end

#rotate_secret(id, body:, idempotency_key: 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:

Returns:

See Also:



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/sentdm/resources/webhooks.rb', line 212

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"),
    body: parsed[:body],
    model: Sentdm::Models::WebhookRotateSecretResponse,
    options: options
  )
end

#test_(id, event_type: nil, test_mode: nil, idempotency_key: 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

  • test_mode (Boolean)

    Body param: Test mode flag - when true, the operation is simulated without side

  • idempotency_key (String)

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

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

Returns:

See Also:



244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/sentdm/resources/webhooks.rb', line 244

def test_(id, params = {})
  parsed, options = Sentdm::WebhookTestParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @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, test_mode: nil, idempotency_key: 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

  • test_mode (Boolean)

    Body param: Test mode flag - when true, the operation is simulated without side

  • idempotency_key (String)

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

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

Returns:

See Also:



277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/sentdm/resources/webhooks.rb', line 277

def toggle_status(id, params = {})
  parsed, options = Sentdm::WebhookToggleStatusParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @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_types: nil, retry_count: nil, test_mode: nil, timeout_seconds: nil, idempotency_key: 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_types (Array<String>)

    Body param

  • retry_count (Integer)

    Body param

  • test_mode (Boolean)

    Body param: Test mode flag - when true, the operation is simulated without side

  • timeout_seconds (Integer)

    Body param

  • idempotency_key (String)

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

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

Returns:

See Also:



93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/sentdm/resources/webhooks.rb', line 93

def update(id, params = {})
  parsed, options = Sentdm::WebhookUpdateParams.dump_request(params)
  header_params = {idempotency_key: "idempotency-key"}
  @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