createsend 5.1.1 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +30 -0
  3. data/README.md +2 -2
  4. data/createsend.gemspec +1 -1
  5. data/lib/createsend/client.rb +19 -3
  6. data/lib/createsend/createsend.rb +1 -1
  7. data/lib/createsend/list.rb +13 -12
  8. data/lib/createsend/subscriber.rb +8 -4
  9. data/lib/createsend/version.rb +1 -1
  10. data/samples/authentication_sample.rb +64 -0
  11. data/samples/clients_sample.rb +79 -0
  12. data/samples/journey_sample.rb +3 -2
  13. data/samples/lists_sample.rb +51 -0
  14. data/samples/segments_sample.rb +21 -0
  15. data/samples/subscribers_sample.rb +51 -0
  16. data/test/administrator_test.rb +5 -5
  17. data/test/campaign_test.rb +114 -113
  18. data/test/client_test.rb +121 -98
  19. data/test/createsend_test.rb +47 -47
  20. data/test/fixtures/active_subscribers.json +5 -0
  21. data/test/fixtures/bounced_subscribers.json +1 -0
  22. data/test/fixtures/campaign_summary.json +2 -1
  23. data/test/fixtures/campaigns.json +37 -26
  24. data/test/fixtures/deleted_subscribers.json +5 -0
  25. data/test/fixtures/drafts.json +4 -2
  26. data/test/fixtures/scheduled_campaigns.json +4 -2
  27. data/test/fixtures/segment_subscribers.json +2 -0
  28. data/test/fixtures/subscriber_details.json +2 -0
  29. data/test/fixtures/{subscriber_details_with_track_pref.json → subscriber_details_with_track_and_sms_pref.json} +4 -1
  30. data/test/fixtures/tags.json +10 -0
  31. data/test/fixtures/unconfirmed_subscribers.json +6 -2
  32. data/test/fixtures/unsubscribed_subscribers.json +6 -1
  33. data/test/helper.rb +1 -1
  34. data/test/journey_test.rb +86 -86
  35. data/test/list_test.rb +130 -123
  36. data/test/person_test.rb +6 -6
  37. data/test/segment_test.rb +23 -22
  38. data/test/subscriber_test.rb +55 -51
  39. data/test/template_test.rb +5 -5
  40. data/test/transactional_classic_email_test.rb +6 -6
  41. data/test/transactional_smart_email_test.rb +19 -19
  42. data/test/transactional_timeline_test.rb +25 -25
  43. metadata +16 -113
@@ -13,8 +13,8 @@ class CampaignTest < Test::Unit::TestCase
13
13
  "http://example.com/campaign.html", "http://example.com/campaign.txt", [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ],
14
14
  [ 'y78q9w8d9w8ud9q8uw', 'djw98quw9duqw98uwd98' ]
15
15
  request = FakeWeb.last_request.body
16
- request.include?("\"TextUrl\":\"http://example.com/campaign.txt\"").should == true
17
- campaign_id.should == "787y87y87y87y87y87y87"
16
+ request.include?("\"TextUrl\":\"http://example.com/campaign.txt\"").should be == true
17
+ campaign_id.should be == "787y87y87y87y87y87y87"
18
18
  end
19
19
 
20
20
  should "create a campaign with a nil text_url param" do
@@ -24,8 +24,8 @@ class CampaignTest < Test::Unit::TestCase
24
24
  "http://example.com/campaign.html", nil, [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ],
25
25
  [ 'y78q9w8d9w8ud9q8uw', 'djw98quw9duqw98uwd98' ]
26
26
  request = FakeWeb.last_request.body
27
- request.include?("\"TextUrl\":null").should == true
28
- campaign_id.should == "787y87y87y87y87y87y87"
27
+ request.include?("\"TextUrl\":null").should be == true
28
+ campaign_id.should be == "787y87y87y87y87y87y87"
29
29
  end
30
30
 
31
31
  should "create a campaign from a template" do
@@ -106,7 +106,7 @@ class CampaignTest < Test::Unit::TestCase
106
106
  campaign_id = CreateSend::Campaign.create_from_template @auth, client_id, "subject", "name", "g'day", "good.day@example.com", "good.day@example.com",
