createsend 4.1.1 → 5.1.1

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.
@@ -0,0 +1,35 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "example+1@example.com",
5
+ "Date": "2019-07-29 10:33:00",
6
+ "URL": "http://test.com",
7
+ "IPAddress": "192.168.0.3",
8
+ "Latitude": -33.8683,
9
+ "Longitude": 151.2086,
10
+ "City": "Sydney",
11
+ "Region": "New South Wales",
12
+ "CountryCode": "AU",
13
+ "CountryName": "Australia"
14
+ },
15
+ {
16
+ "EmailAddress": "example+2@example.com",
17
+ "Date": "2019-07-29 10:35:00",
18
+ "URL": "http://test.com",
19
+ "IPAddress": "192.168.0.3",
20
+ "Latitude": -33.8683,
21
+ "Longitude": 151.2086,
22
+ "City": "Sydney",
23
+ "Region": "New South Wales",
24
+ "CountryCode": "AU",
25
+ "CountryName": "Australia"
26
+ }
27
+ ],
28
+ "ResultsOrderedBy": "Date",
29
+ "OrderDirection": "ASC",
30
+ "PageNumber": 1,
31
+ "PageSize": 2,
32
+ "RecordsOnThisPage": 2,
33
+ "TotalNumberOfRecords": 5,
34
+ "NumberOfPages": 3
35
+ }
@@ -0,0 +1,55 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "example+1@example.com",
5
+ "Date": "2019-07-29 10:33:00",
6
+ "IPAddress": "192.168.0.3",
7
+ "Latitude": -33.8683,
8
+ "Longitude": 151.2086,
9
+ "City": "Sydney",
10
+ "Region": "New South Wales",
11
+ "CountryCode": "AU",
12
+ "CountryName": "Australia"
13
+ },
14
+ {
15
+ "EmailAddress": "example+2@example.com",
16
+ "Date": "2019-07-29 10:35:00",
17
+ "IPAddress": "192.168.0.3",
18
+ "Latitude": -33.8683,
19
+ "Longitude": 151.2086,
20
+ "City": "Sydney",
21
+ "Region": "New South Wales",
22
+ "CountryCode": "AU",
23
+ "CountryName": "Australia"
24
+ },
25
+ {
26
+ "EmailAddress": "example+3@example.com",
27
+ "Date": "2019-07-29 10:35:00",
28
+ "IPAddress": "192.168.0.3",
29
+ "Latitude": -33.8683,
30
+ "Longitude": 151.2086,
31
+ "City": "Sydney",
32
+ "Region": "New South Wales",
33
+ "CountryCode": "AU",
34
+ "CountryName": "Australia"
35
+ },
36
+ {
37
+ "EmailAddress": "example+4@example.com",
38
+ "Date": "2019-07-29 10:35:00",
39
+ "IPAddress": "192.168.0.3",
40
+ "Latitude": -33.8683,
41
+ "Longitude": 151.2086,
42
+ "City": "Sydney",
43
+ "Region": "New South Wales",
44
+ "CountryCode": "AU",
45
+ "CountryName": "Australia"
46
+ }
47
+ ],
48
+ "ResultsOrderedBy": "Date",
49
+ "OrderDirection": "ASC",
50
+ "PageNumber": 1,
51
+ "PageSize": 1000,
52
+ "RecordsOnThisPage": 4,
53
+ "TotalNumberOfRecords": 4,
54
+ "NumberOfPages": 1
55
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "example+1@example.com",
5
+ "SentDate": "2019-07-12 09:45:00"
6
+ },
7
+ {
8
+ "EmailAddress": "example+2@example.com",
9
+ "SentDate": "2019-07-12 10:45:00"
10
+ },
11
+ {
12
+ "EmailAddress": "example+3@example.com",
13
+ "SentDate": "2019-07-13 09:00:00"
14
+ },
15
+ {
16
+ "EmailAddress": "example+4@example.com",
17
+ "SentDate": "2019-07-16 11:45:00"
18
+ }
19
+ ],
20
+ "ResultsOrderedBy": "SentDate",
21
+ "OrderDirection": "ASC",
22
+ "PageNumber": 2,
23
+ "PageSize": 10,
24
+ "RecordsOnThisPage": 4,
25
+ "TotalNumberOfRecords": 14,
26
+ "NumberOfPages": 2
27
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "JourneyID": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",
3
+ "Name": "New journey",
4
+ "TriggerType": "On Subscription",
5
+ "Status": "Active",
6
+ "Emails": [
7
+ {
8
+ "EmailID": "b1b1b1b1b1b1b1b1b1b1",
9
+ "Name": "New Email",
10
+ "Bounced": 0,
11
+ "Clicked": 0,
12
+ "Opened": 3,
13
+ "Sent": 1,
14
+ "UniqueOpened": 1,
15
+ "Unsubscribed": 0
16
+ }
17
+ ]
18
+ }
@@ -0,0 +1,26 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "example+1@example.com",
5
+ "Date": "2019-07-29 10:33:00",
6
+ "IPAddress": "192.168.0.3"
7
+ },
8
+ {
9
+ "EmailAddress": "example+2@example.com",
10
+ "Date": "2019-07-29 10:35:00",
11
+ "IPAddress": "192.168.0.3"
12
+ },
13
+ {
14
+ "EmailAddress": "example+3@example.com",
15
+ "Date": "2019-07-29 10:35:00",
16
+ "IPAddress": "192.168.0.3"
17
+ }
18
+ ],
19
+ "ResultsOrderedBy": "Date",
20
+ "OrderDirection": "ASC",
21
+ "PageNumber": 1,
22
+ "PageSize": 1000,
23
+ "RecordsOnThisPage": 4,
24
+ "TotalNumberOfRecords": 4,
25
+ "NumberOfPages": 1
26
+ }
@@ -0,0 +1,20 @@
1
+ [
2
+ {
3
+ "ListID": "a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a",
4
+ "JourneyID": "b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b",
5
+ "Name": "Journey One",
6
+ "Status": "Not started"
7
+ },
8
+ {
9
+ "ListID": "c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c",
10
+ "JourneyID": "d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d2d",
11
+ "Name": "Journey Two",
12
+ "Status": "Active"
13
+ },
14
+ {
15
+ "ListID": "c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c1c",
16
+ "JourneyID": "e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e2e",
17
+ "Name": "Journey Three",
18
+ "Status": "Paused"
19
+ }
20
+ ]
@@ -0,0 +1,22 @@
1
+ {
2
+ "EmailAddress": "subscriber@example.com",
3
+ "Name": "Subscriber One",
4
+ "Date": "2010-10-25 10:28:00",
5
+ "State": "Active",
6
+ "CustomFields": [
7
+ {
8
+ "Key": "website",
9
+ "Value": "http://example.com"
10
+ },
11
+ {
12
+ "Key": "age",
13
+ "Value": "24"
14
+ },
15
+ {
16
+ "Key": "subscription date",
17
+ "Value": "2010-03-09"
18
+ }
19
+ ],
20
+ "ReadsEmailWith": "Gmail",
21
+ "ConsentToTrack": "Yes"
22
+ }
@@ -11,7 +11,8 @@
11
11
  "Value": "http://example.com"
