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 <a href=“auth0.com/docs/email/providers”>email provider</a>.
-
#delete(request_options: {}, **params) ⇒ untyped
Delete the email provider.
-
#get(request_options: {}, **params) ⇒ Auth0::Types::GetEmailProviderResponseContent
Retrieve details of the <a href=“auth0.com/docs/customize/email/smtp-email-providers”>email provider configuration</a> in your tenant.
- #initialize(client:) ⇒ void constructor
-
#update(request_options: {}, **params) ⇒ Auth0::Types::UpdateEmailProviderResponseContent
Update an <a href=“auth0.com/docs/email/providers”>email provider</a>.
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 <a href=“auth0.com/docs/email/providers”>email provider</a>. The credentials object requires different properties depending on the email provider (which is specified using the name property): <ul>
<li><code>mandrill</code> requires <code>api_key</code></li>
<li><code>sendgrid</code> requires <code>api_key</code></li>
<li>
sparkpost requires api_key. Optionally, set region to eu to use the SparkPost service hosted in Western Europe; set to null to use the SparkPost service hosted in
North America. <code>eu</code> or <code>null</code> are the only valid values for <code>region</code>.
</li>
<li>
mailgun requires api_key and domain. Optionally, set region to eu to use the Mailgun service hosted in Europe; set to null otherwise. eu or
<code>null</code> are the only valid values for <code>region</code>.
</li>
<li>ses requires accessKeyId, secretAccessKey, and region</li>
<li>
<code>smtp</code> requires <code>smtp_host</code>, <code>smtp_port</code>, <code>smtp_user</code>, and
<code>smtp_pass</code>
</li>
</ul> 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: <ul>
<li>
<code>smtp</code> provider, <code>settings</code> may contain <code>headers</code> object.
<ul>
<li>
When using AWS SES SMTP host, you may provide a name of configuration set in
<code>X-SES-Configuration-Set</code> header. Value must be a string.
</li>
<li>
When using Sparkpost host, you may provide value for
<code>X-MSYS_API</code> header. Value must be an object.
</li>
</ul>
</li>
<li>
for ses provider, settings may contain message object, where you can provide
a name of configuration set in <code>configuration_set_name</code> property. Value must be a string.
</li>
</ul>
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/auth0/emails/provider/client.rb', line 118 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) 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.
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/auth0/emails/provider/client.rb', line 152 def delete(request_options: {}, **params) Auth0::Internal::Types::Utils.normalize_keys(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 <a href=“auth0.com/docs/customize/email/smtp-email-providers”>email provider configuration</a> in your tenant. A list of fields to include or exclude may also be specified.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/auth0/emails/provider/client.rb', line 28 def get(request_options: {}, **params) params = Auth0::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[fields include_fields] query_params = {} query_params["fields"] = params[:fields] if params.key?(:fields) query_params["include_fields"] = params[:include_fields] if params.key?(:include_fields) params.except(*query_param_names) 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) 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 <a href=“auth0.com/docs/email/providers”>email provider</a>. The credentials object requires different properties depending on the email provider (which is specified using the name property): <ul>
<li><code>mandrill</code> requires <code>api_key</code></li>
<li><code>sendgrid</code> requires <code>api_key</code></li>
<li>
sparkpost requires api_key. Optionally, set region to eu to use the SparkPost service hosted in Western Europe; set to null to use the SparkPost service hosted in
North America. <code>eu</code> or <code>null</code> are the only valid values for <code>region</code>.
</li>
<li>
mailgun requires api_key and domain. Optionally, set region to eu to use the Mailgun service hosted in Europe; set to null otherwise. eu or
<code>null</code> are the only valid values for <code>region</code>.
</li>
<li>ses requires accessKeyId, secretAccessKey, and region</li>
<li>
<code>smtp</code> requires <code>smtp_host</code>, <code>smtp_port</code>, <code>smtp_user</code>, and
<code>smtp_pass</code>
</li>
</ul> 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: <ul>
<li>
<code>smtp</code> provider, <code>settings</code> may contain <code>headers</code> object.
<ul>
<li>
When using AWS SES SMTP host, you may provide a name of configuration set in
<code>X-SES-Configuration-Set</code> header. Value must be a string.
</li>
<li>
When using Sparkpost host, you may provide value for
<code>X-MSYS_API</code> header. Value must be an object.
</li>
</ul>
for ses provider, settings may contain message object, where you can provide
a name of configuration set in <code>configuration_set_name</code> property. Value must be a string.
</li>
</ul>
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/auth0/emails/provider/client.rb', line 231 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) 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 |