107
107
  [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ], [ 'y78q9w8d9w8ud9q8uw', 'djw98quw9duqw98uwd98' ],
108
108
  "7j8uw98udowy12989e8298u2e", template_content
109
- campaign_id.should == "787y87y87y87y87y87y87"
109
+ campaign_id.should be == "787y87y87y87y87y87y87"
110
110
  end
111
111
 
112
112
  should "send a preview of a draft campaign to a single recipient" do
@@ -137,159 +137,160 @@ class CampaignTest < Test::Unit::TestCase
137
137
  should "get the summary for a campaign" do
138
138
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/summary.json", "campaign_summary.json")
139
139
  summary = @campaign.summary
140
- summary.Recipients.should == 5
141
- summary.TotalOpened.should == 10
142
- summary.Clicks.should == 0
143
- summary.Unsubscribed.should == 0
144
- summary.Bounced.should == 0
145
- summary.UniqueOpened.should == 5
146
- summary.Mentions.should == 23
147
- summary.Forwards.should == 11
148
- summary.Likes.should == 32
149
- summary.WebVersionURL.should == "http://createsend.com/t/r-3A433FC72FFE3B8B"
150
- summary.WebVersionTextURL.should == "http://createsend.com/t/r-3A433FC72FFE3B8B/t"
151
- summary.WorldviewURL.should == "http://client.createsend.com/reports/wv/r/3A433FC72FFE3B8B"
152
- summary.SpamComplaints.should == 23
140
+ summary.Name.should be == "Campaign Name"
141
+ summary.Recipients.should be == 5
142
+ summary.TotalOpened.should be == 10
143
+ summary.Clicks.should be == 0
144
+ summary.Unsubscribed.should be == 0
145
+ summary.Bounced.should be == 0
146
+ summary.UniqueOpened.should be == 5
147
+ summary.Mentions.should be == 23
148
+ summary.Forwards.should be == 11
149
+ summary.Likes.should be == 32
150
+ summary.WebVersionURL.should be == "http://createsend.com/t/r-3A433FC72FFE3B8B"
151
+ summary.WebVersionTextURL.should be == "http://createsend.com/t/r-3A433FC72FFE3B8B/t"
152
+ summary.WorldviewURL.should be == "http://client.createsend.com/reports/wv/r/3A433FC72FFE3B8B"
153
+ summary.SpamComplaints.should be == 23
153
154
  end
154
155
 
155
156
  should "get the email client usage for a campaign" do
156
157
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/emailclientusage.json", "email_client_usage.json")
157
158
  ecu = @campaign.email_client_usage
158
- ecu.size.should == 6
159
- ecu.first.Client.should == "iOS Devices"
160
- ecu.first.Version.should == "iPhone"
161
- ecu.first.Percentage.should == 19.83
162
- ecu.first.Subscribers.should == 7056
159
+ ecu.size.should be == 6
160
+ ecu.first.Client.should be == "iOS Devices"
161
+ ecu.first.Version.should be == "iPhone"
162
+ ecu.first.Percentage.should be == 19.83
163
+ ecu.first.Subscribers.should be == 7056
163
164
  end
164
165
 
165
166
  should "get the lists and segments for a campaign" do
166
167
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/listsandsegments.json", "campaign_listsandsegments.json")
167
168
  ls = @campaign.lists_and_segments
168
- ls.Lists.size.should == 1
169
- ls.Segments.size.should == 1
170
- ls.Lists.first.Name.should == "List One"
171
- ls.Lists.first.ListID.should == "a58ee1d3039b8bec838e6d1482a8a965"
172
- ls.Segments.first.Title.should == "Segment for campaign"
173
- ls.Segments.first.ListID.should == "2bea949d0bf96148c3e6a209d2e82060"
174
- ls.Segments.first.SegmentID.should == "dba84a225d5ce3d19105d7257baac46f"
169
+ ls.Lists.size.should be == 1
170
+ ls.Segments.size.should be == 1
171
+ ls.Lists.first.Name.should be == "List One"
172
+ ls.Lists.first.ListID.should be == "a58ee1d3039b8bec838e6d1482a8a965"
173
+ ls.Segments.first.Title.should be == "Segment for campaign"
174
+ ls.Segments.first.ListID.should be == "2bea949d0bf96148c3e6a209d2e82060"
175
+ ls.Segments.first.SegmentID.should be == "dba84a225d5ce3d19105d7257baac46f"
175
176
  end
