mailgun-ruby 1.1.9 → 1.2.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -0
  3. data/.rubocop_todo.yml +0 -0
  4. data/.ruby-env.yml.example +1 -0
  5. data/.travis.yml +6 -5
  6. data/CHANGELOG.md +16 -0
  7. data/Gemfile +1 -1
  8. data/README.md +30 -3
  9. data/docs/Domains.md +3 -0
  10. data/docs/EmailValidation.md +34 -0
  11. data/docs/OptInHandler.md +1 -1
  12. data/docs/Snippets.md +54 -61
  13. data/docs/Subaccounts.md +68 -0
  14. data/docs/Suppressions.md +10 -0
  15. data/docs/Webhooks.md +0 -0
  16. data/docs/railgun/EmailValidation.md +34 -0
  17. data/docs/railgun/Overview.md +11 -0
  18. data/docs/railgun/Parameters.md +83 -0
  19. data/docs/railgun/Templates.md +92 -0
  20. data/lib/mailgun/address.rb +3 -28
  21. data/lib/mailgun/chains.rb +0 -0
  22. data/lib/mailgun/client.rb +55 -9
  23. data/lib/mailgun/domains/domains.rb +20 -2
  24. data/lib/mailgun/events/events.rb +2 -2
  25. data/lib/mailgun/exceptions/exceptions.rb +28 -1
  26. data/lib/mailgun/messages/batch_message.rb +1 -0
  27. data/lib/mailgun/messages/message_builder.rb +56 -8
  28. data/lib/mailgun/response.rb +7 -0
  29. data/lib/mailgun/subaccounts/subaccounts.rb +84 -0
  30. data/lib/mailgun/suppressions.rb +15 -8
  31. data/lib/mailgun/templates/templates.rb +187 -0
  32. data/lib/mailgun/version.rb +1 -1
  33. data/lib/mailgun/webhooks/webhooks.rb +2 -2
  34. data/lib/mailgun-ruby.rb +1 -1
  35. data/lib/mailgun.rb +5 -1
  36. data/lib/railgun/mailer.rb +85 -12
  37. data/lib/railgun/message.rb +2 -1
  38. data/lib/railgun/railtie.rb +3 -2
  39. data/mailgun.gemspec +15 -12
  40. data/spec/integration/bounces_spec.rb +3 -3
  41. data/spec/integration/campaign_spec.rb +0 -0
  42. data/spec/integration/complaints_spec.rb +0 -0
  43. data/spec/integration/domains_spec.rb +8 -0
  44. data/spec/integration/email_validation_spec.rb +10 -2
  45. data/spec/integration/events_spec.rb +1 -1
  46. data/spec/integration/list_members_spec.rb +0 -0
  47. data/spec/integration/list_spec.rb +0 -0
  48. data/spec/integration/mailer_spec.rb +67 -0
  49. data/spec/integration/mailgun_spec.rb +92 -1
  50. data/spec/integration/routes_spec.rb +0 -0
  51. data/spec/integration/stats_spec.rb +0 -0
  52. data/spec/integration/subaccounts_spec.rb +58 -0
  53. data/spec/integration/suppressions_spec.rb +18 -2
  54. data/spec/integration/templates_spec.rb +135 -0
  55. data/spec/integration/unsubscribes_spec.rb +0 -0
  56. data/spec/integration/webhook_spec.rb +0 -0
  57. data/spec/spec_helper.rb +3 -1
  58. data/spec/unit/connection/test_client.rb +18 -1
  59. data/spec/unit/events/events_spec.rb +19 -0
  60. data/spec/unit/mailgun_spec.rb +43 -2
  61. data/spec/unit/messages/batch_message_spec.rb +56 -40
  62. data/spec/unit/messages/message_builder_spec.rb +149 -16
  63. data/spec/unit/messages/sample_data/unknown.type +0 -0
  64. data/spec/unit/railgun/mailer_spec.rb +388 -0
  65. data/vcr_cassettes/bounces.yml +12 -12
  66. data/vcr_cassettes/complaints.yml +0 -0
  67. data/vcr_cassettes/domains.todo.yml +0 -0
  68. data/vcr_cassettes/domains.yml +51 -1
  69. data/vcr_cassettes/email_validation.yml +5 -5
  70. data/vcr_cassettes/events.yml +0 -0
  71. data/vcr_cassettes/exceptions-invalid-api-key.yml +52 -0
  72. data/vcr_cassettes/exceptions-invalid-data.yml +52 -0
  73. data/vcr_cassettes/exceptions-not-allowed.yml +54 -0
  74. data/vcr_cassettes/list_members.yml +0 -0
  75. data/vcr_cassettes/mailer_invalid_domain.yml +109 -0
  76. data/vcr_cassettes/mailing_list.todo.yml +0 -0
  77. data/vcr_cassettes/mailing_list.yml +0 -0
  78. data/vcr_cassettes/message_deliver.yml +149 -0
  79. data/vcr_cassettes/routes.yml +0 -0
  80. data/vcr_cassettes/send_message.yml +0 -0
  81. data/vcr_cassettes/stats.yml +0 -0
  82. data/vcr_cassettes/subaccounts.yml +270 -0
  83. data/vcr_cassettes/suppressions.yml +66 -15
  84. data/vcr_cassettes/templates.yml +1065 -0
  85. data/vcr_cassettes/unsubscribes.yml +0 -0
  86. data/vcr_cassettes/webhooks.yml +0 -0
  87. metadata +56 -29
  88. data/.ruby-version +0 -1
  89. /data/spec/unit/{railgun_spec.rb → railgun/content_type_spec.rb} +0 -0
