createsend 0.0.1 → 0.0.2
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.
- data/LICENSE +19 -0
- data/README.md +63 -1
- data/createsend.gemspec +2 -2
- data/lib/campaign.rb +73 -29
- data/lib/client.rb +23 -4
- data/lib/createsend.rb +18 -7
- data/lib/list.rb +55 -13
- data/lib/segment.rb +83 -0
- data/lib/subscriber.rb +19 -1
- data/lib/template.rb +5 -0
- data/test/campaign_test.rb +88 -39
- data/test/client_test.rb +19 -9
- data/test/fixtures/active_subscribers.json +69 -67
- data/test/fixtures/bounced_subscribers.json +18 -9
- data/test/fixtures/campaign_bounces.json +25 -16
- data/test/fixtures/campaign_clicks.json +32 -23
- data/test/fixtures/campaign_listsandsegments.json +15 -0
- data/test/fixtures/campaign_opens.json +41 -32
- data/test/fixtures/campaign_recipients.json +91 -0
- data/test/fixtures/campaign_summary.json +1 -1
- data/test/fixtures/campaign_unsubscribes.json +18 -9
- data/test/fixtures/campaigns.json +2 -2
- data/test/fixtures/client_details.json +2 -1
- data/test/fixtures/create_segment.json +1 -0
- data/test/fixtures/drafts.json +4 -2
- data/test/fixtures/import_subscribers_partial_success.json +17 -0
- data/test/fixtures/segment_details.json +20 -0
- data/test/fixtures/segment_subscribers.json +25 -0
- data/test/fixtures/segments.json +4 -2
- data/test/fixtures/suppressionlist.json +36 -12
- data/test/fixtures/unsubscribed_subscribers.json +51 -21
- data/test/list_test.rb +64 -24
- data/test/segment_test.rb +75 -0
- data/test/subscriber_test.rb +19 -0
- metadata +22 -8
- data/test/fixtures/campaign_lists.json +0 -10
data/lib/segment.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
require 'createsend'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
# Represents a subscriber list segment and associated functionality.
|
5
|
+
class Segment
|
6
|
+
attr_reader :segment_id
|
7
|
+
|
8
|
+
def initialize(segment_id)
|
9
|
+
@segment_id = segment_id
|
10
|
+
end
|
11
|
+
|
12
|
+
# Creates a new segment.
|
13
|
+
def self.create(list_id, title, rules)
|
14
|
+
options = { :body => {
|
15
|
+
:Title => title,
|
16
|
+
:Rules => rules }.to_json }
|
17
|
+
response = CreateSend.post "/segments/#{list_id}.json", options
|
18
|
+
response.parsed_response
|
19
|
+
end
|
20
|
+
|
21
|
+
# Updates this segment.
|
22
|
+
def update(title, rules)
|
23
|
+
options = { :body => {
|
24
|
+
:Title => title,
|
25
|
+
:Rules => rules }.to_json }
|
26
|
+
response = CreateSend.put "/segments/#{segment_id}.json", options
|
27
|
+
end
|
28
|
+
|
29
|
+
# Adds a rule to this segment.
|
30
|
+
def add_rule(subject, clauses)
|
31
|
+
options = { :body => {
|
32
|
+
:Subject => subject,
|
33
|
+
:Clauses => clauses }.to_json }
|
34
|
+
response = CreateSend.post "/segments/#{segment_id}/rules.json", options
|
35
|
+
end
|
36
|
+
|
37
|
+
# Gets the active subscribers in this segment.
|
38
|
+
def subscribers(date, page=1, page_size=1000, order_field="email", order_direction="asc")
|
39
|
+
options = { :query => {
|
40
|
+
:date => date,
|
41
|
+
:page => page,
|
42
|
+
:pagesize => page_size,
|
43
|
+
:orderfield => order_field,
|
44
|
+
:orderdirection => order_direction } }
|
45
|
+
response = get "active", options
|
46
|
+
Hashie::Mash.new(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Gets the details of this segment
|
50
|
+
def details
|
51
|
+
response = CreateSend.get "/segments/#{segment_id}.json", {}
|
52
|
+
Hashie::Mash.new(response)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Clears all rules of this segment.
|
56
|
+
def clear_rules
|
57
|
+
response = CreateSend.delete "/segments/#{segment_id}/rules.json", {}
|
58
|
+
end
|
59
|
+
|
60
|
+
# Deletes this segment.
|
61
|
+
def delete
|
62
|
+
response = CreateSend.delete "/segments/#{segment_id}.json", {}
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def get(action, options = {})
|
68
|
+
CreateSend.get uri_for(action), options
|
69
|
+
end
|
70
|
+
|
71
|
+
def post(action, options = {})
|
72
|
+
CreateSend.post uri_for(action), options
|
73
|
+
end
|
74
|
+
|
75
|
+
def put(action, options = {})
|
76
|
+
CreateSend.put uri_for(action), options
|
77
|
+
end
|
78
|
+
|
79
|
+
def uri_for(action)
|
80
|
+
"/segments/#{segment_id}/#{action}.json"
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
data/lib/subscriber.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'createsend'
|
2
2
|
require 'json'
|
3
3
|
|
4
|
+
# Represents a subscriber and associated functionality.
|
4
5
|
class Subscriber
|
5
6
|
attr_reader :list_id
|
6
7
|
attr_reader :email_address
|
@@ -10,12 +11,14 @@ class Subscriber
|
|
10
11
|
@email_address = email_address
|
11
12
|
end
|
12
13
|
|
14
|
+
# Gets a subscriber by list ID and email address.
|
13
15
|
def self.get(list_id, email_address)
|
14
16
|
options = { :query => { :email => email_address } }
|
15
17
|
response = CreateSend.get "/subscribers/#{list_id}.json", options
|
16
18
|
Hashie::Mash.new(response)
|
17
19
|
end
|
18
20
|
|
21
|
+
# Adds a subscriber to a subscriber list.
|
19
22
|
def self.add(list_id, email_address, name, custom_fields, resubscribe)
|
20
23
|
options = { :body => {
|
21
24
|
:EmailAddress => email_address,
|
@@ -26,20 +29,35 @@ class Subscriber
|
|
26
29
|
response.parsed_response
|
27
30
|
end
|
28
31
|
|
32
|
+
# Imports subscribers into a subscriber list.
|
29
33
|
def self.import(list_id, subscribers, resubscribe)
|
30
34
|
options = { :body => {
|
31
35
|
:Subscribers => subscribers,
|
32
36
|
:Resubscribe => resubscribe }.to_json }
|
33
|
-
|
37
|
+
begin
|
38
|
+
response = CreateSend.post "/subscribers/#{list_id}/import.json", options
|
39
|
+
rescue BadRequest => br
|
40
|
+
# Subscriber import will throw BadRequest if some subscribers are not imported
|
41
|
+
# successfully. If this occurs, we want to return the ResultData property of
|
42
|
+
# the BadRequest exception (which is of the same "form" as the response we'd
|
43
|
+
# receive upon a completely successful import)
|
44
|
+
if br.data.ResultData
|
45
|
+
return br.data.ResultData
|
46
|
+
else
|
47
|
+
raise br
|
48
|
+
end
|
49
|
+
end
|
34
50
|
Hashie::Mash.new(response)
|
35
51
|
end
|
36
52
|
|
53
|
+
# Unsubscribes this subscriber from the associated list.
|
37
54
|
def unsubscribe
|
38
55
|
options = { :body => {
|
39
56
|
:EmailAddress => @email_address }.to_json }
|
40
57
|
CreateSend.post "/subscribers/#{@list_id}/unsubscribe.json", options
|
41
58
|
end
|
42
59
|
|
60
|
+
# Gets the historical record of this subscriber's trackable actions.
|
43
61
|
def history
|
44
62
|
options = { :query => { :email => @email_address } }
|
45
63
|
response = CreateSend.get "/subscribers/#{@list_id}/history.json", options
|
data/lib/template.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'createsend'
|
2
2
|
require 'json'
|
3
3
|
|
4
|
+
# Represents an email template and associated functionality.
|
4
5
|
class Template
|
5
6
|
attr_reader :template_id
|
6
7
|
|
@@ -8,6 +9,7 @@ class Template
|
|
8
9
|
@template_id = template_id
|
9
10
|
end
|
10
11
|
|
12
|
+
# Creates a new email template.
|
11
13
|
def self.create(client_id, name, html_url, zip_url, screenshot_url)
|
12
14
|
options = { :body => {
|
13
15
|
:Name => name,
|
@@ -18,11 +20,13 @@ class Template
|
|
18
20
|
response.parsed_response
|
19
21
|
end
|
20
22
|
|
23
|
+
# Gets the details of this email template.
|
21
24
|
def details
|
22
25
|
response = CreateSend.get "/templates/#{template_id}.json", {}
|
23
26
|
Hashie::Mash.new(response)
|
24
27
|
end
|
25
28
|
|
29
|
+
# Updates this email template.
|
26
30
|
def update(name, html_url, zip_url, screenshot_url)
|
27
31
|
options = { :body => {
|
28
32
|
:Name => name,
|
@@ -32,6 +36,7 @@ class Template
|
|
32
36
|
response = CreateSend.put "/templates/#{template_id}.json", options
|
33
37
|
end
|
34
38
|
|
39
|
+
# Deletes this email template.
|
35
40
|
def delete
|
36
41
|
response = CreateSend.delete "/templates/#{template_id}.json", {}
|
37
42
|
end
|
data/test/campaign_test.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
|
-
class
|
3
|
+
class CampaignTest < Test::Unit::TestCase
|
4
4
|
context "when an api caller is authenticated" do
|
5
5
|
setup do
|
6
6
|
@api_key = '123123123123123123123'
|
@@ -12,10 +12,16 @@ class ClientTest < Test::Unit::TestCase
|
|
12
12
|
client_id = '87y8d7qyw8d7yq8w7ydwqwd'
|
13
13
|
stub_post(@api_key, "campaigns/#{client_id}.json", "create_campaign.json")
|
14
14
|
campaign_id = Campaign.create client_id, "subject", "name", "g'day", "good.day@example.com", "good.day@example.com",
|
15
|
-
"http://example.com/campaign.html", "http://example.com/campaign.txt", [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ],
|
15
|
+
"http://example.com/campaign.html", "http://example.com/campaign.txt", [ '7y12989e82ue98u2e', 'dh9w89q8w98wudwd989' ],
|
16
|
+
[ 'y78q9w8d9w8ud9q8uw', 'djw98quw9duqw98uwd98' ]
|
16
17
|
campaign_id.should == "787y87y87y87y87y87y87"
|
17
18
|
end
|
18
|
-
|
19
|
+
|
20
|
+
should "send a preview of a draft campaign" do
|
21
|
+
stub_post(@api_key, "campaigns/#{@campaign.campaign_id}/sendpreview.json", nil)
|
22
|
+
@campaign.send_preview [ "test+89898u9@example.com", "test+787y8y7y8@example.com" ], "random"
|
23
|
+
end
|
24
|
+
|
19
25
|
should "send a campaign" do
|
20
26
|
stub_post(@api_key, "campaigns/#{@campaign.campaign_id}/send.json", nil)
|
21
27
|
@campaign.send "confirmation@example.com"
|
@@ -35,64 +41,107 @@ class ClientTest < Test::Unit::TestCase
|
|
35
41
|
summary.Unsubscribed.should == 0
|
36
42
|
summary.Bounced.should == 0
|
37
43
|
summary.UniqueOpened.should == 5
|
38
|
-
summary.WebVersionURL.should == "http://clientone.createsend.com
|
44
|
+
summary.WebVersionURL.should == "http://clientone.createsend.com/t/ViewEmail/r/3A433FC72FFE3B8B/C67FD2F38AC4859C/"
|
39
45
|
end
|
40
46
|
|
41
|
-
should "get the lists for a campaign" do
|
42
|
-
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
+
should "get the lists and segments for a campaign" do
|
48
|
+
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/listsandsegments.json", "campaign_listsandsegments.json")
|
49
|
+
ls = @campaign.lists_and_segments
|
50
|
+
ls.Lists.size.should == 1
|
51
|
+
ls.Segments.size.should == 1
|
52
|
+
ls.Lists.first.Name.should == "List One"
|
53
|
+
ls.Lists.first.ListID.should == "a58ee1d3039b8bec838e6d1482a8a965"
|
54
|
+
ls.Segments.first.Title.should == "Segment for campaign"
|
55
|
+
ls.Segments.first.ListID.should == "2bea949d0bf96148c3e6a209d2e82060"
|
56
|
+
ls.Segments.first.SegmentID.should == "dba84a225d5ce3d19105d7257baac46f"
|
47
57
|
end
|
48
58
|
|
49
|
-
|
50
|
-
|
51
|
-
|
59
|
+
should "get the recipients for a campaign" do
|
60
|
+
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/recipients.json?pagesize=20&orderfield=email&page=1&orderdirection=asc", "campaign_recipients.json")
|
61
|
+
res = @campaign.recipients page=1, page_size=20
|
62
|
+
res.ResultsOrderedBy.should == "email"
|
63
|
+
res.OrderDirection.should == "asc"
|
64
|
+
res.PageNumber.should == 1
|
65
|
+
res.PageSize.should == 20
|
66
|
+
res.RecordsOnThisPage.should == 20
|
67
|
+
res.TotalNumberOfRecords.should == 2200
|
68
|
+
res.NumberOfPages.should == 110
|
69
|
+
res.Results.size.should == 20
|
70
|
+
res.Results.first.EmailAddress.should == "subs+6g76t7t0@example.com"
|
71
|
+
res.Results.first.ListID.should == "a994a3caf1328a16af9a69a730eaa706"
|
72
|
+
end
|
52
73
|
|
53
74
|
should "get the opens for a campaign" do
|
54
75
|
min_date = "2010-01-01"
|
55
|
-
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/opens.json?date=#{CGI.escape(min_date)}", "campaign_opens.json")
|
76
|
+
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/opens.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_opens.json")
|
56
77
|
opens = @campaign.opens min_date
|
57
|
-
opens.size.should == 5
|
58
|
-
opens.first.EmailAddress.should == "subs+6576576576@example.com"
|
59
|
-
opens.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
|
60
|
-
opens.first.Date.should == "2010-10-11 08:29:00"
|
61
|
-
opens.first.IPAddress.should == "192.168.126.87"
|
78
|
+
opens.Results.size.should == 5
|
79
|
+
opens.Results.first.EmailAddress.should == "subs+6576576576@example.com"
|
80
|
+
opens.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
|
81
|
+
opens.Results.first.Date.should == "2010-10-11 08:29:00"
|
82
|
+
opens.Results.first.IPAddress.should == "192.168.126.87"
|
83
|
+
opens.ResultsOrderedBy.should == "date"
|
84
|
+
opens.OrderDirection.should == "asc"
|
85
|
+
opens.PageNumber.should == 1
|
86
|
+
opens.PageSize.should == 1000
|
87
|
+
opens.RecordsOnThisPage.should == 5
|
88
|
+
opens.TotalNumberOfRecords.should == 5
|
89
|
+
opens.NumberOfPages.should == 1
|
62
90
|
end
|
63
91
|
|
64
92
|
should "get the subscriber clicks for a campaign" do
|
65
93
|
min_date = "2010-01-01"
|
66
|
-
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/clicks.json?date=#{CGI.escape(min_date)}", "campaign_clicks.json")
|
94
|
+
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/clicks.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_clicks.json")
|
67
95
|
clicks = @campaign.clicks min_date
|
68
|
-
clicks.size.should == 3
|
69
|
-
clicks.first.EmailAddress.should == "subs+6576576576@example.com"
|
70
|
-
clicks.first.URL.should == "http://video.google.com.au/?hl=en&tab=wv"
|
71
|
-
clicks.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
|
72
|
-
clicks.first.Date.should == "2010-10-11 08:29:00"
|
73
|
-
clicks.first.IPAddress.should == "192.168.126.87"
|
96
|
+
clicks.Results.size.should == 3
|
97
|
+
clicks.Results.first.EmailAddress.should == "subs+6576576576@example.com"
|
98
|
+
clicks.Results.first.URL.should == "http://video.google.com.au/?hl=en&tab=wv"
|
99
|
+
clicks.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
|
100
|
+
clicks.Results.first.Date.should == "2010-10-11 08:29:00"
|
101
|
+
clicks.Results.first.IPAddress.should == "192.168.126.87"
|
102
|
+
clicks.ResultsOrderedBy.should == "date"
|
103
|
+
clicks.OrderDirection.should == "asc"
|
104
|
+
clicks.PageNumber.should == 1
|
105
|
+
clicks.PageSize.should == 1000
|
106
|
+
clicks.RecordsOnThisPage.should == 3
|
107
|
+
clicks.TotalNumberOfRecords.should == 3
|
108
|
+
clicks.NumberOfPages.should == 1
|
74
109
|
end
|
75
110
|
|
76
111
|
should "get the unsubscribes for a campaign" do
|
77
112
|
min_date = "2010-01-01"
|
78
|
-
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/unsubscribes.json?date=#{CGI.escape(min_date)}", "campaign_unsubscribes.json")
|
113
|
+
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/unsubscribes.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc&date=#{CGI.escape(min_date)}", "campaign_unsubscribes.json")
|
79
114
|
unsubscribes = @campaign.unsubscribes min_date
|
80
|
-
unsubscribes.size.should == 1
|
81
|
-
unsubscribes.first.EmailAddress.should == "subs+6576576576@example.com"
|
82
|
-
unsubscribes.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
|
83
|
-
unsubscribes.first.Date.should == "2010-10-11 08:29:00"
|
84
|
-
unsubscribes.first.IPAddress.should == "192.168.126.87"
|
115
|
+
unsubscribes.Results.size.should == 1
|
116
|
+
unsubscribes.Results.first.EmailAddress.should == "subs+6576576576@example.com"
|
117
|
+
unsubscribes.Results.first.ListID.should == "512a3bc577a58fdf689c654329b50fa0"
|
118
|
+
unsubscribes.Results.first.Date.should == "2010-10-11 08:29:00"
|
119
|
+
unsubscribes.Results.first.IPAddress.should == "192.168.126.87"
|
120
|
+
unsubscribes.ResultsOrderedBy.should == "date"
|
121
|
+
unsubscribes.OrderDirection.should == "asc"
|
122
|
+
unsubscribes.PageNumber.should == 1
|
123
|
+
unsubscribes.PageSize.should == 1000
|
124
|
+
unsubscribes.RecordsOnThisPage.should == 1
|
125
|
+
unsubscribes.TotalNumberOfRecords.should == 1
|
126
|
+
unsubscribes.NumberOfPages.should == 1
|
85
127
|
end
|
86
128
|
|
87
129
|
should "get the bounces for a campaign" do
|
88
|
-
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/bounces.json", "campaign_bounces.json")
|
130
|
+
stub_get(@api_key, "campaigns/#{@campaign.campaign_id}/bounces.json?page=1&pagesize=1000&orderfield=date&orderdirection=asc", "campaign_bounces.json")
|
89
131
|
bounces = @campaign.bounces
|
90
|
-
bounces.size.should == 2
|
91
|
-
bounces.first.EmailAddress.should == "asdf@softbouncemyemail.com"
|
92
|
-
bounces.first.ListID.should == "654523a5855b4a440bae3fb295641546"
|
93
|
-
bounces.first.BounceType.should == "Soft"
|
94
|
-
bounces.first.Date.should == "2010-07-02 16:46:00"
|
95
|
-
bounces.first.Reason.should == "Bounce - But No Email Address Returned "
|
132
|
+
bounces.Results.size.should == 2
|
133
|
+
bounces.Results.first.EmailAddress.should == "asdf@softbouncemyemail.com"
|
134
|
+
bounces.Results.first.ListID.should == "654523a5855b4a440bae3fb295641546"
|
135
|
+
bounces.Results.first.BounceType.should == "Soft"
|
136
|
+
bounces.Results.first.Date.should == "2010-07-02 16:46:00"
|
137
|
+
bounces.Results.first.Reason.should == "Bounce - But No Email Address Returned "
|
138
|
+
bounces.ResultsOrderedBy.should == "date"
|
139
|
+
bounces.OrderDirection.should == "asc"
|
140
|
+
bounces.PageNumber.should == 1
|
141
|
+
bounces.PageSize.should == 1000
|
142
|
+
bounces.RecordsOnThisPage.should == 2
|
143
|
+
bounces.TotalNumberOfRecords.should == 2
|
144
|
+
bounces.NumberOfPages.should == 1
|
96
145
|
end
|
97
146
|
end
|
98
147
|
end
|
data/test/client_test.rb
CHANGED
@@ -17,6 +17,7 @@ class ClientTest < Test::Unit::TestCase
|
|
17
17
|
should "get details of a client" do
|
18
18
|
stub_get(@api_key, "clients/#{@client.client_id}.json", "client_details.json")
|
19
19
|
cl = @client.details
|
20
|
+
cl.ApiKey.should == "639d8cc27198202f5fe6037a8b17a29a59984b86d3289bc9"
|
20
21
|
cl.BasicDetails.ClientID.should == "4a397ccaaa55eb4e6aa1221e1e2d7122"
|
21
22
|
cl.BasicDetails.ContactName.should == "Client One (contact)"
|
22
23
|
cl.AccessDetails.Username.should == "clientone"
|
@@ -28,7 +29,7 @@ class ClientTest < Test::Unit::TestCase
|
|
28
29
|
campaigns = @client.campaigns
|
29
30
|
campaigns.size.should == 2
|
30
31
|
campaigns.first.CampaignID.should == 'fc0ce7105baeaf97f47c99be31d02a91'
|
31
|
-
campaigns.first.WebVersionURL.should == 'http://hello.createsend.com
|
32
|
+
campaigns.first.WebVersionURL.should == 'http://hello.createsend.com/t/ViewEmail/r/765E86829575EE2C/C67FD2F38AC4859C/'
|
32
33
|
campaigns.first.Subject.should == 'Campaign One'
|
33
34
|
campaigns.first.Name.should == 'Campaign One'
|
34
35
|
campaigns.first.SentDate.should == '2010-10-12 12:58:00'
|
@@ -43,6 +44,7 @@ class ClientTest < Test::Unit::TestCase
|
|
43
44
|
drafts.first.Name.should == 'Draft One'
|
44
45
|
drafts.first.Subject.should == 'Draft One'
|
45
46
|
drafts.first.DateCreated.should == '2010-08-19 16:08:00'
|
47
|
+
drafts.first.PreviewURL.should == 'http://hello.createsend.com/t/ViewEmail/r/E97A7BB2E6983DA1/C67FD2F38AC4859C/'
|
46
48
|
end
|
47
49
|
|
48
50
|
should "get all lists" do
|
@@ -53,21 +55,29 @@ class ClientTest < Test::Unit::TestCase
|
|
53
55
|
lists.first.Name.should == 'List One'
|
54
56
|
end
|
55
57
|
|
56
|
-
should "get all segments" do
|
58
|
+
should "get all segments for a client" do
|
57
59
|
stub_get(@api_key, "clients/#{@client.client_id}/segments.json", "segments.json")
|
58
60
|
segments = @client.segments
|
59
61
|
segments.size.should == 2
|
60
62
|
segments.first.ListID.should == 'a58ee1d3039b8bec838e6d1482a8a965'
|
61
|
-
segments.first.
|
63
|
+
segments.first.SegmentID.should == '46aa5e01fd43381863d4e42cf277d3a9'
|
64
|
+
segments.first.Title.should == 'Segment One'
|
62
65
|
end
|
63
66
|
|
64
67
|
should "get suppression list" do
|
65
|
-
stub_get(@api_key, "clients/#{@client.client_id}/suppressionlist.json", "suppressionlist.json")
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
68
|
+
stub_get(@api_key, "clients/#{@client.client_id}/suppressionlist.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc", "suppressionlist.json")
|
69
|
+
res = @client.suppressionlist
|
70
|
+
res.ResultsOrderedBy.should == "email"
|
71
|
+
res.OrderDirection.should == "asc"
|
72
|
+
res.PageNumber.should == 1
|
73
|
+
res.PageSize.should == 1000
|
74
|
+
res.RecordsOnThisPage.should == 5
|
75
|
+
res.TotalNumberOfRecords.should == 5
|
76
|
+
res.NumberOfPages.should == 1
|
77
|
+
res.Results.size.should == 5
|
78
|
+
res.Results.first.EmailAddress.should == "example+1@example.com"
|
79
|
+
res.Results.first.Date.should == "2010-10-26 10:55:31"
|
80
|
+
res.Results.first.State.should == "Suppressed"
|
71
81
|
end
|
72
82
|
|
73
83
|
should "get all templates" do
|
@@ -1,67 +1,69 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
1
|
+
{
|
2
|
+
"Results": [
|
3
|
+
{
|
4
|
+
"EmailAddress": "subs+7t8787Y@example.com",
|
5
|
+
"Name": "Person One",
|
6
|
+
"Date": "2010-10-25 10:28:00",
|
7
|
+
"State": "Active",
|
8
|
+
"CustomFields": [
|
9
|
+
{
|
10
|
+
"Key": "website",
|
11
|
+
"Value": "http://example.com"
|
12
|
+
},
|
13
|
+
{
|
14
|
+
"Key": "age",
|
15
|
+
"Value": "24"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"Key": "subscription date",
|
19
|
+
"Value": "2010-03-09"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
},
|
23
|
+
{
|
24
|
+
"EmailAddress": "subs+7878787y8ggg@example.com",
|
25
|
+
"Name": "Person Two",
|
26
|
+
"Date": "2010-10-25 12:17:00",
|
27
|
+
"State": "Active",
|
28
|
+
"CustomFields": [
|
29
|
+
{
|
30
|
+
"Key": "website",
|
31
|
+
"Value": "http://subdomain.example.com"
|
32
|
+
}
|
33
|
+
]
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"EmailAddress": "subs+7890909i0ggg@example.com",
|
37
|
+
"Name": "Person Three",
|
38
|
+
"Date": "2010-10-25 12:52:00",
|
39
|
+
"State": "Active",
|
40
|
+
"CustomFields": [
|
41
|
+
{
|
42
|
+
"Key": "website",
|
43
|
+
"Value": "http://subdomain.example.com"
|
44
|
+
}
|
45
|
+
]
|
46
|
+
},
|
47
|
+
{
|
48
|
+
"EmailAddress": "subs@example.com",
|
49
|
+
"Name": "Person Four",
|
50
|
+
"Date": "2010-10-27 13:13:00",
|
51
|
+
"State": "Active",
|
52
|
+
"CustomFields": []
|
53
|
+
},
|
54
|
+
{
|
55
|
+
"EmailAddress": "joey@example.com",
|
56
|
+
"Name": "Person Five",
|
57
|
+
"Date": "2010-10-27 13:13:00",
|
58
|
+
"State": "Active",
|
59
|
+
"CustomFields": []
|
60
|
+
}
|
61
|
+
],
|
62
|
+
"ResultsOrderedBy": "email",
|
63
|
+
"OrderDirection": "asc",
|
64
|
+
"PageNumber": 1,
|
65
|
+
"PageSize": 1000,
|
66
|
+
"RecordsOnThisPage": 5,
|
67
|
+
"TotalNumberOfRecords": 5,
|
68
|
+
"NumberOfPages": 1
|
69
|
+
}
|