Class: Auth0::Emails::Provider::Client
- Inherits:
-
Object
- Object
- Auth0::Emails::Provider::Client
- Defined in:
- lib/auth0/emails/provider/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Auth0::Types::CreateEmailProviderResponseContent
Create an email provider.
-
#delete(request_options: {}, **_params) ⇒ untyped
Delete the email provider.
-
#get(request_options: {}, **params) ⇒ Auth0::Types::GetEmailProviderResponseContent
Retrieve details of the email provider configuration in your tenant.
- #initialize(client:) ⇒ void constructor
-
#update(request_options: {}, **params) ⇒ Auth0::Types::UpdateEmailProviderResponseContent
Update an email provider.
Constructor Details
#initialize(client:) ⇒ void
10 11 12 |
# File 'lib/auth0/emails/provider/client.rb', line 10 def initialize(client:) @client = client end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Auth0::Types::CreateEmailProviderResponseContent
Create an email provider. The credentials object
requires different properties depending on the email provider (which is specified using the name property):
mandrillrequiresapi_keysendgridrequiresapi_keysparkpostrequiresapi_key. Optionally, setregiontoeuto use the SparkPost service hosted in Western Europe; set tonullto use the SparkPost service hosted in North America.euornullare the only valid values forregion.mailgunrequiresapi_keyanddomain. Optionally, setregiontoeuto use the Mailgun service hosted in Europe; set tonullotherwise.euornullare the only valid values forregion.sesrequiresaccessKeyId,secretAccessKey, andregionsmtprequiressmtp_host,smtp_port,smtp_user, andsmtp_pass
Depending on the type of provider it is possible to specify settings object with different configuration
options, which will be used when sending an email:
-
smtpprovider,settingsmay containheadersobject.- When using AWS SES SMTP host, you may provide a name of configuration set in
X-SES-Configuration-Setheader. Value must be a string. - When using Sparkpost host, you may provide value for
X-MSYS_APIheader. Value must be an object.
- When using AWS SES SMTP host, you may provide a name of configuration set in
- For
sesprovider,settingsmay containmessageobject, where you can provide a name of configuration set inconfiguration_set_nameproperty. Value must be a string.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/auth0/emails/provider/client.rb', line 105 def create(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "emails/provider", body: Auth0::Emails::Provider::Types::CreateEmailProviderRequestContent.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) (response.body.to_s.empty? ? nil : Auth0::Types::CreateEmailProviderResponseContent.load(response.body)) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#delete(request_options: {}, **_params) ⇒ untyped
Delete the email provider.
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/auth0/emails/provider/client.rb', line 142 def delete(request_options: {}, **_params) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "DELETE", path: "emails/provider", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#get(request_options: {}, **params) ⇒ Auth0::Types::GetEmailProviderResponseContent
Retrieve details of the email provider configuration in your tenant. A list of fields to include or exclude may also be specified.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/auth0/emails/provider/client.rb', line 35 def get(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) query_params = {} query_params["fields"] = params[:fields] if params.key?(:fields) query_params["include_fields"] = params[:include_fields] if params.key?(:include_fields) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "emails/provider", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) (response.body.to_s.empty? ? nil : Auth0::Types::GetEmailProviderResponseContent.load(response.body)) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update(request_options: {}, **params) ⇒ Auth0::Types::UpdateEmailProviderResponseContent
Update an email provider. The credentials object
requires different properties depending on the email provider (which is specified using the name property):
mandrillrequiresapi_keysendgridrequiresapi_keysparkpostrequiresapi_key. Optionally, setregiontoeuto use the SparkPost service hosted in Western Europe; set tonullto use the SparkPost service hosted in North America.euornullare the only valid values forregion.mailgunrequiresapi_keyanddomain. Optionally, setregiontoeuto use the Mailgun service hosted in Europe; set tonullotherwise.euornullare the only valid values forregion.sesrequiresaccessKeyId,secretAccessKey, andregionsmtprequiressmtp_host,smtp_port,smtp_user, andsmtp_pass
Depending on the type of provider it is possible to specify settings object with different configuration
options, which will be used when sending an email:
-
smtpprovider,settingsmay containheadersobject.- When using AWS SES SMTP host, you may provide a name of configuration set in
X-SES-Configuration-Setheader. Value must be a string. - When using Sparkpost host, you may provide value for
X-MSYS_APIheader. Value must be an object.
For
sesprovider,settingsmay containmessageobject, where you can provide a name of configuration set inconfiguration_set_nameproperty. Value must be a string. - When using AWS SES SMTP host, you may provide a name of configuration set in
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/auth0/emails/provider/client.rb', line 200 def update(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) request = Auth0::Internal::JSON::Request.new( base_url: [:base_url], method: "PATCH", path: "emails/provider", body: Auth0::Emails::Provider::Types::UpdateEmailProviderRequestContent.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Auth0::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) (response.body.to_s.empty? ? nil : Auth0::Types::UpdateEmailProviderResponseContent.load(response.body)) else error_class = Auth0::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |