createsend 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e4281f173aaf06254761ef8bde5b7da4233f18c7
4
- data.tar.gz: 36e0b3673d514f1619cc2d1bb26f9721afdaa79b
3
+ metadata.gz: 0cbf47984eff0211b8d39e59f1e081fddffc6394
4
+ data.tar.gz: eea780fdf7c2ea60a2302937e4e08582a72a6c9c
5
5
  SHA512:
6
- metadata.gz: e7a4b1cfa6bcea21ebc3d6b0c27063d3053784ff3cc6fd85bc111b632fa27a18b9cbf2a133384accb7e9877ee8ce8d368150f340b8931f89ae56b2e3d6332f64
7
- data.tar.gz: '0032093a7da459b0d6f58cbbc478d13b779aacacc839dbc12d4d8296ffc2feae4664541dd1a627e886f29fb6e78f19dc64a3745840acbc0591c6af7c08b7d4e5'
6
+ metadata.gz: 78336e5550ffec584bb92e2c89796df4ef086be3a977e1d0257c04c5c26642293f03ba0c6f3218e50205f52dc2be3b533b29941841f5f29172bc31ed4471f4bb
7
+ data.tar.gz: 3337d01b81ad49e92d4d0f3fa0a1f446bbe3dbedb8bba4abb774eceb9d4aca60e2a0ff2eeba3af1070cdabe5eeb304e342f8d24ca63952167962052a0641f98e
data/HISTORY.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # createsend-ruby history
2
2
 