12
12
  }
13
13
  ],
14
- "ReadsEmailWith": ""
14
+ "ReadsEmailWith": "",
15
+ "ConsentToTrack": "Yes"
15
16
  },
16
17
  {
17
18
  "EmailAddress": "subs+7878787y8ggg@example.com",
@@ -24,7 +25,8 @@
24
25
  "Value": "http://subdomain.example.com"
25
26
  }
26
27
  ],
27
- "ReadsEmailWith": ""
28
+ "ReadsEmailWith": "",
29
+ "ConsentToTrack": "No"
28
30
  }
29
31
  ],
30
32
  "ResultsOrderedBy": "email",
data/test/helper.rb CHANGED
@@ -30,7 +30,7 @@ def createsend_url(auth, url)
30
30
  if not url =~ /^http/
31
31
  auth_section = ''
32
32
  auth_section = "#{auth[:api_key]}:x@" if auth and auth.has_key? :api_key
33
- result = "https://#{auth_section}api.createsend.com/api/v3.1/#{url}"
33
+ result = "https://#{auth_section}api.createsend.com/api/v3.2/#{url}"
34
34
  else
35
35
  result = url
36
36
  end
@@ -42,7 +42,8 @@ def stub_request(method, auth, url, filename, status=nil)
42
42
  options.merge!({:body => fixture_file(filename)}) if filename
