/
email_footers.go
89 lines (75 loc) · 3.04 KB
/
email_footers.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
77
78
79
80
81
82
83
84
85
86
87
88
89
package eloqua
import (
"fmt"
)
// EmailFooterService provides access to all the endpoints related
// to email footer data within eloqua
//
// The official Eloqua documentation did not seem to contain footers but everything
// appears to be the same as EmailHeaders references in the below link.
// Eloqua API docs: https://goo.gl/aCdAXT
type EmailFooterService struct {
client *Client
}
// EmailFooter represents an Eloqua email footer object.
type EmailFooter struct {
Type string `json:"type,omitempty"`
ID int `json:"id,omitempty,string"`
CreatedAt int `json:"createdAt,omitempty,string"`
CreatedBy int `json:"createdBy,omitempty,string"`
Depth string `json:"depth,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Permissions []string `json:"permissions,omitempty"`
FolderID int `json:"folderId,omitempty,string"`
UpdatedAt int `json:"updatedAt,omitempty,string"`
UpdatedBy int `json:"updatedBy,omitempty,string"`
Body string `json:"body,omitempty"`
PlainText string `json:"plainText,omitempty"`
IsPlainTextEditable bool `json:"isPlainTextEditable,omitempty,string"`
FieldMerges []FieldMerge `json:"fieldMerges,omitempty"`
Images []Image `json:"images,omitempty"`
Hyperlinks []Hyperlink `json:"hyperlinks,omitempty"`
}
// Create a new email footer in eloqua
func (e *EmailFooterService) Create(name string, emailFooter *EmailFooter) (*EmailFooter, *Response, error) {
if emailFooter == nil {
emailFooter = &EmailFooter{}
}
emailFooter.Name = name
endpoint := "/assets/email/footer"
resp, err := e.client.postRequestDecode(endpoint, emailFooter)
return emailFooter, resp, err
}
// Get an email footer object via its ID
func (e *EmailFooterService) Get(id int) (*EmailFooter, *Response, error) {
endpoint := fmt.Sprintf("/assets/email/footer/%d?depth=complete", id)
emailFooter := &EmailFooter{}
resp, err := e.client.getRequestDecode(endpoint, emailFooter)
return emailFooter, resp, err
}
// List many eloqua email footers
func (e *EmailFooterService) List(opts *ListOptions) ([]EmailFooter, *Response, error) {
endpoint := "/assets/email/footers"
emailFooters := new([]EmailFooter)
resp, err := e.client.getRequestListDecode(endpoint, emailFooters, opts)
return *emailFooters, resp, err
}
// Update an existing email footer in eloqua
func (e *EmailFooterService) Update(id int, name string, emailFooter *EmailFooter) (*EmailFooter, *Response, error) {
if emailFooter == nil {
emailFooter = &EmailFooter{}
}
emailFooter.ID = id
emailFooter.Name = name
endpoint := fmt.Sprintf("/assets/email/footer/%d", emailFooter.ID)
resp, err := e.client.putRequestDecode(endpoint, emailFooter)
return emailFooter, resp, err
}
// Delete an existing email footer from eloqua
func (e *EmailFooterService) Delete(id int) (*Response, error) {
emailFooter := &EmailFooter{ID: id}
endpoint := fmt.Sprintf("/assets/email/footer/%d", emailFooter.ID)
resp, err := e.client.deleteRequest(endpoint, emailFooter)
return resp, err
}