Class: Telnyx::Resources::EmailDomains::Webhooks

Inherits:
Object
  • Object
show all
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

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:



156
157
158
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 156

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.

Parameters:

Returns:

See Also:



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, options = 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: options
  )
end

#delete(id, domain_id:, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse

Delete a webhook

Parameters:

  • id (String)

    Email webhook UUID

  • domain_id (String)

    Email domain UUID

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

Returns:

See Also:



139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 139

def delete(id, params)
  parsed, options = 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: options
  )
end

#list(domain_id, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::EmailDomains::EmailWebhook>

List webhooks for an email domain

Parameters:

Returns:

See Also:



113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 113

def list(domain_id, params = {})
  parsed, options = 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: options
  )
end

#retrieve(id, domain_id:, request_options: {}) ⇒ Telnyx::Models::EmailDomains::EmailWebhookResponse

Retrieve a webhook

Parameters:

  • id (String)

    Email webhook UUID

  • domain_id (String)

    Email domain UUID

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

Returns:

See Also:



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 49

def retrieve(id, params)
  parsed, options = 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: 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.

Parameters:

Returns:

See Also:



81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/telnyx/resources/email_domains/webhooks.rb', line 81

def update(id, params)
  parsed, options = 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: options
  )
end