@@ -0,0 +1,388 @@
1
+ require 'json'
2
+ require 'logger'
3
+ require 'spec_helper'
4
+ require 'mailgun'
5
+ require 'railgun'
6
+
7
+ ActionMailer::Base.raise_delivery_errors = true
8
+ ActionMailer::Base.delivery_method = :test
9
+ Rails.logger = Logger.new('/dev/null')
10
+ Rails.logger.level = Logger::DEBUG
11
+
12
+ class UnitTestMailer < ActionMailer::Base
13
+ default from: 'unittest@example.org'
14
+
15
+ def plain_message(address, subject, headers)
16
+ headers(headers)
17
+ mail(to: address, subject: subject) do |format|
18
+ format.text { render plain: "Test!" }
19
+ format.html { render html: "<p>Test!</p>".html_safe }
20
+ end
21
+ end
22
+
23
+ def message_with_attachment(address, subject)
24
+ attachments['info.txt'] = {
25
+ :content => File.read('docs/railgun/Overview.md'),
26
+ :mime_type => 'text/plain',
27
+ }
28
+ mail(to: address, subject: subject) do |format|
29
+ format.text { render plain: "Test!" }
30
+ format.html { render html: "<p>Test!</p>".html_safe }
31
+ end
32
+ end
33
+
34
+ def message_with_template(address, subject, template_name)
35
+ mail(to: address, subject: subject, template: template_name) do |format|
36
+ format.text { render plain: "Test!" }
37
+ end
38
+ end
39
+
40
+ def message_with_domain(address, subject, domain)
41
+ mail(to: address, subject: subject, domain: domain) do |format|
42
+ format.text { render plain: "Test!" }
43
+ end
44
+ end
45
+
46
+ end
47
+
48
+ describe 'Railgun::Mailer' do
49
+
50
+ it 'has a mailgun_client property which returns a Mailgun::Client' do
51
+ config = {
52
+ api_key: {},
53
+ domain: {}
54
+ }
55
+ @mailer_obj = Railgun::Mailer.new(config)
56
+
57
+ expect(@mailer_obj.mailgun_client).to be_a(Mailgun::Client)
58
+ end
59
+
60
+ context 'when config does not have api_key or domain' do
61
+ it 'raises configuration error' do
62
+ config = {
63
+ api_key: {}
64
+ }
65
+
66
+ expect { Railgun::Mailer.new(config) }.to raise_error(Railgun::ConfigurationError)
67
+ end
68
+ end
69
+
70
+ context 'when fake_message_send is present in config' do
71
+ it 'enables test mode' do
72
+ config = {
73
+ api_key: {},
74
+ domain: {},
75
+ fake_message_send: true
76
+ }
77
+ client_double = double(Mailgun::Client)
78
+ allow(Mailgun::Client).to receive(:new).and_return(client_double)
79
+ expect(client_double).to receive(:enable_test_mode!)
80
+
81
+ Railgun::Mailer.new(config)
82
+ end
83
+ end
84
+
85
+ it 'properly creates a message body' do
86
+ message = UnitTestMailer.plain_message('test@example.org', 'Test!', {})
87
+ body = Railgun.transform_for_mailgun(message)
88
+
89
+ [:from, :subject, :text, :html, 'to'].each do |param|
90
+ expect(body).to include(param)
91
+ end
92
+
93
+ expect(body[:from][0].value).to eq('unittest@example.org')
94
+ expect(body['to']).to eq(['test@example.org'])
95
+ expect(body[:subject]).to eq(['Test!'])
96
+ expect(body[:text]).to eq(['Test!'])
97
+ expect(body[:html]).to eq(['<p>Test!</p>'.html_safe])
98
+ end
99
+
100
+ it 'adds options to message body' do
101
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
102
+ message.mailgun_options ||= {
103
+ 'tracking-opens' => 'true',
104
+ }
105
+
106
+ body = Railgun.transform_for_mailgun(message)
107
+
108
+ expect(body).to include('o:tracking-opens')
109
+ expect(body['o:tracking-opens']).to eq('true')
110
+ end
111
+
112
+ it 'accepts frozen options to message body' do
113
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
114
+ message.mailgun_options ||= {
115
+ 'tags' => ['some-tag']
116
+ }
117
+
118
+ body = Railgun.transform_for_mailgun(message)
119
+
120
+ expect(body).to include('o:tags')
121
+ expect(body['o:tags']).to eq(['some-tag'])
122
+ end
123
+
124
+ it 'adds variables to message body' do
125
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
126
+ message.mailgun_variables ||= {
127
+ 'user' => {:id => '1', :name => 'tstark'},
128
+ }
129
+
130
+ body = Railgun.transform_for_mailgun(message)
131
+
132
+ expect(body).to include('v:user')
133
+
134
+ var_body = JSON.load(body['v:user'])
135
+ expect(var_body).to include('id')
136
+ expect(var_body).to include('name')
137
+ expect(var_body['id']).to eq('1')
138
+ expect(var_body['name']).to eq('tstark')
139
+ end
140
+
141
+ it 'adds headers to message body' do
142
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
143
+ message.mailgun_headers ||= {
144
+ 'x-unit-test' => 'true',
145
+ }
146
+
147
+ body = Railgun.transform_for_mailgun(message)
148
+
149
+ expect(body).to include('h:x-unit-test')
150
+ expect(body['h:x-unit-test']).to eq('true')
151
+ end
152
+
153
+ it 'adds headers to message body from mailer' do
154
+ message = UnitTestMailer.plain_message('test@example.org', '', {
155
+ 'x-unit-test-2' => 'true',
156
+ })
157
+
158
+ body = Railgun.transform_for_mailgun(message)
159
+
160
+ expect(body).to include('h:x-unit-test-2')
161
+ expect(body['h:x-unit-test-2']).to eq('true')
162
+ end
163
+
164
+ it 'properly handles headers that are passed as separate POST params' do
165
+ message = UnitTestMailer.plain_message('test@example.org', 'Test!', {
166
+ # `From`, `To`, and `Subject` are set on the envelope, so they should be ignored as headers
167
+ 'From' => 'units@example.net',
168
+ 'To' => 'user@example.com',
169
+ 'Subject' => 'This should disappear',
170
+ # If `Bcc` or `Cc` are set as headers, they should be carried over as POST params, not headers
171
+ 'Bcc' => ['list@example.org'],
172
+ 'Cc' => ['admin@example.com'],
173
+ # This is an arbitrary header and should be carried over properly
174
+ 'X-Source' => 'unit tests',
175
+ })
176
+
177
+ body = Railgun.transform_for_mailgun(message)
178
+
179
+ ['From', 'To', 'Subject'].each do |header|
180
+ expect(body).not_to include("h:#{header}")
181
+ end
182
+
183
+ ['bcc', 'cc', 'to', 'h:x-source'].each do |param|
184
+ expect(body).to include(param)
185
+ end
186
+
187
+ expect(body[:from][0].value).to eq('unittest@example.org')
188
+ expect(body['to']).to eq(['test@example.org'])
189
+ expect(body[:subject]).to eq(['Test!'])
190
+ expect(body[:text]).to eq(['Test!'])
191
+ expect(body[:html]).to eq(['<p>Test!</p>'.html_safe])
192
+ expect(body['bcc']).to eq(['list@example.org'])
193
+ expect(body['cc']).to eq(['admin@example.com'])
194
+ expect(body['h:x-source']).to eq('unit tests')
195
+ end
196
+
197
+ context 'when mailgun_variables are present' do
198
+ it 'accepts valid JSON and stores it as message[param].' do
199
+ message = UnitTestMailer.plain_message('test@example.org', '', {}).tap do |message|
200
+ message.mailgun_variables = {
201
+ 'my-data' => '{"key":"value"}'
202
+ }
203
+ end
204
+ body = Railgun.transform_for_mailgun(message)
205
+ expect(body["v:my-data"]).to be_kind_of(String)
206
+ expect(body["v:my-data"].to_s).to eq('{"key":"value"}')
207
+ end
208
+
209
+ it 'accepts a hash and appends as data to the message.' do
210
+ message = UnitTestMailer.plain_message('test@example.org', '', {}).tap do |message|
211
+ message.mailgun_variables = {
212
+ 'my-data' => {'key' => 'value'}
213
+ }
214
+ end
215
+ body = Railgun.transform_for_mailgun(message)
216
+
217
+ expect(body["v:my-data"]).to be_kind_of(String)
218
+ expect(body["v:my-data"].to_s).to eq('{"key":"value"}')
219
+ end
220
+
221
+ it 'accepts string values' do
222
+ message = UnitTestMailer.plain_message('test@example.org', '', {}).tap do |message|
223
+ message.mailgun_variables = {
224
+ 'my-data' => 'String Value.'
225
+ }
226
+ end
227
+ body = Railgun.transform_for_mailgun(message)
228
+
229
+ expect(body["v:my-data"]).to be_kind_of(String)
230
+ expect(body["v:my-data"].to_s).to eq('String Value.')
231
+ end
232
+ end
233
+
234
+ it 'properly adds attachments' do
235
+ message = UnitTestMailer.message_with_attachment('test@example.org', '')
236
+ body = Railgun.transform_for_mailgun(message)
237
+
238
+ expect(body).to include(:attachment)
239
+ attachment = body[:attachment][0]
240
+
241
+ expect(attachment.filename).to eq('info.txt')
242
+ expect(attachment.content_type).to eq('text/plain')
243
+ end
244
+
245
+ it 'delivers!' do
246
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
247
+ message.deliver_now
248
+
249
+ expect(ActionMailer::Base.deliveries).to include(message)
250
+ end
251
+
252
+ it 'ignores `reply-to` in headers' do
253
+ message = UnitTestMailer.plain_message('test@example.org', '', {
254
+ 'reply-to' => 'user@example.com',
255
+ })
256
+ message.mailgun_headers = {
257
+ 'Reply-To' => 'administrator@example.org',
258
+ }
259
+ message.headers({'REPLY-TO' => 'admin@example.net'})
260
+ message.reply_to = "dude@example.com.au"
261
+
262
+ body = Railgun.transform_for_mailgun(message)
263
+ expect(body).to include('h:reply-to')
264
+ expect(body).not_to include('h:Reply-To')
265
+ expect(body['h:reply-to']).to eq('dude@example.com.au')
266
+ end
267
+
268
+ it 'ignores `mime-version` in headers' do
269
+ message = UnitTestMailer.plain_message('test@example.org', '', {
270
+ 'mime-version' => '1.0',
271
+ })
272
+ message.mailgun_headers = {
273
+ 'Mime-Version' => '1.1',
274
+ }
275
+ message.headers({'MIME-VERSION' => '1.2'})
276
+
277
+ body = Railgun.transform_for_mailgun(message)
278
+ expect(body).not_to include('h:mime-version')
279
+ end
280
+
281
+ it 'treats `headers()` names as case-insensitve' do
282
+ message = UnitTestMailer.plain_message('test@example.org', '', {
283
+ 'X-BIG-VALUE' => 1,
284
+ })
285
+
286
+ body = Railgun.transform_for_mailgun(message)
287
+ expect(body).to include('h:x-big-value')
288
+ expect(body['h:x-big-value']).to eq("1")
289
+ end
290
+
291
+ it 'treats `mailgun_headers` names as case-insensitive' do
292
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
293
+ message.mailgun_headers = {
294
+ 'X-BIG-VALUE' => 1,
295
+ }
296
+
297
+ body = Railgun.transform_for_mailgun(message)
298
+ expect(body).to include('h:x-big-value')
299
+ expect(body['h:x-big-value']).to eq("1")
300
+ end
301
+
302
+ it 'handles multi-value, mixed case headers correctly' do
303
+ message = UnitTestMailer.plain_message('test@example.org', '', {})
304
+ message.headers({
305
+ 'x-neat-header' => 'foo',
306
+ 'X-Neat-Header' => 'bar',
307
+ 'X-NEAT-HEADER' => 'zoop',
308
+ })
309
+
310
+ body = Railgun.transform_for_mailgun(message)
311
+ expect(body).to include('h:x-neat-header')
312
+ expect(body['h:x-neat-header']).to include('foo')
313
+ expect(body['h:x-neat-header']).to include('bar')
314
+ expect(body['h:x-neat-header']).to include('zoop')
315
+ end
316
+
317
+ context 'when message with template' do
318
+ it 'adds template header to message from mailer params' do
319
+ template_name = 'template.name'
320
+ message = UnitTestMailer.message_with_template('test@example.org', '', template_name)
321
+
322
+ body = Railgun.transform_for_mailgun(message)
323
+
324
+ expect(body).to include('template')
325
+ expect(body['template']).to eq(template_name)
326
+ end
327
+
328
+ context 'when mailgun_template_variables are assigned' do
329
+ it 'adds template variables to message body' do
330
+ message = UnitTestMailer.message_with_template('test@example.org', '', 'template.name')
331
+ version = 'version_1'
332
+ message.mailgun_template_variables ||= {
333
+ 'version' => version,
334
+ 'text' => 'yes'
335
+ }
336
+
337
+ body = Railgun.transform_for_mailgun(message)
338
+
339
+ expect(body).to include('t:version')
340
+ expect(body['t:version']).to eq('version_1')
341
+ expect(body).to include('t:text')
342
+ expect(body['t:text']).to eq('yes')
343
+ end
344
+ end
345
+ end
346
+
347
+ describe 'deliver!' do
348
+ let(:config) do
349
+ {
350
+ api_key: 'api_key',
351
+ domain: 'domain'
352
+ }
353
+ end
354
+ let(:mail) { UnitTestMailer.plain_message('test@example.org', '', {}) }
355
+ let(:response) do
356
+ response = Struct.new(:code, :id)
357
+ response.new(200, rand(50..100))
358
+ end
359
+
360
+ it 'initiates client message send' do
361
+ result = { from: 'test@example.org' }
362
+ allow(Railgun).to receive(:transform_for_mailgun).and_return(result)
363
+
364
+ expect_any_instance_of(Mailgun::Client).to receive(:send_message)
365
+ .with(config[:domain], result)
366
+ .and_return(response)
367
+ Railgun::Mailer.new(config).deliver!(mail)
368
+ end
369
+
370
+ it 'returns response' do
371
+ expect_any_instance_of(Mailgun::Client).to receive(:send_message).and_return(response)
372
+ expect(Railgun::Mailer.new(config).deliver!(mail)).to eq(response)
373
+ end
374
+
375
+ context 'when domain is provided in arguments' do
376
+ let(:new_domain) { 'new_domain' }
377
+ let(:mail) { UnitTestMailer.message_with_domain('test@example.org', '', new_domain) }
378
+
379
+ it 'uses provided domain' do
380
+ result = { from: 'test@example.org' }
381
+ allow(Railgun).to receive(:transform_for_mailgun).and_return(result)
382
+ expect_any_instance_of(Mailgun::Client).to receive(:send_message)
383
+ .with(new_domain, result).and_return(response)
384
+ Railgun::Mailer.new(config).deliver!(mail)
385
+ end
386
+ end
387
+ end
388
+ end
@@ -5,7 +5,7 @@ http_interactions:
5
5
  uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces
6
6
  body:
7
7
  encoding: US-ASCII
8
- string: address=integration-test-email%40DOMAIN.TEST&code=550&error=Integration%20Test
8
+ string: address=integration-test%2Bemail%40DOMAIN.TEST&code=550&error=Integration%20Test
9
9
  headers:
10
10
  Accept:
11
11
  - "*/*; q=0.5, application/xml"
@@ -42,13 +42,13 @@ http_interactions:
42
42
  - Content-Type, x-requested-with
43
43
  body:
44
44
  encoding: UTF-8
45
- string: '{"address":"integration-test-email@DOMAIN.TEST","message":"Address
45
+ string: '{"address":"integration-test+email@DOMAIN.TEST","message":"Address
46
46
  has been added to the bounces table"}'
47
- http_version:
47
+ http_version:
48
48
  recorded_at: Fri, 08 Jan 2016 20:33:29 GMT
49
49
  - request:
50
50
  method: get
51
- uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces/integration-test-email@DOMAIN.TEST
51
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces/integration-test+email@DOMAIN.TEST
52
52
  body:
53
53
  encoding: US-ASCII
54
54
  string: ''
@@ -84,9 +84,9 @@ http_interactions:
84
84
  - Content-Type, x-requested-with
85
85
  body:
86
86
  encoding: UTF-8