176
177
 
177
178
  should "get the recipients for a campaign" do
178
179
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/recipients.json?pagesize=20&orderfield=email&page=1&orderdirection=asc", "campaign_recipients.json")
179
180
  res = @campaign.recipients page=1, page_size=20
180
- res.ResultsOrderedBy.should == "email"
181
- res.OrderDirection.should == "asc"
182
- res.PageNumber.should == 1
183
- res.PageSize.should == 20
184
- res.RecordsOnThisPage.should == 20
185
- res.TotalNumberOfRecords.should == 2200
186
- res.NumberOfPages.should == 110
187
- res.Results.size.should == 20
188
- res.Results.first.EmailAddress.should == "subs+6g76t7t0@example.com"
189
- res.Results.first.ListID.should == "a994a3caf1328a16af9a69a730eaa706"
181
+ res.ResultsOrderedBy.should be == "email"
182
+ res.OrderDirection.should be == "asc"
183
+ res.PageNumber.should be == 1
184
+ res.PageSize.should be == 20
185
+ res.RecordsOnThisPage.should be == 20
186
+ res.TotalNumberOfRecords.should be == 2200
187
+ res.NumberOfPages.should be == 110
188
+ res.Results.size.should be == 20
189
+ res.Results.first.EmailAddress.should be == "subs+6g76t7t0@example.com"
190
+ res.Results.first.ListID.should be == "a994a3caf1328a16af9a69a730eaa706"
190
191
  end
191
192
 
192
193
  should "get the opens for a campaign" do
193
194
  min_date = "2010-01-01"
194
195
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/opens.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_opens.json")
195
196
  opens = @campaign.opens min_date
196
- opens.Results.size.should == 5
197
- opens.Results.first.EmailAddress.should == "subs+6576576576@example.com"
198
- opens.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
199
- opens.Results.first.Date.should == "2010-10-11 08:29:00"
200
- opens.Results.first.IPAddress.should == "192.168.126.87"
201
- opens.Results.first.Latitude.should == -33.8683
202
- opens.Results.first.Longitude.should == 151.2086
203
- opens.Results.first.City.should == "Sydney"
204
- opens.Results.first.Region.should == "New South Wales"
205
- opens.Results.first.CountryCode.should == "AU"
206
- opens.Results.first.CountryName.should == "Australia"
207
- opens.ResultsOrderedBy.should == "date"
208
- opens.OrderDirection.should == "asc"
209
- opens.PageNumber.should == 1
210
- opens.PageSize.should == 1000
211
- opens.RecordsOnThisPage.should == 5
212
- opens.TotalNumberOfRecords.should == 5
213
- opens.NumberOfPages.should == 1
197
+ opens.Results.size.should be == 5
198
+ opens.Results.first.EmailAddress.should be == "subs+6576576576@example.com"
199
+ opens.Results.first.ListID.should be == "512a3bc577a58fdf689c654329b50fa0"
200
+ opens.Results.first.Date.should be == "2010-10-11 08:29:00"
201
+ opens.Results.first.IPAddress.should be == "192.168.126.87"
202
+ opens.Results.first.Latitude.should be == -33.8683
203
+ opens.Results.first.Longitude.should be == 151.2086
204
+ opens.Results.first.City.should be == "Sydney"
205
+ opens.Results.first.Region.should be == "New South Wales"
206
+ opens.Results.first.CountryCode.should be == "AU"
207
+ opens.Results.first.CountryName.should be == "Australia"
208
+ opens.ResultsOrderedBy.should be == "date"
209
+ opens.OrderDirection.should be == "asc"
210
+ opens.PageNumber.should be == 1
211
+ opens.PageSize.should be == 1000
212
+ opens.RecordsOnThisPage.should be == 5
213
+ opens.TotalNumberOfRecords.should be == 5
214
+ opens.NumberOfPages.should be == 1
214
215
  end