3
+ ## v5.1.0 - 3 Sep, 2019
4
+ * Added support for [Journeys API](https://www.campaignmonitor.com/api/journeys/)
5
+
3
6
  ## v5.0.0 - 19 Jun, 2018
4
7
  * Upgrades to Createsend API v3.2 which includes new breaking changes
5
8
  * Breaking: 'Consent to track' field is now mandatory for sending smart and classic transactionl emails
@@ -14,3 +14,4 @@ require 'createsend/administrator'
14
14
  require 'createsend/transactional_classic_email'
15
15
  require 'createsend/transactional_smart_email'
16
16
  require 'createsend/transactional_timeline'
17
+ require 'createsend/journey'
@@ -1,5 +1,5 @@
1
1
  module CreateSend
2
- # Represents a campaign and provides associated funtionality.
2
+ # Represents a campaign and provides associated functionality.
3
3
  class Campaign < CreateSend
4
4
  attr_reader :campaign_id
5
5
 
@@ -181,6 +181,12 @@ module CreateSend
181
181
  super "/clients/#{client_id}.json", {}
182
182
  end
183
183
 
184
+ # Gets the journeys belonging to this client.
185
+ def journeys
186
+ response = get 'journeys'
187
+ response.map{|item| Hashie::Mash.new(item)}
188
+ end
189
+
184
190
  private
185
191
 
186
192
  def get(action, options = {})
@@ -0,0 +1,58 @@
1
+ module CreateSend
2
+ # Represents a journey and provides associated functionality
3
+ class Journey < CreateSend
4
+ attr_reader :journey_id
5
+
6
+ def initialize(auth, journey_id)
7
+ @journey_id = journey_id
8
+ super
9
+ end
10
+
11
+ # Get a full summary of a journey
12
+ def summary
13
+ response = get "/journeys/#{@journey_id}.json"
14
+ Hashie::Mash.new(response)
15
+ end
16
+
17
+ # Gets a list of all recipients of a particular email within a journey
18
+ def email_recipients(email_id="", date="", page=1, page_size=1000, order_direction='asc')
19
+ paged_result_by_date("recipients", email_id, date, page, page_size, order_direction)
20
+ end
21
+
22
+ # Gets a paged list of subscribers who opened a given journey email
23
+ def email_opens(email_id="", date="", page=1, page_size=1000, order_direction='asc')
24
+ paged_result_by_date("opens", email_id, date, page, page_size, order_direction)
25
+ end
26
+
27
+ # Gets a paged list of subscribers who clicked a given journey email
28
+ def email_clicks(email_id="", date="", page=1, page_size=1000, order_direction='asc')
29
+ paged_result_by_date("clicks", email_id, date, page, page_size, order_direction)
30
+ end
31
+
32
+ # Gets a paged result representing all subscribers who unsubscribed from a journey email
33
+ def email_unsubscribes(email_id="", date="", page=1, page_size=1000, order_direction='asc')
34
+ paged_result_by_date("unsubscribes", email_id, date, page, page_size, order_direction)
35
+ end
36
+
37
+ # Gets a paged result of all bounces for a journey email
38
+ def email_bounces(email_id="", date="", page=1, page_size=1000, order_direction='asc')
39
+ paged_result_by_date("bounces", email_id, date, page, page_size, order_direction)
40
+ end
41
+
42
+ private
43
+
44
+ def paged_result_by_date(resource, email_id, date, page, page_size, order_direction)
45
+ options = { :query => {
46
+ :date => date,
47
+ :page => page,
48
+ :pagesize => page_size,
49
+ :orderdirection => order_direction } }
50
+ response = get_journey_email_action email_id, resource, options
51
+ Hashie::Mash.new(response)
52
+ end
53
+
54
+ def get_journey_email_action(email_id, action, options = {})
55
+ get "/journeys/email/#{email_id}/#{action}.json", options
56
+ end
57
+ end
58
+ end
@@ -1,3 +1,3 @@
1
1
  module CreateSend
2
- VERSION = "5.0.0" unless defined?(CreateSend::VERSION)
2
+ VERSION = "5.1.0" unless defined?(CreateSend::VERSION)
3
3
  end
@@ -0,0 +1,86 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ require 'createsend'
3
+
4
+ class JourneySample
5
+ @date = "2019-01-01 00:00"
6
+
7
+ def initialize
8
+ raise 'CREATESEND_API_KEY env var missing' if ENV['CREATESEND_API_KEY'].nil?
9
+ raise 'CREATESEND_CLIENT_ID env var missing' if ENV['CREATESEND_CLIENT_ID'].nil?
10
+ raise 'CREATESEND_JOURNEY_ID env var missing' if ENV['CREATESEND_JOURNEY_ID'].nil?
11
+ raise 'CREATESEND_EMAIL_ID env var missing' if ENV['CREATESEND_EMAIL_ID'].nil?
12
+
13
+ auth = {:api_key => ENV['CREATESEND_API_KEY']}
14
+ @client = CreateSend::Client.new auth, ENV['CREATESEND_CLIENT_ID']
15
+ @journey = CreateSend::Journey.new auth, ENV['CREATESEND_JOURNEY_ID']
16
+ end
17
+
18
+ def get_all_journeys
19
+ @client.journeys
20
+ end
21
+
22
+ def get_journey_summary
23
+ @journey.summary
24
+ end
25
+
26
+ def get_recipients_for_email
27
+ @journey.email_recipients ENV['CREATESEND_EMAIL_ID']
28
+ end
29
+
30
+ def get_email_opens
31
+ opens = []
32
+ loop do
33
+ page = @journey.email_opens email_id = ENV['CREATESEND_EMAIL_ID'], date = @date, order_direction = 'desc'
34
+ opens.concat(page.Results)
35
+ if page.PageNumber == page.NumberOfPages
36
+ break
37
+ end
38
+ end
39
+ opens
40
+ end
41
+
42
+ def get_email_clicks
43
+ clicks = []
44
+ loop do
45
+ page = @journey.email_clicks email_id = ENV['CREATESEND_EMAIL_ID'], date = @date, order_direction = 'desc'
46
+ clicks.concat(page.Results)
47
+ if page.PageNumber == page.NumberOfPages
48
+ break
49
+ end
50
+ end
51
+ clicks
52
+ end
53
+
54
+ def get_email_unsubscribes
55
+ unsubscribes = []
56
+ loop do
57
+ page = @journey.email_unsubscribes email_id = ENV['CREATESEND_EMAIL_ID'], date = @date, order_direction = 'desc'
58
+ unsubscribes.concat(page.Results)
59
+ if page.PageNumber == page.NumberOfPages
60
+ break
61
+ end
62
+ end
63
+ unsubscribes
64
+ end
65
+
66
+ def get_email_bounces
67
+ bounces = []
68
+ loop do
69
+ page = @journey.email_bounces email_id = ENV['CREATESEND_EMAIL_ID'], date = @date, order_direction = 'asc'
70
+ bounces.concat(page.Results)
71
+ if page.PageNumber == page.NumberOfPages
72
+ break
73
+ end
74
+ end
75
+ bounces
76
+ end
77
+ end
78
+
79
+ sample = JourneySample.new
80
+ puts "All journeys: #{sample.get_all_journeys.to_json}\n\n"
81
+ puts "Journey Summary: #{sample.get_journey_summary.to_json}\n\n"
82
+ puts "Email recipients : #{sample.get_recipients_for_email.to_json}\n\n"
83
+ puts "Email Opens : #{sample.get_email_opens.to_json}\n\n"
84
+ puts "Email Clicks : #{sample.get_email_clicks.to_json}\n\n"
85
+ puts "Email Unsubscribes : #{sample.get_email_unsubscribes.to_json}\n\n"
86
+ puts "Email Bounces : #{sample.get_email_bounces.to_json}\n\n"
@@ -8,7 +8,7 @@ class AdministratorTest < Test::Unit::TestCase
8
8
 
9
9
  should "get a administrator by email address" do
10
10
  email = "admin@example.com"
11
- stub_get(@auth, "admins.json?email=#{CGI.escape(email)}", "admin_details.json")
11
+ stub_get(@auth, "admins.json?email=#{ERB::Util.url_encode(email)}", "admin_details.json")
12
12
  admin = CreateSend::Administrator.get @auth, email
13
13
  admin.EmailAddress.should == email
14
14
  admin.Name.should == "Admin One"
@@ -24,13 +24,13 @@ class AdministratorTest < Test::Unit::TestCase
24
24
  should "update an administrator" do
25
25
  email = "admin@example.com"
26
26
  new_email = "new_email_address@example.com"
27
- stub_put(@auth, "admins.json?email=#{CGI.escape(email)}", nil)
27
+ stub_put(@auth, "admins.json?email=#{ERB::Util.url_encode(email)}", nil)
28
28
  @admin.update new_email, "Admin Name"
29
29
  @admin.email_address.should == new_email
30
30
  end
31
31
 
32
32
  should "delete an admin" do
33
- stub_delete(@auth, "admins.json?email=#{CGI.escape(@admin.email_address)}", nil)
33
+ stub_delete(@auth, "admins.json?email=#{ERB::Util.url_encode(@admin.email_address)}", nil)
34
34
  @admin.delete
35
35
  end
36
36
  end
@@ -191,7 +191,7 @@ class CampaignTest < Test::Unit::TestCase
191
191
 
192
192
  should "get the opens for a campaign" do
193
193
  min_date = "2010-01-01"
194
- stub_get(@auth, "campaigns/#{@campaign.campaign_id}/opens.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_opens.json")
194
+ 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
195
  opens = @campaign.opens min_date
196
196
  opens.Results.size.should == 5
197
197
  opens.Results.first.EmailAddress.should == "subs+6576576576@example.com"
@@ -215,7 +215,7 @@ class CampaignTest < Test::Unit::TestCase
215
215
 
216
216
  should "get the subscriber clicks for a campaign" do
217
217
  min_date = "2010-01-01"
218
- stub_get(@auth, "campaigns/#{@campaign.campaign_id}/clicks.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_clicks.json")
218
+ 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
219
  clicks = @campaign.clicks min_date
220
220
  clicks.Results.size.should == 3
221
221
  clicks.Results.first.EmailAddress.should == "subs+6576576576@example.com"
@@ -240,7 +240,7 @@ class CampaignTest < Test::Unit::TestCase
240
240
 
241
241
  should "get the unsubscribes for a campaign" do
242
242
  min_date = "2010-01-01"
243
- stub_get(@auth, "campaigns/#{@campaign.campaign_id}/unsubscribes.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_unsubscribes.json")
243
+ 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
244
  unsubscribes = @campaign.unsubscribes min_date
245
245
  unsubscribes.Results.size.should == 1
246
246
  unsubscribes.Results.first.EmailAddress.should == "subs+6576576576@example.com"
@@ -258,7 +258,7 @@ class CampaignTest < Test::Unit::TestCase
258
258
 
259
259
  should "get the spam complaints for a campaign" do
260
260
  min_date = "2010-01-01"
261
- stub_get(@auth, "campaigns/#{@campaign.campaign_id}/spam.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_spam.json")
261
+ 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
262
  spam = @campaign.spam min_date
263
263
  spam.Results.size.should == 1
264
264
  spam.Results.first.EmailAddress.should == "subs+6576576576@example.com"
@@ -275,7 +275,7 @@ class CampaignTest < Test::Unit::TestCase
275
275
 
276
276
  should "get the bounces for a campaign" do
277
277
  min_date = "2010-01-01"
278
- stub_get(@auth, "campaigns/#{@campaign.campaign_id}/bounces.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_bounces.json")
278
+ 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
279
  bounces = @campaign.bounces min_date
280
280
  bounces.Results.size.should == 2
281
281
  bounces.Results.first.EmailAddress.should == "asdf@softbouncemyemail.com"
@@ -83,7 +83,7 @@ class ClientTest < Test::Unit::TestCase
83
83
 
84
84
  should "get all lists to which a subscriber with a particular email address belongs" do
85
85
  email = "valid@example.com"
86
- stub_get(@auth, "clients/#{@client.client_id}/listsforemail.json?email=#{CGI.escape(email)}", "listsforemail.json")
86
+ stub_get(@auth, "clients/#{@client.client_id}/listsforemail.json?email=#{ERB::Util.url_encode(email)}", "listsforemail.json")
87
87
  lists = @client.lists_for_email(email)
88
88
  lists.size.should == 2
89
89
  lists.first.ListID.should == 'ab4a2b57c7c8f1ba62f898a1af1a575b'
@@ -131,7 +131,7 @@ class ClientTest < Test::Unit::TestCase
131
131
 
132
132
  should "unsuppress an email address" do
133
133
  email = "example@example.com"
134
- stub_put(@auth, "clients/#{@client.client_id}/unsuppress.json?email=#{CGI.escape(email)}", nil)
134
+ stub_put(@auth, "clients/#{@client.client_id}/unsuppress.json?email=#{ERB::Util.url_encode(email)}", nil)
135
135
  result = @client.unsuppress email
136
136
  end
137
137
 
@@ -155,7 +155,7 @@ class ClientTest < Test::Unit::TestCase
155
155
 
156
156
  should "set primary contact" do
157
157
  email = 'person@blackhole.com'
158
- stub_put(@auth, "clients/#{@client.client_id}/primarycontact.json?email=#{CGI.escape(email)}", 'client_set_primary_contact.json')
158
+ stub_put(@auth, "clients/#{@client.client_id}/primarycontact.json?email=#{ERB::Util.url_encode(email)}", 'client_set_primary_contact.json')
159
159
  result = @client.set_primary_contact email
160
160
  result.EmailAddress.should == email
161
161
  end
@@ -217,6 +217,14 @@ class ClientTest < Test::Unit::TestCase
217
217
  stub_delete(@auth, "clients/#{@client.client_id}.json", nil)
218
218
  @client.delete
219
219
  end
220
-
220
+
221
+ should "get all journeys" do
222
+ stub_get(@auth, "clients/#{@client.client_id}/journeys.json", "journeys.json")
223
+ lists = @client.journeys
224
+ lists.size.should == 3
225
+ lists.first.ListID.should == 'a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a'
226
+ lists.first.Name.should == 'Journey One'
227
+ lists.first.Status.should == 'Not started'
228
+ end
221
229
  end
222
230
  end
@@ -82,7 +82,7 @@ class CreateSendTest < Test::Unit::TestCase
82
82
  FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
83
83
  new_access_token, new_expires_in, new_refresh_token = CreateSend::CreateSend.refresh_access_token refresh_token
84
84
 
85
- FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{CGI.escape(refresh_token)}"
85
+ FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(refresh_token)}"
86
86
  new_access_token.should == "SlAV32hkKG2e12e"