87
- string: '{"address":"integration-test-email@DOMAIN.TEST","code":"550","error":"Integration
87
+ string: '{"address":"integration-test+email@DOMAIN.TEST","code":"550","error":"Integration
88
88
  Test","created_at":"Fri, 08 Jan 2016 20:33:28 UTC"}'
89
- http_version:
89
+ http_version:
90
90
  recorded_at: Fri, 08 Jan 2016 20:33:29 GMT
91
91
  - request:
92
92
  method: get
@@ -126,13 +126,13 @@ http_interactions:
126
126
  - Content-Type, x-requested-with
127
127
  body:
128
128
  encoding: UTF-8
129
- string: '{"items":[{"address":"integration-test-email@DOMAIN.TEST","code":"550","error":"Integration
130
- Test","created_at":"Fri, 08 Jan 2016 20:33:28 UTC"}],"paging":{"first":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?limit=100","last":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=last\u0026limit=100","next":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=next\u0026address=integration-test-email%40DOMAIN.TEST\u0026limit=100","previous":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=previous\u0026address=integration-test-email%40DOMAIN.TEST\u0026limit=100"}}'
131
- http_version:
129
+ string: '{"items":[{"address":"integration-test+email@DOMAIN.TEST","code":"550","error":"Integration
130
+ Test","created_at":"Fri, 08 Jan 2016 20:33:28 UTC"}],"paging":{"first":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?limit=100","last":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=last\u0026limit=100","next":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=next\u0026address=integration-test%2Bemaill%40DOMAIN.TEST\u0026limit=100","previous":"https://api.mailgun.net/v3/DOMAIN.TEST/bounces?page=previous\u0026address=integration-test%2Bemail%40DOMAIN.TEST\u0026limit=100"}}'
131
+ http_version:
132
132
  recorded_at: Fri, 08 Jan 2016 20:33:29 GMT
