Class: Telnyx::Resources::EmailDomains::Webhooks
- Inherits:
-
Object
- Object
- Telnyx::Resources::EmailDomains::Webhooks
- Defined in:
- lib/telnyx/resources/email_domains/webhooks.rb,
sig/telnyx/resources/email_domains/webhooks.rbs
Overview
Per-domain webhook endpoints with event subscriptions
Instance Method Summary collapse
-
#create(domain_id, events:, url:, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse
Creates a webhook endpoint subscribed to a specific allowlist of event types.
-
#delete(id, domain_id:, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse
Deletes the webhook subscription identified by ID within the specified email domain and returns the deleted subscription.
-
#initialize(client:) ⇒ Webhooks
constructor
private
A new instance of Webhooks.
-
#list(domain_id, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::EmailDomains::EmailWebhook>
Returns a paginated list of webhook subscriptions scoped to the email domain.
-
#retrieve(id, domain_id:, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse
Returns the webhook subscription identified by ID within the specified email domain.
-
#update(id, domain_id:, events: nil, url: nil, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse
Update a webhook's URL and/or event subscription.
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.
159 160 161 |
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 159 def initialize(client:) @client = client end |
Instance Method Details
#create(domain_id, events:, url:, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse
Creates a webhook endpoint subscribed to a specific allowlist of event types.
Both email.* events (published by email-api) and email_domain.* events
(published by this service) flow through the same webhooks.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 25 def create(domain_id, params) parsed, = Telnyx::EmailDomains::WebhookCreateParams.dump_request(params) @client.request( method: :post, path: ["email_domains/%1$s/webhooks", domain_id], body: parsed, model: Telnyx::EmailDomains::EmailWebhookResponse, options: ) end |
#delete(id, domain_id:, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse
Deletes the webhook subscription identified by ID within the specified email domain and returns the deleted subscription.
142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 142 def delete(id, params) parsed, = Telnyx::EmailDomains::WebhookDeleteParams.dump_request(params) domain_id = parsed.delete(:domain_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :delete, path: ["email_domains/%1$s/webhooks/%2$s", domain_id, id], model: Telnyx::EmailDomains::EmailWebhookResponse, options: ) end |
#list(domain_id, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::EmailDomains::EmailWebhook>
Returns a paginated list of webhook subscriptions scoped to the email domain. Results can be sorted by creation time.
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 115 def list(domain_id, params = {}) parsed, = Telnyx::EmailDomains::WebhookListParams.dump_request(params) query = Telnyx::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: ["email_domains/%1$s/webhooks", domain_id], query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"), page: Telnyx::Internal::DefaultFlatPagination, model: Telnyx::EmailDomains::EmailWebhook, options: ) end |
#retrieve(id, domain_id:, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse
Returns the webhook subscription identified by ID within the specified email domain.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 50 def retrieve(id, params) parsed, = Telnyx::EmailDomains::WebhookRetrieveParams.dump_request(params) domain_id = parsed.delete(:domain_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :get, path: ["email_domains/%1$s/webhooks/%2$s", domain_id, id], model: Telnyx::EmailDomains::EmailWebhookResponse, options: ) end |
#update(id, domain_id:, events: nil, url: nil, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse
Update a webhook's URL and/or event subscription. A webhook is bound to its
domain — domain_id is not mutable.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 82 def update(id, params) parsed, = Telnyx::EmailDomains::WebhookUpdateParams.dump_request(params) domain_id = parsed.delete(:domain_id) do raise ArgumentError.new("missing required path argument #{_1}") end @client.request( method: :patch, path: ["email_domains/%1$s/webhooks/%2$s", domain_id, id], body: parsed, model: Telnyx::EmailDomains::EmailWebhookResponse, options: ) end |