215
216
 
216
217
  should "get the subscriber clicks for a campaign" do
217
218
  min_date = "2010-01-01"
218
219
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/clicks.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_clicks.json")
219
220
  clicks = @campaign.clicks min_date
220
- clicks.Results.size.should == 3
221
- clicks.Results.first.EmailAddress.should == "subs+6576576576@example.com"
222
- clicks.Results.first.URL.should == "http://video.google.com.au/?hl=en&tab=wv"
223
- clicks.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
224
- clicks.Results.first.Date.should == "2010-10-11 08:29:00"
225
- clicks.Results.first.IPAddress.should == "192.168.126.87"
226
- clicks.Results.first.Latitude.should == -33.8683
227
- clicks.Results.first.Longitude.should == 151.2086
228
- clicks.Results.first.City.should == "Sydney"
229
- clicks.Results.first.Region.should == "New South Wales"
230
- clicks.Results.first.CountryCode.should == "AU"
231
- clicks.Results.first.CountryName.should == "Australia"
232
- clicks.ResultsOrderedBy.should == "date"
233
- clicks.OrderDirection.should == "asc"
234
- clicks.PageNumber.should == 1
235
- clicks.PageSize.should == 1000
236
- clicks.RecordsOnThisPage.should == 3
237
- clicks.TotalNumberOfRecords.should == 3
238
- clicks.NumberOfPages.should == 1
221
+ clicks.Results.size.should be == 3
222
+ clicks.Results.first.EmailAddress.should be == "subs+6576576576@example.com"
223
+ clicks.Results.first.URL.should be == "http://video.google.com.au/?hl=en&tab=wv"
224
+ clicks.Results.first.ListID.should be == "512a3bc577a58fdf689c654329b50fa0"
225
+ clicks.Results.first.Date.should be == "2010-10-11 08:29:00"
226
+ clicks.Results.first.IPAddress.should be == "192.168.126.87"
227
+ clicks.Results.first.Latitude.should be == -33.8683
228
+ clicks.Results.first.Longitude.should be == 151.2086
229
+ clicks.Results.first.City.should be == "Sydney"
230
+ clicks.Results.first.Region.should be == "New South Wales"
231
+ clicks.Results.first.CountryCode.should be == "AU"
232
+ clicks.Results.first.CountryName.should be == "Australia"
233
+ clicks.ResultsOrderedBy.should be == "date"
234
+ clicks.OrderDirection.should be == "asc"
235
+ clicks.PageNumber.should be == 1
236
+ clicks.PageSize.should be == 1000
237
+ clicks.RecordsOnThisPage.should be == 3
238
+ clicks.TotalNumberOfRecords.should be == 3
239
+ clicks.NumberOfPages.should be == 1
239
240
  end
240
241
 
241
242
  should "get the unsubscribes for a campaign" do
242
243
  min_date = "2010-01-01"
243
244
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/unsubscribes.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_unsubscribes.json")
244
245
  unsubscribes = @campaign.unsubscribes min_date
245
- unsubscribes.Results.size.should == 1
246
- unsubscribes.Results.first.EmailAddress.should == "subs+6576576576@example.com"
247
- unsubscribes.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
248
- unsubscribes.Results.first.Date.should == "2010-10-11 08:29:00"
249
- unsubscribes.Results.first.IPAddress.should == "192.168.126.87"
250
- unsubscribes.ResultsOrderedBy.should == "date"
251
- unsubscribes.OrderDirection.should == "asc"
252
- unsubscribes.PageNumber.should == 1
253
- unsubscribes.PageSize.should == 1000
254
- unsubscribes.RecordsOnThisPage.should == 1
255
- unsubscribes.TotalNumberOfRecords.should == 1
256
- unsubscribes.NumberOfPages.should == 1
246
+ unsubscribes.Results.size.should be == 1
247
+ unsubscribes.Results.first.EmailAddress.should be == "subs+6576576576@example.com"
248
+ unsubscribes.Results.first.ListID.should be == "512a3bc577a58fdf689c654329b50fa0"
249
+ unsubscribes.Results.first.Date.should be == "2010-10-11 08:29:00"
250
+ unsubscribes.Results.first.IPAddress.should be == "192.168.126.87"
251
+ unsubscribes.ResultsOrderedBy.should be == "date"
252
+ unsubscribes.OrderDirection.should be == "asc"
253
+ unsubscribes.PageNumber.should be == 1
254
+ unsubscribes.PageSize.should be == 1000
255
+ unsubscribes.RecordsOnThisPage.should be == 1
256
+ unsubscribes.TotalNumberOfRecords.should be == 1
257
+ unsubscribes.NumberOfPages.should be == 1
257
258
  end