43
43
  options.merge!({:status => status}) if status
44
44
  options.merge!(:content_type => "application/json; charset=utf-8")
45
- FakeWeb.register_uri(method, createsend_url(auth, url), options)
45
+ createsend_url = createsend_url(auth, url)
46
+ FakeWeb.register_uri(method, createsend_url, options)
46
47
  end
47
48
 
48
49
  def stub_get(*args); stub_request(:get, *args) end
@@ -0,0 +1,156 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class JourneyTest < Test::Unit::TestCase
4
+ multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
5
+ setup do
6
+ @journey = CreateSend::Journey.new @auth, 'a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1'
7
+ end
8
+
9
+ should "get the summary for a journey" do
10
+ stub_get(@auth, "journeys/#{@journey.journey_id}.json", "journey_summary.json")
11
+
12
+ summary = @journey.summary
13
+ summary.Name.should == 'New journey'
14
+ summary.TriggerType.should == 'On Subscription'
15
+ summary.Status.should == 'Active'
16
+
17
+ summary.Emails.size.should == 1
18
+ summary.Emails.first.EmailID.should == 'b1b1b1b1b1b1b1b1b1b1'
19
+ summary.Emails.first.Name.should == 'New Email'
20
+ summary.Emails.first.Bounced.should == 0
21
+ summary.Emails.first.Clicked.should == 0
22
+ summary.Emails.first.Opened.should == 3
23
+ summary.Emails.first.Sent.should == 1
24
+ summary.Emails.first.UniqueOpened.should == 1
25
+ summary.Emails.first.Unsubscribed.should == 0
26
+ end
27
+
28
+ should "return a paged list of recipients of a particular email" do
29
+ journey_date = "2019-07-12 09:22"
30
+ stub_get(@auth, "journeys/email/b1b1b1b1b1b1b1b1b1b1/recipients.json" \
31
+ "?date=#{ERB::Util.url_encode(journey_date)}" \
32
+ "&page=2" \
33
+ "&pagesize=5" \
34
+ "&orderdirection=asc", "journey_recipients.json")
35
+
36
+ recipients = @journey.email_recipients email_id = 'b1b1b1b1b1b1b1b1b1b1', date = journey_date, page = 2, page_size = 5, order_direction = 'asc'
37
+ recipients.Results.size.should == 4
38
+ recipients.Results.first.EmailAddress.should == 'example+1@example.com'
39
+ recipients.Results.first.SentDate.should == '2019-07-12 09:45:00'
40
+
41
+ recipients.ResultsOrderedBy.should == 'SentDate'
42
+ recipients.OrderDirection.should == 'ASC'
43
+ recipients.PageNumber.should == 2
44
+ recipients.PageSize.should == 10
45
+ recipients.RecordsOnThisPage.should == 4
46
+ recipients.TotalNumberOfRecords.should == 14
47
+ recipients.NumberOfPages.should == 2
48
+ end
49
+
50
+ should "return a paged list of subscribers who opened given journey email" do
51
+ journey_date = "2019-02-08 09:22"
52
+ stub_get(@auth, "journeys/email/b1b1b1b1b1b1b1b1b1b1/opens.json" \
53
+ "?date=#{ERB::Util.url_encode(journey_date)}" \
54
+ "&page=2" \
55
+ "&pagesize=5" \
56
+ "&orderdirection=asc", "journey_opens.json")
57
+
58
+ opens = @journey.email_opens email = 'b1b1b1b1b1b1b1b1b1b1', date = journey_date, page = 2, page_size = 5, order_direction = 'asc'
59
+ opens.Results.size.should == 4
60
+ opens.Results.last.EmailAddress.should == "example+4@example.com"
61
+ opens.Results.last.Date.should == "2019-07-29 10:35:00"
62
+ opens.Results.last.IPAddress.should == "192.168.0.3"
63
+ opens.Results.last.Latitude.should == -33.8683
64
+ opens.Results.last.Longitude.should == 151.2086
65
+ opens.Results.last.City.should == "Sydney"
66
+ opens.Results.last.Region.should == "New South Wales"
67
+ opens.Results.last.CountryCode.should == "AU"
68
+ opens.Results.last.CountryName.should == "Australia"
69
+
70
+ opens.ResultsOrderedBy.should == "Date"
71
+ opens.OrderDirection.should == "ASC"
72
+ opens.PageNumber.should == 1
73
+ opens.PageSize.should == 1000
74
+ opens.RecordsOnThisPage.should == 4
75
+ opens.TotalNumberOfRecords.should == 4
76
+ opens.NumberOfPages.should == 1
77
+ end
78
+
79
+ should "return a paged list of subscribers who clicked on a journey email" do
80
+ journey_date = "2019-07-29 10:30"
81
+ stub_get(@auth, "journeys/email/b1b1b1b1b1b1b1b1b1b1/clicks.json" \
82
+ "?date=#{ERB::Util.url_encode(journey_date)}" \
83
+ "&page=1" \
84
+ "&pagesize=2" \
85
+ "&orderdirection=asc", "journey_clicks.json")
86
+
87
+ clicks = @journey.email_clicks email = 'b1b1b1b1b1b1b1b1b1b1', date = journey_date, page = 1, page_size = 2, order_direction = 'asc'
88
+ clicks.Results.size.should == 2
89
+ clicks.Results.first.EmailAddress.should == "example+1@example.com"
90
+ clicks.Results.first.Date.should == "2019-07-29 10:33:00"
91
+ clicks.Results.first.URL.should == "http://test.com"
92
+ clicks.Results.first.IPAddress.should == "192.168.0.3"
93
+ clicks.Results.first.Latitude.should == -33.8683
94
+ clicks.Results.first.Longitude.should == 151.2086
95
+ clicks.Results.first.City.should == "Sydney"
96
+ clicks.Results.first.Region.should == "New South Wales"
97
+ clicks.Results.first.CountryCode.should == "AU"
98
+ clicks.Results.first.CountryName.should == "Australia"
99
+
100
+ clicks.ResultsOrderedBy.should == "Date"
101
+ clicks.OrderDirection.should == "ASC"
102
+ clicks.PageNumber.should == 1
103
+ clicks.PageSize.should == 2
104
+ clicks.RecordsOnThisPage.should == 2
105
+ clicks.TotalNumberOfRecords.should == 5
106
+ clicks.NumberOfPages.should == 3
107
+ end
108
+
109
+ should "return a paged list of subscribers who unsubscribed from a journey email" do
110
+ journey_date = "2019-07-29 10:22"
111
+ stub_get(@auth, "journeys/email/b1b1b1b1b1b1b1b1b1b1/unsubscribes.json" \
112
+ "?date=#{ERB::Util.url_encode(journey_date)}" \
113
+ "&page=1" \
114
+ "&pagesize=10" \
115
+ "&orderdirection=desc", "journey_unsubscribes.json")
116
+
117
+ unsubscribes = @journey.email_unsubscribes email = 'b1b1b1b1b1b1b1b1b1b1', date = journey_date, page = 1, page_size = 10, order_direction = 'desc'
118
+ unsubscribes.Results.size.should == 3
119
+ unsubscribes.Results.first.EmailAddress.should == "example+1@example.com"
120
+ unsubscribes.Results.first.Date.should == "2019-07-29 10:33:00"
121
+ unsubscribes.Results.first.IPAddress.should == "192.168.0.3"
122
+
123
+ unsubscribes.ResultsOrderedBy.should == "Date"
124
+ unsubscribes.OrderDirection.should == "ASC"
125
+ unsubscribes.PageNumber.should == 1
126
+ unsubscribes.PageSize.should == 1000
127
+ unsubscribes.RecordsOnThisPage.should == 4
128
+ unsubscribes.TotalNumberOfRecords.should == 4
129
+ unsubscribes.NumberOfPages.should == 1
130
+ end
131
+
132
+ should "return a paged list of emails that bounced for a journey email" do
133
+ journey_date = "2019-07-29 10:31"
134
+ stub_get(@auth, "journeys/email/b1b1b1b1b1b1b1b1b1b1/bounces.json" \
135
+ "?date=#{ERB::Util.url_encode(journey_date)}" \
136
+ "&page=20" \
137
+ "&pagesize=5" \
138
+ "&orderdirection=desc", "journey_bounces.json")
139
+
140
+ bounces = @journey.email_bounces email = 'b1b1b1b1b1b1b1b1b1b1', date = journey_date, page = 20, page_size = 5, order_direction = 'desc'
141
+ bounces.Results.size.should == 4
142
+ bounces.Results.first.EmailAddress.should == "example+1@example.com"
143
+ bounces.Results.first.BounceType.should == "4"
144
+ bounces.Results.first.Date.should == "2019-07-29 10:33:00"
145
+ bounces.Results.first.Reason.should == "Soft Bounce - Mailbox Full"
146
+
147
+ bounces.ResultsOrderedBy.should == "Date"
148
+ bounces.OrderDirection.should == "ASC"
149
+ bounces.PageNumber.should == 1
150
+ bounces.PageSize.should == 1000
151
+ bounces.RecordsOnThisPage.should == 4
152
+ bounces.TotalNumberOfRecords.should == 4
153
+ bounces.NumberOfPages.should == 1
154
+ end
155
+ end
156
+ end
data/test/list_test.rb CHANGED
@@ -66,7 +66,7 @@ class ListTest < Test::Unit::TestCase
66
66
 