87
87
  new_expires_in.should == 1209600
88
88
  new_refresh_token.should == "tGzv3JOkF0XG5Qx2TlKWIA"
@@ -97,7 +97,7 @@ class CreateSendTest < Test::Unit::TestCase
97
97
  lambda { access_token, expires_in, refresh_token = CreateSend::CreateSend.refresh_access_token(
98
98
  refresh_token) }.should raise_error(
99
99
  Exception, 'Error refreshing access token: invalid_grant - Specified refresh_token was invalid or expired')
100
- FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{CGI.escape(refresh_token)}"
100
+ FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(refresh_token)}"
101
101
  end
102
102
 
103
103
  end
@@ -120,7 +120,7 @@ class CreateSendTest < Test::Unit::TestCase
120
120
  cs = CreateSend::CreateSend.new @auth
121
121
  new_access_token, new_expires_in, new_refresh_token = cs.refresh_token
122
122
 
123
- FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{CGI.escape(@auth[:refresh_token])}"
123
+ FakeWeb.last_request.body.should == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(@auth[:refresh_token])}"
124
124
  new_access_token.should == "SlAV32hkKG2e12e"
125
125
  new_expires_in.should == 1209600
126
126
  new_refresh_token.should == "tGzv3JOkF0XG5Qx2TlKWIA"
