-
Notifications
You must be signed in to change notification settings - Fork 20
/
emails.go
35 lines (29 loc) · 915 Bytes
/
emails.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
package clerk
import (
"encoding/json"
)
type EmailService service
type Email struct {
FromEmailName string `json:"from_email_name"`
Subject string `json:"subject"`
Body string `json:"body"`
EmailAddressID string `json:"email_address_id"`
}
type EmailResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Status string `json:"status,omitempty"`
ToEmailAddress *string `json:"to_email_address,omitempty"`
DeliveredByClerk bool `json:"delivered_by_clerk"`
Data json.RawMessage `json:"data"`
Email
}
func (s *EmailService) Create(email Email) (*EmailResponse, error) {
req, _ := s.client.NewRequest("POST", EmailsUrl, &email)
var emailResponse EmailResponse
_, err := s.client.Do(req, &emailResponse)
if err != nil {
return nil, err
}
return &emailResponse, nil
}