67
67
  should "update a custom field" do
68
68
  key = "[mycustomfield]"
69
- stub_put(@auth, "lists/#{@list.list_id}/customfields/#{CGI.escape(key)}.json", "update_custom_field.json")
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
72
  request.include?("\"FieldName\":\"my renamed custom field\"").should == true
@@ -76,14 +76,14 @@ class ListTest < Test::Unit::TestCase
76
76
 
77
77
  should "delete a custom field" do
78
78
  custom_field_key = "[newdatefield]"
79
- stub_delete(@auth, "lists/#{@list.list_id}/customfields/#{CGI.escape(custom_field_key)}.json", nil)
79
+ stub_delete(@auth, "lists/#{@list.list_id}/customfields/#{ERB::Util.url_encode(custom_field_key)}.json", nil)
80
80
  @list.delete_custom_field custom_field_key
81
81
  end
82
82
 
83
83
  should "update the options of a multi-optioned custom field" do
84
84
  custom_field_key = "[newdatefield]"
85
85
  new_options = [ "one", "two", "three" ]
86
- stub_put(@auth, "lists/#{@list.list_id}/customfields/#{CGI.escape(custom_field_key)}/options.json", nil)
86
+ stub_put(@auth, "lists/#{@list.list_id}/customfields/#{ERB::Util.url_encode(custom_field_key)}/options.json", nil)
87
87
  @list.update_custom_field_options custom_field_key, new_options, true