@@ -246,7 +246,7 @@ class CreateSendTest < Test::Unit::TestCase
246
246
 
247
247
  should "set primary contact" do
248
248
  email = 'admin@blackhole.com'
249
- stub_put(@auth, "primarycontact.json?email=#{CGI.escape(email)}", 'admin_set_primary_contact.json')
249
+ stub_put(@auth, "primarycontact.json?email=#{ERB::Util.url_encode(email)}", 'admin_set_primary_contact.json')
250
250
  result = @cs.set_primary_contact email
251
251
  result.EmailAddress.should == email
252
252
  end
@@ -0,0 +1,35 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "example+1@example.com",
5
+ "BounceType": "4",
6
+ "Date": "2019-07-29 10:33:00",
7
+ "Reason": "Soft Bounce - Mailbox Full"
8
+ },
9
+ {
10
+ "EmailAddress": "example+2@example.com",
11
+ "BounceType": "1",
12
+ "Date": "2019-07-29 10:35:00",
13
+ "Reason": "Hard Bounce"
14
+ },
15
+ {
16
+ "EmailAddress": "example+3@example.com",
17
+ "BounceType": "1",
18
+ "Date": "2019-07-29 10:35:00",
19
+ "Reason": "Hard Bounce"
20
+ },
21
+ {
22
+ "EmailAddress": "example+4@example.com",
23
+ "BounceType": "1",
24
+ "Date": "2019-07-29 10:35:00",
25
+ "Reason": "Hard Bounce"
26
+ }
27
+ ],
28
+ "ResultsOrderedBy": "Date",
29
+ "OrderDirection": "ASC",
30
+ "PageNumber": 1,
31
+ "PageSize": 1000,
32
+ "RecordsOnThisPage": 4,
33
+ "TotalNumberOfRecords": 4,
34
+ "NumberOfPages": 1
35
+ }
@@ -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
+ ]
@@ -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
@@ -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)}&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",
133
133
  "active_subscribers.json")
