-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontact_books.go
More file actions
85 lines (73 loc) · 3.34 KB
/
Copy pathcontact_books.go
File metadata and controls
85 lines (73 loc) · 3.34 KB
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
package bytesend
import "context"
type ContactBookCount struct {
Contacts int `json:"contacts"`
}
type ContactBook struct {
ID string `json:"id"`
Name string `json:"name"`
TeamID int `json:"teamId"`
Properties map[string]string `json:"properties"`
Variables []string `json:"variables"`
Emoji string `json:"emoji"`
DoubleOptInEnabled bool `json:"doubleOptInEnabled,omitempty"`
DoubleOptInFrom string `json:"doubleOptInFrom,omitempty"`
DoubleOptInSubject string `json:"doubleOptInSubject,omitempty"`
DoubleOptInContent string `json:"doubleOptInContent,omitempty"`
CreatedAt string `json:"createdAt"`
UpdatedAt string `json:"updatedAt"`
Count *ContactBookCount `json:"_count,omitempty"`
}
type CreateContactBookPayload struct {
Name string `json:"name"`
Emoji string `json:"emoji,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
Variables []string `json:"variables,omitempty"`
DoubleOptInEnabled *bool `json:"doubleOptInEnabled,omitempty"`
DoubleOptInFrom string `json:"doubleOptInFrom,omitempty"`
DoubleOptInSubject string `json:"doubleOptInSubject,omitempty"`
DoubleOptInContent string `json:"doubleOptInContent,omitempty"`
}
type UpdateContactBookPayload struct {
Name string `json:"name,omitempty"`
Emoji string `json:"emoji,omitempty"`
Properties map[string]string `json:"properties,omitempty"`
Variables []string `json:"variables,omitempty"`
DoubleOptInEnabled *bool `json:"doubleOptInEnabled,omitempty"`
DoubleOptInFrom string `json:"doubleOptInFrom,omitempty"`
DoubleOptInSubject string `json:"doubleOptInSubject,omitempty"`
DoubleOptInContent string `json:"doubleOptInContent,omitempty"`
}
type DeleteContactBookResponse struct {
ID string `json:"id"`
Success bool `json:"success"`
Message string `json:"message"`
}
type ContactBooksService struct {
client *Client
}
func (s *ContactBooksService) List(ctx context.Context) ([]ContactBook, error) {
var resp []ContactBook
err := s.client.get(ctx, "/contactBooks", &resp)
return resp, err
}
func (s *ContactBooksService) Create(ctx context.Context, payload CreateContactBookPayload) (ContactBook, error) {
var resp ContactBook
err := s.client.post(ctx, "/contactBooks", payload, &resp)
return resp, err
}
func (s *ContactBooksService) Get(ctx context.Context, contactBookID string) (ContactBook, error) {
var resp ContactBook
err := s.client.get(ctx, "/contactBooks/"+contactBookID, &resp)
return resp, err
}
func (s *ContactBooksService) Update(ctx context.Context, contactBookID string, payload UpdateContactBookPayload) (ContactBook, error) {
var resp ContactBook
err := s.client.patch(ctx, "/contactBooks/"+contactBookID, payload, &resp)
return resp, err
}
func (s *ContactBooksService) Delete(ctx context.Context, contactBookID string) (DeleteContactBookResponse, error) {
var resp DeleteContactBookResponse
err := s.client.delete(ctx, "/contactBooks/"+contactBookID, nil, &resp)
return resp, err
}