-
Notifications
You must be signed in to change notification settings - Fork 0
/
campaign.go
128 lines (111 loc) · 5.5 KB
/
campaign.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package textgrid
type CreateCampaignPayload struct {
BrandID string `json:"brandId"`
Usecase UseCase `json:"usecase"`
SubUsecases []UseCase `json:"subUsecases"`
Description string `json:"description"`
EmbeddedLink bool `json:"embeddedLink"`
EmbeddedPhone bool `json:"embeddedPhone"`
NumberPool bool `json:"numberPool"`
AgeGated bool `json:"ageGated"`
DirectLending bool `json:"directLending"`
SubscriberOptin bool `json:"subscriberOptin"`
SubscriberOptout bool `json:"subscriberOptout"`
SubscriberHelp bool `json:"subscriberHelp"`
Sample1 string `json:"sample1,omitempty"`
Sample2 string `json:"sample2,omitempty"`
Sample3 string `json:"sample3,omitempty"`
Sample4 string `json:"sample4,omitempty"`
Sample5 string `json:"sample5,omitempty"`
MessageFlow string `json:"messageFlow,omitempty"`
HelpKeywords string `json:"helpKeywords,omitempty"`
HelpMessage string `json:"helpMessage,omitempty"`
OptinKeywords string `json:"optinKeywords,omitempty"`
OptinMessage string `json:"optinMessage,omitempty"`
OptoutKeywords string `json:"optoutKeywords,omitempty"`
OptoutMessage string `json:"optoutMessage,omitempty"`
ReferenceID string `json:"referenceId,omitempty"`
AutoRenewal bool `json:"autoRenewal"`
AffiliateMarketing bool `json:"affiliateMarketing"`
}
type Campaign struct {
ID string `json:"campaignId"`
AccountSid string `json:"accountSid"`
BrandID string `json:"brandId"`
CspID string `json:"cspId"`
ResellerID string `json:"resellerId"`
ReferenceID string `json:"referenceId"`
Status string `json:"status"`
DateCreated TextGridTime `json:"dateCreated"`
BilledDate TextGridTime `json:"billedDate"`
AutoRenewal bool `json:"autoRenewal"`
Usecase UseCase `json:"usecase"`
SubUsecases []UseCase `json:"subUsecases"`
Description string `json:"description"`
EmbeddedLink bool `json:"embeddedLink"`
EmbeddedPhone bool `json:"embeddedPhone"`
AffiliateMarketing bool `json:"affiliateMarketing"`
NumberPool bool `json:"numberPool"`
AgeGated bool `json:"ageGated"`
DirectLending bool `json:"directLending"`
SubscriberOptin bool `json:"subscriberOptin"`
SubscriberOptout bool `json:"subscriberOptout"`
SubscriberHelp bool `json:"subscriberHelp"`
Sample1 string `json:"sample1,omitempty"`
Sample2 string `json:"sample2,omitempty"`
Sample3 string `json:"sample3,omitempty"`
Sample4 string `json:"sample4,omitempty"`
Sample5 string `json:"sample5,omitempty"`
MessageFlow string `json:"messageFlow"`
HelpKeywords string `json:"helpKeywords"`
HelpMessage string `json:"helpMessage"`
OptinKeywords string `json:"optinKeywords"`
OptinMessage string `json:"optinMessage"`
OptoutKeywords string `json:"optoutKeywords"`
OptoutMessage string `json:"optoutMessage"`
DcaSharingStatus SecondaryDcaSharingStatus `json:"SecondaryDcaSharingStatus"`
DcaDeclineReason string `json:"SecondaryDcaDeclineReason"`
}
type SecondaryDcaSharingStatus string
var (
SecondaryDcaSharingStatusBlank SecondaryDcaSharingStatus = ""
SecondaryDcaSharingStatusPending SecondaryDcaSharingStatus = "PENDING"
SecondaryDcaSharingStatusAccepted SecondaryDcaSharingStatus = "ACCEPTED"
SecondaryDcaSharingStatusDeclined SecondaryDcaSharingStatus = "DECLINED"
)
// CreateCampaign submits a campaign for registration and review
func (t *textGrid) CreateCampaign(payload CreateCampaignPayload) (*Campaign, error) {
result := new(Campaign)
if err := t.post("campaigns/campaign", payload, result); err != nil {
return nil, err
}
return result, nil
}
// GetCampaigns returns all of the campaigns associated with the account
func (t *textGrid) GetCampaigns() ([]Campaign, error) {
result := make([]Campaign, 0)
if err := t.get("campaigns/campaign", nil, &result); err != nil {
return nil, err
}
return result, nil
}
// GetCampaign gets the campaign details by the provided id
func (t *textGrid) GetCampaign(id string) (*Campaign, error) {
result := new(Campaign)
if err := t.get("campaigns/campaign/"+id, nil, result); err != nil {
return nil, err
}
return result, nil
}
func (t *textGrid) DeactivateCampaign(id string) error {
return t.delete("campaigns/campaign/"+id, nil)
}
type attachNumberToCampaign struct {
PhoneNumberSids []string `json:"phoneNumberSids"`
}
func (t *textGrid) AttachNumberToCampaign(id, numberID string) error {
payload := attachNumberToCampaign{
PhoneNumberSids: []string{numberID},
}
return t.post("campaigns/number/"+id, payload, nil)
}