wj-mailgun-ruby 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rubocop.yml +8 -0
  4. data/.rubocop_todo.yml +22 -0
  5. data/.ruby-env.yml.example +12 -0
  6. data/.ruby-version +1 -0
  7. data/.travis.yml +24 -0
  8. data/Gemfile +6 -0
  9. data/LICENSE +191 -0
  10. data/README.md +241 -0
  11. data/Rakefile +35 -0
  12. data/docs/Domains.md +54 -0
  13. data/docs/Events.md +46 -0
  14. data/docs/MessageBuilder.md +105 -0
  15. data/docs/Messages.md +107 -0
  16. data/docs/OptInHandler.md +103 -0
  17. data/docs/Snippets.md +526 -0
  18. data/docs/Suppressions.md +82 -0
  19. data/docs/Webhooks.md +40 -0
  20. data/lib/mailgun-ruby.rb +2 -0
  21. data/lib/mailgun.rb +39 -0
  22. data/lib/mailgun/address.rb +45 -0
  23. data/lib/mailgun/chains.rb +16 -0
  24. data/lib/mailgun/client.rb +199 -0
  25. data/lib/mailgun/domains/domains.rb +84 -0
  26. data/lib/mailgun/events/events.rb +120 -0
  27. data/lib/mailgun/exceptions/exceptions.rb +65 -0
  28. data/lib/mailgun/lists/opt_in_handler.rb +58 -0
  29. data/lib/mailgun/messages/batch_message.rb +125 -0
  30. data/lib/mailgun/messages/message_builder.rb +413 -0
  31. data/lib/mailgun/response.rb +62 -0
  32. data/lib/mailgun/suppressions.rb +270 -0
  33. data/lib/mailgun/version.rb +4 -0
  34. data/lib/mailgun/webhooks/webhooks.rb +101 -0
  35. data/lib/railgun.rb +8 -0
  36. data/lib/railgun/attachment.rb +56 -0
  37. data/lib/railgun/errors.rb +27 -0
  38. data/lib/railgun/mailer.rb +161 -0
  39. data/lib/railgun/message.rb +17 -0
  40. data/lib/railgun/railtie.rb +9 -0
  41. data/mailgun.gemspec +37 -0
  42. data/spec/integration/bounces_spec.rb +44 -0
  43. data/spec/integration/campaign_spec.rb +60 -0
  44. data/spec/integration/complaints_spec.rb +38 -0
  45. data/spec/integration/domains_spec.rb +39 -0
  46. data/spec/integration/email_validation_spec.rb +57 -0
  47. data/spec/integration/events_spec.rb +28 -0
  48. data/spec/integration/list_members_spec.rb +63 -0
  49. data/spec/integration/list_spec.rb +58 -0
  50. data/spec/integration/mailgun_spec.rb +121 -0
  51. data/spec/integration/messages/sample_data/mime.txt +38 -0
  52. data/spec/integration/routes_spec.rb +74 -0
  53. data/spec/integration/stats_spec.rb +15 -0
  54. data/spec/integration/suppressions_spec.rb +126 -0
  55. data/spec/integration/unsubscribes_spec.rb +42 -0
  56. data/spec/integration/webhook_spec.rb +54 -0
  57. data/spec/spec_helper.rb +45 -0
  58. data/spec/unit/connection/test_client.rb +99 -0
  59. data/spec/unit/events/events_spec.rb +50 -0
  60. data/spec/unit/lists/opt_in_handler_spec.rb +24 -0
  61. data/spec/unit/mailgun_spec.rb +127 -0
  62. data/spec/unit/messages/batch_message_spec.rb +131 -0
  63. data/spec/unit/messages/message_builder_spec.rb +584 -0
  64. data/spec/unit/messages/sample_data/mailgun_icon.png +0 -0
  65. data/spec/unit/messages/sample_data/mime.txt +38 -0
  66. data/spec/unit/messages/sample_data/rackspace_logo.jpg +0 -0
  67. data/vcr_cassettes/bounces.yml +175 -0
  68. data/vcr_cassettes/complaints.yml +175 -0
  69. data/vcr_cassettes/domains.todo.yml +42 -0
  70. data/vcr_cassettes/domains.yml +360 -0
  71. data/vcr_cassettes/email_validation.yml +167 -0
  72. data/vcr_cassettes/events.yml +108 -0
  73. data/vcr_cassettes/exceptions.yml +45 -0
  74. data/vcr_cassettes/list_members.yml +320 -0
  75. data/vcr_cassettes/mailing_list.todo.yml +43 -0
  76. data/vcr_cassettes/mailing_list.yml +390 -0
  77. data/vcr_cassettes/routes.yml +359 -0
  78. data/vcr_cassettes/send_message.yml +107 -0
  79. data/vcr_cassettes/stats.yml +44 -0
  80. data/vcr_cassettes/suppressions.yml +676 -0
  81. data/vcr_cassettes/unsubscribes.yml +191 -0
  82. data/vcr_cassettes/webhooks.yml +276 -0
  83. metadata +263 -0