133
133
  - request:
134
134
  method: delete
135
- uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces/integration-test-email@DOMAIN.TEST
135
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/bounces/integration-test+email@DOMAIN.TEST
136
136
  body:
137
137
  encoding: US-ASCII
138
138
  string: ''
@@ -168,8 +168,8 @@ http_interactions:
168
168
  - Content-Type, x-requested-with
169
169
  body:
170
170
  encoding: UTF-8
171
- string: '{"address":"integration-test-email@DOMAIN.TEST","message":"Bounced
171
+ string: '{"address":"integration-test+email@DOMAIN.TEST","message":"Bounced
172
172
  address has been removed"}'
173
- http_version:
173
+ http_version:
174
174
  recorded_at: Fri, 08 Jan 2016 20:33:30 GMT
175
175
  recorded_with: VCR 3.0.1
File without changes
File without changes
@@ -357,4 +357,54 @@ http_interactions:
357
357
  }
358
358
  http_version:
359
359
  recorded_at: Fri, 15 Jan 2016 20:12:54 GMT
360
- recorded_with: VCR 3.0.1
360
+ - request:
361
+ method: put
362
+ uri: https://api.mailgun.net/v3/domains/integration-test.domain.invalid
363
+ body:
364
+ encoding: UTF-8
365
+ string: spam_action=block&web_scheme=https&wildcard=true
366
+ headers:
367
+ Accept:
368
+ - "*/*"
369
+ User-Agent:
370
+ - rest-client/2.1.0 (darwin21.6.0 x86_64) ruby/2.5.1p57
371
+ Content-Length:
372
+ - '48'
373
+ Content-Type:
374
+ - application/x-www-form-urlencoded
375
+ Accept-Encoding:
376
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
377
+ Host:
378
+ - api.mailgun.net
379
+ Authorization:
380
+ - Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
381
+ response:
382
+ status:
383
+ code: 200
384
+ message: OK
385
+ headers:
386
+ Access-Control-Allow-Credentials:
387
+ - 'true'
388
+ Access-Control-Allow-Origin:
389
+ - "*"
390
+ Cache-Control:
391
+ - no-store
392
+ Content-Length:
393
+ - '445'
394
+ Content-Type:
395
+ - application/json; charset=utf-8
396
+ Date:
397
+ - Mon, 17 Apr 2023 13:03:16 GMT
398
+ Strict-Transport-Security:
399
+ - max-age=63072000; includeSubDomains
400
+ X-Xss-Protection:
401
+ - 1; mode=block
402
+ body:
403
+ encoding: UTF-8
404
+ string: '{"message":"Domain has been updated","domain":{"created_at":"Mon, 25
405
+ Jan 2021 10:11:26 GMT","id":"600e994e20b1a14a5990856d","is_disabled":false,"name":"integration-test.domain.invalid","require_tls":false,"skip_verification":false,"smtp_login":"postmaster@DOMAIN.TEST","spam_action":"block","state":"active","type":"sandbox","web_prefix":"email","web_scheme":"https","wildcard":true}}
406
+
407
+ '
408
+ http_version:
409
+ recorded_at: Mon, 17 Apr 2023 13:04:47 GMT
410
+ recorded_with: VCR 3.0.3
@@ -48,11 +48,11 @@ http_interactions:
48
48
  "Alice <alice@example.com>",
