forked from SparkPost/gosparkpost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vars_test.go
104 lines (92 loc) · 4.11 KB
/
vars_test.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
package gosparkpost_test
import (
"encoding/json"
sp "github.com/SparkPost/gosparkpost"
"github.com/SparkPost/gosparkpost/events"
"github.com/pkg/errors"
)
func init() {
json.Unmarshal([]byte(`"2017-04-26T21:37:32.000+00:00"`), &msgEventsPage1.out.Events[0].(*events.Click).Timestamp)
json.Unmarshal([]byte(`"2017-04-26T21:37:17.000+00:00"`), &msgEventsPage2.out.Events[0].(*events.Open).Timestamp)
json.Unmarshal([]byte(`"2017-04-26T21:37:17.000+00:00"`), &msgEventsPage3.out.Events[0].(*events.Open).Timestamp)
}
var click1 = &events.Click{
EventCommon: events.EventCommon{Type: "click"},
CampaignID: "",
CustomerID: "42",
DeliveryMethod: "esmtp",
GeoIP: &events.GeoIP{Country: "US", Region: "NY", City: "Bronx", Latitude: 40.8499, Longitude: -73.8769},
IPAddress: "66.102.8.2",
MessageID: "0001441ead58afdeb21d",
Metadata: map[string]interface{}{},
Tags: []string{},
Recipient: "[email protected]",
RecipientType: "",
TargetLinkName: "",
TargetLinkURL: "https://sparkpost.com",
TemplateID: "best-template-ever",
TemplateVersion: "10",
TransmissionID: "30494147183576458",
UserAgent: "lynx",
}
var open1 = &events.Open{
EventCommon: events.EventCommon{Type: "open"},
CampaignID: "",
CustomerID: "42",
DeliveryMethod: "esmtp",
GeoIP: &events.GeoIP{Country: "US", Region: "NY", City: "Bronx", Latitude: 40.8499, Longitude: -73.8769},
IPAddress: "66.102.8.28",
MessageID: "0001441ead58afdeb21d",
Metadata: map[string]interface{}{},
Tags: []string{},
Recipient: "[email protected]",
RecipientType: "",
TemplateID: "best-template-ever",
TemplateVersion: "10",
TransmissionID: "30494147183576458",
UserAgent: "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)",
}
var open2 = &events.Open{
EventCommon: events.EventCommon{Type: "open"},
CampaignID: "",
CustomerID: "42",
DeliveryMethod: "esmtp",
GeoIP: &events.GeoIP{Country: "US", Region: "NY", City: "Bronx", Latitude: 40.8499, Longitude: -73.8769},
IPAddress: "66.102.8.2",
MessageID: "00042a25ad58fc0145e1",
Metadata: map[string]interface{}{},
Tags: []string{},
Recipient: "[email protected]",
RecipientType: "",
TemplateID: "best-template-ever",
TemplateVersion: "10",
TransmissionID: "84537445295705713",
UserAgent: "Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko Firefox/11.0 (via ggpht.com GoogleImageProxy)",
}
var msgEventsPageAll = EventsPageResult{nil, 200, ``, &sp.EventsPage{
TotalCount: 3,
Events: events.Events{click1, open1, open2},
}}
var msgEventsPage1 = EventsPageResult{nil, 200, ``, &sp.EventsPage{
TotalCount: 3,
Events: events.Events{click1},
NextPage: "/api/v1/message-events?page=2&per_page=1&from=2017-04-26T00:00&to=2017-04-27T01:09&timezone=UTC",
LastPage: "/api/v1/message-events?page=3&per_page=1&from=2017-04-26T00:00&to=2017-04-27T01:09&timezone=UTC",
}}
var msgEventsPage2 = EventsPageResult{nil, 200, ``, &sp.EventsPage{
TotalCount: 3,
Events: events.Events{open1},
NextPage: "/api/v1/message-events?page=3&per_page=1&from=2017-04-26T00:00&to=2017-04-27T01:12&timezone=UTC",
PrevPage: "/api/v1/message-events?page=1&per_page=1&from=2017-04-26T00:00&to=2017-04-27T01:12&timezone=UTC",
FirstPage: "/api/v1/message-events?page=1&per_page=1&from=2017-04-26T00:00&to=2017-04-27T01:12&timezone=UTC",
LastPage: "/api/v1/message-events?page=3&per_page=1&from=2017-04-26T00:00&to=2017-04-27T01:12&timezone=UTC",
}}
var msgEventsPage2Syntax = EventsPageResult{
errors.New("parsing api response: unexpected end of JSON input"), 200, `{`, nil}
var msgEventsPage3 = EventsPageResult{nil, 200, ``, &sp.EventsPage{
TotalCount: 3,
Events: events.Events{open2},
PrevPage: "/api/v1/message-events?page=2&per_page=1&from=2017-04-26T00:00&to=2017-04-27T01:13&timezone=UTC",
FirstPage: "/api/v1/message-events?page=1&per_page=1&from=2017-04-26T00:00&to=2017-04-27T01:13&timezone=UTC",
}}
var msgEventsPage4 = EventsPageResult{nil, 200, ``, &sp.EventsPage{}}