134
134
  res = @list.active min_date
135
135
  res.ResultsOrderedBy.should == "email"
@@ -156,7 +156,7 @@ 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)}&includetrackingpreference=true",
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
161
  res = @list.unconfirmed(min_date, 1, 1000, "email", "asc", true)
162
162
  res.ResultsOrderedBy.should == "email"
@@ -175,7 +175,7 @@ class ListTest < Test::Unit::TestCase
175
175
 
176
176
  should "get the unsubscribed subscribers for a list" do
177
177
  min_date = "2010-01-01"
178
- stub_get(@auth, "lists/#{@list.list_id}/unsubscribed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}&includetrackingpreference=false",
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",
179
179
  "unsubscribed_subscribers.json")
180
180
  res = @list.unsubscribed min_date
181
181
  res.ResultsOrderedBy.should == "email"
@@ -196,7 +196,7 @@ class ListTest < Test::Unit::TestCase
196
196
 
197
197
  should "get the deleted subscribers for a list" do
198
198
  min_date = "2010-01-01"
199
- stub_get(@auth, "lists/#{@list.list_id}/deleted.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}&includetrackingpreference=false",
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",
200
200
  "deleted_subscribers.json")
201
201
  res = @list.deleted min_date
202
202
  res.ResultsOrderedBy.should == "email"
@@ -217,7 +217,7 @@ class ListTest < Test::Unit::TestCase
217
217
 
218
218
  should "get the bounced subscribers for a list" do
219
219
  min_date = "2010-01-01"
220
- stub_get(@auth, "lists/#{@list.list_id}/bounced.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{CGI.escape(min_date)}&includetrackingpreference=false",
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",
221
221
  "bounced_subscribers.json")
222
222
  res = @list.bounced min_date
223
223
  res.ResultsOrderedBy.should == "email"
@@ -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
@@ -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)}&includetrackingpreference=false",
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)}&includetrackingpreference=false", "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"
@@ -23,7 +23,7 @@ class SubscriberTest < Test::Unit::TestCase
23
23
 
24
24
  should "get a subscriber with track preference information" do
25
25
  email = "subscriber@example.com"
26
- stub_get(@auth, "subscribers/#{@list_id}.json?email=#{CGI.escape(email)}&includetrackingpreference=true", "subscriber_details_with_track_pref.json")
26
+ stub_get(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}&includetrackingpreference=true", "subscriber_details_with_track_pref.json")
27
27
  subscriber = CreateSend::Subscriber.get @auth, @list_id, email, true
28
28
  subscriber.EmailAddress.should == email
29
29
  subscriber.Name.should == "Subscriber One"
@@ -55,7 +55,7 @@ class SubscriberTest < Test::Unit::TestCase
55
55
  should "update a subscriber with custom fields" do