49
49
  "bob@example.com"
50
50
  ],
51
- "unparseable": [
51
+ "unparsable": [
52
52
  "example.org"
53
53
  ]
54
54
  }
55
- http_version:
55
+ http_version:
56
56
  recorded_at: Wed, 26 Oct 2016 22:44:50 GMT
57
57
  - request:
58
58
  method: get
@@ -107,7 +107,7 @@ http_interactions:
107
107
  "local_part": "alice"
108
108
  }
109
109
  }
110
- http_version:
110
+ http_version:
111
111
  recorded_at: Wed, 26 Oct 2016 22:44:50 GMT
112
112
  - request:
113
113
  method: get
@@ -162,7 +162,7 @@ http_interactions:
162
162
  "local_part": null
163
163
  }
164
164
  }
165
- http_version:
165
+ http_version:
166
166
  recorded_at: Wed, 26 Oct 2016 22:44:50 GMT
167
167
  - request:
168
168
  method: get
@@ -210,6 +210,6 @@ http_interactions:
210
210
  false, "is_role_address": false, "is_valid": true, "mailbox_verification":
211
211
  "true", "parts": {"display_name": null, "domain": "mailgun.net", "local_part":
212
212
  "alice"}}'
213
- http_version:
213
+ http_version:
214
214
  recorded_at: Tue, 12 Sep 2017 16:55:09 GMT
