mailgun-ruby 1.2.15 → 1.3.5

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +52 -3
  4. data/Gemfile +1 -0
  5. data/README.md +2 -2
  6. data/docs/MessageBuilder.md +12 -0
  7. data/docs/Metrics.md +108 -0
  8. data/docs/Webhooks.md +4 -2
  9. data/lib/mailgun/chains.rb +1 -1
  10. data/lib/mailgun/client.rb +40 -30
  11. data/lib/mailgun/domains/domains.rb +19 -0
  12. data/lib/mailgun/events/events.rb +4 -4
  13. data/lib/mailgun/exceptions/exceptions.rb +7 -7
  14. data/lib/mailgun/messages/message_builder.rb +14 -2
  15. data/lib/mailgun/metrics/metrics.rb +61 -0
  16. data/lib/mailgun/response.rb +11 -10
  17. data/lib/mailgun/version.rb +1 -1
  18. data/lib/mailgun.rb +2 -1
  19. data/mailgun.gemspec +6 -3
  20. data/spec/integration/domains_spec.rb +95 -92
  21. data/spec/integration/email_validation_spec.rb +2 -1
  22. data/spec/integration/list_spec.rb +1 -1
  23. data/spec/integration/mailer_spec.rb +5 -5
  24. data/spec/integration/mailgun_spec.rb +14 -12
  25. data/spec/integration/metrics_spec.rb +218 -0
  26. data/spec/integration/routes_spec.rb +17 -1
  27. data/spec/integration/stats_spec.rb +1 -1
  28. data/spec/integration/unsubscribes_spec.rb +2 -2
  29. data/spec/integration/webhook_spec.rb +1 -1
  30. data/spec/spec_helper.rb +1 -0
  31. data/spec/unit/connection/test_client.rb +1 -1
  32. data/spec/unit/events/events_spec.rb +1 -1
  33. data/spec/unit/exceptions/exceptions_spec.rb +3 -3
  34. data/spec/unit/messages/message_builder_spec.rb +4 -3
  35. data/vcr_cassettes/bounces.yml +59 -98
  36. data/vcr_cassettes/complaints.yml +237 -97
  37. data/vcr_cassettes/domains.yml +332 -763
  38. data/vcr_cassettes/email_validation.yml +81 -144
  39. data/vcr_cassettes/events.yml +24 -63
  40. data/vcr_cassettes/exceptions.yml +49 -2
  41. data/vcr_cassettes/list_members.yml +187 -179
  42. data/vcr_cassettes/mailing_list.yml +309 -17
  43. data/vcr_cassettes/metrics.yml +116 -0
  44. data/vcr_cassettes/routes.yml +246 -246
  45. data/vcr_cassettes/send_message.yml +54 -3
  46. data/vcr_cassettes/stats.yml +28 -24
  47. data/vcr_cassettes/suppressions.yml +229 -447
  48. data/vcr_cassettes/unsubscribes.yml +219 -9
  49. metadata +58 -15
  50. data/docs/Messages.md +0 -107
  51. /data/docs/{railgun/Templates.md → Templates.md} +0 -0
@@ -2,312 +2,320 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: https://api:<APIKEY>@api.mailgun.net/v3/lists
5
+ uri: https://api.mailgun.net/v3/lists
6
6
  body:
7
- encoding: US-ASCII
8
- string: address=integration_test_list%40DOMAIN.TEST&name=Integration%20Test%20List&description=This%20list%20should%20be%20deleted%20automatically.&access_level=members
7
+ encoding: UTF-8
8
+ string: access_level=members&address=integration_test_list%40&description=This+list+should+be+deleted+automatically.&name=Integration+Test+List
9
9
  headers:
10
+ User-Agent:
11
+ - mailgun-sdk-ruby/1.3.2
10
12
  Accept:
11
- - "*/*; q=0.5, application/xml"
12
- Accept-Encoding:
13
- - gzip, deflate
14
- Content-Length:
15
- - '195'
13
+ - "*/*"
14
+ Authorization:
15
+ - Basic xxx
16
16
  Content-Type:
17
17
  - application/x-www-form-urlencoded
18
- User-Agent:
19
- - Ruby
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
20
  response:
21
21
  status:
22
22
  code: 200
23
23
  message: OK
24
24
  headers:
25
- Server:
26
- - nginx
27
- Date:
28
- - Fri, 08 Jan 2016 20:20:43 GMT
29
- Content-Type:
30
- - application/json
31
- Content-Length:
32
- - '361'
33
- Connection:
34
- - keep-alive
35
- Content-Disposition:
36
- - inline
25
+ Access-Control-Allow-Credentials:
26
+ - 'true'
37
27
  Access-Control-Allow-Origin:
38
28
  - "*"
39
- Access-Control-Max-Age:
40
- - '600'
41
- Access-Control-Allow-Methods:
42
- - GET, POST, PUT, DELETE, OPTIONS
43
- Access-Control-Allow-Headers:
44
- - Content-Type, x-requested-with
29
+ Cache-Control:
30
+ - no-store
31
+ Content-Length:
32
+ - '70'
33
+ Content-Type:
34
+ - application/json
35
+ Date:
36
+ - Wed, 26 Feb 2025 18:55:07 GMT
37
+ Server:
38
+ - TwistedWeb/22.10.0
39
+ Strict-Transport-Security:
40
+ - max-age=63072000; includeSubDomains
41
+ X-Mailgun-Key-Id:
42
+ - c02fd0ba-d8dbad66
43
+ X-Xss-Protection:
44
+ - 1; mode=block
45
45
  body:
46
46
  encoding: UTF-8
47
47
  string: |-
48
48
  {
49
49
  "list": {
50
50
  "access_level": "members",
51
- "address": "integration_test_list@DOMAIN.TEST",
52
- "created_at": "Fri, 08 Jan 2016 20:20:43 -0000",
51
+ "address": "integration_test_list@",
52
+ "created_at": "Sun, 26 Jan 2025 07:29:23 -0000",
53
53
  "description": "This list should be deleted automatically.",
54
54
  "members_count": 0,
55
- "name": "Integration Test List"
55
+ "name": "Integration Test List",
56
+ "reply_preference": "list"
56
57
  },
57
58
  "message": "Mailing list has been created"
58
59
  }
59
- http_version:
60
- recorded_at: Fri, 08 Jan 2016 20:20:43 GMT
60
+ http_version:
61
+ recorded_at: Wed, 26 Feb 2025 18:55:07 GMT
61
62
  - request:
62
63
  method: post
63
- uri: https://api:<APIKEY>@api.mailgun.net/v3/lists/integration_test_list@DOMAIN.TEST/members
64
+ uri: https://api.mailgun.net/v3/lists/integration_test_list@/members
64
65
  body:
65
- encoding: US-ASCII
66
- string: address=integration_test_member_member%40DOMAIN.TEST&name=Jane%20Doe&subscribed=true&upsert=no
66
+ encoding: UTF-8
67
+ string: address=integration_test_member_member%40&name=Jane+Doe&subscribed=true&upsert=no
67
68
  headers:
69
+ User-Agent:
70
+ - mailgun-sdk-ruby/1.3.2
68
71
  Accept:
69
- - "*/*; q=0.5, application/xml"
70
- Accept-Encoding:
71
- - gzip, deflate
72
- Content-Length:
73
- - '129'
72
+ - "*/*"
73
+ Authorization:
74
+ - Basic xxx
74
75
  Content-Type:
75
76
  - application/x-www-form-urlencoded
76
- User-Agent:
77
- - Ruby
77
+ Accept-Encoding:
78
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
78
79
  response:
79
80
  status:
80
81
  code: 200
81
82
  message: OK
82
83
  headers:
83
- Server:
84
- - nginx
85
- Date:
86
- - Fri, 08 Jan 2016 20:20:43 GMT
87
- Content-Type:
88
- - application/json
89
- Content-Length:
90
- - '233'
91
- Connection:
92
- - keep-alive
93
- Content-Disposition:
94
- - inline
84
+ Access-Control-Allow-Credentials:
85
+ - 'true'
95
86
  Access-Control-Allow-Origin:
96
87
  - "*"
