mailgun-ruby 1.2.0 → 1.2.10

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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -1
  3. data/docs/Domains.md +3 -0
  4. data/docs/OptInHandler.md +1 -1
  5. data/docs/Snippets.md +54 -61
  6. data/docs/railgun/Templates.md +92 -0
  7. data/lib/mailgun/address.rb +3 -28
  8. data/lib/mailgun/client.rb +43 -10
  9. data/lib/mailgun/domains/domains.rb +19 -1
  10. data/lib/mailgun/exceptions/exceptions.rb +28 -1
  11. data/lib/mailgun/messages/batch_message.rb +1 -0
  12. data/lib/mailgun/messages/message_builder.rb +55 -7
  13. data/lib/mailgun/suppressions.rb +15 -8
  14. data/lib/mailgun/version.rb +1 -1
  15. data/lib/mailgun-ruby.rb +1 -1
  16. data/lib/mailgun.rb +3 -1
  17. data/lib/railgun/mailer.rb +30 -9
  18. data/lib/railgun/message.rb +2 -1
  19. data/lib/railgun/railtie.rb +3 -2
  20. data/mailgun.gemspec +1 -1
  21. data/spec/integration/bounces_spec.rb +3 -3
  22. data/spec/integration/domains_spec.rb +8 -0
  23. data/spec/integration/email_validation_spec.rb +1 -8
  24. data/spec/integration/mailer_spec.rb +67 -0
  25. data/spec/integration/mailgun_spec.rb +76 -1
  26. data/spec/integration/suppressions_spec.rb +18 -2
  27. data/spec/unit/connection/test_client.rb +18 -1
  28. data/spec/unit/mailgun_spec.rb +43 -2
  29. data/spec/unit/messages/batch_message_spec.rb +56 -40
  30. data/spec/unit/messages/message_builder_spec.rb +149 -16
  31. data/spec/unit/messages/sample_data/unknown.type +0 -0
  32. data/spec/unit/railgun/mailer_spec.rb +171 -0
  33. data/vcr_cassettes/bounces.yml +12 -12
  34. data/vcr_cassettes/domains.yml +51 -1
  35. data/vcr_cassettes/exceptions-invalid-api-key.yml +52 -0
  36. data/vcr_cassettes/exceptions-invalid-data.yml +52 -0
  37. data/vcr_cassettes/exceptions-not-allowed.yml +54 -0
  38. data/vcr_cassettes/mailer_invalid_domain.yml +109 -0
  39. data/vcr_cassettes/message_deliver.yml +149 -0
  40. data/vcr_cassettes/suppressions.yml +66 -15
  41. metadata +15 -6
