forked from charlires/go-auth0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_template.go
83 lines (68 loc) · 3.04 KB
/
email_template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package management
// EmailTemplate is used to customize emails.
//
// See https://auth0.com/docs/customize/email/email-templates
type EmailTemplate struct {
// The template name. Can be one of "verify_email", "reset_email",
// "welcome_email", "blocked_account", "stolen_credentials",
// "enrollment_email", "change_password", "password_reset" or
// "mfa_oob_code".
Template *string `json:"template,omitempty"`
// The body of the template.
Body *string `json:"body,omitempty"`
// The sender of the email.
From *string `json:"from,omitempty"`
// The URL to redirect the user to after a successful action.
ResultURL *string `json:"resultUrl,omitempty"`
// The subject of the email.
Subject *string `json:"subject,omitempty"`
// The syntax of the template body.
Syntax *string `json:"syntax,omitempty"`
// The lifetime in seconds that the link within the email will be valid for.
URLLifetimeInSecoonds *int `json:"urlLifetimeInSeconds,omitempty"`
// Whether or not the template is enabled.
Enabled *bool `json:"enabled,omitempty"`
// Whether the `reset_email` and `verify_email` templates should include the user's
// email address as the email parameter in the returnUrl (true) or whether no email
// address should be included in the redirect (false). Defaults to true.
IncludeEmailInRedirect *bool `json:"includeEmailInRedirect,omitempty"`
}
// EmailTemplateManager manages Auth0 EmailTemplate resources.
type EmailTemplateManager struct {
*Management
}
func newEmailTemplateManager(m *Management) *EmailTemplateManager {
return &EmailTemplateManager{m}
}
// Create an email template.
//
// See: https://auth0.com/docs/api/management/v2#!/Email_Templates/post_email_templates
func (m *EmailTemplateManager) Create(e *EmailTemplate, opts ...RequestOption) error {
return m.Request("POST", m.URI("email-templates"), e, opts...)
}
// Read an email template by pre-defined name.
//
// These names are `verify_email`, `reset_email`, `welcome_email`,
// `blocked_account`, `stolen_credentials`, `enrollment_email`, and
// `mfa_oob_code`.
//
// The names `change_password`, and `password_reset` are also supported for
// legacy scenarios.
//
// See: https://auth0.com/docs/api/management/v2#!/Email_Templates/get_email_templates_by_templateName
func (m *EmailTemplateManager) Read(template string, opts ...RequestOption) (e *EmailTemplate, err error) {
err = m.Request("GET", m.URI("email-templates", template), &e, opts...)
return
}
// Update an email template.
//
// See: https://auth0.com/docs/api/management/v2#!/Email_Templates/patch_email_templates_by_templateName
func (m *EmailTemplateManager) Update(template string, e *EmailTemplate, opts ...RequestOption) (err error) {
return m.Request("PATCH", m.URI("email-templates", template), e, opts...)
}
// Replace an email template.
//
// See: https://auth0.com/docs/api/management/v2#!/Email_Templates/put_email_templates_by_templateName
func (m *EmailTemplateManager) Replace(template string, e *EmailTemplate, opts ...RequestOption) (err error) {
return m.Request("PUT", m.URI("email-templates", template), e, opts...)
}