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](auth0.com/docs/email/providers).
-
#delete(request_options: {}, **_params) ⇒ untyped
Delete the email provider.
-
#get(request_options: {}, **params) ⇒ Auth0::Types::GetEmailProviderResponseContent
Retrieve details of the [email provider configuration](auth0.com/docs/customize/email/smtp-email-providers) in your tenant.
- #initialize(client:) ⇒ void constructor
-
#update(request_options: {}, **params) ⇒ Auth0::Types::UpdateEmailProviderResponseContent
Update an [email provider](auth0.com/docs/email/providers).
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](auth0.com/docs/email/providers). The ‘credentials` object requires different properties depending on the email provider (which is specified using the `name` property):
-
‘mandrill` requires `api_key`
-
‘sendgrid` requires `api_key`
-
‘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. `eu` or `null` are the only valid values for `region`. -
‘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 `null` are the only valid values for `region`. -
‘ses` requires `accessKeyId`, `secretAccessKey`, and `region`
-
‘smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and
`smtp_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:
-
‘smtp` provider, `settings` may contain `headers` object.
- When using AWS SES SMTP host, you may provide a name of configuration set in `X-SES-Configuration-Set` header. Value must be a string. - When using Sparkpost host, you may provide value for `X-MSYS_API` header. Value must be an object. -
For ‘ses` provider, `settings` may contain `message` object, where you can provide a name of configuration set in `configuration_set_name` property. Value must be a string.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/auth0/emails/provider/client.rb', line 91 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.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/auth0/emails/provider/client.rb', line 125 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](auth0.com/docs/customize/email/smtp-email-providers) in your tenant. A list of fields to include or exclude may also be specified.
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 |
# File 'lib/auth0/emails/provider/client.rb', line 29 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) 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](auth0.com/docs/email/providers). The ‘credentials` object requires different properties depending on the email provider (which is specified using the `name` property):
-
‘mandrill` requires `api_key`
-
‘sendgrid` requires `api_key`
-
‘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. `eu` or `null` are the only valid values for `region`. -
‘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 `null` are the only valid values for `region`. -
‘ses` requires `accessKeyId`, `secretAccessKey`, and `region`
-
‘smtp` requires `smtp_host`, `smtp_port`, `smtp_user`, and
`smtp_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:
-
‘smtp` provider, `settings` may contain `headers` object.
- When using AWS SES SMTP host, you may provide a name of configuration set in `X-SES-Configuration-Set` header. Value must be a string. - When using Sparkpost host, you may provide value for `X-MSYS_API` header. Value must be an object.For ‘ses` provider, `settings` may contain `message` object, where you can provide a name of configuration set in `configuration_set_name` property. Value must be a string.
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/auth0/emails/provider/client.rb', line 180 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 |