258
259
 
259
260
  should "get the spam complaints for a campaign" do
260
261
  min_date = "2010-01-01"
261
262
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/spam.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_spam.json")
262
263
  spam = @campaign.spam min_date
263
- spam.Results.size.should == 1
264
- spam.Results.first.EmailAddress.should == "subs+6576576576@example.com"
265
- spam.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
266
- spam.Results.first.Date.should == "2010-10-11 08:29:00"
267
- spam.ResultsOrderedBy.should == "date"
268
- spam.OrderDirection.should == "asc"
269
- spam.PageNumber.should == 1
270
- spam.PageSize.should == 1000
271
- spam.RecordsOnThisPage.should == 1
272
- spam.TotalNumberOfRecords.should == 1
273
- spam.NumberOfPages.should == 1
264
+ spam.Results.size.should be == 1
265
+ spam.Results.first.EmailAddress.should be == "subs+6576576576@example.com"
266
+ spam.Results.first.ListID.should be == "512a3bc577a58fdf689c654329b50fa0"
267
+ spam.Results.first.Date.should be == "2010-10-11 08:29:00"
268
+ spam.ResultsOrderedBy.should be == "date"
269
+ spam.OrderDirection.should be == "asc"
270
+ spam.PageNumber.should be == 1
271
+ spam.PageSize.should be == 1000
272
+ spam.RecordsOnThisPage.should be == 1
273
+ spam.TotalNumberOfRecords.should be == 1
274
+ spam.NumberOfPages.should be == 1
274
275
  end
275
276
 
276
277
  should "get the bounces for a campaign" do
277
278
  min_date = "2010-01-01"
278
279
  stub_get(@auth, "campaigns/#{@campaign.campaign_id}/bounces.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}", "campaign_bounces.json")
279
280
  bounces = @campaign.bounces min_date
280
- bounces.Results.size.should == 2
281
- bounces.Results.first.EmailAddress.should == "asdf@softbouncemyemail.com"
282
- bounces.Results.first.ListID.should == "654523a5855b4a440bae3fb295641546"
283
- bounces.Results.first.BounceType.should == "Soft"
284
- bounces.Results.first.Date.should == "2010-07-02 16:46:00"
285
- bounces.Results.first.Reason.should == "Bounce - But No Email Address Returned "
286
- bounces.ResultsOrderedBy.should == "date"
287
- bounces.OrderDirection.should == "asc"
288
- bounces.PageNumber.should == 1
289
- bounces.PageSize.should == 1000
290
- bounces.RecordsOnThisPage.should == 2
291
- bounces.TotalNumberOfRecords.should == 2
292
- bounces.NumberOfPages.should == 1
281
+ bounces.Results.size.should be == 2
282
+ bounces.Results.first.EmailAddress.should be == "asdf@softbouncemyemail.com"
283
+ bounces.Results.first.ListID.should be == "654523a5855b4a440bae3fb295641546"
284
+ bounces.Results.first.BounceType.should be == "Soft"
285
+ bounces.Results.first.Date.should be == "2010-07-02 16:46:00"
286
+ bounces.Results.first.Reason.should be == "Bounce - But No Email Address Returned "
287
+ bounces.ResultsOrderedBy.should be == "date"
288
+ bounces.OrderDirection.should be == "asc"
289
+ bounces.PageNumber.should be == 1
290
+ bounces.PageSize.should be == 1000
291
+ bounces.RecordsOnThisPage.should be == 2
292
+ bounces.TotalNumberOfRecords.should be == 2
293
+ bounces.NumberOfPages.should be == 1
293
294
  end
294
295
  end
295
296
  end