@@ -10,93 +10,93 @@ import (
10
10
)
11
11
12
12
type (
13
- // Email defines the LabStack email service.
14
- Email struct {
13
+ // Jet defines the LabStack jet service.
14
+ Jet struct {
15
15
sling * sling.Sling
16
16
logger * log.Logger
17
17
}
18
18
19
- // EmailMessage defines the email message.
20
- EmailMessage struct {
19
+ // JetMessage defines the jet message.
20
+ JetMessage struct {
21
21
inlines []string
22
22
attachments []string
23
- Time string `json:"time,omitempty"`
24
- To string `json:"to,omitempty"`
25
- From string `json:"from,omitempty"`
26
- Subject string `json:"subject,omitempty"`
27
- Body string `json:"body,omitempty"`
28
- Inlines []* emailFile `json:"inlines,omitempty"`
29
- Attachments []* emailFile `json:"attachments,omitempty"`
30
- Status string `json:"status,omitempty"`
23
+ Time string `json:"time,omitempty"`
24
+ To string `json:"to,omitempty"`
25
+ From string `json:"from,omitempty"`
26
+ Subject string `json:"subject,omitempty"`
27
+ Body string `json:"body,omitempty"`
28
+ Inlines []* jetFile `json:"inlines,omitempty"`
29
+ Attachments []* jetFile `json:"attachments,omitempty"`
30
+ Status string `json:"status,omitempty"`
31
31
}
32
32
33
- emailFile struct {
33
+ jetFile struct {
34
34
Name string `json:"name"`
35
35
Type string `json:"type"`
36
36
Content string `json:"content"`
37
37
}
38
38
39
- // EmailError defines the email error.
40
- EmailError struct {
39
+ // JetError defines the jet error.
40
+ JetError struct {
41
41
Code int `json:"code"`
42
42
Message string `json:"message"`
43
43
}
44
44
)
45
45
46
- func NewEmailMessage (to , from , subject string ) * EmailMessage {
47
- return & EmailMessage {
46
+ func NewJetMessage (to , from , subject string ) * JetMessage {
47
+ return & JetMessage {
48
48
To : to ,
49
49
From : from ,
50
50
Subject : subject ,
51
51
}
52
52
}
53
53
54
- func (m * EmailMessage ) addInlines () error {
54
+ func (m * JetMessage ) addInlines () error {
55
55
for _ , inline := range m .inlines {
56
56
data , err := ioutil .ReadFile (inline )
57
57
if err != nil {
58
58
return err
59
59
}
60
- m .Inlines = append (m .Inlines , & emailFile {
60
+ m .Inlines = append (m .Inlines , & jetFile {
61
61
Name : filepath .Base (inline ),
62
62
Content : base64 .StdEncoding .EncodeToString (data ),
63
63
})
64
64
}
65
65
return nil
66
66
}
67
67
68
- func (m * EmailMessage ) addAttachments () error {
68
+ func (m * JetMessage ) addAttachments () error {
69
69
for _ , attachment := range m .attachments {
70
70
data , err := ioutil .ReadFile (attachment )
71
71
if err != nil {
72
72
return err
73
73
}
74
- m .Inlines = append (m .Attachments , & emailFile {
74
+ m .Inlines = append (m .Attachments , & jetFile {
75
75
Name : filepath .Base (attachment ),
76
76
Content : base64 .StdEncoding .EncodeToString (data ),
77
77
})
78
78
}
79
79
return nil
80
80
}
81
81
82
- func (m * EmailMessage ) AddInline (path string ) {
82
+ func (m * JetMessage ) AddInline (path string ) {
83
83
m .inlines = append (m .inlines , path )
84
84
}
85
85
86
- func (m * EmailMessage ) AddAttachment (path string ) {
86
+ func (m * JetMessage ) AddAttachment (path string ) {
87
87
m .attachments = append (m .attachments , path )
88
88
}
89
89
90
- // Send sends the email message.
91
- func (e * Email ) Send (m * EmailMessage ) (* EmailMessage , error ) {
90
+ // Send sends the jet message.
91
+ func (e * Jet ) Send (m * JetMessage ) (* JetMessage , error ) {
92
92
if err := m .addInlines (); err != nil {
93
93
return nil , err
94
94
}
95
95
if err := m .addAttachments (); err != nil {
96
96
return nil , err
97
97
}
98
- em := new (EmailMessage )
99
- ee := new (EmailError )
98
+ em := new (JetMessage )
99
+ ee := new (JetError )
100
100
_ , err := e .sling .Post ("" ).BodyJSON (m ).Receive (em , ee )
101
101
if err != nil {
102
102
return nil , err
@@ -107,6 +107,6 @@ func (e *Email) Send(m *EmailMessage) (*EmailMessage, error) {
107
107
return nil , ee
108
108
}
109
109
110
- func (e * EmailError ) Error () string {
110
+ func (e * JetError ) Error () string {
111
111
return e .Message
112
112
}
0 commit comments