88
88
  end
89
89
 
@@ -129,7 +129,7 @@ class ListTest < Test::Unit::TestCase
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=#{CGI.escape(min_date)}",
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",
133
133
  "active_subscribers.json")
134
134
  res = @list.active min_date
135
135
  res.ResultsOrderedBy.should == "email"
@@ -156,9 +156,9 @@ class ListTest < Test::Unit::TestCase
156
156
 
157
157
  should "get the unconfirmed subscribers for a list" do
158
158
  min_date = "2010-01-01"
159
- stub_get(@auth, "lists/#{@list.list_id}/unconfirmed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}",
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
160
  "unconfirmed_subscribers.json")
161
- res = @list.unconfirmed min_date
161
+ res = @list.unconfirmed(min_date, 1, 1000, "email", "asc", true)
162
162
  res.ResultsOrderedBy.should == "email"
163
163
  res.OrderDirection.should == "asc"
164
164
  res.PageNumber.should == 1
@@ -170,11 +170,12 @@ class ListTest < Test::Unit::TestCase
170
170
  res.Results.first.EmailAddress.should == "subs+7t8787Y@example.com"
171
171
  res.Results.first.Name.should =="Unconfirmed One"
172
172
  res.Results.first.State.should == "Unconfirmed"
173
+ res.Results.first.ConsentToTrack.should == "Yes"
173
174
  end