@@ -0,0 +1,149 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.mailgun.net/v3/DOMAIN.TEST/messages
6
+ body:
7
+ encoding: US-ASCII
8
+ string: from[]=bob%40DOMAIN.TEST&subject[]=subject&html[]=%3Cp%3ETest%21%3C%2Fp%3E&text[]=Test%21&to[]=bob%40DOMAIN.TEST&h%3Acontent-type=multipart%2Falternative%3B+boundary%3D%22--%3D%3D_mimepart_6098f913d64ca_62833fd4d74521802775%22%3B+charset%3DUTF-8
9
+ headers:
10
+ Accept:
11
+ - "*/*"
12
+ User-Agent:
13
+ - rest-client/2.1.0 (darwin18.7.0 x86_64) ruby/2.2.2p95
14
+ Content-Length:
15
+ - '261'
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: 200
27
+ message: OK
28
+ headers:
29
+ Access-Control-Allow-Credentials:
30
+ - 'true'
31
+ Access-Control-Allow-Headers:
32
+ - Content-Type, x-requested-with, Authorization
33
+ Access-Control-Allow-Methods:
34
+ - GET, POST, PUT, DELETE, OPTIONS
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ Access-Control-Max-Age:
38
+ - '600'
39
+ Cache-Control:
40
+ - no-store
41
+ Content-Disposition:
42
+ - inline
43
+ Content-Type:
44
+ - application/json
45
+ Date:
46
+ - Mon, 10 May 2021 09:12:52 GMT
47
+ Server:
48
+ - nginx
49
+ Strict-Transport-Security:
50
+ - max-age=63072000; includeSubDomains
51
+ X-Ratelimit-Limit:
52
+ - '2000000'
53
+ X-Ratelimit-Remaining:
54
+ - '1999999'
55
+ X-Ratelimit-Reset:
56
+ - '1620637982656'
57
+ X-Recipient-Limit:
58
+ - '1000000'
59
+ X-Recipient-Remaining:
60
+ - '999999'
61
+ X-Recipient-Reset:
62
+ - '1620637982657'
63
+ Content-Length:
64
+ - '136'
65
+ Connection:
66
+ - keep-alive
67
+ body:
68
+ encoding: UTF-8
69
+ string: |-
70
+ {
71
+ "id": "<20210510091252.1.D6347B73DA43962E@DOMAIN.TEST>",
72
+ "message": "Queued. Thank you."
73
+ }
74
+ http_version:
75
+ recorded_at: Mon, 10 May 2021 09:12:52 GMT
76
+ - request:
77
+ method: post
78
+ uri: https://api.mailgun.net/v3/DOMAIN.TEST/messages
79
+ body:
80
+ encoding: US-ASCII
81
+ string: from[]=bob%40DOMAIN.TEST&subject[]=subject&html[]=%3Cp%3ETest%21%3C%2Fp%3E&text[]=Test%21&to[]=bob%40DOMAIN.TEST&h%3Amessage-id=%3C20210510091252.1.D6347B73DA43962E%40DOMAIN.TEST%3E&h%3Acontent-type=multipart%2Falternative%3B+boundary%3D%22--%3D%3D_mimepart_6098f913d64ca_62833fd4d74521802775%22%3B+charset%3DUTF-8
82
+ headers:
83
+ Accept:
84
+ - "*/*"
85
+ User-Agent:
86
+ - rest-client/2.1.0 (darwin18.7.0 x86_64) ruby/2.2.2p95
87
+ Content-Length:
88
+ - '370'
89
+ Content-Type:
90
+ - application/x-www-form-urlencoded
91
+ Accept-Encoding:
92
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
93
+ Host:
94
+ - api.mailgun.net
95
+ Authorization:
96
+ - Basic YXBpOmQ5MTViNWNkYjlhNTgzNjg1ZDhmM2ZiMWJlYzBmMjBmLTA3YmM3YjA1LWZhNDgxNmEx
97
+ response:
98
+ status:
99
+ code: 200
100
+ message: OK
101
+ headers:
102
+ Access-Control-Allow-Credentials:
103
+ - 'true'
104
+ Access-Control-Allow-Headers:
105
+ - Content-Type, x-requested-with, Authorization
106
+ Access-Control-Allow-Methods:
107
+ - GET, POST, PUT, DELETE, OPTIONS
108
+ Access-Control-Allow-Origin:
109
+ - "*"
110
+ Access-Control-Max-Age:
111
+ - '600'
112
+ Cache-Control:
113
+ - no-store
114
+ Content-Disposition:
115
+ - inline
116
+ Content-Type:
117
+ - application/json
118
+ Date:
119
+ - Mon, 10 May 2021 09:12:56 GMT
120
+ Server:
121
+ - nginx
122
+ Strict-Transport-Security:
123
+ - max-age=63072000; includeSubDomains
124
+ X-Ratelimit-Limit:
125
+ - '2000000'
126
+ X-Ratelimit-Remaining:
127
+ - '1999998'
128
+ X-Ratelimit-Reset:
129
+ - '1620637982656'
130
+ X-Recipient-Limit:
131
+ - '1000000'
132
+ X-Recipient-Remaining:
133
+ - '999998'
134
+ X-Recipient-Reset:
135
+ - '1620637982657'
136
+ Content-Length:
137
+ - '136'
138
+ Connection:
139
+ - keep-alive
140
+ body:
141
+ encoding: UTF-8
142
+ string: |-
143
+ {
144
+ "id": "<20210510091252.1.D6347B73DA43962E@DOMAIN.TEST>",
145
+ "message": "Queued. Thank you."
146
+ }
147
+ http_version:
148
+ recorded_at: Mon, 10 May 2021 09:12:56 GMT
149
+ recorded_with: VCR 3.0.3
@@ -49,7 +49,7 @@ http_interactions:
49
49
  body:
50
50
  encoding: UTF-8
51
51
  string: '{"message":"4 addresses have been added to the bounces table"}'
52
- http_version:
52
+ http_version:
53
53
  recorded_at: Wed, 30 Nov 2016 20:53:49 GMT
54
54
  - request:
55
55
  method: delete
@@ -93,7 +93,7 @@ http_interactions:
93
93
  encoding: UTF-8
94
94
  string: '{"address":"test1@example.com","message":"Bounced address has been
95
95
  removed"}'
96
- http_version:
96
+ http_version:
97
97
  recorded_at: Wed, 30 Nov 2016 20:53:49 GMT
98
98
  - request:
99
99
  method: delete
@@ -137,7 +137,7 @@ http_interactions:
137
137
  encoding: UTF-8
138
138
  string: '{"address":"test2@example.org","message":"Bounced address has been
139
139
  removed"}'
140
- http_version:
140
+ http_version:
141
141
  recorded_at: Wed, 30 Nov 2016 20:53:50 GMT
142
142
  - request:
143
143
  method: delete
@@ -181,7 +181,7 @@ http_interactions:
181
181
  encoding: UTF-8
182
182
  string: '{"address":"test3@example.net","message":"Bounced address has been
183
183
  removed"}'
184
- http_version:
184
+ http_version:
185
185
  recorded_at: Wed, 30 Nov 2016 20:53:50 GMT
186
186
  - request:
187
187
  method: delete
@@ -225,7 +225,7 @@ http_interactions:
225
225
  encoding: UTF-8
226
226
  string: '{"address":"test4@example.info","message":"Bounced address has been
227
227
  removed"}'
228
- http_version:
228
+ http_version:
229
229
  recorded_at: Wed, 30 Nov 2016 20:53:50 GMT
230
230
  - request:
231
231
  method: post
@@ -274,7 +274,7 @@ http_interactions:
274
274
  body:
275
275
  encoding: UTF-8
276
276
  string: '{"message":"4 addresses have been added to the unsubscribes table"}'
277
- http_version:
277
+ http_version:
278
278
  recorded_at: Wed, 30 Nov 2016 20:53:51 GMT
279
279
  - request:
280
280
  method: delete
@@ -318,7 +318,7 @@ http_interactions:
318
318
  encoding: UTF-8
319
319
  string: '{"address":"test1@example.com","message":"Unsubscribe event has been
320
320
  removed"}'
321
- http_version:
321
+ http_version:
322
322
  recorded_at: Wed, 30 Nov 2016 20:53:51 GMT
323
323
  - request:
324
324
  method: delete
@@ -362,7 +362,7 @@ http_interactions:
362
362
  encoding: UTF-8
363
363
  string: '{"address":"test2@example.org","message":"Unsubscribe event has been
364
364
  removed"}'
365
- http_version:
365
+ http_version:
366
366
  recorded_at: Wed, 30 Nov 2016 20:53:51 GMT
367
367
  - request:
368
368
  method: delete
@@ -406,7 +406,7 @@ http_interactions:
406
406
  encoding: UTF-8
407
407
  string: '{"address":"test3@example.net","message":"Unsubscribe event has been
408
408
  removed"}'
409
- http_version:
409
+ http_version:
410
410
  recorded_at: Wed, 30 Nov 2016 20:53:51 GMT
411
411
  - request:
412
412
  method: delete
@@ -450,7 +450,7 @@ http_interactions:
450
450
  encoding: UTF-8
451
451
  string: '{"address":"test4@example.info","message":"Unsubscribe event has been