56
56
  email = "subscriber@example.com"
57
57
  new_email = "new_email_address@example.com"
58
- 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)
59
59
  custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ]
60
60
  @subscriber.update new_email, "Subscriber", custom_fields, true, "Yes"
61
61
  @subscriber.email_address.should == new_email
@@ -64,7 +64,7 @@ class SubscriberTest < Test::Unit::TestCase
64
64
  should "update a subscriber with custom fields including the clear option" do
65
65
  email = "subscriber@example.com"
66
66
  new_email = "new_email_address@example.com"
67
- 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)
68
68
  custom_fields = [ { :Key => 'website', :Value => '', :Clear => true } ]
69
69
  @subscriber.update new_email, "Subscriber", custom_fields, true, "No"
70
70
  @subscriber.email_address.should == new_email
@@ -152,7 +152,7 @@ class SubscriberTest < Test::Unit::TestCase
152
152
  end
153
153
 
154
154
  should "get a subscriber's history" do
155
- 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")
156
156
  history = @subscriber.history
157
157
  history.size.should == 1
158
158
  history.first.Name.should == "Campaign One"
@@ -166,7 +166,7 @@ class SubscriberTest < Test::Unit::TestCase
166
166
  end
167
167
 
168
168
  should "delete a subscriber" do
169
- 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)
170
170
  @subscriber.delete
171
171
  end
172
172
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: createsend
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Dennes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-19 00:00:00.000000000 Z
11
+ date: 2019-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -174,6 +174,7 @@ files:
174
174
  - lib/createsend/campaign.rb
175
175
  - lib/createsend/client.rb
176
176
  - lib/createsend/createsend.rb
177
+ - lib/createsend/journey.rb
177
178
  - lib/createsend/list.rb
178
179
  - lib/createsend/person.rb
179
180
  - lib/createsend/segment.rb
@@ -183,6 +184,7 @@ files:
183
184
  - lib/createsend/transactional_smart_email.rb
184
185
  - lib/createsend/transactional_timeline.rb
185
186
  - lib/createsend/version.rb
187
+ - samples/journey_sample.rb
186
188
  - test/administrator_test.rb
187
189
  - test/campaign_test.rb
188
190
  - test/client_test.rb
@@ -228,6 +230,13 @@ files:
228
230
  - test/fixtures/import_subscribers.json
229
231
  - test/fixtures/import_subscribers_partial_success.json
230
232
  - test/fixtures/invalid_oauth_token_api_error.json
233
+ - test/fixtures/journey_bounces.json
234
+ - test/fixtures/journey_clicks.json
235
+ - test/fixtures/journey_opens.json
236
+ - test/fixtures/journey_recipients.json
237
+ - test/fixtures/journey_summary.json
238
+ - test/fixtures/journey_unsubscribes.json
239
+ - test/fixtures/journeys.json
231
240
  - test/fixtures/list_details.json
232
241
  - test/fixtures/list_stats.json
233
242
  - test/fixtures/list_webhooks.json
@@ -270,6 +279,7 @@ files:
270
279
  - test/fixtures/unsubscribed_subscribers.json
271
280
  - test/fixtures/update_custom_field.json
272
281
  - test/helper.rb
282
+ - test/journey_test.rb
273
283
  - test/list_test.rb
274
284
  - test/person_test.rb
275
285
  - test/segment_test.rb
@@ -349,6 +359,13 @@ test_files:
349
359
  - test/fixtures/import_subscribers.json
350
360
  - test/fixtures/import_subscribers_partial_success.json
351
361
  - test/fixtures/invalid_oauth_token_api_error.json
362
+ - test/fixtures/journey_bounces.json
363
+ - test/fixtures/journey_clicks.json
364
+ - test/fixtures/journey_opens.json
365
+ - test/fixtures/journey_recipients.json
366
+ - test/fixtures/journey_summary.json
367
+ - test/fixtures/journey_unsubscribes.json
368
+ - test/fixtures/journeys.json
352
369
  - test/fixtures/list_details.json
353
370
  - test/fixtures/list_stats.json
354
371
  - test/fixtures/list_webhooks.json
@@ -391,6 +408,7 @@ test_files:
391
408
  - test/fixtures/unsubscribed_subscribers.json
392
409
  - test/fixtures/update_custom_field.json
393
410
  - test/helper.rb
411
+ - test/journey_test.rb
394
412
  - test/list_test.rb
395
413
  - test/person_test.rb
396
414
  - test/segment_test.rb