174
175
 
175
176
  should "get the unsubscribed subscribers for a list" do
176
177
  min_date = "2010-01-01"
177
- stub_get(@auth, "lists/#{@list.list_id}/unsubscribed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}",
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",
178
179
  "unsubscribed_subscribers.json")
179
180
  res = @list.unsubscribed min_date
180
181
  res.ResultsOrderedBy.should == "email"
@@ -195,7 +196,7 @@ class ListTest < Test::Unit::TestCase
195
196
 
196
197
  should "get the deleted subscribers for a list" do
197
198
  min_date = "2010-01-01"
198
- stub_get(@auth, "lists/#{@list.list_id}/deleted.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}",
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",
199
200
  "deleted_subscribers.json")
200
201
  res = @list.deleted min_date
201
202
  res.ResultsOrderedBy.should == "email"
@@ -216,7 +217,7 @@ class ListTest < Test::Unit::TestCase
216
217
 
217
218
  should "get the bounced subscribers for a list" do
218
219
  min_date = "2010-01-01"
219
- stub_get(@auth, "lists/#{@list.list_id}/bounced.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}",
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",
220
221
  "bounced_subscribers.json")
221
222
  res = @list.bounced min_date
222
223
  res.ResultsOrderedBy.should == "email"
data/test/person_test.rb CHANGED
@@ -9,7 +9,7 @@ class PersonTest < Test::Unit::TestCase
9
9
 
10
10
  should "get a person by client id and email address" do
11
11
  email = "person@example.com"
12
- stub_get(@auth, "clients/#{@client_id}/people.json?email=#{CGI.escape(email)}", "person_details.json")
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
14
  person.EmailAddress.should == email
15
15
  person.Name.should == "Person One"
@@ -26,13 +26,13 @@ class PersonTest < Test::Unit::TestCase
26
26
  should "update a person" do
27
27
  email = "person@example.com"
28
28
  new_email = "new_email_address@example.com"
29
- stub_put(@auth, "clients/#{@client_id}/people.json?email=#{CGI.escape(email)}", nil)
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
31
  @person.email_address.should == new_email
32
32
  end
33
33
 
34
34
  should "delete a person" do
35
- stub_delete(@auth, "clients/#{@person.client_id}/people.json?email=#{CGI.escape(@person.email_address)}", nil)
35
+ stub_delete(@auth, "clients/#{@person.client_id}/people.json?email=#{ERB::Util.url_encode(@person.email_address)}", nil)
36
36
  @person.delete
37
37
  end
38
38
  end
data/test/segment_test.rb CHANGED
@@ -28,7 +28,7 @@ class SegmentTest < Test::Unit::TestCase
28
28
 
29
29
  should "get the active subscribers for a particular segment in the list" do
30
30
  min_date = "2010-01-01"
31
- stub_get(@auth, "segments/#{@segment.segment_id}/active.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}",
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
34
  res.ResultsOrderedBy.should == "email"
@@ -9,7 +9,7 @@ class SubscriberTest < Test::Unit::TestCase
9
9
 
10
10
  should "get a subscriber by list id and email address" do
11
11
  email = "subscriber@example.com"
12
- stub_get(@auth, "subscribers/#{@list_id}.json?email=#{CGI.escape(email)}", "subscriber_details.json")
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
14
  subscriber.EmailAddress.should == email
15
15
  subscriber.Name.should == "Subscriber One"
@@ -21,16 +21,25 @@ class SubscriberTest < Test::Unit::TestCase
21
21
  subscriber.ReadsEmailWith.should == "Gmail"
22
22
  end
23
23
 
24
+ should "get a subscriber with track preference information" do
25
+ email = "subscriber@example.com"
26
+ stub_get(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}&includetrackingpreference=true", "subscriber_details_with_track_pref.json")
27
+ subscriber = CreateSend::Subscriber.get @auth, @list_id, email, true
28
+ subscriber.EmailAddress.should == email
29
+ subscriber.Name.should == "Subscriber One"
30
+ subscriber.ConsentToTrack == "Yes"
31
+ end
32
+
24
33
  should "add a subscriber without custom fields" do
25
34
  stub_post(@auth, "subscribers/#{@list_id}.json", "add_subscriber.json")
26
- email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", [], true
35
+ email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", [], true, "Yes"
27
36
  email_address.should == "subscriber@example.com"
28
37
  end
29
38
 
30
39
  should "add a subscriber with custom fields" do
31
40
  stub_post(@auth, "subscribers/#{@list_id}.json", "add_subscriber.json")
32
41
  custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ]