452
452
  removed"}'
453
- http_version:
453
+ http_version:
454
454
  recorded_at: Wed, 30 Nov 2016 20:53:52 GMT
455
455
  - request:
456
456
  method: post
@@ -498,7 +498,7 @@ http_interactions:
498
498
  encoding: UTF-8
499
499
  string: '{"message":"4 complaint addresses have been added to the complaints
500
500
  table"}'
501
- http_version:
501
+ http_version:
502
502
  recorded_at: Wed, 30 Nov 2016 20:53:52 GMT
503
503
  - request:
504
504
  method: delete
@@ -541,7 +541,7 @@ http_interactions:
541
541
  body:
542
542
  encoding: UTF-8
543
543
  string: '{"address":"test1@example.com","message":"Spam complaint has been removed"}'
544
- http_version:
544
+ http_version:
545
545
  recorded_at: Wed, 30 Nov 2016 20:53:52 GMT
546
546
  - request:
547
547
  method: delete
@@ -584,7 +584,7 @@ http_interactions:
584
584
  body:
585
585
  encoding: UTF-8
586
586
  string: '{"address":"test2@example.org","message":"Spam complaint has been removed"}'
587
- http_version:
587
+ http_version:
588
588
  recorded_at: Wed, 30 Nov 2016 20:53:52 GMT
589
589
  - request:
590
590
  method: delete
@@ -627,7 +627,7 @@ http_interactions:
627
627
  body:
628
628
  encoding: UTF-8
629
629
  string: '{"address":"test3@example.net","message":"Spam complaint has been removed"}'
630
- http_version:
630
+ http_version:
631
631
  recorded_at: Wed, 30 Nov 2016 20:53:53 GMT
632
632
  - request:
633
633
  method: delete
@@ -671,6 +671,57 @@ http_interactions:
671
671
  encoding: UTF-8
672
672
  string: '{"address":"test4@example.info","message":"Spam complaint has been
673
673
  removed"}'
674
- http_version:
674
+ http_version:
675
675
  recorded_at: Wed, 30 Nov 2016 20:53:53 GMT
676
+ - request:
677
+ method: post
678
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/unsubscribes
679
+ body:
680
+ encoding: UTF-8
681
+ string: '[{"address":"test4@example.info","tag":"integration"},{"address":"test3@example.net","tag":"integration"},{"address":"test2@example.org","tag":"integration"},{"address":"test1@example.com","tag":"integration"}]'
682
+ headers:
683
+ Accept:
684
+ - "*/*"
685
+ Accept-Encoding:
686
+ - gzip, deflate
687
+ User-Agent:
688
+ - rest-client/2.0.2 (darwin18.7.0 x86_64) ruby/2.5.7p206
689
+ Content-Type:
690
+ - application/json
691
+ Content-Length:
692
+ - '210'
693
+ Host:
694
+ - api.mailgun.net
695
+ response:
696
+ status:
697
+ code: 200
698
+ message: OK
699
+ headers:
700
+ Access-Control-Allow-Headers:
701
+ - Content-Type, x-requested-with
702
+ Access-Control-Allow-Methods:
703
+ - GET, POST, PUT, DELETE, OPTIONS
704
+ Access-Control-Allow-Origin:
705
+ - "*"
706
+ Access-Control-Max-Age:
707
+ - '600'
708
+ Content-Type:
709
+ - application/json; charset=utf-8
710
+ Date:
711
+ - Tue, 04 Feb 2020 15:16:07 GMT
712
+ Server:
713
+ - nginx
714
+ Strict-Transport-Security:
715
+ - max-age=63072000; includeSubDomains
716
+ Content-Length:
717
+ - '68'
718
+ Connection:
719
+ - keep-alive
720
+ body:
721
+ encoding: UTF-8
722
+ string: '{"message":"4 addresses have been added to the unsubscribes table"}
723
+
724
+ '
725
+ http_version:
726
+ recorded_at: Tue, 04 Feb 2020 15:16:07 GMT
676
727
  recorded_with: VCR 3.0.3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailgun-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mailgun
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-12 00:00:00.000000000 Z
12
+ date: 2023-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -127,14 +127,14 @@ dependencies:
127
127
  name: rest-client
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - "~>"
130
+ - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: 2.0.2
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - "~>"
137
+ - - ">="
138
138
  - !ruby/object:Gem::Version
