createsend 5.1.1 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +30 -0
- data/README.md +2 -2
- data/createsend.gemspec +1 -1
- data/lib/createsend/client.rb +19 -3
- data/lib/createsend/createsend.rb +1 -1
- data/lib/createsend/list.rb +13 -12
- data/lib/createsend/subscriber.rb +8 -4
- data/lib/createsend/version.rb +1 -1
- data/samples/authentication_sample.rb +64 -0
- data/samples/clients_sample.rb +79 -0
- data/samples/journey_sample.rb +3 -2
- data/samples/lists_sample.rb +51 -0
- data/samples/segments_sample.rb +21 -0
- data/samples/subscribers_sample.rb +51 -0
- data/test/administrator_test.rb +5 -5
- data/test/campaign_test.rb +114 -113
- data/test/client_test.rb +121 -98
- data/test/createsend_test.rb +47 -47
- data/test/fixtures/active_subscribers.json +5 -0
- data/test/fixtures/bounced_subscribers.json +1 -0
- data/test/fixtures/campaign_summary.json +2 -1
- data/test/fixtures/campaigns.json +37 -26
- data/test/fixtures/deleted_subscribers.json +5 -0
- data/test/fixtures/drafts.json +4 -2
- data/test/fixtures/scheduled_campaigns.json +4 -2
- data/test/fixtures/segment_subscribers.json +2 -0
- data/test/fixtures/subscriber_details.json +2 -0
- data/test/fixtures/{subscriber_details_with_track_pref.json → subscriber_details_with_track_and_sms_pref.json} +4 -1
- data/test/fixtures/tags.json +10 -0
- data/test/fixtures/unconfirmed_subscribers.json +6 -2
- data/test/fixtures/unsubscribed_subscribers.json +6 -1
- data/test/helper.rb +1 -1
- data/test/journey_test.rb +86 -86
- data/test/list_test.rb +130 -123
- data/test/person_test.rb +6 -6
- data/test/segment_test.rb +23 -22
- data/test/subscriber_test.rb +55 -51
- data/test/template_test.rb +5 -5
- data/test/transactional_classic_email_test.rb +6 -6
- data/test/transactional_smart_email_test.rb +19 -19
- data/test/transactional_timeline_test.rb +25 -25
- metadata +16 -113
data/test/list_test.rb
CHANGED
@@ -11,13 +11,13 @@ class ListTest < Test::Unit::TestCase
|
|
11
11
|
should "create a list without passing in unsubscribe setting" do
|
12
12
|
stub_post(@auth, "lists/#{@client_id}.json", "create_list.json")
|
13
13
|
list_id = CreateSend::List.create @auth, @client_id, "List One", "", false, ""
|
14
|
-
list_id.should == "e3c5f034d68744f7881fdccf13c2daee"
|
14
|
+
list_id.should be == "e3c5f034d68744f7881fdccf13c2daee"
|
15
15
|
end
|
16
16
|
|
17
17
|
should "create a list passing in unsubscribe setting" do
|
18
18
|
stub_post(@auth, "lists/#{@client_id}.json", "create_list.json")
|
19
19
|
list_id = CreateSend::List.create @auth, @client_id, "List One", "", false, "", "OnlyThisList"
|
20
|
-
list_id.should == "e3c5f034d68744f7881fdccf13c2daee"
|
20
|
+
list_id.should be == "e3c5f034d68744f7881fdccf13c2daee"
|
21
21
|
end
|
22
22
|
|
23
23
|
should "update a list without passing in unsubscribe setting" do
|
@@ -44,11 +44,11 @@ class ListTest < Test::Unit::TestCase
|
|
44
44
|
stub_post(@auth, "lists/#{@list.list_id}/customfields.json", "create_custom_field.json")
|
45
45
|
personalisation_tag = @list.create_custom_field "new date field", "Date"
|
46
46
|
request = FakeWeb.last_request.body
|
47
|
-
request.include?("\"FieldName\":\"new date field\"").should == true
|
48
|
-
request.include?("\"DataType\":\"Date\"").should == true
|
49
|
-
request.include?("\"Options\":[]").should == true
|
50
|
-
request.include?("\"VisibleInPreferenceCenter\":true").should == true
|
51
|
-
personalisation_tag.should == "[newdatefield]"
|
47
|
+
request.include?("\"FieldName\":\"new date field\"").should be == true
|
48
|
+
request.include?("\"DataType\":\"Date\"").should be == true
|
49
|
+
request.include?("\"Options\":[]").should be == true
|
50
|
+
request.include?("\"VisibleInPreferenceCenter\":true").should be == true
|
51
|
+
personalisation_tag.should be == "[newdatefield]"
|
52
52
|
end
|
53
53
|
|
54
54
|
should "create a custom field with options and visible_in_preference_center" do
|
@@ -57,11 +57,11 @@ class ListTest < Test::Unit::TestCase
|
|
57
57
|
personalisation_tag = @list.create_custom_field("newsletter format",
|
58
58
|
"MultiSelectOne", options, false)
|
59
59
|
request = FakeWeb.last_request.body
|
60
|
-
request.include?("\"FieldName\":\"newsletter format\"").should == true
|
61
|
-
request.include?("\"DataType\":\"MultiSelectOne\"").should == true
|
62
|
-
request.include?("\"Options\":[\"one\",\"two\"]").should == true
|
63
|
-
request.include?("\"VisibleInPreferenceCenter\":false").should == true
|
64
|
-
personalisation_tag.should == "[newdatefield]"
|
60
|
+
request.include?("\"FieldName\":\"newsletter format\"").should be == true
|
61
|
+
request.include?("\"DataType\":\"MultiSelectOne\"").should be == true
|
62
|
+
request.include?("\"Options\":[\"one\",\"two\"]").should be == true
|
63
|
+
request.include?("\"VisibleInPreferenceCenter\":false").should be == true
|
64
|
+
personalisation_tag.should be == "[newdatefield]"
|
65
65
|
end
|
66
66
|
|
67
67
|
should "update a custom field" do
|
@@ -69,9 +69,9 @@ class ListTest < Test::Unit::TestCase
|
|
69
69
|
stub_put(@auth, "lists/#{@list.list_id}/customfields/#{ERB::Util.url_encode(key)}.json", "update_custom_field.json")
|
70
70
|
personalisation_tag = @list.update_custom_field key, "my renamed custom field", true
|
71
71
|
request = FakeWeb.last_request.body
|
72
|
-
request.include?("\"FieldName\":\"my renamed custom field\"").should == true
|
73
|
-
request.include?("\"VisibleInPreferenceCenter\":true").should == true
|
74
|
-
personalisation_tag.should == "[myrenamedcustomfield]"
|
72
|
+
request.include?("\"FieldName\":\"my renamed custom field\"").should be == true
|
73
|
+
request.include?("\"VisibleInPreferenceCenter\":true").should be == true
|
74
|
+
personalisation_tag.should be == "[myrenamedcustomfield]"
|
75
75
|
end
|
76
76
|
|
77
77
|
should "delete a custom field" do
|
@@ -90,168 +90,175 @@ class ListTest < Test::Unit::TestCase
|
|
90
90
|
should "get the details of a list" do
|
91
91
|
stub_get(@auth, "lists/#{@list.list_id}.json", "list_details.json")
|
92
92
|
details = @list.details
|
93
|
-
details.ConfirmedOptIn.should == false
|
94
|
-
details.Title.should == "a non-basic list :)"
|
95
|
-
details.UnsubscribePage.should == ""
|
96
|
-
details.ListID.should == "2fe4c8f0373ce320e2200596d7ef168f"
|
97
|
-
details.ConfirmationSuccessPage.should == ""
|
98
|
-
details.UnsubscribeSetting.should == "AllClientLists"
|
93
|
+
details.ConfirmedOptIn.should be == false
|
94
|
+
details.Title.should be == "a non-basic list :)"
|
95
|
+
details.UnsubscribePage.should be == ""
|
96
|
+
details.ListID.should be == "2fe4c8f0373ce320e2200596d7ef168f"
|
97
|
+
details.ConfirmationSuccessPage.should be == ""
|
98
|
+
details.UnsubscribeSetting.should be == "AllClientLists"
|
99
99
|
end
|
100
100
|
|
101
101
|
should "get the custom fields for a list" do
|
102
102
|
stub_get(@auth, "lists/#{@list.list_id}/customfields.json", "custom_fields.json")
|
103
103
|
cfs = @list.custom_fields
|
104
|
-
cfs.size.should == 3
|
105
|
-
cfs.first.FieldName.should == "website"
|
106
|
-
cfs.first.Key.should == "[website]"
|
107
|
-
cfs.first.DataType.should == "Text"
|
108
|
-
cfs.first.FieldOptions.should == []
|
109
|
-
cfs.first.VisibleInPreferenceCenter.should == true
|
104
|
+
cfs.size.should be == 3
|
105
|
+
cfs.first.FieldName.should be == "website"
|
106
|
+
cfs.first.Key.should be == "[website]"
|
107
|
+
cfs.first.DataType.should be == "Text"
|
108
|
+
cfs.first.FieldOptions.should be == []
|
109
|
+
cfs.first.VisibleInPreferenceCenter.should be == true
|
110
110
|
end
|
111
111
|
|
112
112
|
should "get the segments for a list" do
|
113
113
|
stub_get(@auth, "lists/#{@list.list_id}/segments.json", "segments.json")
|
114
114
|
segments = @list.segments
|
115
|
-
segments.size.should == 2
|
116
|
-
segments.first.ListID.should == 'a58ee1d3039b8bec838e6d1482a8a965'
|
117
|
-
segments.first.SegmentID.should == '46aa5e01fd43381863d4e42cf277d3a9'
|
118
|
-
segments.first.Title.should == 'Segment One'
|
115
|
+
segments.size.should be == 2
|
116
|
+
segments.first.ListID.should be == 'a58ee1d3039b8bec838e6d1482a8a965'
|
117
|
+
segments.first.SegmentID.should be == '46aa5e01fd43381863d4e42cf277d3a9'
|
118
|
+
segments.first.Title.should be == 'Segment One'
|
119
119
|
end
|
120
120
|
|
121
121
|
should "get the stats for a list" do
|
122
122
|
stub_get(@auth, "lists/#{@list.list_id}/stats.json", "list_stats.json")
|
123
123
|
stats = @list.stats
|
124
|
-
stats.TotalActiveSubscribers.should == 6
|
125
|
-
stats.TotalUnsubscribes.should == 2
|
126
|
-
stats.TotalDeleted.should == 0
|
127
|
-
stats.TotalBounces.should == 0
|
124
|
+
stats.TotalActiveSubscribers.should be == 6
|
125
|
+
stats.TotalUnsubscribes.should be == 2
|
126
|
+
stats.TotalDeleted.should be == 0
|
127
|
+
stats.TotalBounces.should be == 0
|
128
128
|
end
|
129
129
|
|
130
130
|
should "get the active subscribers for a list" do
|
131
131
|
min_date = "2010-01-01"
|
132
|
-
stub_get(@auth, "lists/#{@list.list_id}/active.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false",
|
132
|
+
stub_get(@auth, "lists/#{@list.list_id}/active.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false&includesmspreference=false",
|
133
133
|
"active_subscribers.json")
|
134
134
|
res = @list.active min_date
|
135
|
-
res.ResultsOrderedBy.should == "email"
|
136
|
-
res.OrderDirection.should == "asc"
|
137
|
-
res.PageNumber.should == 1
|
138
|
-
res.PageSize.should == 1000
|
139
|
-
res.RecordsOnThisPage.should == 5
|
140
|
-
res.TotalNumberOfRecords.should == 5
|
141
|
-
res.NumberOfPages.should == 1
|
142
|
-
res.Results.size.should == 5
|
143
|
-
res.Results.first.EmailAddress.should == "subs+7t8787Y@example.com"
|
144
|
-
res.Results.first.Name.should =="Person One"
|
145
|
-
res.Results.first.Date.should == "2010-10-25 10:28:00"
|
146
|
-
res.Results.first.
|
147
|
-
res.Results.first.
|
148
|
-
res.Results.first.CustomFields
|
149
|
-
res.Results.first.CustomFields[0].
|
150
|
-
res.Results.first.CustomFields[
|
151
|
-
res.Results.first.CustomFields[1].
|
152
|
-
res.Results.first.CustomFields[
|
153
|
-
res.Results.first.CustomFields[2].
|
154
|
-
res.Results.first.
|
135
|
+
res.ResultsOrderedBy.should be == "email"
|
136
|
+
res.OrderDirection.should be == "asc"
|
137
|
+
res.PageNumber.should be == 1
|
138
|
+
res.PageSize.should be == 1000
|
139
|
+
res.RecordsOnThisPage.should be == 5
|
140
|
+
res.TotalNumberOfRecords.should be == 5
|
141
|
+
res.NumberOfPages.should be == 1
|
142
|
+
res.Results.size.should be == 5
|
143
|
+
res.Results.first.EmailAddress.should be == "subs+7t8787Y@example.com"
|
144
|
+
res.Results.first.Name.should be =="Person One"
|
145
|
+
res.Results.first.Date.should be == "2010-10-25 10:28:00"
|
146
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-25 10:28:00"
|
147
|
+
res.Results.first.State.should be == "Active"
|
148
|
+
res.Results.first.CustomFields.size.should be == 5
|
149
|
+
res.Results.first.CustomFields[0].Key.should be == "website"
|
150
|
+
res.Results.first.CustomFields[0].Value.should be == "http://example.com"
|
151
|
+
res.Results.first.CustomFields[1].Key.should be == "multi select field"
|
152
|
+
res.Results.first.CustomFields[1].Value.should be == "option one"
|
153
|
+
res.Results.first.CustomFields[2].Key.should be == "multi select field"
|
154
|
+
res.Results.first.CustomFields[2].Value.should be == "option two"
|
155
|
+
res.Results.first.ReadsEmailWith.should be == "Gmail"
|
155
156
|
end
|
156
157
|
|
157
158
|
should "get the unconfirmed subscribers for a list" do
|
158
159
|
min_date = "2010-01-01"
|
159
|
-
stub_get(@auth, "lists/#{@list.list_id}/unconfirmed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=true",
|
160
|
+
stub_get(@auth, "lists/#{@list.list_id}/unconfirmed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=true&includesmspreference=true",
|
160
161
|
"unconfirmed_subscribers.json")
|
161
|
-
res = @list.unconfirmed(min_date, 1, 1000, "email", "asc", true)
|
162
|
-
res.ResultsOrderedBy.should == "email"
|
163
|
-
res.OrderDirection.should == "asc"
|
164
|
-
res.PageNumber.should == 1
|
165
|
-
res.PageSize.should == 1000
|
166
|
-
res.RecordsOnThisPage.should == 2
|
167
|
-
res.TotalNumberOfRecords.should == 2
|
168
|
-
res.NumberOfPages.should == 1
|
169
|
-
res.Results.size.should == 2
|
170
|
-
res.Results.first.EmailAddress.should == "subs+7t8787Y@example.com"
|
171
|
-
res.Results.first.Name.should =="Unconfirmed One"
|
172
|
-
res.Results.first.
|
173
|
-
res.Results.first.
|
162
|
+
res = @list.unconfirmed(min_date, 1, 1000, "email", "asc", true, include_sms_preference:true)
|
163
|
+
res.ResultsOrderedBy.should be == "email"
|
164
|
+
res.OrderDirection.should be == "asc"
|
165
|
+
res.PageNumber.should be == 1
|
166
|
+
res.PageSize.should be == 1000
|
167
|
+
res.RecordsOnThisPage.should be == 2
|
168
|
+
res.TotalNumberOfRecords.should be == 2
|
169
|
+
res.NumberOfPages.should be == 1
|
170
|
+
res.Results.size.should be == 2
|
171
|
+
res.Results.first.EmailAddress.should be == "subs+7t8787Y@example.com"
|
172
|
+
res.Results.first.Name.should be =="Unconfirmed One"
|
173
|
+
res.Results.first.Date.should be =="2010-10-25 10:28:00"
|
174
|
+
res.Results.first.ListJoinedDate.should be =="2010-10-25 10:28:00"
|
175
|
+
res.Results.first.State.should be == "Unconfirmed"
|
176
|
+
res.Results.first.ConsentToTrack.should be == "Yes"
|
177
|
+
res.Results.first.ConsentToSendSms.should be == "No"
|
174
178
|
end
|
175
179
|
|
176
180
|
should "get the unsubscribed subscribers for a list" do
|
177
181
|
min_date = "2010-01-01"
|
178
|
-
stub_get(@auth, "lists/#{@list.list_id}/unsubscribed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false",
|
182
|
+
stub_get(@auth, "lists/#{@list.list_id}/unsubscribed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false&includesmspreference=false",
|
179
183
|
"unsubscribed_subscribers.json")
|
180
184
|
res = @list.unsubscribed min_date
|
181
|
-
res.ResultsOrderedBy.should == "email"
|
182
|
-
res.OrderDirection.should == "asc"
|
183
|
-
res.PageNumber.should == 1
|
184
|
-
res.PageSize.should == 1000
|
185
|
-
res.RecordsOnThisPage.should == 5
|
186
|
-
res.TotalNumberOfRecords.should == 5
|
187
|
-
res.NumberOfPages.should == 1
|
188
|
-
res.Results.size.should == 5
|
189
|
-
res.Results.first.EmailAddress.should == "subscriber@example.com"
|
190
|
-
res.Results.first.Name.should == "Unsub One"
|
191
|
-
res.Results.first.Date.should == "2010-10-25 13:11:00"
|
192
|
-
res.Results.first.
|
193
|
-
res.Results.first.
|
194
|
-
res.Results.first.
|
185
|
+
res.ResultsOrderedBy.should be == "email"
|
186
|
+
res.OrderDirection.should be == "asc"
|
187
|
+
res.PageNumber.should be == 1
|
188
|
+
res.PageSize.should be == 1000
|
189
|
+
res.RecordsOnThisPage.should be == 5
|
190
|
+
res.TotalNumberOfRecords.should be == 5
|
191
|
+
res.NumberOfPages.should be == 1
|
192
|
+
res.Results.size.should be == 5
|
193
|
+
res.Results.first.EmailAddress.should be == "subscriber@example.com"
|
194
|
+
res.Results.first.Name.should be == "Unsub One"
|
195
|
+
res.Results.first.Date.should be == "2010-10-25 13:11:00"
|
196
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-25 13:11:00"
|
197
|
+
res.Results.first.State.should be == "Unsubscribed"
|
198
|
+
res.Results.first.CustomFields.size.should be == 0
|
199
|
+
res.Results.first.ReadsEmailWith.should be == "Gmail"
|
195
200
|
end
|
196
201
|
|
197
202
|
should "get the deleted subscribers for a list" do
|
198
203
|
min_date = "2010-01-01"
|
199
|
-
stub_get(@auth, "lists/#{@list.list_id}/deleted.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false",
|
204
|
+
stub_get(@auth, "lists/#{@list.list_id}/deleted.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false&includesmspreference=false",
|
200
205
|
"deleted_subscribers.json")
|
201
206
|
res = @list.deleted min_date
|
202
|
-
res.ResultsOrderedBy.should == "email"
|
203
|
-
res.OrderDirection.should == "asc"
|
204
|
-
res.PageNumber.should == 1
|
205
|
-
res.PageSize.should == 1000
|
206
|
-
res.RecordsOnThisPage.should == 5
|
207
|
-
res.TotalNumberOfRecords.should == 5
|
208
|
-
res.NumberOfPages.should == 1
|
209
|
-
res.Results.size.should == 5
|
210
|
-
res.Results.first.EmailAddress.should == "subscriber@example.com"
|
211
|
-
res.Results.first.Name.should == "Deleted One"
|
212
|
-
res.Results.first.Date.should == "2010-10-25 13:11:00"
|
213
|
-
res.Results.first.
|
214
|
-
res.Results.first.
|
215
|
-
res.Results.first.
|
207
|
+
res.ResultsOrderedBy.should be == "email"
|
208
|
+
res.OrderDirection.should be == "asc"
|
209
|
+
res.PageNumber.should be == 1
|
210
|
+
res.PageSize.should be == 1000
|
211
|
+
res.RecordsOnThisPage.should be == 5
|
212
|
+
res.TotalNumberOfRecords.should be == 5
|
213
|
+
res.NumberOfPages.should be == 1
|
214
|
+
res.Results.size.should be == 5
|
215
|
+
res.Results.first.EmailAddress.should be == "subscriber@example.com"
|
216
|
+
res.Results.first.Name.should be == "Deleted One"
|
217
|
+
res.Results.first.Date.should be == "2010-10-25 13:11:00"
|
218
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-25 13:11:00"
|
219
|
+
res.Results.first.State.should be == "Deleted"
|
220
|
+
res.Results.first.CustomFields.size.should be == 0
|
221
|
+
res.Results.first.ReadsEmailWith.should be == "Gmail"
|
216
222
|
end
|
217
223
|
|
218
224
|
should "get the bounced subscribers for a list" do
|
219
225
|
min_date = "2010-01-01"
|
220
|
-
stub_get(@auth, "lists/#{@list.list_id}/bounced.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false",
|
226
|
+
stub_get(@auth, "lists/#{@list.list_id}/bounced.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false&includesmspreference=false",
|
221
227
|
"bounced_subscribers.json")
|
222
228
|
res = @list.bounced min_date
|
223
|
-
res.ResultsOrderedBy.should == "email"
|
224
|
-
res.OrderDirection.should == "asc"
|
225
|
-
res.PageNumber.should == 1
|
226
|
-
res.PageSize.should == 1000
|
227
|
-
res.RecordsOnThisPage.should == 1
|
228
|
-
res.TotalNumberOfRecords.should == 1
|
229
|
-
res.NumberOfPages.should == 1
|
230
|
-
res.Results.size.should == 1
|
231
|
-
res.Results.first.EmailAddress.should == "bouncedsubscriber@example.com"
|
232
|
-
res.Results.first.Name.should == "Bounced One"
|
233
|
-
res.Results.first.Date.should == "2010-10-25 13:11:00"
|
234
|
-
res.Results.first.
|
235
|
-
res.Results.first.
|
236
|
-
res.Results.first.
|
229
|
+
res.ResultsOrderedBy.should be == "email"
|
230
|
+
res.OrderDirection.should be == "asc"
|
231
|
+
res.PageNumber.should be == 1
|
232
|
+
res.PageSize.should be == 1000
|
233
|
+
res.RecordsOnThisPage.should be == 1
|
234
|
+
res.TotalNumberOfRecords.should be == 1
|
235
|
+
res.NumberOfPages.should be == 1
|
236
|
+
res.Results.size.should be == 1
|
237
|
+
res.Results.first.EmailAddress.should be == "bouncedsubscriber@example.com"
|
238
|
+
res.Results.first.Name.should be == "Bounced One"
|
239
|
+
res.Results.first.Date.should be == "2010-10-25 13:11:00"
|
240
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-25 13:11:00"
|
241
|
+
res.Results.first.State.should be == "Bounced"
|
242
|
+
res.Results.first.CustomFields.size.should be == 0
|
243
|
+
res.Results.first.ReadsEmailWith.should be == ""
|
237
244
|
end
|
238
245
|
|
239
246
|
should "get the webhooks for a list" do
|
240
247
|
stub_get(@auth, "lists/#{@list.list_id}/webhooks.json", "list_webhooks.json")
|
241
248
|
hooks = @list.webhooks
|
242
|
-
hooks.size.should == 2
|
243
|
-
hooks.first.WebhookID.should == "943678317049bc13"
|
244
|
-
hooks.first.Events.size.should == 1
|
245
|
-
hooks.first.Events.first.should == "Deactivate"
|
246
|
-
hooks.first.Url.should == "http://www.postbin.org/d9w8ud9wud9w"
|
247
|
-
hooks.first.Status.should == "Active"
|
248
|
-
hooks.first.PayloadFormat.should == "Json"
|
249
|
+
hooks.size.should be == 2
|
250
|
+
hooks.first.WebhookID.should be == "943678317049bc13"
|
251
|
+
hooks.first.Events.size.should be == 1
|
252
|
+
hooks.first.Events.first.should be == "Deactivate"
|
253
|
+
hooks.first.Url.should be == "http://www.postbin.org/d9w8ud9wud9w"
|
254
|
+
hooks.first.Status.should be == "Active"
|
255
|
+
hooks.first.PayloadFormat.should be == "Json"
|
249
256
|
end
|
250
257
|
|
251
258
|
should "create a webhook for a list" do
|
252
259
|
stub_post(@auth, "lists/#{@list.list_id}/webhooks.json", "create_list_webhook.json")
|
253
260
|
webhook_id = @list.create_webhook ["Unsubscribe", "Spam"], "http://example.com/unsub", "json"
|
254
|
-
webhook_id.should == "6a783d359bd44ef62c6ca0d3eda4412a"
|
261
|
+
webhook_id.should be == "6a783d359bd44ef62c6ca0d3eda4412a"
|
255
262
|
end
|
256
263
|
|
257
264
|
should "test a webhook for a list" do
|
data/test/person_test.rb
CHANGED
@@ -11,16 +11,16 @@ class PersonTest < Test::Unit::TestCase
|
|
11
11
|
email = "person@example.com"
|
12
12
|
stub_get(@auth, "clients/#{@client_id}/people.json?email=#{ERB::Util.url_encode(email)}", "person_details.json")
|
13
13
|
person = CreateSend::Person.get @auth, @client_id, email
|
14
|
-
person.EmailAddress.should == email
|
15
|
-
person.Name.should == "Person One"
|
16
|
-
person.AccessLevel.should == 1023
|
17
|
-
person.Status.should == "Active"
|
14
|
+
person.EmailAddress.should be == email
|
15
|
+
person.Name.should be == "Person One"
|
16
|
+
person.AccessLevel.should be == 1023
|
17
|
+
person.Status.should be == "Active"
|
18
18
|
end
|
19
19
|
|
20
20
|
should "add a person" do
|
21
21
|
stub_post(@auth, "clients/#{@client_id}/people.json", "add_person.json")
|
22
22
|
result = CreateSend::Person.add @auth, @client_id, "person@example.com", "Person", 0, "Password"
|
23
|
-
result.EmailAddress.should == "person@example.com"
|
23
|
+
result.EmailAddress.should be == "person@example.com"
|
24
24
|
end
|
25
25
|
|
26
26
|
should "update a person" do
|
@@ -28,7 +28,7 @@ class PersonTest < Test::Unit::TestCase
|
|
28
28
|
new_email = "new_email_address@example.com"
|
29
29
|
stub_put(@auth, "clients/#{@client_id}/people.json?email=#{ERB::Util.url_encode(email)}", nil)
|
30
30
|
@person.update new_email, "Person", 1023, "NewPassword"
|
31
|
-
@person.email_address.should == new_email
|
31
|
+
@person.email_address.should be == new_email
|
32
32
|
end
|
33
33
|
|
34
34
|
should "delete a person" do
|
data/test/segment_test.rb
CHANGED
@@ -11,7 +11,7 @@ class SegmentTest < Test::Unit::TestCase
|
|
11
11
|
rule_groups = [ { :Rules => [ { :RuleType => "EmailAddress", :Clause => "CONTAINS example.com" } ] } ]
|
12
12
|
stub_post(@auth, "segments/#{list_id}.json", "create_segment.json")
|
13
13
|
res = CreateSend::Segment.create @auth, list_id, "new segment title", rule_groups
|
14
|
-
res.should == "0246c2aea610a3545d9780bf6ab89006"
|
14
|
+
res.should be == "0246c2aea610a3545d9780bf6ab89006"
|
15
15
|
end
|
16
16
|
|
17
17
|
should "update a segment" do
|
@@ -31,19 +31,20 @@ class SegmentTest < Test::Unit::TestCase
|
|
31
31
|
stub_get(@auth, "segments/#{@segment.segment_id}/active.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false",
|
32
32
|
"segment_subscribers.json")
|
33
33
|
res = @segment.subscribers min_date
|
34
|
-
res.ResultsOrderedBy.should == "email"
|
35
|
-
res.OrderDirection.should == "asc"
|
36
|
-
res.PageNumber.should == 1
|
37
|
-
res.PageSize.should == 1000
|
38
|
-
res.RecordsOnThisPage.should == 2
|
39
|
-
res.TotalNumberOfRecords.should == 2
|
40
|
-
res.NumberOfPages.should == 1
|
41
|
-
res.Results.size.should == 2
|
42
|
-
res.Results.first.EmailAddress.should == "personone@example.com"
|
43
|
-
res.Results.first.Name.should == "Person One"
|
44
|
-
res.Results.first.Date.should == "2010-10-27 13:13:00"
|
45
|
-
res.Results.first.
|
46
|
-
res.Results.first.
|
34
|
+
res.ResultsOrderedBy.should be == "email"
|
35
|
+
res.OrderDirection.should be == "asc"
|
36
|
+
res.PageNumber.should be == 1
|
37
|
+
res.PageSize.should be == 1000
|
38
|
+
res.RecordsOnThisPage.should be == 2
|
39
|
+
res.TotalNumberOfRecords.should be == 2
|
40
|
+
res.NumberOfPages.should be == 1
|
41
|
+
res.Results.size.should be == 2
|
42
|
+
res.Results.first.EmailAddress.should be == "personone@example.com"
|
43
|
+
res.Results.first.Name.should be == "Person One"
|
44
|
+
res.Results.first.Date.should be == "2010-10-27 13:13:00"
|
45
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-27 13:13:00"
|
46
|
+
res.Results.first.State.should be == "Active"
|
47
|
+
res.Results.first.CustomFields.should be == []
|
47
48
|
end
|
48
49
|
|
49
50
|
should "delete a segment" do
|
@@ -54,14 +55,14 @@ class SegmentTest < Test::Unit::TestCase
|
|
54
55
|
should "get the details of a segment" do
|
55
56
|
stub_get(@auth, "segments/#{@segment.segment_id}.json", "segment_details.json")
|
56
57
|
res = @segment.details
|
57
|
-
res.ActiveSubscribers.should == 0
|
58
|
-
res.RuleGroups.size.should == 2
|
59
|
-
res.RuleGroups.first.Rules.size.should == 1
|
60
|
-
res.RuleGroups.first.Rules.first.RuleType.should == "EmailAddress"
|
61
|
-
res.RuleGroups.first.Rules.first.Clause.should == "CONTAINS @hello.com"
|
62
|
-
res.ListID.should == "2bea949d0bf96148c3e6a209d2e82060"
|
63
|
-
res.SegmentID.should == "dba84a225d5ce3d19105d7257baac46f"
|
64
|
-
res.Title.should == "My Segment"
|
58
|
+
res.ActiveSubscribers.should be == 0
|
59
|
+
res.RuleGroups.size.should be == 2
|
60
|
+
res.RuleGroups.first.Rules.size.should be == 1
|
61
|
+
res.RuleGroups.first.Rules.first.RuleType.should be == "EmailAddress"
|
62
|
+
res.RuleGroups.first.Rules.first.Clause.should be == "CONTAINS @hello.com"
|
63
|
+
res.ListID.should be == "2bea949d0bf96148c3e6a209d2e82060"
|
64
|
+
res.SegmentID.should be == "dba84a225d5ce3d19105d7257baac46f"
|
65
|
+
res.Title.should be == "My Segment"
|
65
66
|
end
|
66
67
|
|
67
68
|
should "clear a segment's rules" do
|
data/test/subscriber_test.rb
CHANGED
@@ -11,36 +11,40 @@ class SubscriberTest < Test::Unit::TestCase
|
|
11
11
|
email = "subscriber@example.com"
|
12
12
|
stub_get(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}&includetrackingpreference=false", "subscriber_details.json")
|
13
13
|
subscriber = CreateSend::Subscriber.get @auth, @list_id, email
|
14
|
-
subscriber.EmailAddress.should == email
|
15
|
-
subscriber.Name.should == "Subscriber One"
|
16
|
-
subscriber.Date.should == "2010-10-25 10:28:00"
|
17
|
-
subscriber.
|
18
|
-
subscriber.
|
19
|
-
subscriber.
|
20
|
-
subscriber.CustomFields.
|
21
|
-
subscriber.
|
14
|
+
subscriber.EmailAddress.should be == email
|
15
|
+
subscriber.Name.should be == "Subscriber One"
|
16
|
+
subscriber.Date.should be == "2010-10-25 10:28:00"
|
17
|
+
subscriber.MobileNumber.should be == "+61423153526"
|
18
|
+
subscriber.ListJoinedDate.should be == "2010-10-25 10:28:00"
|
19
|
+
subscriber.State.should be == "Active"
|
20
|
+
subscriber.CustomFields.size.should be == 3
|
21
|
+
subscriber.CustomFields.first.Key.should be == 'website'
|
22
|
+
subscriber.CustomFields.first.Value.should be == 'http://example.com'
|
23
|
+
subscriber.ReadsEmailWith.should be == "Gmail"
|
22
24
|
end
|
23
25
|
|
24
|
-
should "get a subscriber with track preference information" do
|
26
|
+
should "get a subscriber with track and sms preference information" do
|
25
27
|
email = "subscriber@example.com"
|
26
|
-
stub_get(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}&includetrackingpreference=true", "
|
28
|
+
stub_get(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}&includetrackingpreference=true", "subscriber_details_with_track_and_sms_pref.json")
|
27
29
|
subscriber = CreateSend::Subscriber.get @auth, @list_id, email, true
|
28
|
-
subscriber.EmailAddress.should == email
|
29
|
-
subscriber.Name.should == "Subscriber One"
|
30
|
-
subscriber.
|
30
|
+
subscriber.EmailAddress.should be == email
|
31
|
+
subscriber.Name.should be == "Subscriber One"
|
32
|
+
subscriber.MobileNumber.should be == "+61423153526"
|
33
|
+
subscriber.ConsentToTrack.should be == "Yes"
|
34
|
+
subscriber.ConsentToSendSms.should be == "No"
|
31
35
|
end
|
32
36
|
|
33
37
|
should "add a subscriber without custom fields" do
|
34
38
|
stub_post(@auth, "subscribers/#{@list_id}.json", "add_subscriber.json")
|
35
39
|
email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", [], true, "Yes"
|
36
|
-
email_address.should == "subscriber@example.com"
|
40
|
+
email_address.should be == "subscriber@example.com"
|
37
41
|
end
|
38
42
|
|
39
43
|
should "add a subscriber with custom fields" do
|
40
44
|
stub_post(@auth, "subscribers/#{@list_id}.json", "add_subscriber.json")
|
41
45
|
custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ]
|
42
46
|
email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true, "Yes"
|
43
|
-
email_address.should == "subscriber@example.com"
|
47
|
+
email_address.should be == "subscriber@example.com"
|
44
48
|
end
|
45
49
|
|
46
50
|
should "add a subscriber with custom fields including multi-option fields" do
|
@@ -49,7 +53,7 @@ class SubscriberTest < Test::Unit::TestCase
|
|
49
53
|
{ :Key => 'multioptionselectmany', :Value => 'firstoption' },
|
50
54
|
{ :Key => 'multioptionselectmany', :Value => 'secondoption' } ]
|
51
55
|
email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true, "Yes"
|
52
|
-
email_address.should == "subscriber@example.com"
|
56
|
+
email_address.should be == "subscriber@example.com"
|
53
57
|
end
|
54
58
|
|
55
59
|
should "update a subscriber with custom fields" do
|
@@ -58,7 +62,7 @@ class SubscriberTest < Test::Unit::TestCase
|
|
58
62
|
stub_put(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}", nil)
|
59
63
|
custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ]
|
60
64
|
@subscriber.update new_email, "Subscriber", custom_fields, true, "Yes"
|
61
|
-
@subscriber.email_address.should == new_email
|
65
|
+
@subscriber.email_address.should be == new_email
|
62
66
|
end
|
63
67
|
|
64
68
|
should "update a subscriber with custom fields including the clear option" do
|
@@ -67,7 +71,7 @@ class SubscriberTest < Test::Unit::TestCase
|
|
67
71
|
stub_put(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}", nil)
|
68
72
|
custom_fields = [ { :Key => 'website', :Value => '', :Clear => true } ]
|
69
73
|
@subscriber.update new_email, "Subscriber", custom_fields, true, "No"
|
70
|
-
@subscriber.email_address.should == new_email
|
74
|
+
@subscriber.email_address.should be == new_email
|
71
75
|
end
|
72
76
|
|
73
77
|
should "import many subscribers at once" do
|
@@ -78,11 +82,11 @@ class SubscriberTest < Test::Unit::TestCase
|
|
78
82
|
{ :EmailAddress => "example+3@example.com", :Name => "Example Three" },
|
79
83
|
]
|
80
84
|
import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers, true
|
81
|
-
import_result.FailureDetails.size.should == 0
|
82
|
-
import_result.TotalUniqueEmailsSubmitted.should == 3
|
83
|
-
import_result.TotalExistingSubscribers.should == 0
|
84
|
-
import_result.TotalNewSubscribers.should == 3
|
85
|
-
import_result.DuplicateEmailsInSubmission.size.should == 0
|
85
|
+
import_result.FailureDetails.size.should be == 0
|
86
|
+
import_result.TotalUniqueEmailsSubmitted.should be == 3
|
87
|
+
import_result.TotalExistingSubscribers.should be == 0
|
88
|
+
import_result.TotalNewSubscribers.should be == 3
|
89
|
+
import_result.DuplicateEmailsInSubmission.size.should be == 0
|
86
90
|
end
|
87
91
|
|
88
92
|
should "import many subscribers at once, and start subscription-based autoresponders" do
|
@@ -93,11 +97,11 @@ class SubscriberTest < Test::Unit::TestCase
|
|
93
97
|
{ :EmailAddress => "example+3@example.com", :Name => "Example Three" },
|
94
98
|
]
|
95
99
|
import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers, true, true
|
96
|
-
import_result.FailureDetails.size.should == 0
|
97
|
-
import_result.TotalUniqueEmailsSubmitted.should == 3
|
98
|
-
import_result.TotalExistingSubscribers.should == 0
|
99
|
-
import_result.TotalNewSubscribers.should == 3
|
100
|
-
import_result.DuplicateEmailsInSubmission.size.should == 0
|
100
|
+
import_result.FailureDetails.size.should be == 0
|
101
|
+
import_result.TotalUniqueEmailsSubmitted.should be == 3
|
102
|
+
import_result.TotalExistingSubscribers.should be == 0
|
103
|
+
import_result.TotalNewSubscribers.should be == 3
|
104
|
+
import_result.DuplicateEmailsInSubmission.size.should be == 0
|
101
105
|
end
|
102
106
|
|
103
107
|
should "import many subscribers at once with custom fields, including the clear option" do
|
@@ -108,11 +112,11 @@ class SubscriberTest < Test::Unit::TestCase
|
|
108
112
|
{ :EmailAddress => "example+3@example.com", :Name => "Example Three", :CustomFields => [ { :Key => 'website', :Value => '', :Clear => false } ] },
|
109
113
|
]
|
110
114
|
import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers, true
|
111
|
-
import_result.FailureDetails.size.should == 0
|
112
|
-
import_result.TotalUniqueEmailsSubmitted.should == 3
|
113
|
-
import_result.TotalExistingSubscribers.should == 0
|
114
|
-
import_result.TotalNewSubscribers.should == 3
|
115
|
-
import_result.DuplicateEmailsInSubmission.size.should == 0
|
115
|
+
import_result.FailureDetails.size.should be == 0
|
116
|
+
import_result.TotalUniqueEmailsSubmitted.should be == 3
|
117
|
+
import_result.TotalExistingSubscribers.should be == 0
|
118
|
+
import_result.TotalNewSubscribers.should be == 3
|
119
|
+
import_result.DuplicateEmailsInSubmission.size.should be == 0
|
116
120
|
end
|
117
121
|
|
118
122
|
should "import many subscribers at once with partial success" do
|
@@ -124,14 +128,14 @@ class SubscriberTest < Test::Unit::TestCase
|
|
124
128
|
{ :EmailAddress => "example+3@example.com", :Name => "Example Three" },
|
125
129
|
]
|
126
130
|
import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers, true
|
127
|
-
import_result.FailureDetails.size.should == 1
|
128
|
-
import_result.FailureDetails.first.EmailAddress.should == "example+1@example"
|
129
|
-
import_result.FailureDetails.first.Code.should == 1
|
130
|
-
import_result.FailureDetails.first.Message.should == "Invalid Email Address"
|
131
|
-
import_result.TotalUniqueEmailsSubmitted.should == 3
|
132
|
-
import_result.TotalExistingSubscribers.should == 2
|
133
|
-
import_result.TotalNewSubscribers.should == 0
|
134
|
-
import_result.DuplicateEmailsInSubmission.size.should == 0
|
131
|
+
import_result.FailureDetails.size.should be == 1
|
132
|
+
import_result.FailureDetails.first.EmailAddress.should be == "example+1@example"
|
133
|
+
import_result.FailureDetails.first.Code.should be == 1
|
134
|
+
import_result.FailureDetails.first.Message.should be == "Invalid Email Address"
|
135
|
+
import_result.TotalUniqueEmailsSubmitted.should be == 3
|
136
|
+
import_result.TotalExistingSubscribers.should be == 2
|
137
|
+
import_result.TotalNewSubscribers.should be == 0
|
138
|
+
import_result.DuplicateEmailsInSubmission.size.should be == 0
|
135
139
|
end
|
136
140
|
|
137
141
|
should "raise a BadRequest error if the import _completely_ fails because of a bad request" do
|
@@ -142,7 +146,7 @@ class SubscriberTest < Test::Unit::TestCase
|
|
142
146
|
{ :EmailAddress => "example+2@example.com", :Name => "Example Two" },
|
143
147
|
{ :EmailAddress => "example+3@example.com", :Name => "Example Three" },
|
144
148
|
]
|
145
|
-
lambda {
|
149
|
+
lambda { CreateSend::Subscriber.import @auth, @list_id, subscribers,
|
146
150
|
true }.should raise_error(CreateSend::BadRequest)
|
147
151
|
end
|
148
152
|
|
@@ -154,15 +158,15 @@ class SubscriberTest < Test::Unit::TestCase
|
|
154
158
|
should "get a subscriber's history" do
|
155
159
|
stub_get(@auth, "subscribers/#{@subscriber.list_id}/history.json?email=#{ERB::Util.url_encode(@subscriber.email_address)}", "subscriber_history.json")
|
156
160
|
history = @subscriber.history
|
157
|
-
history.size.should == 1
|
158
|
-
history.first.Name.should == "Campaign One"
|
159
|
-
history.first.Type.should == "Campaign"
|
160
|
-
history.first.ID.should == "fc0ce7105baeaf97f47c99be31d02a91"
|
161
|
-
history.first.Actions.size.should == 6
|
162
|
-
history.first.Actions.first.Event.should == "Open"
|
163
|
-
history.first.Actions.first.Date.should == "2010-10-12 13:18:00"
|
164
|
-
history.first.Actions.first.IPAddress.should == "192.168.126.87"
|
165
|
-
history.first.Actions.first.Detail.should == ""
|
161
|
+
history.size.should be == 1
|
162
|
+
history.first.Name.should be == "Campaign One"
|
163
|
+
history.first.Type.should be == "Campaign"
|
164
|
+
history.first.ID.should be == "fc0ce7105baeaf97f47c99be31d02a91"
|
165
|
+
history.first.Actions.size.should be == 6
|
166
|
+
history.first.Actions.first.Event.should be == "Open"
|
167
|
+
history.first.Actions.first.Date.should be == "2010-10-12 13:18:00"
|
168
|
+
history.first.Actions.first.IPAddress.should be == "192.168.126.87"
|
169
|
+
history.first.Actions.first.Detail.should be == ""
|
166
170
|
end
|
167
171
|
|
168
172
|
should "delete a subscriber" do
|