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,177 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class SubscriberTest < Test::Unit::TestCase
|
4
|
+
multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
|
5
|
+
setup do
|
6
|
+
@list_id = "d98h2938d9283d982u3d98u88"
|
7
|
+
@subscriber = CreateSend::Subscriber.new @auth, @list_id, "subscriber@example.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
should "get a subscriber by list id and email address" do
|
11
|
+
email = "subscriber@example.com"
|
12
|
+
stub_get(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}&includetrackingpreference=false", "subscriber_details.json")
|
13
|
+
subscriber = CreateSend::Subscriber.get @auth, @list_id, email
|
14
|
+
subscriber.EmailAddress.should be == email
|
15
|
+
subscriber.Name.should be == "Subscriber One"
|
16
|
+
subscriber.Date.should be == "2010-10-25 10:28:00"
|
17
|
+
subscriber.MobileNumber.should be == "+61423153526"
|
18
|
+
subscriber.ListJoinedDate.should be == "2010-10-25 10:28:00"
|
19
|
+
subscriber.State.should be == "Active"
|
20
|
+
subscriber.CustomFields.size.should be == 3
|
21
|
+
subscriber.CustomFields.first.Key.should be == 'website'
|
22
|
+
subscriber.CustomFields.first.Value.should be == 'http://example.com'
|
23
|
+
subscriber.ReadsEmailWith.should be == "Gmail"
|
24
|
+
end
|
25
|
+
|
26
|
+
should "get a subscriber with track and sms preference information" do
|
27
|
+
email = "subscriber@example.com"
|
28
|
+
stub_get(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}&includetrackingpreference=true", "subscriber_details_with_track_and_sms_pref.json")
|
29
|
+
subscriber = CreateSend::Subscriber.get @auth, @list_id, email, true
|
30
|
+
subscriber.EmailAddress.should be == email
|
31
|
+
subscriber.Name.should be == "Subscriber One"
|
32
|
+
subscriber.MobileNumber.should be == "+61423153526"
|
33
|
+
subscriber.ConsentToTrack.should be == "Yes"
|
34
|
+
subscriber.ConsentToSendSms.should be == "No"
|
35
|
+
end
|
36
|
+
|
37
|
+
should "add a subscriber without custom fields" do
|
38
|
+
stub_post(@auth, "subscribers/#{@list_id}.json", "add_subscriber.json")
|
39
|
+
email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", [], true, "Yes"
|
40
|
+
email_address.should be == "subscriber@example.com"
|
41
|
+
end
|
42
|
+
|
43
|
+
should "add a subscriber with custom fields" do
|
44
|
+
stub_post(@auth, "subscribers/#{@list_id}.json", "add_subscriber.json")
|
45
|
+
custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ]
|
46
|
+
email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true, "Yes"
|
47
|
+
email_address.should be == "subscriber@example.com"
|
48
|
+
end
|
49
|
+
|
50
|
+
should "add a subscriber with custom fields including multi-option fields" do
|
51
|
+
stub_post(@auth, "subscribers/#{@list_id}.json", "add_subscriber.json")
|
52
|
+
custom_fields = [ { :Key => 'multioptionselectone', :Value => 'myoption' },
|
53
|
+
{ :Key => 'multioptionselectmany', :Value => 'firstoption' },
|
54
|
+
{ :Key => 'multioptionselectmany', :Value => 'secondoption' } ]
|
55
|
+
email_address = CreateSend::Subscriber.add @auth, @list_id, "subscriber@example.com", "Subscriber", custom_fields, true, "Yes"
|
56
|
+
email_address.should be == "subscriber@example.com"
|
57
|
+
end
|
58
|
+
|
59
|
+
should "update a subscriber with custom fields" do
|
60
|
+
email = "subscriber@example.com"
|
61
|
+
new_email = "new_email_address@example.com"
|
62
|
+
stub_put(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}", nil)
|
63
|
+
custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ]
|
64
|
+
@subscriber.update new_email, "Subscriber", custom_fields, true, "Yes"
|
65
|
+
@subscriber.email_address.should be == new_email
|
66
|
+
end
|
67
|
+
|
68
|
+
should "update a subscriber with custom fields including the clear option" do
|
69
|
+
email = "subscriber@example.com"
|
70
|
+
new_email = "new_email_address@example.com"
|
71
|
+
stub_put(@auth, "subscribers/#{@list_id}.json?email=#{ERB::Util.url_encode(email)}", nil)
|
72
|
+
custom_fields = [ { :Key => 'website', :Value => '', :Clear => true } ]
|
73
|
+
@subscriber.update new_email, "Subscriber", custom_fields, true, "No"
|
74
|
+
@subscriber.email_address.should be == new_email
|
75
|
+
end
|
76
|
+
|
77
|
+
should "import many subscribers at once" do
|
78
|
+
stub_post(@auth, "subscribers/#{@list_id}/import.json", "import_subscribers.json")
|
79
|
+
subscribers = [
|
80
|
+
{ :EmailAddress => "example+1@example.com", :Name => "Example One" },
|
81
|
+
{ :EmailAddress => "example+2@example.com", :Name => "Example Two" },
|
82
|
+
{ :EmailAddress => "example+3@example.com", :Name => "Example Three" },
|
83
|
+
]
|
84
|
+
import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers, true
|
85
|
+
import_result.FailureDetails.size.should be == 0
|
86
|
+
import_result.TotalUniqueEmailsSubmitted.should be == 3
|
87
|
+
import_result.TotalExistingSubscribers.should be == 0
|
88
|
+
import_result.TotalNewSubscribers.should be == 3
|
89
|
+
import_result.DuplicateEmailsInSubmission.size.should be == 0
|
90
|
+
end
|
91
|
+
|
92
|
+
should "import many subscribers at once, and start subscription-based autoresponders" do
|
93
|
+
stub_post(@auth, "subscribers/#{@list_id}/import.json", "import_subscribers.json")
|
94
|
+
subscribers = [
|
95
|
+
{ :EmailAddress => "example+1@example.com", :Name => "Example One" },
|
96
|
+
{ :EmailAddress => "example+2@example.com", :Name => "Example Two" },
|
97
|
+
{ :EmailAddress => "example+3@example.com", :Name => "Example Three" },
|
98
|
+
]
|
99
|
+
import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers, true, true
|
100
|
+
import_result.FailureDetails.size.should be == 0
|
101
|
+
import_result.TotalUniqueEmailsSubmitted.should be == 3
|
102
|
+
import_result.TotalExistingSubscribers.should be == 0
|
103
|
+
import_result.TotalNewSubscribers.should be == 3
|
104
|
+
import_result.DuplicateEmailsInSubmission.size.should be == 0
|
105
|
+
end
|
106
|
+
|
107
|
+
should "import many subscribers at once with custom fields, including the clear option" do
|
108
|
+
stub_post(@auth, "subscribers/#{@list_id}/import.json", "import_subscribers.json")
|
109
|
+
subscribers = [
|
110
|
+
{ :EmailAddress => "example+1@example.com", :Name => "Example One", :CustomFields => [ { :Key => 'website', :Value => '', :Clear => true } ] },
|
111
|
+
{ :EmailAddress => "example+2@example.com", :Name => "Example Two", :CustomFields => [ { :Key => 'website', :Value => '', :Clear => false } ] },
|
112
|
+
{ :EmailAddress => "example+3@example.com", :Name => "Example Three", :CustomFields => [ { :Key => 'website', :Value => '', :Clear => false } ] },
|
113
|
+
]
|
114
|
+
import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers, true
|
115
|
+
import_result.FailureDetails.size.should be == 0
|
116
|
+
import_result.TotalUniqueEmailsSubmitted.should be == 3
|
117
|
+
import_result.TotalExistingSubscribers.should be == 0
|
118
|
+
import_result.TotalNewSubscribers.should be == 3
|
119
|
+
import_result.DuplicateEmailsInSubmission.size.should be == 0
|
120
|
+
end
|
121
|
+
|
122
|
+
should "import many subscribers at once with partial success" do
|
123
|
+
# Stub request with 400 Bad Request as the expected response status
|
124
|
+
stub_post(@auth, "subscribers/#{@list_id}/import.json", "import_subscribers_partial_success.json", 400)
|
125
|
+
subscribers = [
|
126
|
+
{ :EmailAddress => "example+1@example", :Name => "Example One" },
|
127
|
+
{ :EmailAddress => "example+2@example.com", :Name => "Example Two" },
|
128
|
+
{ :EmailAddress => "example+3@example.com", :Name => "Example Three" },
|
129
|
+
]
|
130
|
+
import_result = CreateSend::Subscriber.import @auth, @list_id, subscribers, true
|
131
|
+
import_result.FailureDetails.size.should be == 1
|
132
|
+
import_result.FailureDetails.first.EmailAddress.should be == "example+1@example"
|
133
|
+
import_result.FailureDetails.first.Code.should be == 1
|
134
|
+
import_result.FailureDetails.first.Message.should be == "Invalid Email Address"
|
135
|
+
import_result.TotalUniqueEmailsSubmitted.should be == 3
|
136
|
+
import_result.TotalExistingSubscribers.should be == 2
|
137
|
+
import_result.TotalNewSubscribers.should be == 0
|
138
|
+
import_result.DuplicateEmailsInSubmission.size.should be == 0
|
139
|
+
end
|
140
|
+
|
141
|
+
should "raise a BadRequest error if the import _completely_ fails because of a bad request" do
|
142
|
+
# Stub request with 400 Bad Request as the expected response status
|
143
|
+
stub_post(@auth, "subscribers/#{@list_id}/import.json", "custom_api_error.json", 400)
|
144
|
+
subscribers = [
|
145
|
+
{ :EmailAddress => "example+1@example", :Name => "Example One" },
|
146
|
+
{ :EmailAddress => "example+2@example.com", :Name => "Example Two" },
|
147
|
+
{ :EmailAddress => "example+3@example.com", :Name => "Example Three" },
|
148
|
+
]
|
149
|
+
lambda { CreateSend::Subscriber.import @auth, @list_id, subscribers,
|
150
|
+
true }.should raise_error(CreateSend::BadRequest)
|
151
|
+
end
|
152
|
+
|
153
|
+
should "unsubscribe a subscriber" do
|
154
|
+
stub_post(@auth, "subscribers/#{@subscriber.list_id}/unsubscribe.json", nil)
|
155
|
+
@subscriber.unsubscribe
|
156
|
+
end
|
157
|
+
|
158
|
+
should "get a subscriber's history" do
|
159
|
+
stub_get(@auth, "subscribers/#{@subscriber.list_id}/history.json?email=#{ERB::Util.url_encode(@subscriber.email_address)}", "subscriber_history.json")
|
160
|
+
history = @subscriber.history
|
161
|
+
history.size.should be == 1
|
162
|
+
history.first.Name.should be == "Campaign One"
|
163
|
+
history.first.Type.should be == "Campaign"
|
164
|
+
history.first.ID.should be == "fc0ce7105baeaf97f47c99be31d02a91"
|
165
|
+
history.first.Actions.size.should be == 6
|
166
|
+
history.first.Actions.first.Event.should be == "Open"
|
167
|
+
history.first.Actions.first.Date.should be == "2010-10-12 13:18:00"
|
168
|
+
history.first.Actions.first.IPAddress.should be == "192.168.126.87"
|
169
|
+
history.first.Actions.first.Detail.should be == ""
|
170
|
+
end
|
171
|
+
|
172
|
+
should "delete a subscriber" do
|
173
|
+
stub_delete(@auth, "subscribers/#{@subscriber.list_id}.json?email=#{ERB::Util.url_encode(@subscriber.email_address)}", nil)
|
174
|
+
@subscriber.delete
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TemplateTest < Test::Unit::TestCase
|
4
|
+
multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
|
5
|
+
setup do
|
6
|
+
@template = CreateSend::Template.new @auth, '98y2e98y289dh89h938389'
|
7
|
+
end
|
8
|
+
|
9
|
+
should "create a template" do
|
10
|
+
client_id = '87y8d7qyw8d7yq8w7ydwqwd'
|
11
|
+
stub_post(@auth, "templates/#{client_id}.json", "create_template.json")
|
12
|
+
template_id = CreateSend::Template.create @auth, client_id, "Template One", "http://templates.org/index.html",
|
13
|
+
"http://templates.org/files.zip"
|
14
|
+
template_id.should be == "98y2e98y289dh89h938389"
|
15
|
+
end
|
16
|
+
|
17
|
+
should "get details of a template" do
|
18
|
+
stub_get(@auth, "templates/#{@template.template_id}.json", "template_details.json")
|
19
|
+
t = @template.details
|
20
|
+
t.TemplateID.should be == "98y2e98y289dh89h938389"
|
21
|
+
t.Name.should be == "Template One"
|
22
|
+
t.PreviewURL.should be == "http://preview.createsend.com/createsend/templates/previewTemplate.aspx?ID=01AF532CD8889B33&d=r&c=E816F55BFAD1A753"
|
23
|
+
t.ScreenshotURL.should be == "http://preview.createsend.com/ts/r/14/833/263/14833263.jpg?0318092600"
|
24
|
+
end
|
25
|
+
|
26
|
+
should "update a template" do
|
27
|
+
stub_put(@auth, "templates/#{@template.template_id}.json", nil)
|
28
|
+
@template.update "Template One Updated", "http://templates.org/index.html", "http://templates.org/files.zip"
|
29
|
+
end
|
30
|
+
|
31
|
+
should "delete a template" do
|
32
|
+
stub_delete(@auth, "templates/#{@template.template_id}.json", nil)
|
33
|
+
@template.delete
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TransactionalClassicEmailTest < Test::Unit::TestCase
|
4
|
+
multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
|
5
|
+
setup do
|
6
|
+
@client_id = "87y8d7qyw8d7yq8w7ydwqwd"
|
7
|
+
@email = CreateSend::Transactional::ClassicEmail.new @auth, @client_id
|
8
|
+
end
|
9
|
+
|
10
|
+
should "send classic email to one recipient" do
|
11
|
+
stub_post(@auth, "transactional/classicemail/send", "tx_send_single.json")
|
12
|
+
email = {
|
13
|
+
"From" => "George <george@example.com>",
|
14
|
+
"Subject" => "Thanks for signing up to Vandelay Industries",
|
15
|
+
"To" => "Bob Sacamano <bob@example.com>",
|
16
|
+
"HTML" => "<h1>Welcome</h1><a href='http://example.com/'>Click here</a>",
|
17
|
+
"Group" => 'Ruby test group'
|
18
|
+
}
|
19
|
+
response = CreateSend::Transactional::ClassicEmail.new(@auth).send(email)
|
20
|
+
response.length.should be == 1
|
21
|
+
response[0].Recipient.should be == "\"Bob Sacamano\" <bob@example.com>"
|
22
|
+
end
|
23
|
+
|
24
|
+
should "send classic email to with all the options" do
|
25
|
+
stub_post(@auth, "transactional/classicemail/send", "tx_send_multiple.json")
|
26
|
+
email = {
|
27
|
+
"From" => "T-Bone <tbone@example.com>",
|
28
|
+
"ReplyTo" => "george@example.com",
|
29
|
+
"Subject" => "Thanks for signing up to Vandelay Industries",
|
30
|
+
"To" => [
|
31
|
+
"Bob Sacamano <bob@example.com>",
|
32
|
+
"Newman <newman@example.com>",
|
33
|
+
],
|
34
|
+
"CC" => [],
|
35
|
+
"BCC" => [],
|
36
|
+
"HTML" => "<h1>Welcome</h1><a href='http://example.com/'>Click here</a>",
|
37
|
+
"Text" => "Instead of using the auto-generated text from the HTML, you can supply your own.",
|
38
|
+
"Attachments" => [
|
39
|
+
"Name" => "filename.gif",
|
40
|
+
"Type" => "image/gif",
|
41
|
+
"Content" => "R0lGODlhIAAgAKIAAP8AAJmZADNmAMzMAP//AAAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMwMTQgNzkuMTU2Nzk3LCAyMDE0LzA4LzIwLTA5OjUzOjAyICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxNCAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowNzZGOUNGOUVDRDIxMUU0ODM2RjhGMjNCMTcxN0I2RiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowNzZGOUNGQUVDRDIxMUU0ODM2RjhGMjNCMTcxN0I2RiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjA3NkY5Q0Y3RUNEMjExRTQ4MzZGOEYyM0IxNzE3QjZGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjA3NkY5Q0Y4RUNEMjExRTQ4MzZGOEYyM0IxNzE3QjZGIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAACAAIAAAA5loutz+MKpSpIWU3r1KCBW3eYQmWgWhmiemEgPbNqk6xDOd1XGYV77UzTfbTWC4nAHYQRKLu1VSuXxlpsodAFDAZrfcIbXDFXqhNacoQ3vZpuxHSJZ2zufyTqcunugdd00vQ0F4chQCAgYCaTcxiYuMMhGJFG89kYpFl5MzkoRPnpJskFSaDqctRoBxHEQsdGs0f7Qjq3utDwkAOw=="
|
42
|
+
],
|
43
|
+
"Group" => "Ruby test group",
|
44
|
+
"AddRecipientsToListID" => "6d0366fcee146ab9bdaf3247446bbfdd"
|
45
|
+
}
|
46
|
+
response = CreateSend::Transactional::ClassicEmail.new(@auth).send(email)
|
47
|
+
response.length.should be == 2
|
48
|
+
response[1].Recipient.should be == "\"Newman\" <newman@example.com>"
|
49
|
+
end
|
50
|
+
|
51
|
+
should "get the list of classic groups" do
|
52
|
+
stub_get(@auth, "transactional/classicemail/groups", "tx_classicemail_groups.json")
|
53
|
+
response = CreateSend::Transactional::ClassicEmail.new(@auth).groups
|
54
|
+
response.length.should be == 3
|
55
|
+
response[0].Group.should be == "Password Reset"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TransactionalSmartEmailTest < Test::Unit::TestCase
|
4
|
+
multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
|
5
|
+
setup do
|
6
|
+
@client_id = "87y8d7qyw8d7yq8w7ydwqwd"
|
7
|
+
@smart_email_id = "bcf40510-f968-11e4-ab73-bf67677cc1f4"
|
8
|
+
@email = CreateSend::Transactional::SmartEmail.new @auth, @smart_email_id
|
9
|
+
end
|
10
|
+
|
11
|
+
should "get the list of smart emails" do
|
12
|
+
stub_get(@auth, "transactional/smartemail", "tx_smartemails.json")
|
13
|
+
response = CreateSend::Transactional::SmartEmail.list(@auth)
|
14
|
+
response.length.should be == 2
|
15
|
+
response[0].ID.should be == "1e654df2-f484-11e4-970c-6c4008bc7468"
|
16
|
+
response[0].Name.should be == "Welcome email"
|
17
|
+
response[0].Status.should be == "Active"
|
18
|
+
end
|
19
|
+
|
20
|
+
should "get the list of active smart emails using a client ID" do
|
21
|
+
stub_get(@auth, "transactional/smartemail?status=active&client=#{@client_id}", "tx_smartemails.json")
|
22
|
+
response = CreateSend::Transactional::SmartEmail.list(@auth, { :client => @client_id, :status => 'active'} )
|
23
|
+
response.length.should be == 2
|
24
|
+
response[0].ID.should be == "1e654df2-f484-11e4-970c-6c4008bc7468"
|
25
|
+
response[0].Name.should be == "Welcome email"
|
26
|
+
response[0].Status.should be == "Active"
|
27
|
+
end
|
28
|
+
|
29
|
+
should "get the details of smart email" do
|
30
|
+
stub_get(@auth, "transactional/smartemail/#{@smart_email_id}", "tx_smartemail_details.json")
|
31
|
+
response = CreateSend::Transactional::SmartEmail.new(@auth, @smart_email_id).details
|
32
|
+
response.Name.should be == "Reset Password"
|
33
|
+
response.Status.should be == "active"
|
34
|
+
response.Properties.ReplyTo.should be == "joe@example.com"
|
35
|
+
end
|
36
|
+
|
37
|
+
should "send smart email to one recipient" do
|
38
|
+
stub_post(@auth, "transactional/smartemail/#{@smart_email_id}/send", "tx_send_single.json")
|
39
|
+
email = {
|
40
|
+
"To" => "Bob Sacamano <bob@example.com>",
|
41
|
+
"Data" => {
|
42
|
+
"anEmailVariable" => 'foo',
|
43
|
+
"anotherEmailVariable" => 'bar'
|
44
|
+
}
|
45
|
+
}
|
46
|
+
response = CreateSend::Transactional::SmartEmail.new(@auth, @smart_email_id).send(email)
|
47
|
+
response.length.should be == 1
|
48
|
+
response[0].MessageID.should be == "0cfe150d-d507-11e4-84a7-c31e5b59881d"
|
49
|
+
response[0].Recipient.should be == "\"Bob Sacamano\" <bob@example.com>"
|
50
|
+
response[0].Status.should be == "Received"
|
51
|
+
end
|
52
|
+
|
53
|
+
should "send smart email to multiple recipients with all the options" do
|
54
|
+
stub_post(@auth, "transactional/smartemail/#{@smart_email_id}/send", "tx_send_multiple.json")
|
55
|
+
email = {
|
56
|
+
"To" => [
|
57
|
+
"Bob Sacamano <bob@example.com>",
|
58
|
+
"Newman <newman@example.com>",
|
59
|
+
],
|
60
|
+
"CC" => [],
|
61
|
+
"BCC" => [],
|
62
|
+
"Data" => {
|
63
|
+
"anEmailVariable" => 'foo',
|
64
|
+
"anotherEmailVariable" => 'bar'
|
65
|
+
},
|
66
|
+
"Attachments" => [
|
67
|
+
"Name" => "filename.gif",
|
68
|
+
"Type" => "image/gif",
|
69
|
+
"Content" => "R0lGODlhIAAgAKIAAP8AAJmZADNmAMzMAP//AAAAAP///wAAACH/C1hNUCBEYXRhWE1QPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMwMTQgNzkuMTU2Nzk3LCAyMDE0LzA4LzIwLTA5OjUzOjAyICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxNCAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowNzZGOUNGOUVDRDIxMUU0ODM2RjhGMjNCMTcxN0I2RiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowNzZGOUNGQUVDRDIxMUU0ODM2RjhGMjNCMTcxN0I2RiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjA3NkY5Q0Y3RUNEMjExRTQ4MzZGOEYyM0IxNzE3QjZGIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjA3NkY5Q0Y4RUNEMjExRTQ4MzZGOEYyM0IxNzE3QjZGIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+Af/+/fz7+vn49/b19PPy8fDv7u3s6+rp6Ofm5eTj4uHg397d3Nva2djX1tXU09LR0M/OzczLysnIx8bFxMPCwcC/vr28u7q5uLe2tbSzsrGwr66trKuqqainpqWko6KhoJ+enZybmpmYl5aVlJOSkZCPjo2Mi4qJiIeGhYSDgoGAf359fHt6eXh3dnV0c3JxcG9ubWxramloZ2ZlZGNiYWBfXl1cW1pZWFdWVVRTUlFQT05NTEtKSUhHRkVEQ0JBQD8+PTw7Ojk4NzY1NDMyMTAvLi0sKyopKCcmJSQjIiEgHx4dHBsaGRgXFhUUExIREA8ODQwLCgkIBwYFBAMCAQAAIfkEAAAAAAAsAAAAACAAIAAAA5loutz+MKpSpIWU3r1KCBW3eYQmWgWhmiemEgPbNqk6xDOd1XGYV77UzTfbTWC4nAHYQRKLu1VSuXxlpsodAFDAZrfcIbXDFXqhNacoQ3vZpuxHSJZ2zufyTqcunugdd00vQ0F4chQCAgYCaTcxiYuMMhGJFG89kYpFl5MzkoRPnpJskFSaDqctRoBxHEQsdGs0f7Qjq3utDwkAOw=="
|
70
|
+
],
|
71
|
+
"AddRecipientsToListID" => true
|
72
|
+
}
|
73
|
+
response = CreateSend::Transactional::SmartEmail.new(@auth, @smart_email_id).send(email)
|
74
|
+
response.length.should be == 2
|
75
|
+
response[1].MessageID.should be == "0cfe150d-d507-11e4-b579-a64eb0d9c74d"
|
76
|
+
response[1].Recipient.should be == "\"Newman\" <newman@example.com>"
|
77
|
+
response[1].Status.should be == "Received"
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
|
+
|
3
|
+
class TransactionalTimelineTest < Test::Unit::TestCase
|
4
|
+
multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
|
5
|
+
setup do
|
6
|
+
@client_id = "87y8d7qyw8d7yq8w7ydwqwd"
|
7
|
+
@message_id = "ddc697c7-0788-4df3-a71a-a7cb935f00bd"
|
8
|
+
@before_id = 'e2e270e6-fbce-11e4-97fc-a7cf717ca157'
|
9
|
+
@after_id = 'e96fc6ca-fbce-11e4-949f-c3ccd6a68863'
|
10
|
+
@smart_email_id = 'bb4a6ebb-663d-42a0-bdbe-60512cf30a01'
|
11
|
+
end
|
12
|
+
|
13
|
+
should "get statistics with the default parameters" do
|
14
|
+
stub_get(@auth, "transactional/statistics", "tx_statistics_classic.json")
|
15
|
+
response = CreateSend::Transactional::Timeline.new(@auth).statistics
|
16
|
+
response.Sent.should be == 1000
|
17
|
+
response.Opened.should be == 300
|
18
|
+
end
|
19
|
+
|
20
|
+
should "get statistics filtered by date and classic group" do
|
21
|
+
stub_get(@auth, "transactional/statistics?from=2015-01-01&to=2015-06-30&timezone=client&group=Password%20Reset", "tx_statistics_classic.json")
|
22
|
+
response = CreateSend::Transactional::Timeline.new(@auth).statistics(
|
23
|
+
"from" => "2015-01-01",
|
24
|
+
"to" => "2015-06-30",
|
25
|
+
"timezone" => "client",
|
26
|
+
"group" => "Password Reset"
|
27
|
+
)
|
28
|
+
response.Query.TimeZone.should be == "(GMT+10:00) Canberra, Melbourne, Sydney"
|
29
|
+
response.Query.Group.should be == "Password Reset"
|
30
|
+
response.Sent.should be == 1000
|
31
|
+
end
|
32
|
+
|
33
|
+
should "get statistics filtered by date and smart email" do
|
34
|
+
stub_get(@auth, "transactional/statistics?from=2015-01-01&to=2015-06-30&timezone=utc&smartEmailID=#{@smart_email_id}", "tx_statistics_smart.json")
|
35
|
+
response = CreateSend::Transactional::Timeline.new(@auth).statistics(
|
36
|
+
"from" => "2015-01-01",
|
37
|
+
"to" => "2015-06-30",
|
38
|
+
"timezone" => "utc",
|
39
|
+
"smartEmailID" => "bb4a6ebb-663d-42a0-bdbe-60512cf30a01"
|
40
|
+
)
|
41
|
+
response.Query.TimeZone.should be == "UTC"
|
42
|
+
response.Query.SmartEmailID.should be == "bb4a6ebb-663d-42a0-bdbe-60512cf30a01"
|
43
|
+
response.Sent.should be == 1000
|
44
|
+
end
|
45
|
+
|
46
|
+
should "get the message timeline with default parameters" do
|
47
|
+
stub_get(@auth, "transactional/messages", "tx_messages.json")
|
48
|
+
response = CreateSend::Transactional::Timeline.new(@auth).messages
|
49
|
+
response.length.should be == 3
|
50
|
+
response[0].MessageID.should be == "ddc697c7-0788-4df3-a71a-a7cb935f00bd"
|
51
|
+
response[0].Status.should be == "Delivered"
|
52
|
+
end
|
53
|
+
|
54
|
+
should "get the message timeline for a smart email" do
|
55
|
+
stub_get(@auth, "transactional/messages?status=all&count=200&sentBeforeID=#{@before_id}&sentAfterID=#{@after_id}&smartEmailID=#{@smart_email_id}&clientID=#{@client_id}", "tx_messages_smart.json")
|
56
|
+
response = CreateSend::Transactional::Timeline.new(@auth).messages(
|
57
|
+
"status" => 'all',
|
58
|
+
"count" => 200,
|
59
|
+
"sentBeforeID" => @before_id,
|
60
|
+
"sentAfterID" => @after_id,
|
61
|
+
"smartEmailID" => @smart_email_id,
|
62
|
+
"clientID" => @client_id
|
63
|
+
)
|
64
|
+
response.length.should be == 1
|
65
|
+
response[0].MessageID.should be == "ddc697c7-0788-4df3-a71a-a7cb935f00bd"
|
66
|
+
response[0].Status.should be == "Delivered"
|
67
|
+
end
|
68
|
+
|
69
|
+
should "get the message timeline for a classic group" do
|
70
|
+
stub_get(@auth, "transactional/messages?status=all&count=200&sentBeforeID=#{@before_id}&sentAfterID=#{@after_id}&group=Password%20Reset&clientID=#{@client_id}", "tx_messages_classic.json")
|
71
|
+
response = CreateSend::Transactional::Timeline.new(@auth).messages(
|
72
|
+
"status" => 'all',
|
73
|
+
"count" => 200,
|
74
|
+
"sentBeforeID" => @before_id,
|
75
|
+
"sentAfterID" => @after_id,
|
76
|
+
"group" => 'Password Reset',
|
77
|
+
"clientID" => @client_id
|
78
|
+
)
|
79
|
+
response.length.should be == 1
|
80
|
+
response[0].Group.should be == "Password Reset"
|
81
|
+
response[0].Status.should be == "Delivered"
|
82
|
+
end
|
83
|
+
|
84
|
+
should "get the message details" do
|
85
|
+
stub_get(@auth, "transactional/messages/#{@message_id}", "tx_message_details.json")
|
86
|
+
response = CreateSend::Transactional::Timeline.new(@auth).details(@message_id)
|
87
|
+
response.TotalOpens.should be == 1
|
88
|
+
response.TotalClicks.should be == 1
|
89
|
+
end
|
90
|
+
|
91
|
+
should "get the message details with statistics" do
|
92
|
+
stub_get(@auth, "transactional/messages/#{@message_id}?statistics=true", "tx_message_details_with_statistics.json")
|
93
|
+
response = CreateSend::Transactional::Timeline.new(@auth).details(@message_id, :statistics => true)
|
94
|
+
response.Opens.length.should be == 1
|
95
|
+
response.Clicks.length.should be == 1
|
96
|
+
end
|
97
|
+
|
98
|
+
should "resend a message" do
|
99
|
+
stub_post(@auth, "transactional/messages/#{@message_id}/resend", "tx_send_single.json")
|
100
|
+
response = CreateSend::Transactional::Timeline.new(@auth).resend(@message_id)
|
101
|
+
response.length.should be == 1
|
102
|
+
response[0].MessageID.should be == "0cfe150d-d507-11e4-84a7-c31e5b59881d"
|
103
|
+
response[0].Recipient.should be == "\"Bob Sacamano\" <bob@example.com>"
|
104
|
+
response[0].Status.should be == "Received"
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
|