createsend-sendowlfork 6.1.0.pre.hashie5
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.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +9 -0
- data/.travis.yml +7 -0
- data/CONTRIBUTING.md +8 -0
- data/Gemfile +3 -0
- data/HISTORY.md +299 -0
- data/LICENSE +19 -0
- data/README.md +220 -0
- data/RELEASE.md +53 -0
- data/Rakefile +24 -0
- data/createsend.gemspec +31 -0
- data/lib/createsend/administrator.rb +49 -0
- data/lib/createsend/cacert.pem +3849 -0
- data/lib/createsend/campaign.rb +202 -0
- data/lib/createsend/client.rb +224 -0
- data/lib/createsend/createsend.rb +291 -0
- data/lib/createsend/journey.rb +58 -0
- data/lib/createsend/list.rb +258 -0
- data/lib/createsend/person.rb +59 -0
- data/lib/createsend/segment.rb +81 -0
- data/lib/createsend/subscriber.rb +113 -0
- data/lib/createsend/template.rb +42 -0
- data/lib/createsend/transactional_classic_email.rb +32 -0
- data/lib/createsend/transactional_smart_email.rb +31 -0
- data/lib/createsend/transactional_timeline.rb +45 -0
- data/lib/createsend/version.rb +3 -0
- data/lib/createsend.rb +17 -0
- data/samples/authentication_sample.rb +64 -0
- data/samples/clients_sample.rb +79 -0
- data/samples/journey_sample.rb +87 -0
- data/samples/lists_sample.rb +51 -0
- data/samples/segments_sample.rb +21 -0
- data/samples/subscribers_sample.rb +51 -0
- data/test/administrator_test.rb +37 -0
- data/test/campaign_test.rb +296 -0
- data/test/client_test.rb +253 -0
- data/test/createsend_test.rb +321 -0
- data/test/fixtures/active_subscribers.json +87 -0
- data/test/fixtures/add_admin.json +3 -0
- data/test/fixtures/add_person.json +3 -0
- data/test/fixtures/add_subscriber.json +1 -0
- data/test/fixtures/admin_details.json +5 -0
- data/test/fixtures/admin_get_primary_contact.json +3 -0
- data/test/fixtures/admin_set_primary_contact.json +3 -0
- data/test/fixtures/administrators.json +12 -0
- data/test/fixtures/billingdetails.json +3 -0
- data/test/fixtures/bounced_subscribers.json +20 -0
- data/test/fixtures/campaign_bounces.json +25 -0
- data/test/fixtures/campaign_clicks.json +50 -0
- data/test/fixtures/campaign_listsandsegments.json +15 -0
- data/test/fixtures/campaign_opens.json +71 -0
- data/test/fixtures/campaign_recipients.json +91 -0
- data/test/fixtures/campaign_spam.json +16 -0
- data/test/fixtures/campaign_summary.json +16 -0
- data/test/fixtures/campaign_unsubscribes.json +17 -0
- data/test/fixtures/campaigns.json +37 -0
- data/test/fixtures/client_details.json +28 -0
- data/test/fixtures/client_get_primary_contact.json +3 -0
- data/test/fixtures/client_set_primary_contact.json +3 -0
- data/test/fixtures/clients.json +10 -0
- data/test/fixtures/countries.json +247 -0
- data/test/fixtures/create_campaign.json +1 -0
- data/test/fixtures/create_client.json +1 -0
- data/test/fixtures/create_custom_field.json +1 -0
- data/test/fixtures/create_list.json +1 -0
- data/test/fixtures/create_list_webhook.json +1 -0
- data/test/fixtures/create_segment.json +1 -0
- data/test/fixtures/create_template.json +1 -0
- data/test/fixtures/custom_api_error.json +4 -0
- data/test/fixtures/custom_fields.json +23 -0
- data/test/fixtures/deleted_subscribers.json +61 -0
- data/test/fixtures/drafts.json +26 -0
- data/test/fixtures/email_client_usage.json +38 -0
- data/test/fixtures/expired_oauth_token_api_error.json +4 -0
- data/test/fixtures/external_session.json +3 -0
- data/test/fixtures/import_subscribers.json +7 -0
- data/test/fixtures/import_subscribers_partial_success.json +17 -0
- data/test/fixtures/invalid_oauth_token_api_error.json +4 -0
- data/test/fixtures/journey_bounces.json +35 -0
- data/test/fixtures/journey_clicks.json +35 -0
- data/test/fixtures/journey_opens.json +55 -0
- data/test/fixtures/journey_recipients.json +27 -0
- data/test/fixtures/journey_summary.json +18 -0
- data/test/fixtures/journey_unsubscribes.json +26 -0
- data/test/fixtures/journeys.json +20 -0
- data/test/fixtures/list_details.json +8 -0
- data/test/fixtures/list_stats.json +26 -0
- data/test/fixtures/list_webhooks.json +18 -0
- data/test/fixtures/lists.json +10 -0
- data/test/fixtures/listsforemail.json +14 -0
- data/test/fixtures/oauth_exchange_token.json +5 -0
- data/test/fixtures/oauth_exchange_token_error.json +4 -0
- data/test/fixtures/oauth_refresh_token_error.json +4 -0
- data/test/fixtures/people.json +14 -0
- data/test/fixtures/person_details.json +6 -0
- data/test/fixtures/refresh_oauth_token.json +5 -0
- data/test/fixtures/revoked_oauth_token_api_error.json +4 -0
- data/test/fixtures/scheduled_campaigns.json +30 -0
- data/test/fixtures/segment_details.json +24 -0
- data/test/fixtures/segment_subscribers.json +27 -0
- data/test/fixtures/segments.json +12 -0
- data/test/fixtures/subscriber_details.json +23 -0
- data/test/fixtures/subscriber_details_with_track_and_sms_pref.json +25 -0
- data/test/fixtures/subscriber_history.json +45 -0
- data/test/fixtures/suppressionlist.json +41 -0
- data/test/fixtures/systemdate.json +3 -0
- data/test/fixtures/tags.json +10 -0
- data/test/fixtures/template_details.json +6 -0
- data/test/fixtures/templates.json +14 -0
- data/test/fixtures/timezones.json +99 -0
- data/test/fixtures/transfer_credits.json +4 -0
- data/test/fixtures/tx_classicemail_groups.json +14 -0
- data/test/fixtures/tx_message_details.json +36 -0
- data/test/fixtures/tx_message_details_with_statistics.json +72 -0
- data/test/fixtures/tx_messages.json +38 -0
- data/test/fixtures/tx_messages_classic.json +15 -0
- data/test/fixtures/tx_messages_smart.json +15 -0
- data/test/fixtures/tx_resend_message.json +6 -0
- data/test/fixtures/tx_send_multiple.json +12 -0
- data/test/fixtures/tx_send_single.json +7 -0
- data/test/fixtures/tx_smartemail_details.json +23 -0
- data/test/fixtures/tx_smartemails.json +15 -0
- data/test/fixtures/tx_statistics_classic.json +14 -0
- data/test/fixtures/tx_statistics_smart.json +14 -0
- data/test/fixtures/unconfirmed_subscribers.json +43 -0
- data/test/fixtures/unsubscribed_subscribers.json +61 -0
- data/test/fixtures/update_custom_field.json +1 -0
- data/test/helper.rb +79 -0
- data/test/journey_test.rb +156 -0
- data/test/list_test.rb +288 -0
- data/test/person_test.rb +39 -0
- data/test/segment_test.rb +74 -0
- data/test/subscriber_test.rb +177 -0
- data/test/template_test.rb +36 -0
- data/test/transactional_classic_email_test.rb +60 -0
- data/test/transactional_smart_email_test.rb +83 -0
- data/test/transactional_timeline_test.rb +110 -0
- metadata +431 -0
@@ -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 be == 'New journey'
|
14
|
+
summary.TriggerType.should be == 'On Subscription'
|
15
|
+
summary.Status.should be == 'Active'
|
16
|
+
|
17
|
+
summary.Emails.size.should be == 1
|
18
|
+
summary.Emails.first.EmailID.should be == 'b1b1b1b1b1b1b1b1b1b1'
|
19
|
+
summary.Emails.first.Name.should be == 'New Email'
|
20
|
+
summary.Emails.first.Bounced.should be == 0
|
21
|
+
summary.Emails.first.Clicked.should be == 0
|
22
|
+
summary.Emails.first.Opened.should be == 3
|
23
|
+
summary.Emails.first.Sent.should be == 1
|
24
|
+
summary.Emails.first.UniqueOpened.should be == 1
|
25
|
+
summary.Emails.first.Unsubscribed.should be == 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 be == 4
|
38
|
+
recipients.Results.first.EmailAddress.should be == 'example+1@example.com'
|
39
|
+
recipients.Results.first.SentDate.should be == '2019-07-12 09:45:00'
|
40
|
+
|
41
|
+
recipients.ResultsOrderedBy.should be == 'SentDate'
|
42
|
+
recipients.OrderDirection.should be == 'ASC'
|
43
|
+
recipients.PageNumber.should be == 2
|
44
|
+
recipients.PageSize.should be == 10
|
45
|
+
recipients.RecordsOnThisPage.should be == 4
|
46
|
+
recipients.TotalNumberOfRecords.should be == 14
|
47
|
+
recipients.NumberOfPages.should be == 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 be == 4
|
60
|
+
opens.Results.last.EmailAddress.should be == "example+4@example.com"
|
61
|
+
opens.Results.last.Date.should be == "2019-07-29 10:35:00"
|
62
|
+
opens.Results.last.IPAddress.should be == "192.168.0.3"
|
63
|
+
opens.Results.last.Latitude.should be == -33.8683
|
64
|
+
opens.Results.last.Longitude.should be == 151.2086
|
65
|
+
opens.Results.last.City.should be == "Sydney"
|
66
|
+
opens.Results.last.Region.should be == "New South Wales"
|
67
|
+
opens.Results.last.CountryCode.should be == "AU"
|
68
|
+
opens.Results.last.CountryName.should be == "Australia"
|
69
|
+
|
70
|
+
opens.ResultsOrderedBy.should be == "Date"
|
71
|
+
opens.OrderDirection.should be == "ASC"
|
72
|
+
opens.PageNumber.should be == 1
|
73
|
+
opens.PageSize.should be == 1000
|
74
|
+
opens.RecordsOnThisPage.should be == 4
|
75
|
+
opens.TotalNumberOfRecords.should be == 4
|
76
|
+
opens.NumberOfPages.should be == 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 be == 2
|
89
|
+
clicks.Results.first.EmailAddress.should be == "example+1@example.com"
|
90
|
+
clicks.Results.first.Date.should be == "2019-07-29 10:33:00"
|
91
|
+
clicks.Results.first.URL.should be == "http://test.com"
|
92
|
+
clicks.Results.first.IPAddress.should be == "192.168.0.3"
|
93
|
+
clicks.Results.first.Latitude.should be == -33.8683
|
94
|
+
clicks.Results.first.Longitude.should be == 151.2086
|
95
|
+
clicks.Results.first.City.should be == "Sydney"
|
96
|
+
clicks.Results.first.Region.should be == "New South Wales"
|
97
|
+
clicks.Results.first.CountryCode.should be == "AU"
|
98
|
+
clicks.Results.first.CountryName.should be == "Australia"
|
99
|
+
|
100
|
+
clicks.ResultsOrderedBy.should be == "Date"
|
101
|
+
clicks.OrderDirection.should be == "ASC"
|
102
|
+
clicks.PageNumber.should be == 1
|
103
|
+
clicks.PageSize.should be == 2
|
104
|
+
clicks.RecordsOnThisPage.should be == 2
|
105
|
+
clicks.TotalNumberOfRecords.should be == 5
|
106
|
+
clicks.NumberOfPages.should be == 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 be == 3
|
119
|
+
unsubscribes.Results.first.EmailAddress.should be == "example+1@example.com"
|
120
|
+
unsubscribes.Results.first.Date.should be == "2019-07-29 10:33:00"
|
121
|
+
unsubscribes.Results.first.IPAddress.should be == "192.168.0.3"
|
122
|
+
|
123
|
+
unsubscribes.ResultsOrderedBy.should be == "Date"
|
124
|
+
unsubscribes.OrderDirection.should be == "ASC"
|
125
|
+
unsubscribes.PageNumber.should be == 1
|
126
|
+
unsubscribes.PageSize.should be == 1000
|
127
|
+
unsubscribes.RecordsOnThisPage.should be == 4
|
128
|
+
unsubscribes.TotalNumberOfRecords.should be == 4
|
129
|
+
unsubscribes.NumberOfPages.should be == 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 be == 4
|
142
|
+
bounces.Results.first.EmailAddress.should be == "example+1@example.com"
|
143
|
+
bounces.Results.first.BounceType.should be == "4"
|
144
|
+
bounces.Results.first.Date.should be == "2019-07-29 10:33:00"
|
145
|
+
bounces.Results.first.Reason.should be == "Soft Bounce - Mailbox Full"
|
146
|
+
|
147
|
+
bounces.ResultsOrderedBy.should be == "Date"
|
148
|
+
bounces.OrderDirection.should be == "ASC"
|
149
|
+
bounces.PageNumber.should be == 1
|
150
|
+
bounces.PageSize.should be == 1000
|
151
|
+
bounces.RecordsOnThisPage.should be == 4
|
152
|
+
bounces.TotalNumberOfRecords.should be == 4
|
153
|
+
bounces.NumberOfPages.should be == 1
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
data/test/list_test.rb
ADDED
@@ -0,0 +1,288 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class ListTest < Test::Unit::TestCase
|
4
|
+
multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
|
5
|
+
setup do
|
6
|
+
@client_id = "87y8d7qyw8d7yq8w7ydwqwd"
|
7
|
+
@list_id = "e3c5f034d68744f7881fdccf13c2daee"
|
8
|
+
@list = CreateSend::List.new @auth, @list_id
|
9
|
+
end
|
10
|
+
|
11
|
+
should "create a list without passing in unsubscribe setting" do
|
12
|
+
stub_post(@auth, "lists/#{@client_id}.json", "create_list.json")
|
13
|
+
list_id = CreateSend::List.create @auth, @client_id, "List One", "", false, ""
|
14
|
+
list_id.should be == "e3c5f034d68744f7881fdccf13c2daee"
|
15
|
+
end
|
16
|
+
|
17
|
+
should "create a list passing in unsubscribe setting" do
|
18
|
+
stub_post(@auth, "lists/#{@client_id}.json", "create_list.json")
|
19
|
+
list_id = CreateSend::List.create @auth, @client_id, "List One", "", false, "", "OnlyThisList"
|
20
|
+
list_id.should be == "e3c5f034d68744f7881fdccf13c2daee"
|
21
|
+
end
|
22
|
+
|
23
|
+
should "update a list without passing in unsubscribe setting" do
|
24
|
+
stub_put(@auth, "lists/#{@list.list_id}.json", nil)
|
25
|
+
@list.update "List One Renamed", "", false, ""
|
26
|
+
end
|
27
|
+
|
28
|
+
should "update a list passing in unsubscribe setting" do
|
29
|
+
stub_put(@auth, "lists/#{@list.list_id}.json", nil)
|
30
|
+
@list.update "List One Renamed", "", false, "", "OnlyThisList"
|
31
|
+
end
|
32
|
+
|
33
|
+
should "update a list passing in unsubscribe setting and suppression list options" do
|
34
|
+
stub_put(@auth, "lists/#{@list.list_id}.json", nil)
|
35
|
+
@list.update "List One Renamed", "", false, "", "OnlyThisList", true, true
|
36
|
+
end
|
37
|
+
|
38
|
+
should "delete a list" do
|
39
|
+
stub_delete(@auth, "lists/#{@list.list_id}.json", nil)
|
40
|
+
@list.delete
|
41
|
+
end
|
42
|
+
|
43
|
+
should "create a custom field" do
|
44
|
+
stub_post(@auth, "lists/#{@list.list_id}/customfields.json", "create_custom_field.json")
|
45
|
+
personalisation_tag = @list.create_custom_field "new date field", "Date"
|
46
|
+
request = FakeWeb.last_request.body
|
47
|
+
request.include?("\"FieldName\":\"new date field\"").should be == true
|
48
|
+
request.include?("\"DataType\":\"Date\"").should be == true
|
49
|
+
request.include?("\"Options\":[]").should be == true
|
50
|
+
request.include?("\"VisibleInPreferenceCenter\":true").should be == true
|
51
|
+
personalisation_tag.should be == "[newdatefield]"
|
52
|
+
end
|
53
|
+
|
54
|
+
should "create a custom field with options and visible_in_preference_center" do
|
55
|
+
stub_post(@auth, "lists/#{@list.list_id}/customfields.json", "create_custom_field.json")
|
56
|
+
options = ["one", "two"]
|
57
|
+
personalisation_tag = @list.create_custom_field("newsletter format",
|
58
|
+
"MultiSelectOne", options, false)
|
59
|
+
request = FakeWeb.last_request.body
|
60
|
+
request.include?("\"FieldName\":\"newsletter format\"").should be == true
|
61
|
+
request.include?("\"DataType\":\"MultiSelectOne\"").should be == true
|
62
|
+
request.include?("\"Options\":[\"one\",\"two\"]").should be == true
|
63
|
+
request.include?("\"VisibleInPreferenceCenter\":false").should be == true
|
64
|
+
personalisation_tag.should be == "[newdatefield]"
|
65
|
+
end
|
66
|
+
|
67
|
+
should "update a custom field" do
|
68
|
+
key = "[mycustomfield]"
|
69
|
+
stub_put(@auth, "lists/#{@list.list_id}/customfields/#{ERB::Util.url_encode(key)}.json", "update_custom_field.json")
|
70
|
+
personalisation_tag = @list.update_custom_field key, "my renamed custom field", true
|
71
|
+
request = FakeWeb.last_request.body
|
72
|
+
request.include?("\"FieldName\":\"my renamed custom field\"").should be == true
|
73
|
+
request.include?("\"VisibleInPreferenceCenter\":true").should be == true
|
74
|
+
personalisation_tag.should be == "[myrenamedcustomfield]"
|
75
|
+
end
|
76
|
+
|
77
|
+
should "delete a custom field" do
|
78
|
+
custom_field_key = "[newdatefield]"
|
79
|
+
stub_delete(@auth, "lists/#{@list.list_id}/customfields/#{ERB::Util.url_encode(custom_field_key)}.json", nil)
|
80
|
+
@list.delete_custom_field custom_field_key
|
81
|
+
end
|
82
|
+
|
83
|
+
should "update the options of a multi-optioned custom field" do
|
84
|
+
custom_field_key = "[newdatefield]"
|
85
|
+
new_options = [ "one", "two", "three" ]
|
86
|
+
stub_put(@auth, "lists/#{@list.list_id}/customfields/#{ERB::Util.url_encode(custom_field_key)}/options.json", nil)
|
87
|
+
@list.update_custom_field_options custom_field_key, new_options, true
|
88
|
+
end
|
89
|
+
|
90
|
+
should "get the details of a list" do
|
91
|
+
stub_get(@auth, "lists/#{@list.list_id}.json", "list_details.json")
|
92
|
+
details = @list.details
|
93
|
+
details.ConfirmedOptIn.should be == false
|
94
|
+
details.Title.should be == "a non-basic list :)"
|
95
|
+
details.UnsubscribePage.should be == ""
|
96
|
+
details.ListID.should be == "2fe4c8f0373ce320e2200596d7ef168f"
|
97
|
+
details.ConfirmationSuccessPage.should be == ""
|
98
|
+
details.UnsubscribeSetting.should be == "AllClientLists"
|
99
|
+
end
|
100
|
+
|
101
|
+
should "get the custom fields for a list" do
|
102
|
+
stub_get(@auth, "lists/#{@list.list_id}/customfields.json", "custom_fields.json")
|
103
|
+
cfs = @list.custom_fields
|
104
|
+
cfs.size.should be == 3
|
105
|
+
cfs.first.FieldName.should be == "website"
|
106
|
+
cfs.first.Key.should be == "[website]"
|
107
|
+
cfs.first.DataType.should be == "Text"
|
108
|
+
cfs.first.FieldOptions.should be == []
|
109
|
+
cfs.first.VisibleInPreferenceCenter.should be == true
|
110
|
+
end
|
111
|
+
|
112
|
+
should "get the segments for a list" do
|
113
|
+
stub_get(@auth, "lists/#{@list.list_id}/segments.json", "segments.json")
|
114
|
+
segments = @list.segments
|
115
|
+
segments.size.should be == 2
|
116
|
+
segments.first.ListID.should be == 'a58ee1d3039b8bec838e6d1482a8a965'
|
117
|
+
segments.first.SegmentID.should be == '46aa5e01fd43381863d4e42cf277d3a9'
|
118
|
+
segments.first.Title.should be == 'Segment One'
|
119
|
+
end
|
120
|
+
|
121
|
+
should "get the stats for a list" do
|
122
|
+
stub_get(@auth, "lists/#{@list.list_id}/stats.json", "list_stats.json")
|
123
|
+
stats = @list.stats
|
124
|
+
stats.TotalActiveSubscribers.should be == 6
|
125
|
+
stats.TotalUnsubscribes.should be == 2
|
126
|
+
stats.TotalDeleted.should be == 0
|
127
|
+
stats.TotalBounces.should be == 0
|
128
|
+
end
|
129
|
+
|
130
|
+
should "get the active subscribers for a list" do
|
131
|
+
min_date = "2010-01-01"
|
132
|
+
stub_get(@auth, "lists/#{@list.list_id}/active.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false&includesmspreference=false",
|
133
|
+
"active_subscribers.json")
|
134
|
+
res = @list.active min_date
|
135
|
+
res.ResultsOrderedBy.should be == "email"
|
136
|
+
res.OrderDirection.should be == "asc"
|
137
|
+
res.PageNumber.should be == 1
|
138
|
+
res.PageSize.should be == 1000
|
139
|
+
res.RecordsOnThisPage.should be == 5
|
140
|
+
res.TotalNumberOfRecords.should be == 5
|
141
|
+
res.NumberOfPages.should be == 1
|
142
|
+
res.Results.size.should be == 5
|
143
|
+
res.Results.first.EmailAddress.should be == "subs+7t8787Y@example.com"
|
144
|
+
res.Results.first.Name.should be =="Person One"
|
145
|
+
res.Results.first.Date.should be == "2010-10-25 10:28:00"
|
146
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-25 10:28:00"
|
147
|
+
res.Results.first.State.should be == "Active"
|
148
|
+
res.Results.first.CustomFields.size.should be == 5
|
149
|
+
res.Results.first.CustomFields[0].Key.should be == "website"
|
150
|
+
res.Results.first.CustomFields[0].Value.should be == "http://example.com"
|
151
|
+
res.Results.first.CustomFields[1].Key.should be == "multi select field"
|
152
|
+
res.Results.first.CustomFields[1].Value.should be == "option one"
|
153
|
+
res.Results.first.CustomFields[2].Key.should be == "multi select field"
|
154
|
+
res.Results.first.CustomFields[2].Value.should be == "option two"
|
155
|
+
res.Results.first.ReadsEmailWith.should be == "Gmail"
|
156
|
+
end
|
157
|
+
|
158
|
+
should "get the unconfirmed subscribers for a list" do
|
159
|
+
min_date = "2010-01-01"
|
160
|
+
stub_get(@auth, "lists/#{@list.list_id}/unconfirmed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=true&includesmspreference=true",
|
161
|
+
"unconfirmed_subscribers.json")
|
162
|
+
res = @list.unconfirmed(min_date, 1, 1000, "email", "asc", true, include_sms_preference:true)
|
163
|
+
res.ResultsOrderedBy.should be == "email"
|
164
|
+
res.OrderDirection.should be == "asc"
|
165
|
+
res.PageNumber.should be == 1
|
166
|
+
res.PageSize.should be == 1000
|
167
|
+
res.RecordsOnThisPage.should be == 2
|
168
|
+
res.TotalNumberOfRecords.should be == 2
|
169
|
+
res.NumberOfPages.should be == 1
|
170
|
+
res.Results.size.should be == 2
|
171
|
+
res.Results.first.EmailAddress.should be == "subs+7t8787Y@example.com"
|
172
|
+
res.Results.first.Name.should be =="Unconfirmed One"
|
173
|
+
res.Results.first.Date.should be =="2010-10-25 10:28:00"
|
174
|
+
res.Results.first.ListJoinedDate.should be =="2010-10-25 10:28:00"
|
175
|
+
res.Results.first.State.should be == "Unconfirmed"
|
176
|
+
res.Results.first.ConsentToTrack.should be == "Yes"
|
177
|
+
res.Results.first.ConsentToSendSms.should be == "No"
|
178
|
+
end
|
179
|
+
|
180
|
+
should "get the unsubscribed subscribers for a list" do
|
181
|
+
min_date = "2010-01-01"
|
182
|
+
stub_get(@auth, "lists/#{@list.list_id}/unsubscribed.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false&includesmspreference=false",
|
183
|
+
"unsubscribed_subscribers.json")
|
184
|
+
res = @list.unsubscribed min_date
|
185
|
+
res.ResultsOrderedBy.should be == "email"
|
186
|
+
res.OrderDirection.should be == "asc"
|
187
|
+
res.PageNumber.should be == 1
|
188
|
+
res.PageSize.should be == 1000
|
189
|
+
res.RecordsOnThisPage.should be == 5
|
190
|
+
res.TotalNumberOfRecords.should be == 5
|
191
|
+
res.NumberOfPages.should be == 1
|
192
|
+
res.Results.size.should be == 5
|
193
|
+
res.Results.first.EmailAddress.should be == "subscriber@example.com"
|
194
|
+
res.Results.first.Name.should be == "Unsub One"
|
195
|
+
res.Results.first.Date.should be == "2010-10-25 13:11:00"
|
196
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-25 13:11:00"
|
197
|
+
res.Results.first.State.should be == "Unsubscribed"
|
198
|
+
res.Results.first.CustomFields.size.should be == 0
|
199
|
+
res.Results.first.ReadsEmailWith.should be == "Gmail"
|
200
|
+
end
|
201
|
+
|
202
|
+
should "get the deleted subscribers for a list" do
|
203
|
+
min_date = "2010-01-01"
|
204
|
+
stub_get(@auth, "lists/#{@list.list_id}/deleted.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false&includesmspreference=false",
|
205
|
+
"deleted_subscribers.json")
|
206
|
+
res = @list.deleted min_date
|
207
|
+
res.ResultsOrderedBy.should be == "email"
|
208
|
+
res.OrderDirection.should be == "asc"
|
209
|
+
res.PageNumber.should be == 1
|
210
|
+
res.PageSize.should be == 1000
|
211
|
+
res.RecordsOnThisPage.should be == 5
|
212
|
+
res.TotalNumberOfRecords.should be == 5
|
213
|
+
res.NumberOfPages.should be == 1
|
214
|
+
res.Results.size.should be == 5
|
215
|
+
res.Results.first.EmailAddress.should be == "subscriber@example.com"
|
216
|
+
res.Results.first.Name.should be == "Deleted One"
|
217
|
+
res.Results.first.Date.should be == "2010-10-25 13:11:00"
|
218
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-25 13:11:00"
|
219
|
+
res.Results.first.State.should be == "Deleted"
|
220
|
+
res.Results.first.CustomFields.size.should be == 0
|
221
|
+
res.Results.first.ReadsEmailWith.should be == "Gmail"
|
222
|
+
end
|
223
|
+
|
224
|
+
should "get the bounced subscribers for a list" do
|
225
|
+
min_date = "2010-01-01"
|
226
|
+
stub_get(@auth, "lists/#{@list.list_id}/bounced.json?pagesize=1000&orderfield=email&page=1&orderdirection=asc&date=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false&includesmspreference=false",
|
227
|
+
"bounced_subscribers.json")
|
228
|
+
res = @list.bounced min_date
|
229
|
+
res.ResultsOrderedBy.should be == "email"
|
230
|
+
res.OrderDirection.should be == "asc"
|
231
|
+
res.PageNumber.should be == 1
|
232
|
+
res.PageSize.should be == 1000
|
233
|
+
res.RecordsOnThisPage.should be == 1
|
234
|
+
res.TotalNumberOfRecords.should be == 1
|
235
|
+
res.NumberOfPages.should be == 1
|
236
|
+
res.Results.size.should be == 1
|
237
|
+
res.Results.first.EmailAddress.should be == "bouncedsubscriber@example.com"
|
238
|
+
res.Results.first.Name.should be == "Bounced One"
|
239
|
+
res.Results.first.Date.should be == "2010-10-25 13:11:00"
|
240
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-25 13:11:00"
|
241
|
+
res.Results.first.State.should be == "Bounced"
|
242
|
+
res.Results.first.CustomFields.size.should be == 0
|
243
|
+
res.Results.first.ReadsEmailWith.should be == ""
|
244
|
+
end
|
245
|
+
|
246
|
+
should "get the webhooks for a list" do
|
247
|
+
stub_get(@auth, "lists/#{@list.list_id}/webhooks.json", "list_webhooks.json")
|
248
|
+
hooks = @list.webhooks
|
249
|
+
hooks.size.should be == 2
|
250
|
+
hooks.first.WebhookID.should be == "943678317049bc13"
|
251
|
+
hooks.first.Events.size.should be == 1
|
252
|
+
hooks.first.Events.first.should be == "Deactivate"
|
253
|
+
hooks.first.Url.should be == "http://www.postbin.org/d9w8ud9wud9w"
|
254
|
+
hooks.first.Status.should be == "Active"
|
255
|
+
hooks.first.PayloadFormat.should be == "Json"
|
256
|
+
end
|
257
|
+
|
258
|
+
should "create a webhook for a list" do
|
259
|
+
stub_post(@auth, "lists/#{@list.list_id}/webhooks.json", "create_list_webhook.json")
|
260
|
+
webhook_id = @list.create_webhook ["Unsubscribe", "Spam"], "http://example.com/unsub", "json"
|
261
|
+
webhook_id.should be == "6a783d359bd44ef62c6ca0d3eda4412a"
|
262
|
+
end
|
263
|
+
|
264
|
+
should "test a webhook for a list" do
|
265
|
+
webhook_id = "jiuweoiwueoiwueowiueo"
|
266
|
+
stub_get(@auth, "lists/#{@list.list_id}/webhooks/#{webhook_id}/test.json", nil)
|
267
|
+
@list.test_webhook webhook_id
|
268
|
+
end
|
269
|
+
|
270
|
+
should "delete a webhook for a list" do
|
271
|
+
webhook_id = "jiuweoiwueoiwueowiueo"
|
272
|
+
stub_delete(@auth, "lists/#{@list.list_id}/webhooks/#{webhook_id}.json", nil)
|
273
|
+
@list.delete_webhook webhook_id
|
274
|
+
end
|
275
|
+
|
276
|
+
should "activate a webhook for a list" do
|
277
|
+
webhook_id = "jiuweoiwueoiwueowiueo"
|
278
|
+
stub_put(@auth, "lists/#{@list.list_id}/webhooks/#{webhook_id}/activate.json", nil)
|
279
|
+
@list.activate_webhook webhook_id
|
280
|
+
end
|
281
|
+
|
282
|
+
should "de-activate a webhook for a list" do
|
283
|
+
webhook_id = "jiuweoiwueoiwueowiueo"
|
284
|
+
stub_put(@auth, "lists/#{@list.list_id}/webhooks/#{webhook_id}/deactivate.json", nil)
|
285
|
+
@list.deactivate_webhook webhook_id
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
data/test/person_test.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class PersonTest < Test::Unit::TestCase
|
4
|
+
multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
|
5
|
+
setup do
|
6
|
+
@client_id = "d98h2938d9283d982u3d98u88"
|
7
|
+
@person = CreateSend::Person.new @auth, @client_id, "person@example.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
should "get a person by client id and email address" do
|
11
|
+
email = "person@example.com"
|
12
|
+
stub_get(@auth, "clients/#{@client_id}/people.json?email=#{ERB::Util.url_encode(email)}", "person_details.json")
|
13
|
+
person = CreateSend::Person.get @auth, @client_id, email
|
14
|
+
person.EmailAddress.should be == email
|
15
|
+
person.Name.should be == "Person One"
|
16
|
+
person.AccessLevel.should be == 1023
|
17
|
+
person.Status.should be == "Active"
|
18
|
+
end
|
19
|
+
|
20
|
+
should "add a person" do
|
21
|
+
stub_post(@auth, "clients/#{@client_id}/people.json", "add_person.json")
|
22
|
+
result = CreateSend::Person.add @auth, @client_id, "person@example.com", "Person", 0, "Password"
|
23
|
+
result.EmailAddress.should be == "person@example.com"
|
24
|
+
end
|
25
|
+
|
26
|
+
should "update a person" do
|
27
|
+
email = "person@example.com"
|
28
|
+
new_email = "new_email_address@example.com"
|
29
|
+
stub_put(@auth, "clients/#{@client_id}/people.json?email=#{ERB::Util.url_encode(email)}", nil)
|
30
|
+
@person.update new_email, "Person", 1023, "NewPassword"
|
31
|
+
@person.email_address.should be == new_email
|
32
|
+
end
|
33
|
+
|
34
|
+
should "delete a person" do
|
35
|
+
stub_delete(@auth, "clients/#{@person.client_id}/people.json?email=#{ERB::Util.url_encode(@person.email_address)}", nil)
|
36
|
+
@person.delete
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class SegmentTest < Test::Unit::TestCase
|
4
|
+
multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
|
5
|
+
setup do
|
6
|
+
@segment = CreateSend::Segment.new @auth, '98y2e98y289dh89h938389'
|
7
|
+
end
|
8
|
+
|
9
|
+
should "create a new segment" do
|
10
|
+
list_id = "2983492834987394879837498"
|
11
|
+
rule_groups = [ { :Rules => [ { :RuleType => "EmailAddress", :Clause => "CONTAINS example.com" } ] } ]
|
12
|
+
stub_post(@auth, "segments/#{list_id}.json", "create_segment.json")
|
13
|
+
res = CreateSend::Segment.create @auth, list_id, "new segment title", rule_groups
|
14
|
+
res.should be == "0246c2aea610a3545d9780bf6ab89006"
|
15
|
+
end
|
16
|
+
|
17
|
+
should "update a segment" do
|
18
|
+
rules = [ { :Rules => [ { :RuleType => "Name", :Clause => "PROVIDED" } ] } ]
|
19
|
+
stub_put(@auth, "segments/#{@segment.segment_id}.json", nil)
|
20
|
+
@segment.update "new title for segment", rules
|
21
|
+
end
|
22
|
+
|
23
|
+
should "add a rule group to a segment" do
|
24
|
+
rule_group = [ { :RuleType => "EmailAddress", :Clause => "CONTAINS @hello.com" } ]
|
25
|
+
stub_post(@auth, "segments/#{@segment.segment_id}/rules.json", nil)
|
26
|
+
@segment.add_rule_group rule_group
|
27
|
+
end
|
28
|
+
|
29
|
+
should "get the active subscribers for a particular segment in the list" do
|
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=#{ERB::Util.url_encode(min_date)}&includetrackingpreference=false",
|
32
|
+
"segment_subscribers.json")
|
33
|
+
res = @segment.subscribers min_date
|
34
|
+
res.ResultsOrderedBy.should be == "email"
|
35
|
+
res.OrderDirection.should be == "asc"
|
36
|
+
res.PageNumber.should be == 1
|
37
|
+
res.PageSize.should be == 1000
|
38
|
+
res.RecordsOnThisPage.should be == 2
|
39
|
+
res.TotalNumberOfRecords.should be == 2
|
40
|
+
res.NumberOfPages.should be == 1
|
41
|
+
res.Results.size.should be == 2
|
42
|
+
res.Results.first.EmailAddress.should be == "personone@example.com"
|
43
|
+
res.Results.first.Name.should be == "Person One"
|
44
|
+
res.Results.first.Date.should be == "2010-10-27 13:13:00"
|
45
|
+
res.Results.first.ListJoinedDate.should be == "2010-10-27 13:13:00"
|
46
|
+
res.Results.first.State.should be == "Active"
|
47
|
+
res.Results.first.CustomFields.should be == []
|
48
|
+
end
|
49
|
+
|
50
|
+
should "delete a segment" do
|
51
|
+
stub_delete(@auth, "segments/#{@segment.segment_id}.json", nil)
|
52
|
+
@segment.delete
|
53
|
+
end
|
54
|
+
|
55
|
+
should "get the details of a segment" do
|
56
|
+
stub_get(@auth, "segments/#{@segment.segment_id}.json", "segment_details.json")
|
57
|
+
res = @segment.details
|
58
|
+
res.ActiveSubscribers.should be == 0
|
59
|
+
res.RuleGroups.size.should be == 2
|
60
|
+
res.RuleGroups.first.Rules.size.should be == 1
|
61
|
+
res.RuleGroups.first.Rules.first.RuleType.should be == "EmailAddress"
|
62
|
+
res.RuleGroups.first.Rules.first.Clause.should be == "CONTAINS @hello.com"
|
63
|
+
res.ListID.should be == "2bea949d0bf96148c3e6a209d2e82060"
|
64
|
+
res.SegmentID.should be == "dba84a225d5ce3d19105d7257baac46f"
|
65
|
+
res.Title.should be == "My Segment"
|
66
|
+
end
|
67
|
+
|
68
|
+
should "clear a segment's rules" do
|
69
|
+
stub_delete(@auth, "segments/#{@segment.segment_id}/rules.json", nil)
|
70
|
+
@segment.clear_rules
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|