Class: Sendmux::Management::Generated::WebhooksApi

Inherits:
Object
  • Object
show all
Defined in:
lib/sendmux_management_generated/api/webhooks_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ WebhooksApi

Returns a new instance of WebhooksApi.



19
20
21
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#management_create_webhook(opts = {}) ⇒ WebhookSubscriptionWithSecretResponse

Create a webhook subscription Creates a new webhook subscription and returns the signing secret ONCE in the response body. Store it securely — it cannot be retrieved later. Use ‘POST /webhooks/id/rotate-secret` to issue a new one. Supply an `Idempotency-Key` header (any unique string, max 255 chars) to safely retry on network errors. Replays with the same key return the original response; replays with a different body return `409 idempotency_conflict`.

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:



28
29
30
31
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 28

def management_create_webhook(opts = {})
  data, _status_code, _headers = management_create_webhook_with_http_info(opts)
  data
end

#management_create_webhook_with_http_info(opts = {}) ⇒ Array<(WebhookSubscriptionWithSecretResponse, Integer, Hash)>

Create a webhook subscription Creates a new webhook subscription and returns the signing secret ONCE in the response body. Store it securely — it cannot be retrieved later. Use &#x60;POST /webhooks/id/rotate-secret&#x60; to issue a new one. Supply an &#x60;Idempotency-Key&#x60; header (any unique string, max 255 chars) to safely retry on network errors. Replays with the same key return the original response; replays with a different body return &#x60;409 idempotency_conflict&#x60;.

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 39

def management_create_webhook_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.management_create_webhook ...'
  end
  if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"idempotency_key"]" when calling WebhooksApi.management_create_webhook, the character length must be smaller than or equal to 255.'
  end

  # resource path
  local_var_path = '/webhooks'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'webhook_create_body'])

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookSubscriptionWithSecretResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"WebhooksApi.management_create_webhook",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#management_create_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#management_delete_webhook(public_id, opts = {}) ⇒ WebhookDeletedResponse

Delete a webhook subscription Permanently removes the subscription. In-flight retries are dropped.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



98
99
100
101
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 98

def management_delete_webhook(public_id, opts = {})
  data, _status_code, _headers = management_delete_webhook_with_http_info(public_id, opts)
  data
end

#management_delete_webhook_with_http_info(public_id, opts = {}) ⇒ Array<(WebhookDeletedResponse, Integer, Hash)>

Delete a webhook subscription Permanently removes the subscription. In-flight retries are dropped.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(WebhookDeletedResponse, Integer, Hash)>)

    WebhookDeletedResponse data, response status code and response headers



108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 108

def management_delete_webhook_with_http_info(public_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.management_delete_webhook ...'
  end
  # verify the required parameter 'public_id' is set
  if @api_client.config.client_side_validation && public_id.nil?
    fail ArgumentError, "Missing the required parameter 'public_id' when calling WebhooksApi.management_delete_webhook"
  end
  # resource path
  local_var_path = '/webhooks/{public_id}'.sub('{public_id}', CGI.escape(public_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookDeletedResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"WebhooksApi.management_delete_webhook",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#management_delete_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#management_get_delivery_payload(public_id, delivery_id, opts = {}) ⇒ WebhookDeliveryPayloadResponse

Get a webhook delivery payload Returns the retained JSON request body for one delivery attempt. Payloads are retained for 7 days and may no longer be available after ‘payload_expires_at`.

Parameters:

  • public_id (String)
  • delivery_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



162
163
164
165
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 162

def management_get_delivery_payload(public_id, delivery_id, opts = {})
  data, _status_code, _headers = management_get_delivery_payload_with_http_info(public_id, delivery_id, opts)
  data
end

#management_get_delivery_payload_with_http_info(public_id, delivery_id, opts = {}) ⇒ Array<(WebhookDeliveryPayloadResponse, Integer, Hash)>

Get a webhook delivery payload Returns the retained JSON request body for one delivery attempt. Payloads are retained for 7 days and may no longer be available after &#x60;payload_expires_at&#x60;.

Parameters:

  • public_id (String)
  • delivery_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 173

