forked from go-auth0/auth0
/
email_template.go
76 lines (61 loc) · 2.43 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
package management
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"`
}
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) error {
return m.post(m.uri("email-templates"), e)
}
// Retrieve 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) (*EmailTemplate, error) {
e := new(EmailTemplate)
err := m.get(m.uri("email-templates", template), e)
return e, err
}
// Modify 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) (err error) {
return m.patch(m.uri("email-templates", template), e)
}
// 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) (err error) {
return m.put(m.uri("email-templates", template), e)
}