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.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +9 -0
  4. data/.travis.yml +7 -0
  5. data/CONTRIBUTING.md +8 -0
  6. data/Gemfile +3 -0
  7. data/HISTORY.md +299 -0
  8. data/LICENSE +19 -0
  9. data/README.md +220 -0
  10. data/RELEASE.md +53 -0
  11. data/Rakefile +24 -0
  12. data/createsend.gemspec +31 -0
  13. data/lib/createsend/administrator.rb +49 -0
  14. data/lib/createsend/cacert.pem +3849 -0
  15. data/lib/createsend/campaign.rb +202 -0
  16. data/lib/createsend/client.rb +224 -0
  17. data/lib/createsend/createsend.rb +291 -0
  18. data/lib/createsend/journey.rb +58 -0
  19. data/lib/createsend/list.rb +258 -0
  20. data/lib/createsend/person.rb +59 -0
  21. data/lib/createsend/segment.rb +81 -0
  22. data/lib/createsend/subscriber.rb +113 -0
  23. data/lib/createsend/template.rb +42 -0
  24. data/lib/createsend/transactional_classic_email.rb +32 -0
  25. data/lib/createsend/transactional_smart_email.rb +31 -0
  26. data/lib/createsend/transactional_timeline.rb +45 -0
  27. data/lib/createsend/version.rb +3 -0
  28. data/lib/createsend.rb +17 -0
  29. data/samples/authentication_sample.rb +64 -0
  30. data/samples/clients_sample.rb +79 -0
  31. data/samples/journey_sample.rb +87 -0
  32. data/samples/lists_sample.rb +51 -0
  33. data/samples/segments_sample.rb +21 -0
  34. data/samples/subscribers_sample.rb +51 -0
  35. data/test/administrator_test.rb +37 -0
  36. data/test/campaign_test.rb +296 -0
  37. data/test/client_test.rb +253 -0
  38. data/test/createsend_test.rb +321 -0
  39. data/test/fixtures/active_subscribers.json +87 -0
  40. data/test/fixtures/add_admin.json +3 -0
  41. data/test/fixtures/add_person.json +3 -0
  42. data/test/fixtures/add_subscriber.json +1 -0
  43. data/test/fixtures/admin_details.json +5 -0
  44. data/test/fixtures/admin_get_primary_contact.json +3 -0
  45. data/test/fixtures/admin_set_primary_contact.json +3 -0
  46. data/test/fixtures/administrators.json +12 -0
  47. data/test/fixtures/billingdetails.json +3 -0
  48. data/test/fixtures/bounced_subscribers.json +20 -0
  49. data/test/fixtures/campaign_bounces.json +25 -0
  50. data/test/fixtures/campaign_clicks.json +50 -0
  51. data/test/fixtures/campaign_listsandsegments.json +15 -0
  52. data/test/fixtures/campaign_opens.json +71 -0
  53. data/test/fixtures/campaign_recipients.json +91 -0
  54. data/test/fixtures/campaign_spam.json +16 -0
  55. data/test/fixtures/campaign_summary.json +16 -0
  56. data/test/fixtures/campaign_unsubscribes.json +17 -0
  57. data/test/fixtures/campaigns.json +37 -0
  58. data/test/fixtures/client_details.json +28 -0
  59. data/test/fixtures/client_get_primary_contact.json +3 -0
  60. data/test/fixtures/client_set_primary_contact.json +3 -0
  61. data/test/fixtures/clients.json +10 -0
  62. data/test/fixtures/countries.json +247 -0
  63. data/test/fixtures/create_campaign.json +1 -0
  64. data/test/fixtures/create_client.json +1 -0
  65. data/test/fixtures/create_custom_field.json +1 -0
  66. data/test/fixtures/create_list.json +1 -0
  67. data/test/fixtures/create_list_webhook.json +1 -0
  68. data/test/fixtures/create_segment.json +1 -0
  69. data/test/fixtures/create_template.json +1 -0
  70. data/test/fixtures/custom_api_error.json +4 -0
  71. data/test/fixtures/custom_fields.json +23 -0
  72. data/test/fixtures/deleted_subscribers.json +61 -0
  73. data/test/fixtures/drafts.json +26 -0
  74. data/test/fixtures/email_client_usage.json +38 -0
  75. data/test/fixtures/expired_oauth_token_api_error.json +4 -0
  76. data/test/fixtures/external_session.json +3 -0
  77. data/test/fixtures/import_subscribers.json +7 -0
  78. data/test/fixtures/import_subscribers_partial_success.json +17 -0
  79. data/test/fixtures/invalid_oauth_token_api_error.json +4 -0
  80. data/test/fixtures/journey_bounces.json +35 -0
  81. data/test/fixtures/journey_clicks.json +35 -0
  82. data/test/fixtures/journey_opens.json +55 -0
  83. data/test/fixtures/journey_recipients.json +27 -0
  84. data/test/fixtures/journey_summary.json +18 -0
  85. data/test/fixtures/journey_unsubscribes.json +26 -0
  86. data/test/fixtures/journeys.json +20 -0
  87. data/test/fixtures/list_details.json +8 -0
  88. data/test/fixtures/list_stats.json +26 -0
  89. data/test/fixtures/list_webhooks.json +18 -0
  90. data/test/fixtures/lists.json +10 -0
  91. data/test/fixtures/listsforemail.json +14 -0
  92. data/test/fixtures/oauth_exchange_token.json +5 -0
  93. data/test/fixtures/oauth_exchange_token_error.json +4 -0
  94. data/test/fixtures/oauth_refresh_token_error.json +4 -0
  95. data/test/fixtures/people.json +14 -0
  96. data/test/fixtures/person_details.json +6 -0
  97. data/test/fixtures/refresh_oauth_token.json +5 -0
  98. data/test/fixtures/revoked_oauth_token_api_error.json +4 -0
  99. data/test/fixtures/scheduled_campaigns.json +30 -0
  100. data/test/fixtures/segment_details.json +24 -0
  101. data/test/fixtures/segment_subscribers.json +27 -0
  102. data/test/fixtures/segments.json +12 -0
  103. data/test/fixtures/subscriber_details.json +23 -0
  104. data/test/fixtures/subscriber_details_with_track_and_sms_pref.json +25 -0
  105. data/test/fixtures/subscriber_history.json +45 -0
  106. data/test/fixtures/suppressionlist.json +41 -0
  107. data/test/fixtures/systemdate.json +3 -0
  108. data/test/fixtures/tags.json +10 -0
  109. data/test/fixtures/template_details.json +6 -0
  110. data/test/fixtures/templates.json +14 -0
  111. data/test/fixtures/timezones.json +99 -0
  112. data/test/fixtures/transfer_credits.json +4 -0
  113. data/test/fixtures/tx_classicemail_groups.json +14 -0
  114. data/test/fixtures/tx_message_details.json +36 -0
  115. data/test/fixtures/tx_message_details_with_statistics.json +72 -0
  116. data/test/fixtures/tx_messages.json +38 -0
  117. data/test/fixtures/tx_messages_classic.json +15 -0
  118. data/test/fixtures/tx_messages_smart.json +15 -0
  119. data/test/fixtures/tx_resend_message.json +6 -0
  120. data/test/fixtures/tx_send_multiple.json +12 -0
  121. data/test/fixtures/tx_send_single.json +7 -0
  122. data/test/fixtures/tx_smartemail_details.json +23 -0
  123. data/test/fixtures/tx_smartemails.json +15 -0
  124. data/test/fixtures/tx_statistics_classic.json +14 -0
  125. data/test/fixtures/tx_statistics_smart.json +14 -0
  126. data/test/fixtures/unconfirmed_subscribers.json +43 -0
  127. data/test/fixtures/unsubscribed_subscribers.json +61 -0
  128. data/test/fixtures/update_custom_field.json +1 -0
  129. data/test/helper.rb +79 -0
  130. data/test/journey_test.rb +156 -0
  131. data/test/list_test.rb +288 -0
  132. data/test/person_test.rb +39 -0
  133. data/test/segment_test.rb +74 -0
  134. data/test/subscriber_test.rb +177 -0
  135. data/test/template_test.rb +36 -0
  136. data/test/transactional_classic_email_test.rb +60 -0
  137. data/test/transactional_smart_email_test.rb +83 -0
  138. data/test/transactional_timeline_test.rb +110 -0
  139. metadata +431 -0