@@ -0,0 +1,191 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/unsubscribes
6
+ body:
7
+ encoding: US-ASCII
8
+ string: address=integration-test-email%40DOMAIN.TEST&tag=*
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '85'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Fri, 08 Jan 2016 18:55:05 GMT
29
+ Content-Type:
30
+ - application/json; charset=utf-8
31
+ Content-Length:
32
+ - '144'
33
+ Connection:
34
+ - keep-alive
35
+ Access-Control-Allow-Origin:
36
+ - "*"
37
+ - "*"
38
+ Access-Control-Max-Age:
39
+ - '600'
40
+ - '600'
41
+ Access-Control-Allow-Methods:
42
+ - GET, POST, PUT, DELETE, OPTIONS
43
+ - GET, POST, PUT, DELETE, OPTIONS
44
+ Access-Control-Allow-Headers:
45
+ - Content-Type, x-requested-with
46
+ - Content-Type, x-requested-with
47
+ body:
48
+ encoding: UTF-8
49
+ string: '{"address":"integration-test-email@DOMAIN.TEST","message":"Address
50
+ has been added to the unsubscribes table"}'
51
+ http_version:
52
+ recorded_at: Fri, 08 Jan 2016 18:55:05 GMT
53
+ - request:
54
+ method: get
55
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/unsubscribes/integration-test-email@DOMAIN.TEST
56
+ body:
57
+ encoding: US-ASCII
58
+ string: ''
59
+ headers:
60
+ Accept:
61
+ - "*/*"
62
+ Accept-Encoding:
63
+ - gzip, deflate
64
+ User-Agent:
65
+ - Ruby
66
+ response:
67
+ status:
68
+ code: 200
69
+ message: OK
70
+ headers:
71
+ Server:
72
+ - nginx
73
+ Date:
74
+ - Fri, 08 Jan 2016 18:55:05 GMT
75
+ Content-Type:
76
+ - application/json; charset=utf-8
77
+ Content-Length:
78
+ - '141'
79
+ Connection:
80
+ - keep-alive
81
+ Access-Control-Allow-Origin:
82
+ - "*"
83
+ - "*"
84
+ Access-Control-Max-Age:
85
+ - '600'
86
+ - '600'
87
+ Access-Control-Allow-Methods:
88
+ - GET, POST, PUT, DELETE, OPTIONS
89
+ - GET, POST, PUT, DELETE, OPTIONS
90
+ Access-Control-Allow-Headers:
91
+ - Content-Type, x-requested-with
92
+ - Content-Type, x-requested-with
93
+ body:
94
+ encoding: UTF-8
95
+ string: '{"address":"integration-test-email@DOMAIN.TEST","tags":["*"],"created_at":"Fri,
96
+ 08 Jan 2016 18:55:04 UTC"}'
97
+ http_version:
98
+ recorded_at: Fri, 08 Jan 2016 18:55:05 GMT
99
+ - request:
100
+ method: get
101
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/unsubscribes
102
+ body:
103
+ encoding: US-ASCII
104
+ string: ''
105
+ headers:
106
+ Accept:
107
+ - "*/*"
108
+ Accept-Encoding:
109
+ - gzip, deflate
110
+ User-Agent:
111
+ - Ruby
112
+ response:
113
+ status:
114
+ code: 200
115
+ message: OK
116
+ headers:
117
+ Server:
118
+ - nginx
119
+ Date:
120
+ - Fri, 08 Jan 2016 18:55:27 GMT
121
+ Content-Type:
122
+ - application/json; charset=utf-8
123
+ Content-Length:
124
+ - '812'
125
+ Connection:
126
+ - keep-alive
127
+ Access-Control-Allow-Origin:
128
+ - "*"
129
+ - "*"
130
+ Access-Control-Max-Age:
131
+ - '600'
132
+ - '600'
133
+ Access-Control-Allow-Methods:
134
+ - GET, POST, PUT, DELETE, OPTIONS
135
+ - GET, POST, PUT, DELETE, OPTIONS
136
+ Access-Control-Allow-Headers:
137
+ - Content-Type, x-requested-with
138
+ - Content-Type, x-requested-with
139
+ body:
140
+ encoding: UTF-8
141
+ string: '{"items":[{"address":"integration-test-email@DOMAIN.TEST","tags":["*"],"created_at":"Fri,
142
+ 08 Jan 2016 18:55:04 UTC"}],"paging":{"first":"https://api.mailgun.net/v3/DOMAIN.TEST/unsubscribes?limit=100","last":"https://api.mailgun.net/v3/DOMAIN.TEST/unsubscribes?page=last\u0026limit=100","next":"https://api.mailgun.net/v3/DOMAIN.TEST/unsubscribes?page=next\u0026address=integration-test-email%40DOMAIN.TEST\u0026limit=100","previous":"https://api.mailgun.net/v3/DOMAIN.TEST/unsubscribes?page=previous\u0026address=integration-test-email%40DOMAIN.TEST\u0026limit=100"}}'
143
+ http_version:
144
+ recorded_at: Fri, 08 Jan 2016 18:55:28 GMT
145
+ - request:
146
+ method: delete
147
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/unsubscribes/integration-test-email@DOMAIN.TEST
148
+ body:
149
+ encoding: US-ASCII
150
+ string: ''
151
+ headers:
152
+ Accept:
153
+ - "*/*; q=0.5, application/xml"
154
+ Accept-Encoding:
155
+ - gzip, deflate
156
+ User-Agent:
157
+ - Ruby
158
+ response:
159
+ status:
160
+ code: 200
161
+ message: OK
162
+ headers:
163
+ Server:
164
+ - nginx
165
+ Date:
166
+ - Fri, 08 Jan 2016 18:55:28 GMT
167
+ Content-Type:
168
+ - application/json; charset=utf-8
169
+ Content-Length:
170
+ - '130'
171
+ Connection:
172
+ - keep-alive
173
+ Access-Control-Allow-Origin:
174
+ - "*"
175
+ - "*"
176
+ Access-Control-Max-Age:
177
+ - '600'
178
+ - '600'
179
+ Access-Control-Allow-Methods:
180
+ - GET, POST, PUT, DELETE, OPTIONS
181
+ - GET, POST, PUT, DELETE, OPTIONS
182
+ Access-Control-Allow-Headers:
183
+ - Content-Type, x-requested-with
184
+ - Content-Type, x-requested-with
185
+ body:
186
+ encoding: UTF-8
187
+ string: '{"address":"integration-test-email@DOMAIN.TEST","message":"Unsubscribe
188
+ event has been removed"}'
189
+ http_version:
190
+ recorded_at: Fri, 08 Jan 2016 18:55:28 GMT
191
+ recorded_with: VCR 3.0.1
@@ -0,0 +1,276 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/domains/DOMAIN.TEST/webhooks
6
+ body:
7
+ encoding: US-ASCII
8
+ string: id=bounce&url=http%3A%2F%2Fexample.com%2Fmailgun%2Fevents%2Fbounce
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '66'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Server:
26
+ - nginx
27
+ Date:
28
+ - Fri, 08 Jan 2016 19:05:55 GMT
29
+ Content-Type:
30
+ - application/json
31
+ Content-Length:
32
+ - '117'
33
+ Connection:
34
+ - keep-alive
35
+ Content-Disposition:
36
+ - inline
37
+ Access-Control-Allow-Origin:
38
+ - "*"
39
+ - "*"
40
+ Access-Control-Max-Age:
41
+ - '600'
42
+ - '600'
43
+ Access-Control-Allow-Methods:
44
+ - GET, POST, PUT, DELETE, OPTIONS
45
+ - GET, POST, PUT, DELETE, OPTIONS
46
+ Access-Control-Allow-Headers:
47
+ - Content-Type, x-requested-with
48
+ - Content-Type, x-requested-with
49
+ body:
50
+ encoding: UTF-8
51
+ string: |-
52
+ {
53
+ "message": "Webhook has been created",
54
+ "webhook": {
55
+ "url": "http://example.com/mailgun/events/bounce"
56
+ }
57
+ }
58
+ http_version:
59
+ recorded_at: Fri, 08 Jan 2016 19:05:55 GMT
60
+ - request:
61
+ method: get
62
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/domains/DOMAIN.TEST/webhooks/bounce
63
+ body:
64
+ encoding: US-ASCII
65
+ string: ''
66
+ headers:
67
+ Accept:
68
+ - "*/*"
69
+ Accept-Encoding:
70
+ - gzip, deflate
71
+ User-Agent:
72
+ - Ruby
73
+ response:
74
+ status:
75
+ code: 200
76
+ message: OK
77
+ headers:
78
+ Server:
79
+ - nginx
80
+ Date:
81
+ - Fri, 08 Jan 2016 19:05:55 GMT
82
+ Content-Type:
83
+ - application/json
84
+ Content-Length:
85
+ - '76'
86
+ Connection:
87
+ - keep-alive
88
+ Content-Disposition:
89
+ - inline
90
+ Access-Control-Allow-Origin:
91
+ - "*"
92
+ - "*"
93
+ Access-Control-Max-Age:
94
+ - '600'
95
+ - '600'
96
+ Access-Control-Allow-Methods:
97
+ - GET, POST, PUT, DELETE, OPTIONS
98
+ - GET, POST, PUT, DELETE, OPTIONS
99
+ Access-Control-Allow-Headers:
100
+ - Content-Type, x-requested-with
101
+ - Content-Type, x-requested-with
102
+ body:
103
+ encoding: UTF-8
104
+ string: |-
105
+ {
106
+ "webhook": {
107
+ "url": "http://example.com/mailgun/events/bounce"
108
+ }
109
+ }
110
+ http_version:
111
+ recorded_at: Fri, 08 Jan 2016 19:05:56 GMT
112
+ - request:
113
+ method: get
114
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/domains/DOMAIN.TEST/webhooks
115
+ body:
116
+ encoding: US-ASCII
117
+ string: ''
118
+ headers:
119
+ Accept:
120
+ - "*/*"
121
+ Accept-Encoding:
122
+ - gzip, deflate
123
+ User-Agent:
124
+ - Ruby
125
+ response:
126
+ status:
127
+ code: 200
128
+ message: OK
129
+ headers:
130
+ Server:
131
+ - nginx
132
+ Date:
133
+ - Fri, 08 Jan 2016 19:05:56 GMT
134
+ Content-Type:
135
+ - application/json
136
+ Content-Length:
137
+ - '101'
138
+ Connection:
139
+ - keep-alive
140
+ Content-Disposition:
141
+ - inline
142
+ Access-Control-Allow-Origin:
143
+ - "*"
144
+ - "*"
145
+ Access-Control-Max-Age:
146
+ - '600'
147
+ - '600'
148
+ Access-Control-Allow-Methods:
149
+ - GET, POST, PUT, DELETE, OPTIONS
150
+ - GET, POST, PUT, DELETE, OPTIONS
151
+ Access-Control-Allow-Headers:
152
+ - Content-Type, x-requested-with
153
+ - Content-Type, x-requested-with
154
+ body:
155
+ encoding: UTF-8
156
+ string: |-
157
+ {
158
+ "webhooks": {
159
+ "bounce": {
160
+ "url": "http://example.com/mailgun/events/bounce"
161
+ }
162
+ }
163
+ }
164
+ http_version:
165
+ recorded_at: Fri, 08 Jan 2016 19:05:56 GMT
166
+ - request:
167
+ method: put
168
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/domains/DOMAIN.TEST/webhooks/bounce
169
+ body:
170
+ encoding: US-ASCII
171
+ string: id=bounce&url=http%3A%2F%2Fexample.com%2Fmailgun%2Fevents%2Fbounceup
172
+ headers:
173
+ Accept:
174
+ - "*/*; q=0.5, application/xml"
175
+ Accept-Encoding:
176
+ - gzip, deflate
177
+ Content-Length:
178
+ - '70'
179
+ Content-Type:
180
+ - application/x-www-form-urlencoded
181
+ User-Agent:
182
+ - Ruby
183
+ response:
184
+ status:
185
+ code: 200
186
+ message: OK
187
+ headers:
188
+ Server:
189
+ - nginx
190
+ Date:
191
+ - Fri, 08 Jan 2016 19:05:56 GMT
192
+ Content-Type:
193
+ - application/json
194
+ Content-Length:
195
+ - '121'
196
+ Connection:
197
+ - keep-alive
198
+ Content-Disposition:
199
+ - inline
200
+ Access-Control-Allow-Origin:
201
+ - "*"
202
+ - "*"
203
+ Access-Control-Max-Age:
204
+ - '600'
205
+ - '600'
206
+ Access-Control-Allow-Methods:
207
+ - GET, POST, PUT, DELETE, OPTIONS
208
+ - GET, POST, PUT, DELETE, OPTIONS
209
+ Access-Control-Allow-Headers:
210
+ - Content-Type, x-requested-with
211
+ - Content-Type, x-requested-with
212
+ body:
213
+ encoding: UTF-8
214
+ string: |-
215
+ {
216
+ "message": "Webhook has been updated",
217
+ "webhook": {
218
+ "url": "http://example.com/mailgun/events/bounceup"
219
+ }
220
+ }
221
+ http_version:
222
+ recorded_at: Fri, 08 Jan 2016 19:05:56 GMT
223
+ - request:
224
+ method: delete
225
+ uri: https://api:<APIKEY>@api.mailgun.net/v3/domains/DOMAIN.TEST/webhooks/bounce
226
+ body:
227
+ encoding: US-ASCII
228
+ string: ''
229
+ headers:
230
+ Accept:
231
+ - "*/*; q=0.5, application/xml"
232
+ Accept-Encoding:
233
+ - gzip, deflate
234
+ User-Agent:
235
+ - Ruby
236
+ response:
237
+ status:
238
+ code: 200
239
+ message: OK
240
+ headers:
241
+ Server:
242
+ - nginx
243
+ Date:
244
+ - Fri, 08 Jan 2016 19:05:56 GMT
245
+ Content-Type:
246
+ - application/json
247
+ Content-Length:
248
+ - '121'
249
+ Connection:
250
+ - keep-alive
251
+ Content-Disposition:
252
+ - inline
253
+ Access-Control-Allow-Origin:
254
+ - "*"
255
+ - "*"
256
+ Access-Control-Max-Age:
257
+ - '600'
258
+ - '600'
259
+ Access-Control-Allow-Methods:
260
+ - GET, POST, PUT, DELETE, OPTIONS
261
+ - GET, POST, PUT, DELETE, OPTIONS
262
+ Access-Control-Allow-Headers:
263
+ - Content-Type, x-requested-with
264
+ - Content-Type, x-requested-with
265
+ body:
266
+ encoding: UTF-8
267
+ string: |-
268
+ {
269
+ "message": "Webhook has been deleted",
270
+ "webhook": {
271
+ "url": "http://example.com/mailgun/events/bounceup"
272
+ }
273
+ }
274
+ http_version:
275
+ recorded_at: Fri, 08 Jan 2016 19:05:57 GMT
276
+ recorded_with: VCR 3.0.1