33
- email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true
42
+ email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true, "Yes"
34
43
  email_address.should == "subscriber@example.com"
35
44
  end
36
45
 
@@ -39,25 +48,25 @@ class SubscriberTest < Test::Unit::TestCase
39
48
  custom_fields = [ { :Key => 'multioptionselectone', :Value => 'myoption' },
40
49
  { :Key => 'multioptionselectmany', :Value => 'firstoption' },
41
50
  { :Key => 'multioptionselectmany', :Value => 'secondoption' } ]
42
- email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true
51
+ email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true, "Yes"
43
52
  email_address.should == "subscriber@example.com"
44
53
  end
45
54
 
46
55
  should "update a subscriber with custom fields" do
47
56
  email = "subscriber@example.com"
48
57
  new_email = "new_email_address@example.com"
49
- stub_put(@auth, "subscribers/#{@list_id}.json?email=#{CGI.escape(email)}", nil)
58
+ stub_put(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}", nil)
50
59
  custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ]
51
- @subscriber.update new_email, "Subscriber", custom_fields, true
60
+ @subscriber.update new_email, "Subscriber", custom_fields, true, "Yes"
52
61
  @subscriber.email_address.should == new_email
53
62
  end
54
63
 
55
64
  should "update a subscriber with custom fields including the clear option" do
56
65
  email = "subscriber@example.com"
57
66
  new_email = "new_email_address@example.com"
58
- stub_put(@auth, "subscribers/#{@list_id}.json?email=#{CGI.escape(email)}", nil)
67
+ stub_put(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}", nil)
59
68
  custom_fields = [ { :Key => 'website', :Value => '', :Clear => true } ]
60
- @subscriber.update new_email, "Subscriber", custom_fields, true
69
+ @subscriber.update new_email, "Subscriber", custom_fields, true, "No"
61
70
  @subscriber.email_address.should == new_email
62
71
  end
63
72
 
@@ -133,8 +142,8 @@ class SubscriberTest < Test::Unit::TestCase
133
142
  { :EmailAddress => "example+2@example.com", :Name => "Example Two" },
134
143
  { :EmailAddress => "example+3@example.com", :Name => "Example Three" },
135
144
  ]
136
- lambda { import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers, true
137
- }.should raise_error(CreateSend::BadRequest)
145
+ lambda { import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers,
146
+ true }.should raise_error(CreateSend::BadRequest)
138
147
  end
139
148
 
140
149
  should "unsubscribe a subscriber" do
@@ -143,7 +152,7 @@ class SubscriberTest < Test::Unit::TestCase
143
152
  end
144
153
 
145
154
  should "get a subscriber's history" do
146
- stub_get(@auth, "subscribers/#{@subscriber.list_id}/history.json?email=#{CGI.escape(@subscriber.email_address)}", "subscriber_history.json")
155
+ stub_get(@auth, "subscribers/#{@subscriber.list_id}/history.json?email=#{ERB::Util.url_encode(@subscriber.email_address)}", "subscriber_history.json")
147
156
  history = @subscriber.history
148
157
  history.size.should == 1
149
158
  history.first.Name.should == "Campaign One"
@@ -157,7 +166,7 @@ class SubscriberTest < Test::Unit::TestCase
157
166
  end
158
167
 
159
168
  should "delete a subscriber" do
160
- stub_delete(@auth, "subscribers/#{@subscriber.list_id}.json?email=#{CGI.escape(@subscriber.email_address)}", nil)
169
+ stub_delete(@auth, "subscribers/#{@subscriber.list_id}.json?email=#{ERB::Util.url_encode(@subscriber.email_address)}", nil)
161
170
  @subscriber.delete
162
171
  end
163
172
  end