@@ -0,0 +1,321 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class CreateSendTest < Test::Unit::TestCase
4
+
5
+ context "when an api caller requires createsend" do
6
+ setup do
7
+ @access_token = "h9898wu98u9dqjoijnwld"
8
+ @refresh_token = "tGzv3JOkF0XG5Qx2TlKWIA"
9
+ @api_key = "hiuhqiw78hiqhwdwdqwdqw2s2e2"
10
+ end
11
+
12
+ should "authenticate using an oauth access token and refresh token" do
13
+ auth = {
14
+ :access_token => @access_token,
15
+ :refresh_token => @refresh_token
16
+ }
17
+ cs = CreateSend::CreateSend.new auth
18
+ cs.auth_details.should be == auth
19
+ end
20
+
21
+ should "authenticate using an api key" do
22
+ auth = {:api_key => @api_key}
23
+ cs = CreateSend::CreateSend.new auth
24
+ cs.auth_details.should be == auth
25
+ end
26
+
27
+ should "get the authorization url without state included" do
28
+ client_id = 8998879
29
+ redirect_uri = 'http://example.com/auth'
30
+ scope = 'ViewReports,CreateCampaigns,SendCampaigns'
31
+ url = CreateSend::CreateSend.authorize_url(client_id, redirect_uri, scope)
32
+ url.should be == "https://api.createsend.com/oauth?client_id=8998879&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&scope=ViewReports%2CCreateCampaigns%2CSendCampaigns"
33
+ end
34
+
35
+ should "get the authorization url with state included" do
36
+ client_id = 8998879
37
+ redirect_uri = 'http://example.com/auth'
38
+ scope = 'ViewReports,CreateCampaigns,SendCampaigns'
39
+ state = 89879287
40
+ url = CreateSend::CreateSend.authorize_url(client_id, redirect_uri, scope, state)
41
+ url.should be == "https://api.createsend.com/oauth?client_id=8998879&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&scope=ViewReports%2CCreateCampaigns%2CSendCampaigns&state=89879287"
42
+ end
43
+
44
+ should "exchange an OAuth token for an access token, 'expires in' value, and refresh token" do
45
+ client_id = 8998879
46
+ client_secret = 'iou0q9wud0q9wd0q9wid0q9iwd0q9wid0q9wdqwd'
47
+ redirect_uri = 'http://example.com/auth'
48
+ code = 'jdiwouo8uowi9o9o'
49
+ options = {
50
+ :body => fixture_file("oauth_exchange_token.json"),
51
+ :content_type => "application/json; charset=utf-8" }
52
+ FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
53
+ access_token, expires_in, refresh_token = CreateSend::CreateSend.exchange_token(
54
+ client_id, client_secret, redirect_uri, code)
55
+
56
+ FakeWeb.last_request.body.should be == "grant_type=authorization_code&client_id=8998879&client_secret=iou0q9wud0q9wd0q9wid0q9iwd0q9wid0q9wdqwd&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&code=jdiwouo8uowi9o9o"
57
+ access_token.should be == "SlAV32hkKG"
58
+ expires_in.should be == 1209600
59
+ refresh_token.should be == "tGzv3JOkF0XG5Qx2TlKWIA"
60
+ end
61
+
62
+ should "raise an error when an attempt to exchange an OAuth token for an access token fails" do
63
+ client_id = 8998879
64
+ client_secret = 'iou0q9wud0q9wd0q9wid0q9iwd0q9wid0q9wdqwd'
65
+ redirect_uri = 'http://example.com/auth'
66
+ code = 'invalidcode'
67
+ options = {
68
+ :body => fixture_file("oauth_exchange_token_error.json"),
69
+ :content_type => "application/json; charset=utf-8" }
70
+ FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
71
+ lambda { CreateSend::CreateSend.exchange_token(
72
+ client_id, client_secret, redirect_uri, code) }.should raise_error(
73
+ Exception, 'Error exchanging code for access token: invalid_grant - Specified code was invalid or expired')
74
+ FakeWeb.last_request.body.should be == "grant_type=authorization_code&client_id=8998879&client_secret=iou0q9wud0q9wd0q9wid0q9iwd0q9wid0q9wdqwd&redirect_uri=http%3A%2F%2Fexample.com%2Fauth&code=invalidcode"
75
+ end
76
+
77
+ should "refresh an access token given a refresh token" do
78
+ refresh_token = 'ASP95S4aR+9KsgfHB0dapTYxNA=='
79
+ options = {
80
+ :body => fixture_file("refresh_oauth_token.json"),
81
+ :content_type => "application/json; charset=utf-8" }
82
+ FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
83
+ new_access_token, new_expires_in, new_refresh_token = CreateSend::CreateSend.refresh_access_token refresh_token
84
+
85
+ FakeWeb.last_request.body.should be == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(refresh_token)}"
86
+ new_access_token.should be == "SlAV32hkKG2e12e"
87
+ new_expires_in.should be == 1209600
88
+ new_refresh_token.should be == "tGzv3JOkF0XG5Qx2TlKWIA"
89
+ end
90
+
91
+ should "raise an error when an attempt to refresh an access token fails" do
92
+ refresh_token = 'ASP95S4aR+9KsgfHB0dapTYxNA=='
93
+ options = {
94
+ :body => fixture_file("oauth_refresh_token_error.json"),
95
+ :content_type => "application/json; charset=utf-8" }
96
+ FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
97
+ lambda { CreateSend::CreateSend.refresh_access_token(
98
+ refresh_token) }.should raise_error(
99
+ Exception, 'Error refreshing access token: invalid_grant - Specified refresh_token was invalid or expired')
100
+ FakeWeb.last_request.body.should be == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(refresh_token)}"
101
+ end
102
+
103
+ end
104
+
105
+ context "when an api caller is authenticated using oauth" do
106
+ setup do
107
+ @access_token = "ASP95S4aR+9KsgfHB0dapTYxNA=="
108
+ @refresh_token = "5S4aASP9R+9KsgfHB0dapTYxNA=="
109
+ @auth = {
110
+ :access_token => @access_token,
111
+ :refresh_token => @refresh_token
112
+ }
113
+ end
114
+
115
+ should "refresh the current access token" do
116
+ options = {
117
+ :body => fixture_file("refresh_oauth_token.json"),
118
+ :content_type => "application/json; charset=utf-8" }
119
+ FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
120
+ cs = CreateSend::CreateSend.new @auth
121
+ new_access_token, new_expires_in, new_refresh_token = cs.refresh_token
122
+
123
+ FakeWeb.last_request.body.should be == "grant_type=refresh_token&refresh_token=#{ERB::Util.url_encode(@auth[:refresh_token])}"
124
+ new_access_token.should be == "SlAV32hkKG2e12e"
125
+ new_expires_in.should be == 1209600
126
+ new_refresh_token.should be == "tGzv3JOkF0XG5Qx2TlKWIA"
127
+ cs.auth_details.should be == {
128
+ :access_token => new_access_token,
129
+ :refresh_token => new_refresh_token
130
+ }
131
+ end
132
+
133
+ should "raise an error when an attempt to refresh the access token is made but refresh token is nil" do
134
+ cs = CreateSend::CreateSend.new :access_token => 'any token', :refresh_token => nil
135
+ lambda { cs.refresh_token }.should raise_error(
136
+ Exception, '@auth_details[:refresh_token] does not contain a refresh token.')
137
+ end
138
+
139
+ should "raise an error when an attempt to refresh the access token is made but no there was no refresh token passed in" do
140
+ cs = CreateSend::CreateSend.new :access_token => 'any token'
141
+ lambda { cs.refresh_token }.should raise_error(
142
+ Exception, '@auth_details[:refresh_token] does not contain a refresh token.')
143
+ end
144
+
145
+ should "raise an error when an attempt to refresh the access token is made but no there was no auth hash passed in" do
146
+ cs = CreateSend::CreateSend.new
147
+ lambda { cs.refresh_token }.should raise_error(
148
+ Exception, '@auth_details[:refresh_token] does not contain a refresh token.')
149
+ end
150
+
151
+ should "raise an error when an attempt to refresh the access token is made but the refresh token is invalid" do
152
+ refresh_token = 'ASP95S4aR+9KsgfHB0dapTYxNA=='
153
+ cs = CreateSend::CreateSend.new :access_token => 'any token', :refresh_token => refresh_token
154
+ options = {
155
+ :body => fixture_file("oauth_refresh_token_error.json"),
156
+ :content_type => "application/json; charset=utf-8" }
157
+ FakeWeb.register_uri(:post, "https://api.createsend.com/oauth/token", options)
158
+ lambda { refresh_token = cs.refresh_token }.should raise_error(
159
+ Exception, 'Error refreshing access token: invalid_grant - Specified refresh_token was invalid or expired')
160
+ end
161
+
162
+ should "raise a CreateSend::InvalidOAuthToken error when an access token is invalid" do
163
+ cs = CreateSend::CreateSend.new @auth
164
+ stub_get(@auth, "countries.json", "invalid_oauth_token_api_error.json", ["401", "Unauthorized"])
165
+ lambda { cs.countries }.should raise_error(CreateSend::InvalidOAuthToken)
166
+ end
167
+
168
+ should "raise a CreateSend::ExpiredOAuthToken error when an access token is expired" do
169
+ cs = CreateSend::CreateSend.new @auth
170
+ stub_get(@auth, "countries.json", "expired_oauth_token_api_error.json", ["401", "Unauthorized"])
171
+ lambda { cs.countries }.should raise_error(CreateSend::ExpiredOAuthToken)
172
+ end
173
+
174
+ should "raise a CreateSend::RevokedOAuthToken error when an access token is revoked" do
175
+ cs = CreateSend::CreateSend.new @auth
176
+ stub_get(@auth, "countries.json", "revoked_oauth_token_api_error.json", ["401", "Unauthorized"])
177
+ lambda { cs.countries }.should raise_error(CreateSend::RevokedOAuthToken)
178
+ end
179
+
180
+ end
181
+
182
+ multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
183
+ setup do
184
+ @cs = CreateSend::CreateSend.new @auth
185
+ end
186
+
187
+ should "include the correct user agent string when making a call" do
188
+ CreateSend::CreateSend.headers["User-Agent"].should be ==
189
+ "createsend-ruby-#{CreateSend::VERSION}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}-#{RUBY_PLATFORM}"
190
+ stub_get(@auth, "clients.json", "clients.json")
191
+ clients = @cs.clients
192
+ clients.size.should be == 2
193
+ end
194
+
195
+ should "allow a custom user agent string to be set when making a call" do
196
+ CreateSend::CreateSend.user_agent "custom user agent"
197
+ CreateSend::CreateSend.headers["User-Agent"].should be == "custom user agent"
198
+ stub_get(@auth, "clients.json", "clients.json")
199
+ clients = @cs.clients
200
+ clients.size.should be == 2
201
+ CreateSend::CreateSend.user_agent nil
202
+ end
203
+
204
+ should "get all clients" do
205
+ stub_get(@auth, "clients.json", "clients.json")
206
+ clients = @cs.clients
207
+ clients.size.should be == 2
208
+ clients.first.ClientID.should be == '4a397ccaaa55eb4e6aa1221e1e2d7122'
209
+ clients.first.Name.should be == 'Client One'
210
+ end
211
+
212
+ should "get billing details" do
213
+ stub_get(@auth, "billingdetails.json", "billingdetails.json")
214
+ bd = @cs.billing_details
215
+ bd.Credits.should be == 3021
216
+ end
217
+
218
+ should "get all countries" do
219
+ stub_get(@auth, "countries.json", "countries.json")
220
+ countries = @cs.countries
221
+ countries.size.should be == 245
222
+ assert countries.include? "Australia"
223
+ end
224
+
225
+ should "get system date" do
226
+ stub_get(@auth, "systemdate.json", "systemdate.json")
227
+ systemdate = @cs.systemdate.SystemDate
228
+ systemdate.should be == "2010-10-15 09:27:00"
229
+ end
230
+
231
+ should "get all timezones" do
232
+ stub_get(@auth, "timezones.json", "timezones.json")
233
+ timezones = @cs.timezones
234
+ timezones.size.should be == 97
235
+ assert timezones.include? "(GMT+12:00) Fiji"
236
+ end
237
+
238
+ should "get all administrators" do
239
+ stub_get(@auth, "admins.json", "administrators.json")
240
+ administrators = @cs.administrators
241
+ administrators.size.should be == 2
242
+ administrators.first.EmailAddress.should be == "admin1@blackhole.com"
243
+ administrators.first.Name.should be == 'Admin One'
244
+ administrators.first.Status.should be == 'Active'
245
+ end
246
+
247
+ should "set primary contact" do
248
+ email = 'admin@blackhole.com'
249
+ stub_put(@auth, "primarycontact.json?email=#{ERB::Util.url_encode(email)}", 'admin_set_primary_contact.json')
250
+ result = @cs.set_primary_contact email
251
+ result.EmailAddress.should be == email
252
+ end
253
+
254
+ should "get primary contact" do
255
+ stub_get(@auth, "primarycontact.json", 'admin_get_primary_contact.json')
256
+ result = @cs.get_primary_contact
257
+ result.EmailAddress.should be == 'admin@blackhole.com'
258
+ end
259
+
260
+ should "get an external session url" do
261
+ email = "exammple@example.com"
262
+ chrome = "None"
263
+ url = "/subscribers"
264
+ integrator_id = "qw989q8wud98qwyd"
265
+ client_id = "9q8uw9d8u9wud"
266
+ stub_put(@auth, "externalsession.json", "external_session.json")
267
+ result = @cs.external_session_url email, chrome, url, integrator_id, client_id
268
+ result.SessionUrl.should be == "https://external1.createsend.com/cd/create/ABCDEF12/DEADBEEF?url=FEEDDAD1"
269
+ end
270
+
271
+ end
272
+
273
+ context "when the CreateSend API responds with an error" do
274
+
275
+ multiple_contexts "authenticated_using_oauth_context", "authenticated_using_api_key_context" do
276
+ setup do
277
+ @cs = CreateSend::CreateSend.new @auth
278
+ @template = CreateSend::Template.new @auth, '98y2e98y289dh89h938389'
279
+ end
280
+
281
+ { ["400", "Bad Request"] => CreateSend::BadRequest,
282
+ ["401", "Unauthorized"] => CreateSend::Unauthorized,
283
+ ["404", "Not Found"] => CreateSend::NotFound,
284
+ ["418", "I'm a teapot"] => CreateSend::ClientError,
285
+ ["500", "Server Error"] => CreateSend::ServerError
286
+ }.each do |status, exception|
287
+ context "#{status.first}, a get" do
288
+ should "raise a #{exception.name} error" do
289
+ stub_get(@auth, "countries.json", (status.first == '400' or status.first == '401') ? 'custom_api_error.json' : nil, status)
290
+ lambda { @cs.countries }.should raise_error(exception)
291
+ end
292
+ end
293
+
294
+ context "#{status.first}, a post" do
295
+ should "raise a #{exception.name} error" do
296
+ stub_post(@auth, "clients.json", (status.first == '400' or status.first == '401') ? 'custom_api_error.json' : nil, status)
297
+ lambda { CreateSend::Client.create @auth, "Client Company Name",
298
+ "(GMT+10:00) Canberra, Melbourne, Sydney", "Australia" }.should raise_error(exception)
299
+ end
300
+ end
301
+
302
+ context "#{status.first}, a put" do
303
+ should "raise a #{exception.name} error" do
304
+ stub_put(@auth, "templates/#{@template.template_id}.json", (status.first == '400' or status.first == '401') ? 'custom_api_error.json' : nil, status)
305
+ lambda { @template.update "Template One Updated", "http://templates.org/index.html",
306
+ "http://templates.org/files.zip" }.should raise_error(exception)
307
+ end
308
+ end
309
+
310
+ context "#{status.first}, a delete" do
311
+ should "raise a #{exception.name} error" do
312
+ stub_delete(@auth, "templates/#{@template.template_id}.json", (status.first == '400' or status.first == '401') ? 'custom_api_error.json' : nil, status)
313
+ lambda { @template.delete }.should raise_error(exception)
314
+ end
315
+ end
316
+ end
317
+ end
318
+
319
+ end
320
+
321
+ end
@@ -0,0 +1,87 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "subs+7t8787Y@example.com",
5
+ "Name": "Person One",
6
+ "Date": "2010-10-25 10:28:00",
7
+ "ListJoinedDate": "2010-10-25 10:28:00",
8
+ "State": "Active",
9
+ "CustomFields": [
10
+ {
11
+ "Key": "website",
12
+ "Value": "http://example.com"
13
+ },
14
+ {
15
+ "Key": "multi select field",
16
+ "Value": "option one"
17
+ },
18
+ {
19
+ "Key": "multi select field",
20
+ "Value": "option two"
21
+ },
22
+ {
23
+ "Key": "age",
24
+ "Value": "24"
25
+ },
26
+ {
27
+ "Key": "subscription date",
28
+ "Value": "2010-03-09"
29
+ }
30
+ ],
31
+ "ReadsEmailWith": "Gmail"
32
+ },
33
+ {
34
+ "EmailAddress": "subs+7878787y8ggg@example.com",
35
+ "Name": "Person Two",
36
+ "Date": "2010-10-25 12:17:00",
37
+ "ListJoinedDate": "2010-10-25 12:17:00",
38
+ "State": "Active",
39
+ "CustomFields": [
40
+ {
41
+ "Key": "website",
42
+ "Value": "http://subdomain.example.com"
43
+ }
44
+ ],
45
+ "ReadsEmailWith": "Gmail"
46
+ },
47
+ {
48
+ "EmailAddress": "subs+7890909i0ggg@example.com",
49
+ "Name": "Person Three",
50
+ "Date": "2010-10-25 12:52:00",
51
+ "ListJoinedDate": "2010-10-25 12:52:00",
52
+ "State": "Active",
53
+ "CustomFields": [
54
+ {
55
+ "Key": "website",
56
+ "Value": "http://subdomain.example.com"
57
+ }
58
+ ],
59
+ "ReadsEmailWith": ""
60
+ },
61
+ {
62
+ "EmailAddress": "subs@example.com",
63
+ "Name": "Person Four",
64
+ "Date": "2010-10-27 13:13:00",
65
+ "ListJoinedDate": "2010-10-27 13:13:00",
66
+ "State": "Active",
67
+ "CustomFields": [],
68
+ "ReadsEmailWith": ""
69
+ },
70
+ {
71
+ "EmailAddress": "joey@example.com",
72
+ "Name": "Person Five",
73
+ "Date": "2010-10-27 13:13:00",
74
+ "ListJoinedDate": "2010-10-27 13:13:00",
75
+ "State": "Active",
76
+ "CustomFields": [],
77
+ "ReadsEmailWith": "Gmail"
78
+ }
79
+ ],
80
+ "ResultsOrderedBy": "email",
81
+ "OrderDirection": "asc",
82
+ "PageNumber": 1,
83
+ "PageSize": 1000,
84
+ "RecordsOnThisPage": 5,
85
+ "TotalNumberOfRecords": 5,
86
+ "NumberOfPages": 1
87
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "EmailAddress": "admin@example.com"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "EmailAddress": "person@example.com"
3
+ }
@@ -0,0 +1 @@
1
+ "subscriber@example.com"
@@ -0,0 +1,5 @@
1
+ {
2
+ "EmailAddress": "admin@example.com",
3
+ "Name": "Admin One",
4
+ "Status": "Active"
5
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "EmailAddress": "admin@blackhole.com"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "EmailAddress": "admin@blackhole.com"
3
+ }
@@ -0,0 +1,12 @@
1
+ [
2
+ {
3
+ "EmailAddress": "admin1@blackhole.com",
4
+ "Name": "Admin One",
5
+ "Status": "Active"
6
+ },
7
+ {
8
+ "EmailAddress": "admin2@blackhole.com",
9
+ "Name": "Admin Two",
10
+ "Status": "Active"
11
+ }
12
+ ]
@@ -0,0 +1,3 @@
1
+ {
2
+ "Credits": 3021
3
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "bouncedsubscriber@example.com",
5
+ "Name": "Bounced One",
6
+ "Date": "2010-10-25 13:11:00",
7
+ "ListJoinedDate": "2010-10-25 13:11:00",
8
+ "State": "Bounced",
9
+ "CustomFields": [],
10
+ "ReadsEmailWith": ""
11
+ }
12
+ ],
13
+ "ResultsOrderedBy": "email",
14
+ "OrderDirection": "asc",
15
+ "PageNumber": 1,
16
+ "PageSize": 1000,
17
+ "RecordsOnThisPage": 1,
18
+ "TotalNumberOfRecords": 1,
19
+ "NumberOfPages": 1
20
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "asdf@softbouncemyemail.com",
5
+ "ListID": "654523a5855b4a440bae3fb295641546",
6
+ "BounceType": "Soft",
7
+ "Date": "2010-07-02 16:46:00",
8
+ "Reason": "Bounce - But No Email Address Returned "
9
+ },
10
+ {
11
+ "EmailAddress": "asdf@hardbouncemyemail.com",
12
+ "ListID": "654523a5855b4a440bae3fb295641546",
13
+ "BounceType": "Soft",
14
+ "Date": "2010-07-02 16:46:00",
15
+ "Reason": "Soft Bounce - General"
16
+ }
17
+ ],
18
+ "ResultsOrderedBy": "date",
19
+ "OrderDirection": "asc",
20
+ "PageNumber": 1,
21
+ "PageSize": 1000,
22
+ "RecordsOnThisPage": 2,
23
+ "TotalNumberOfRecords": 2,
24
+ "NumberOfPages": 1
25
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "subs+6576576576@example.com",
5
+ "URL": "http://video.google.com.au/?hl=en&tab=wv",
6
+ "ListID": "512a3bc577a58fdf689c654329b50fa0",
7
+ "Date": "2010-10-11 08:29:00",
8
+ "IPAddress": "192.168.126.87",
9
+ "Latitude": -33.8683,
10
+ "Longitude": 151.2086,
11
+ "City": "Sydney",
12
+ "Region": "New South Wales",
13
+ "CountryCode": "AU",
14
+ "CountryName": "Australia"
15
+ },
16
+ {
17
+ "EmailAddress": "subs+6576576576@example.com",
18
+ "URL": "http://mail.google.com/mail/?hl=en&tab=wm",
19
+ "ListID": "512a3bc577a58fdf689c654329b50fa0",
20
+ "Date": "2010-10-11 08:29:00",
21
+ "IPAddress": "192.168.126.87",
22
+ "Latitude": -33.8683,
23
+ "Longitude": 151.2086,
24
+ "City": "Sydney",
25
+ "Region": "New South Wales",
26
+ "CountryCode": "AU",
27
+ "CountryName": "Australia"
28
+ },
29
+ {
30
+ "EmailAddress": "subs+6576576576@example.com",
31
+ "URL": "http://mail.google.com/mail/?hl=en&tab=wm",
32
+ "ListID": "512a3bc577a58fdf689c654329b50fa0",
33
+ "Date": "2010-10-06 17:24:00",
34
+ "IPAddress": "192.168.126.87",
35
+ "Latitude": -33.8683,
36
+ "Longitude": 151.2086,
37
+ "City": "Sydney",
38
+ "Region": "New South Wales",
39
+ "CountryCode": "AU",
40
+ "CountryName": "Australia"
41
+ }
42
+ ],
43
+ "ResultsOrderedBy": "date",
44
+ "OrderDirection": "asc",
45
+ "PageNumber": 1,
46
+ "PageSize": 1000,
47
+ "RecordsOnThisPage": 3,
48
+ "TotalNumberOfRecords": 3,
49
+ "NumberOfPages": 1
50
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "Lists": [
3
+ {
4
+ "ListID": "a58ee1d3039b8bec838e6d1482a8a965",
5
+ "Name": "List One"
6
+ }
7
+ ],
8
+ "Segments": [
9
+ {
10
+ "ListID": "2bea949d0bf96148c3e6a209d2e82060",
11
+ "SegmentID": "dba84a225d5ce3d19105d7257baac46f",
12
+ "Title": "Segment for campaign"
13
+ }
14
+ ]
15
+ }
@@ -0,0 +1,71 @@
1
+ {
2
+ "Results": [
3
+ {
4
+ "EmailAddress": "subs+6576576576@example.com",
5
+ "ListID": "512a3bc577a58fdf689c654329b50fa0",
6
+ "Date": "2010-10-11 08:29:00",
7
+ "IPAddress": "192.168.126.87",
8
+ "Latitude": -33.8683,
9
+ "Longitude": 151.2086,
10
+ "City": "Sydney",
11
+ "Region": "New South Wales",
12
+ "CountryCode": "AU",
13
+ "CountryName": "Australia"
14
+ },
15
+ {
16
+ "EmailAddress": "subs+6576576576@example.com",
17
+ "ListID": "512a3bc577a58fdf689c654329b50fa0",
18
+ "Date": "2010-10-08 14:24:00",
19
+ "IPAddress": "192.168.126.87",
20
+ "Latitude": -33.8683,
21
+ "Longitude": 151.2086,
22
+ "City": "Sydney",
23
+ "Region": "New South Wales",
24
+ "CountryCode": "AU",
25
+ "CountryName": "Australia"
26
+ },
27
+ {
28
+ "EmailAddress": "subs+6576576576@example.com",
29
+ "ListID": "512a3bc577a58fdf689c654329b50fa0",
30
+ "Date": "2010-10-07 10:20:00",
31
+ "IPAddress": "192.168.126.87",
32
+ "Latitude": -33.8683,
33
+ "Longitude": 151.2086,
34
+ "City": "Sydney",
35
+ "Region": "New South Wales",
36
+ "CountryCode": "AU",
37
+ "CountryName": "Australia"
38
+ },
39
+ {
40
+ "EmailAddress": "subs+6576576576@example.com",
41
+ "ListID": "512a3bc577a58fdf689c654329b50fa0",
42
+ "Date": "2010-10-07 07:15:00",
43
+ "IPAddress": "192.168.126.87",
44
+ "Latitude": -33.8683,
45
+ "Longitude": 151.2086,
46
+ "City": "Sydney",
47
+ "Region": "New South Wales",
48
+ "CountryCode": "AU",
49
+ "CountryName": "Australia"
50
+ },
51
+ {
52
+ "EmailAddress": "subs+6576576576@example.com",
53
+ "ListID": "512a3bc577a58fdf689c654329b50fa0",
54
+ "Date": "2010-10-07 06:58:00",
55
+ "IPAddress": "192.168.126.87",
56
+ "Latitude": -33.8683,
57
+ "Longitude": 151.2086,
58
+ "City": "Sydney",
59
+ "Region": "New South Wales",
60
+ "CountryCode": "AU",
61
+ "CountryName": "Australia"
62
+ }
63
+ ],
64
+ "ResultsOrderedBy": "date",
65
+ "OrderDirection": "asc",
66
+ "PageNumber": 1,
67
+ "PageSize": 1000,
68
+ "RecordsOnThisPage": 5,
69
+ "TotalNumberOfRecords": 5,
70
+ "NumberOfPages": 1
71
+ }