forked from belong-inc/go-hubspot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
marketing_transactional.go
49 lines (40 loc) · 1.67 KB
/
marketing_transactional.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
package hubspot
import "fmt"
const transactionalBasePath = "transactional"
// TransactionalService is an interface for the marketing/transactional service of the HubSpot API.
// Reference: https://developers.hubspot.com/docs/api/marketing/transactional-emails
type TransactionalService interface {
SendSingleEmail(props *SendSingleEmailProperties) (*SendSingleEmailResponse, error)
}
// TransactionalServiceOp provides the default implementation of TransactionService.
type TransactionalServiceOp struct {
transactionalPath string
client *Client
}
var _ TransactionalService = (*TransactionalServiceOp)(nil)
type SendSingleEmailMessage struct {
To string `json:"to"`
From string `json:"from,omitempty"`
SendId string `json:"sendId,omitempty"`
ReplyTo []string `json:"replyTo,omitempty"`
Cc []string `json:"cc,omitempty"`
Bcc []string `json:"bcc,omitempty"`
}
type SendSingleEmailProperties struct {
EmailId int64 `json:"emailId"`
Message *SendSingleEmailMessage `json:"message"`
ContactProperties *Contact `json:"contactProperties,omitempty"`
CustomProperties interface{} `json:"customProperties,omitempty"`
}
type SendSingleEmailResponse struct {
RequestedAt string `json:"requestedAt"`
StatusId string `json:"statusId"`
Status string `json:"status"`
}
func (s *TransactionalServiceOp) SendSingleEmail(props *SendSingleEmailProperties) (*SendSingleEmailResponse, error) {
resource := &SendSingleEmailResponse{}
if err := s.client.Post(fmt.Sprintf("%s/single-email/send", s.transactionalPath), props, resource); err != nil {
return nil, err
}
return resource, nil
}