97
- Access-Control-Max-Age:
98
- - '600'
99
- Access-Control-Allow-Methods:
100
- - GET, POST, PUT, DELETE, OPTIONS
101
- Access-Control-Allow-Headers:
102
- - Content-Type, x-requested-with
88
+ Cache-Control:
89
+ - no-store
90
+ Content-Length:
91
+ - '70'
92
+ Content-Type:
93
+ - application/json
94
+ Date:
95
+ - Wed, 26 Feb 2025 18:55:08 GMT
96
+ Server:
97
+ - TwistedWeb/22.10.0
98
+ Strict-Transport-Security:
99
+ - max-age=63072000; includeSubDomains
100
+ X-Mailgun-Key-Id:
101
+ - c02fd0ba-d8dbad66
102
+ X-Xss-Protection:
103
+ - 1; mode=block
103
104
  body:
104
105
  encoding: UTF-8
105
106
  string: |-
106
107
  {
107
108
  "member": {
108
- "address": "integration_test_member_member@DOMAIN.TEST",
109
+ "address": "integration_test_member_member@",
109
110
  "name": "Jane Doe",
110
111
  "subscribed": true,
111
112
  "vars": {}
112
113
  },
113
114
  "message": "Mailing list member has been created"
114
115
  }
115
- http_version:
116
- recorded_at: Fri, 08 Jan 2016 20:20:44 GMT
116
+ http_version:
117
+ recorded_at: Wed, 26 Feb 2025 18:55:08 GMT
117
118
  - request:
118
119
  method: get
119
- uri: https://api:<APIKEY>@api.mailgun.net/v3/lists/integration_test_list@DOMAIN.TEST/members/integration_test_member_member@DOMAIN.TEST
120
+ uri: https://api.mailgun.net/v3/lists/integration_test_list@/members/integration_test_member_member@
120
121
  body:
121
122
  encoding: US-ASCII
122
123
  string: ''
123
124
  headers:
125
+ User-Agent:
126
+ - mailgun-sdk-ruby/1.3.2
124
127
  Accept:
125
128
  - "*/*"
129
+ Authorization:
130
+ - Basic xxx
126
131
  Accept-Encoding:
127
- - gzip, deflate
128
- User-Agent:
129
- - Ruby
132
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
130
133
  response:
131
134
  status:
132
135
  code: 200
133
136
  message: OK
134
137
  headers:
135
- Server:
136
- - nginx
137
- Date:
138
- - Fri, 08 Jan 2016 20:20:43 GMT
139
- Content-Type:
140
- - application/json
141
- Content-Length:
142
- - '180'
143
- Connection:
144
- - keep-alive
145
- Content-Disposition:
146
- - inline
138
+ Access-Control-Allow-Credentials:
139
+ - 'true'
147
140
  Access-Control-Allow-Origin:
148
141
  - "*"
149
- Access-Control-Max-Age:
150
- - '600'
151
- Access-Control-Allow-Methods:
152
- - GET, POST, PUT, DELETE, OPTIONS
153
- Access-Control-Allow-Headers:
154
- - Content-Type, x-requested-with
142
+ Cache-Control:
143
+ - no-store
144
+ Content-Length:
145
+ - '60'
146
+ Content-Type:
147
+ - application/json
148
+ Date:
149
+ - Wed, 26 Feb 2025 18:55:09 GMT
150
+ Server:
151
+ - TwistedWeb/22.10.0
152
+ Strict-Transport-Security:
153
+ - max-age=63072000; includeSubDomains
154
+ X-Mailgun-Key-Id:
155
+ - c02fd0ba-d8dbad66
156
+ X-Xss-Protection:
157
+ - 1; mode=block
155
158
  body:
156
159
  encoding: UTF-8
157
160
  string: |-
158
161
  {
159
162
  "member": {
160
- "address": "integration_test_member_member@DOMAIN.TEST",
163
+ "address": "integration_test_member_member@",
161
164
  "name": "Jane Doe",
162
165
  "subscribed": true,
163
166
  "vars": {}
164
167
  }
165
168
  }
166
- http_version:
167
- recorded_at: Fri, 08 Jan 2016 20:20:44 GMT
169
+ http_version:
170
+ recorded_at: Wed, 26 Feb 2025 18:55:09 GMT
168
171
  - request:
169
172
  method: put
170
- uri: https://api:<APIKEY>@api.mailgun.net/v3/lists/integration_test_list@DOMAIN.TEST/members/integration_test_member_member@DOMAIN.TEST
173
+ uri: https://api.mailgun.net/v3/lists/integration_test_list@/members/integration_test_member_member@
171
174
  body:
172
- encoding: US-ASCII
173
- string: name=Jane%20Doe%20Update&subscribed=false
175
+ encoding: UTF-8
176
+ string: name=Jane+Doe+Update&subscribed=false
174
177
  headers:
178
+ User-Agent:
179
+ - mailgun-sdk-ruby/1.3.2
175
180
  Accept:
176
- - "*/*; q=0.5, application/xml"
177
- Accept-Encoding:
178
- - gzip, deflate
179
- Content-Length:
180
- - '41'
181
+ - "*/*"
182
+ Authorization:
183
+ - Basic xxx
181
184
  Content-Type:
182
185
  - application/x-www-form-urlencoded
183
- User-Agent:
184
- - Ruby
186
+ Accept-Encoding:
187
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
185
188
  response:
186
189
  status:
187
190
  code: 200
188
191
  message: OK
189
192
  headers:
190
- Server:
191
- - nginx
192
- Date:
193
- - Fri, 08 Jan 2016 20:20:44 GMT
194
- Content-Type:
195
- - application/json
196
- Content-Length:
197
- - '241'
198
- Connection:
199
- - keep-alive
200
- Content-Disposition:
201
- - inline
193
+ Access-Control-Allow-Credentials:
194
+ - 'true'
202
195
  Access-Control-Allow-Origin:
203
196
  - "*"
204
- Access-Control-Max-Age:
205
- - '600'
206
- Access-Control-Allow-Methods:
207
- - GET, POST, PUT, DELETE, OPTIONS
208
- Access-Control-Allow-Headers:
209
- - Content-Type, x-requested-with
197
+ Cache-Control:
198
+ - no-store
199
+ Content-Length:
200
+ - '60'
201
+ Content-Type:
202
+ - application/json
203
+ Date:
204
+ - Wed, 26 Feb 2025 18:55:09 GMT
205
+ Server:
206
+ - TwistedWeb/22.10.0
207
+ Strict-Transport-Security:
208
+ - max-age=63072000; includeSubDomains
209
+ X-Mailgun-Key-Id:
210
+ - c02fd0ba-d8dbad66
211
+ X-Xss-Protection:
212
+ - 1; mode=block
210
213
  body:
211
214
  encoding: UTF-8
212
215
  string: |-
213
216
  {
214
217
  "member": {
215
- "address": "integration_test_member_member@DOMAIN.TEST",
218
+ "address": "integration_test_member_member@",
216
219
  "name": "Jane Doe Update",
217
220
  "subscribed": false,
218
221
  "vars": {}
219
222
  },
220
223
  "message": "Mailing list member has been updated"
221
224
  }
222
- http_version:
223
- recorded_at: Fri, 08 Jan 2016 20:20:44 GMT
225
+ http_version:
226
+ recorded_at: Wed, 26 Feb 2025 18:55:09 GMT
224
227
  - request:
225
228
  method: delete
226
- uri: https://api:<APIKEY>@api.mailgun.net/v3/lists/integration_test_list@DOMAIN.TEST/members/integration_test_member_member@DOMAIN.TEST
229
+ uri: https://api.mailgun.net/v3/lists/integration_test_list@/members/integration_test_member_member@
227
230
  body:
228
231
  encoding: US-ASCII
229
232
  string: ''
230
233
  headers:
234
+ User-Agent:
235
+ - mailgun-sdk-ruby/1.3.2
231
236
  Accept:
232
- - "*/*; q=0.5, application/xml"
237
+ - "*/*"
238
+ Authorization:
239
+ - Basic xxx
233
240
  Accept-Encoding:
234
- - gzip, deflate
235
- User-Agent:
236
- - Ruby
241
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
237
242
  response:
238
243
  status:
239
244
  code: 200
240
245
  message: OK
241
246
  headers:
242
- Server:
243
- - nginx
244
- Date:
245
- - Fri, 08 Jan 2016 20:20:44 GMT
246
- Content-Type:
247
- - application/json
248
- Content-Length:
249
- - '169'
250
- Connection:
251
- - keep-alive
252
- Content-Disposition:
253
- - inline
247
+ Access-Control-Allow-Credentials:
248
+ - 'true'
254
249
  Access-Control-Allow-Origin:
255
250
  - "*"