139
139
  version: 2.0.2
140
140
  description: Mailgun's Official Ruby SDK for interacting with the Mailgun API.
@@ -162,6 +162,7 @@ files:
162
162
  - docs/Webhooks.md
163
163
  - docs/railgun/Overview.md
164
164
  - docs/railgun/Parameters.md
165
+ - docs/railgun/Templates.md
165
166
  - lib/mailgun-ruby.rb
166
167
  - lib/mailgun.rb
167
168
  - lib/mailgun/address.rb
@@ -192,6 +193,7 @@ files:
192
193
  - spec/integration/events_spec.rb
193
194
  - spec/integration/list_members_spec.rb
194
195
  - spec/integration/list_spec.rb
196
+ - spec/integration/mailer_spec.rb
195
197
  - spec/integration/mailgun_spec.rb
196
198
  - spec/integration/messages/sample_data/mime.txt
197
199
  - spec/integration/routes_spec.rb
@@ -209,6 +211,7 @@ files:
209
211
  - spec/unit/messages/sample_data/mailgun_icon.png
210
212
  - spec/unit/messages/sample_data/mime.txt
211
213
  - spec/unit/messages/sample_data/rackspace_logo.jpg
214
+ - spec/unit/messages/sample_data/unknown.type
212
215
  - spec/unit/railgun/content_type_spec.rb
213
216
  - spec/unit/railgun/mailer_spec.rb
214
217
  - vcr_cassettes/bounces.yml
@@ -217,10 +220,15 @@ files:
217
220
  - vcr_cassettes/domains.yml
218
221
  - vcr_cassettes/email_validation.yml
219
222
  - vcr_cassettes/events.yml
223
+ - vcr_cassettes/exceptions-invalid-api-key.yml
224
+ - vcr_cassettes/exceptions-invalid-data.yml
225
+ - vcr_cassettes/exceptions-not-allowed.yml
220
226
  - vcr_cassettes/exceptions.yml
221
227
  - vcr_cassettes/list_members.yml
228
+ - vcr_cassettes/mailer_invalid_domain.yml
222
229
  - vcr_cassettes/mailing_list.todo.yml
223
230
  - vcr_cassettes/mailing_list.yml
231
+ - vcr_cassettes/message_deliver.yml
224
232
  - vcr_cassettes/routes.yml
225
233
  - vcr_cassettes/send_message.yml
226
234
  - vcr_cassettes/stats.yml
@@ -246,8 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
254
  - !ruby/object:Gem::Version
247
255
  version: '0'
248
256
  requirements: []
249
- rubyforge_project:
250
- rubygems_version: 2.7.7
257
+ rubygems_version: 3.0.3
251
258
  signing_key:
252
259
  specification_version: 4
253
260
  summary: Mailgun's Official Ruby SDK
@@ -260,6 +267,7 @@ test_files:
260
267
  - spec/integration/events_spec.rb
261
268
  - spec/integration/list_members_spec.rb
262
269
  - spec/integration/list_spec.rb
270
+ - spec/integration/mailer_spec.rb
263
271
  - spec/integration/mailgun_spec.rb
264
272
  - spec/integration/messages/sample_data/mime.txt
265
273
  - spec/integration/routes_spec.rb
@@ -277,5 +285,6 @@ test_files:
277
285
  - spec/unit/messages/sample_data/mailgun_icon.png
278
286
  - spec/unit/messages/sample_data/mime.txt
279
287
  - spec/unit/messages/sample_data/rackspace_logo.jpg
288
+ - spec/unit/messages/sample_data/unknown.type
280
289
  - spec/unit/railgun/content_type_spec.rb
281
290
  - spec/unit/railgun/mailer_spec.rb