215
215
  recorded_with: VCR 3.0.3
File without changes
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.mailgun.net/v3/DOMAIN.TEST/messages
6
+ body:
7
+ encoding: UTF-8
8
+ string: from=sally%test.com&to=sally%test.com&subject=Exception+Integration+Test&text=INTEGRATION+TESTING
9
+ headers:
10
+ Accept:
11
+ - "*/*"
12
+ User-Agent:
13
+ - rest-client/2.1.0 (darwin21.6.0 x86_64) ruby/2.5.1p57
14
+ Content-Length:
15
+ - '119'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Host:
21
+ - api.mailgun.net
22
+ Authorization:
23
+ - Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2YwNS1mYTQ4MTZhMQ==
24
+ response:
25
+ status:
26
+ code: 401
27
+ message: Unauthorized
28
+ headers:
29
+ Access-Control-Allow-Credentials:
30
+ - 'true'
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Cache-Control:
34
+ - no-store
35
+ Content-Length:
36
+ - '9'
37
+ Content-Type:
38
+ - text/plain; charset=utf-8
39
+ Date:
40
+ - Sun, 28 May 2023 11:29:25 GMT
41
+ Strict-Transport-Security:
42
+ - max-age=63072000; includeSubDomains
43
+ Www-Authenticate:
44
+ - Basic realm="MG API"
45
+ X-Xss-Protection:
46
+ - 1; mode=block
47
+ body:
48
+ encoding: UTF-8
49
+ string: Forbidden
50
+ http_version:
51
+ recorded_at: Sun, 28 May 2023 11:29:25 GMT
52
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.mailgun.net/v3/DOMAIN.TEST/messages
6
+ body:
7
+ encoding: UTF-8
8
+ string: from=sally%40gmail.com&to=sallygmail.com&subject=Exception+Integration+Test&text=INTEGRATION+TESTING
9
+ headers:
10
+ Accept:
11
+ - "*/*"
12
+ User-Agent:
13
+ - rest-client/2.1.0 (darwin21.6.0 x86_64) ruby/2.5.1p57
14
+ Content-Length:
15
+ - '116'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Host:
21
+ - api.mailgun.net
22
+ Authorization:
23
+ - Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
24
+ response:
25
+ status:
26
+ code: 400
27
+ message: Bad Request
28
+ headers:
29
+ Access-Control-Allow-Credentials:
30
+ - 'true'
31
+ Access-Control-Allow-Origin:
32
+ - "*"
33
+ Cache-Control:
34
+ - no-store
35
+ Content-Length:
36
+ - '78'
37
+ Content-Type:
38
+ - application/json; charset=utf-8
39
+ Date:
40
+ - Sun, 28 May 2023 11:35:04 GMT
41
+ Strict-Transport-Security:
42
+ - max-age=63072000; includeSubDomains
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"message":"to parameter is not a valid address. please check documentation"}
48
+
49
+ '
50
+ http_version:
51
+ recorded_at: Sun, 28 May 2023 11:35:04 GMT
52
+ recorded_with: VCR 3.0.3