256
- Access-Control-Max-Age:
257
- - '600'
258
- Access-Control-Allow-Methods:
259
- - GET, POST, PUT, DELETE, OPTIONS
260
- Access-Control-Allow-Headers:
261
- - Content-Type, x-requested-with
251
+ Cache-Control:
252
+ - no-store
253
+ Content-Disposition:
254
+ - inline
255
+ Content-Length:
256
+ - '88'
257
+ Content-Type:
258
+ - application/json
259
+ Date:
260
+ - Wed, 26 Feb 2025 19:35:10 GMT
261
+ Server:
262
+ - TwistedWeb/22.10.0
263
+ Strict-Transport-Security:
264
+ - max-age=63072000; includeSubDomains
265
+ X-Mailgun-Key-Id:
266
+ - c02fd0ba-d8dbad66
267
+ X-Xss-Protection:
268
+ - 1; mode=block
262
269
  body:
263
270
  encoding: UTF-8
264
- string: |-
265
- {
266
- "member": {
267
- "address": "integration_test_member_member@DOMAIN.TEST"
268
- },
269
- "message": "Mailing list member has been deleted"
270
- }
271
- http_version:
272
- recorded_at: Fri, 08 Jan 2016 20:20:44 GMT
271
+ string: '{"member":{"address":"integration_test_member_member@"},"message":"Mailing list member
272
+ has been deleted"}
273
+
274
+ '
275
+ http_version:
276
+ recorded_at: Wed, 26 Feb 2025 19:35:11 GMT
273
277
  - request:
274
278
  method: delete
275
- uri: https://api:<APIKEY>@api.mailgun.net/v3/lists/integration_test_list@DOMAIN.TEST
279
+ uri: https://api.mailgun.net/v3/lists/integration_test_list@
276
280
  body:
277
281
  encoding: US-ASCII
278
282
  string: ''
279
283
  headers:
284
+ User-Agent:
285
+ - mailgun-sdk-ruby/1.3.0
280
286
  Accept:
281
- - "*/*; q=0.5, application/xml"
287
+ - "*/*"
288
+ Authorization:
289
+ - Basic xxx==
282
290
  Accept-Encoding:
283
- - gzip, deflate
284
- User-Agent:
285
- - Ruby
291
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
286
292
  response:
287
293
  status:
288
294
  code: 200
289
295
  message: OK
290
296
  headers:
291
- Server:
292
- - nginx
293
- Date:
294
- - Fri, 08 Jan 2016 20:20:44 GMT
295
- Content-Type:
296
- - application/json
297
- Content-Length:
298
- - '133'
299
- Connection:
300
- - keep-alive
301
- Content-Disposition:
302
- - inline
297
+ Access-Control-Allow-Credentials:
298
+ - 'true'
303
299
  Access-Control-Allow-Origin:
304
- - "*"
305
- Access-Control-Max-Age:
306
- - '600'
307
- Access-Control-Allow-Methods:
308
- - GET, POST, PUT, DELETE, OPTIONS
309
- Access-Control-Allow-Headers:
310
- - Content-Type, x-requested-with
300
+ - "*"
301
+ Cache-Control:
302
+ - no-store
303
+ Content-Disposition:
304
+ - inline
305
+ Content-Length:
306
+ - '138'
307
+ Content-Type:
308
+ - application/json
309
+ Date:
310
+ - Sun, 26 Jan 2025 07:29:26 GMT
311
+ Server:
312
+ - TwistedWeb/20.3.0
313
+ Strict-Transport-Security:
314
+ - max-age=63072000; includeSubDomains
315
+ X-Mailgun-Key-Id:
316
+ - 90b59dea-f2d12a53
317
+ X-Xss-Protection:
318
+ - 1; mode=block
311
319
  body:
312
320
  encoding: UTF-8
313
321
  string: |-
@@ -315,6 +323,6 @@ http_interactions:
315
323
  "address": "integration_test_list@DOMAIN.TEST",
316
324
  "message": "Mailing list has been removed"
317
325
  }
318
- http_version:
319
- recorded_at: Fri, 08 Jan 2016 20:20:45 GMT
320
- recorded_with: VCR 3.0.1
326
+ http_version:
327
+ recorded_at: Wed, 26 Feb 2025 19:35:11 GMT
328
+ recorded_with: VCR 3.0.3