-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail_data.go
76 lines (65 loc) · 1.85 KB
/
mail_data.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 vcago
import (
"encoding/json"
"log"
"github.com/Viva-con-Agua/vcago/vmod"
)
type MailData struct {
TO string `json:"to" bson:"to"`
Service string `json:"service" bson:"service"`
Name string `json:"name" bson:"name"`
Scope string `json:"scope" bson:"scope"`
Lang string `json:"lang" bson:"lang"`
User vmod.User `json:"user" bson:"user"`
Content vmod.Content `json:"content" bson:"content"`
LinkToken LinkToken `json:"link_token" bson:"link_token"`
CurrentUser MailUser `json:"current_user" bson:"current_user"`
ContactUser MailUser `json:"contact_user" bson:"contact_user"`
}
type MailUser struct {
ID string `json:"id"`
Email string `json:"email"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
}
func NewMailData(to string, service string, name string, scope string, lang string) *MailData {
return &MailData{
TO: to,
Service: service,
Name: name,
Scope: scope,
}
}
func (i *MailData) Send() (err error) {
mode := Settings.String("MAIL_MODE", "w", "local")
if mode == "local" {
output, _ := json.MarshalIndent(i, "", "\t")
log.Print(string(output))
}
return
}
func (i *MailData) AddUser(user *vmod.User) {
i.User = *user
}
func (i *MailData) AddLinkToken(token *LinkToken) {
i.LinkToken = *token
}
func (i *MailData) AddContent(content *vmod.Content) {
i.Content = *content
}
func (i *MailData) AddCurrentUser(id string, email string, firstName string, lastName string) {
i.CurrentUser = MailUser{
ID: id,
Email: email,
FirstName: firstName,
LastName: lastName,
}
}
func (i *MailData) AddContactUser(id string, email string, firstName string, lastName string) {
i.ContactUser = MailUser{
ID: id,
Email: email,
FirstName: firstName,
LastName: lastName,
}
}