def management_get_delivery_payload_with_http_info(public_id, delivery_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.management_get_delivery_payload ...'
  end
  # verify the required parameter 'public_id' is set
  if @api_client.config.client_side_validation && public_id.nil?
    fail ArgumentError, "Missing the required parameter 'public_id' when calling WebhooksApi.management_get_delivery_payload"
  end
  # verify the required parameter 'delivery_id' is set
  if @api_client.config.client_side_validation && delivery_id.nil?
    fail ArgumentError, "Missing the required parameter 'delivery_id' when calling WebhooksApi.management_get_delivery_payload"
  end
  # resource path
  local_var_path = '/webhooks/{public_id}/deliveries/{delivery_id}/payload'.sub('{public_id}', CGI.escape(public_id.to_s)).sub('{delivery_id}', CGI.escape(delivery_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookDeliveryPayloadResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"WebhooksApi.management_get_delivery_payload",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#management_get_delivery_payload\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#management_get_webhook(public_id, opts = {}) ⇒ WebhookSubscriptionResponse

Get a webhook subscription Returns a single webhook subscription. The signing secret is never included. Responses carry a weak ‘ETag` header — send it back as `If-None-Match` on the next request and the server will return `304 Not Modified` (no body) when the resource has not changed. The same ETag is the value to use in `If-Match` on PATCH for optimistic concurrency.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :if_none_match (String)

Returns:



231
232
233
234
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 231

def management_get_webhook(public_id, opts = {})
  data, _status_code, _headers = management_get_webhook_with_http_info(public_id, opts)
  data
end

#management_get_webhook_with_http_info(public_id, opts = {}) ⇒ Array<(WebhookSubscriptionResponse, Integer, Hash)>

Get a webhook subscription Returns a single webhook subscription. The signing secret is never included. Responses carry a weak &#x60;ETag&#x60; header — send it back as &#x60;If-None-Match&#x60; on the next request and the server will return &#x60;304 Not Modified&#x60; (no body) when the resource has not changed. The same ETag is the value to use in &#x60;If-Match&#x60; on PATCH for optimistic concurrency.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :if_none_match (String)

Returns:

  • (Array<(WebhookSubscriptionResponse, Integer, Hash)>)

    WebhookSubscriptionResponse data, response status code and response headers



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 242

def management_get_webhook_with_http_info(public_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.management_get_webhook ...'
  end
  # verify the required parameter 'public_id' is set
  if @api_client.config.client_side_validation && public_id.nil?
    fail ArgumentError, "Missing the required parameter 'public_id' when calling WebhooksApi.management_get_webhook"
  end
  # resource path
  local_var_path = '/webhooks/{public_id}'.sub('{public_id}', CGI.escape(public_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'If-None-Match'] = opts[:'if_none_match'] if !opts[:'if_none_match'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookSubscriptionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"WebhooksApi.management_get_webhook",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#management_get_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#management_list_delivery(public_id, opts = {}) ⇒ WebhookDeliveryAttemptCursorListResponse

List webhook delivery attempts Returns recent delivery attempts for one webhook subscription, ordered by ‘created_at` descending. Delivery metadata is retained for 7 days. Use the payload endpoint while `payload_available` is true to inspect the exact JSON request body that was delivered.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :cursor (String)
  • :limit (Integer)
  • :event_type (String)
  • :result (String)

Returns:



300
301
302
303
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 300

def management_list_delivery(public_id, opts = {})
  data, _status_code, _headers = management_list_delivery_with_http_info(public_id, opts)
  data
end

#management_list_delivery_with_http_info(public_id, opts = {}) ⇒ Array<(WebhookDeliveryAttemptCursorListResponse, Integer, Hash)>

List webhook delivery attempts Returns recent delivery attempts for one webhook subscription, ordered by &#x60;created_at&#x60; descending. Delivery metadata is retained for 7 days. Use the payload endpoint while &#x60;payload_available&#x60; is true to inspect the exact JSON request body that was delivered.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :cursor (String)
  • :limit (Integer)
  • :event_type (String)
  • :result (String)

Returns:



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 314

def management_list_delivery_with_http_info(public_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.management_list_delivery ...'
  end
  # verify the required parameter 'public_id' is set
  if @api_client.config.client_side_validation && public_id.nil?
    fail ArgumentError, "Missing the required parameter 'public_id' when calling WebhooksApi.management_list_delivery"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling WebhooksApi.management_list_delivery, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling WebhooksApi.management_list_delivery, must be greater than or equal to 1.'
  end

  allowable_values = ["message.delivered", "message.bounced", "message.complained", "message.rejected", "message.delivery_delayed", "message.received", "message.received.spam", "sendmux.test", "unknown_default_open_api"]
  if @api_client.config.client_side_validation && opts[:'event_type'] && !allowable_values.include?(opts[:'event_type'])
    fail ArgumentError, "invalid value for \"event_type\", must be one of #{allowable_values}"
  end
  allowable_values = ["success", "retrying", "failed", "permanent_failure", "unknown_default_open_api"]
  if @api_client.config.client_side_validation && opts[:'result'] && !allowable_values.include?(opts[:'result'])
    fail ArgumentError, "invalid value for \"result\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/webhooks/{public_id}/deliveries'.sub('{public_id}', CGI.escape(public_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'event_type'] = opts[:'event_type'] if !opts[:'event_type'].nil?
  query_params[:'result'] = opts[:'result'] if !opts[:'result'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookDeliveryAttemptCursorListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"WebhooksApi.management_list_delivery",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#management_list_delivery\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#management_list_webhooks(opts = {}) ⇒ WebhookSubscriptionCursorListResponse

List webhook subscriptions Returns a cursor-paginated list of webhook subscriptions configured for the team, ordered by ‘created_at` descending. The signing secret is never included. Pass `cursor=<next_cursor>` from the previous response to fetch the next page.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :cursor (String)
  • :limit (Integer)

Returns:



388
389
390
391
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 388

def management_list_webhooks(opts = {})
  data, _status_code, _headers = management_list_webhooks_with_http_info(opts)
  data
end

#management_list_webhooks_with_http_info(opts = {}) ⇒ Array<(WebhookSubscriptionCursorListResponse, Integer, Hash)>

List webhook subscriptions Returns a cursor-paginated list of webhook subscriptions configured for the team, ordered by &#x60;created_at&#x60; descending. The signing secret is never included. Pass &#x60;cursor&#x3D;&lt;next_cursor&gt;&#x60; from the previous response to fetch the next page.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :cursor (String)
  • :limit (Integer)

Returns:



399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 399

def management_list_webhooks_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.management_list_webhooks ...'
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling WebhooksApi.management_list_webhooks, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling WebhooksApi.management_list_webhooks, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/webhooks'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookSubscriptionCursorListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"WebhooksApi.management_list_webhooks",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#management_list_webhooks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#management_rotate_webhook_secret(public_id, opts = {}) ⇒ WebhookSubscriptionWithSecretResponse

Rotate the signing secret Generates a fresh signing secret and returns it ONCE. The old secret is immediately invalidated — the next event delivery is signed with the new secret. Store the new value securely; it cannot be retrieved later. Supply an ‘Idempotency-Key` header to safely retry on network errors — replays under the same key return the original rotation response rather than minting a fresh secret. Replays against a different `public_id` under the same key return `409 idempotency_conflict`.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

Returns:



459
460
461
462
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 459

def management_rotate_webhook_secret(public_id, opts = {})
  data, _status_code, _headers = management_rotate_webhook_secret_with_http_info(public_id, opts)
  data
end

#management_rotate_webhook_secret_with_http_info(public_id, opts = {}) ⇒ Array<(WebhookSubscriptionWithSecretResponse, Integer, Hash)>

Rotate the signing secret Generates a fresh signing secret and returns it ONCE. The old secret is immediately invalidated — the next event delivery is signed with the new secret. Store the new value securely; it cannot be retrieved later. Supply an &#x60;Idempotency-Key&#x60; header to safely retry on network errors — replays under the same key return the original rotation response rather than minting a fresh secret. Replays against a different &#x60;public_id&#x60; under the same key return &#x60;409 idempotency_conflict&#x60;.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

Returns:



470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 470

def management_rotate_webhook_secret_with_http_info(public_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.management_rotate_webhook_secret ...'
  end
  # verify the required parameter 'public_id' is set
  if @api_client.config.client_side_validation && public_id.nil?
    fail ArgumentError, "Missing the required parameter 'public_id' when calling WebhooksApi.management_rotate_webhook_secret"
  end
  if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"idempotency_key"]" when calling WebhooksApi.management_rotate_webhook_secret, the character length must be smaller than or equal to 255.'
  end

  # resource path
  local_var_path = '/webhooks/{public_id}/rotate-secret'.sub('{public_id}', CGI.escape(public_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookSubscriptionWithSecretResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"WebhooksApi.management_rotate_webhook_secret",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#management_rotate_webhook_secret\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#management_test_webhook(public_id, opts = {}) ⇒ ManagementTestWebhook200Response

Send a synthetic test event Publishes a synthetic ‘sendmux.test` event to this webhook subscription. The subscription must include `"sendmux.test"` in `event_types`, and mailbox filters do not block the test delivery. Returns the generated `event_id` so you can correlate the `X-Sendmux-Event-Id` header on your endpoint. Supply an `Idempotency-Key` header to safely retry on network errors — replays under the same key return the original `event_id` rather than publishing a second test event.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

Returns:



529
530
531
532
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 529

def management_test_webhook(public_id, opts = {})
  data, _status_code, _headers = management_test_webhook_with_http_info(public_id, opts)
  data
end

#management_test_webhook_with_http_info(public_id, opts = {}) ⇒ Array<(ManagementTestWebhook200Response, Integer, Hash)>

Send a synthetic test event Publishes a synthetic &#x60;sendmux.test&#x60; event to this webhook subscription. The subscription must include &#x60;&quot;sendmux.test&quot;&#x60; in &#x60;event_types&#x60;, and mailbox filters do not block the test delivery. Returns the generated &#x60;event_id&#x60; so you can correlate the &#x60;X-Sendmux-Event-Id&#x60; header on your endpoint. Supply an &#x60;Idempotency-Key&#x60; header to safely retry on network errors — replays under the same key return the original &#x60;event_id&#x60; rather than publishing a second test event.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :idempotency_key (String)

Returns:



540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 540

def management_test_webhook_with_http_info(public_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.management_test_webhook ...'
  end
  # verify the required parameter 'public_id' is set
  if @api_client.config.client_side_validation && public_id.nil?
    fail ArgumentError, "Missing the required parameter 'public_id' when calling WebhooksApi.management_test_webhook"
  end
  if @api_client.config.client_side_validation && !opts[:'idempotency_key'].nil? && opts[:'idempotency_key'].to_s.length > 255
    fail ArgumentError, 'invalid value for "opts[:"idempotency_key"]" when calling WebhooksApi.management_test_webhook, the character length must be smaller than or equal to 255.'
  end

  # resource path
  local_var_path = '/webhooks/{public_id}/test'.sub('{public_id}', CGI.escape(public_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  header_params[:'Idempotency-Key'] = opts[:'idempotency_key'] if !opts[:'idempotency_key'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'ManagementTestWebhook200Response'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"WebhooksApi.management_test_webhook",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#management_test_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#management_update_webhook(public_id, opts = {}) ⇒ WebhookSubscriptionResponse

Update a webhook subscription Updates the URL, event types, or enabled flag. Any field omitted from the request body is left unchanged. The signing secret is unaffected — use ‘POST /webhooks/id/rotate-secret` to rotate it. For optimistic concurrency, send `If-Match: <etag>` using the ETag from a prior GET. A mismatched `If-Match` returns `409 conflict` (the server’s ETag is echoed back so you can decide whether to re-fetch). Responses carry the new ETag so chained edits can pipeline without a re-GET.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:



600
601
602
603
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 600

def management_update_webhook(public_id, opts = {})
  data, _status_code, _headers = management_update_webhook_with_http_info(public_id, opts)
  data
end

#management_update_webhook_with_http_info(public_id, opts = {}) ⇒ Array<(WebhookSubscriptionResponse, Integer, Hash)>

Update a webhook subscription Updates the URL, event types, or enabled flag. Any field omitted from the request body is left unchanged. The signing secret is unaffected — use &#x60;POST /webhooks/id/rotate-secret&#x60; to rotate it. For optimistic concurrency, send &#x60;If-Match: &lt;etag&gt;&#x60; using the ETag from a prior GET. A mismatched &#x60;If-Match&#x60; returns &#x60;409 conflict&#x60; (the server&#39;s ETag is echoed back so you can decide whether to re-fetch). Responses carry the new ETag so chained edits can pipeline without a re-GET.

Parameters:

  • public_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Array<(WebhookSubscriptionResponse, Integer, Hash)>)

    WebhookSubscriptionResponse data, response status code and response headers



612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
# File 'lib/sendmux_management_generated/api/webhooks_api.rb', line 612

def management_update_webhook_with_http_info(public_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: WebhooksApi.management_update_webhook ...'
  end
  # verify the required parameter 'public_id' is set
  if @api_client.config.client_side_validation && public_id.nil?
    fail ArgumentError, "Missing the required parameter 'public_id' when calling WebhooksApi.management_update_webhook"
  end
  # resource path
  local_var_path = '/webhooks/{public_id}'.sub('{public_id}', CGI.escape(public_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end
  header_params[:'If-Match'] = opts[:'if_match'] if !opts[:'if_match'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'webhook_update_body'])

  # return_type
  return_type = opts[:debug_return_type] || 'WebhookSubscriptionResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['bearerAuth']

  new_options = opts.merge(
    :operation => :"WebhooksApi.management_update_webhook",
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: WebhooksApi#management_update_webhook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end