mailgun-ruby 1.4.5 → 1.4.6

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 (120) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +17 -1
  3. data/README.md +3 -1
  4. data/lib/mailgun/api_keys/api_keys.rb +2 -2
  5. data/lib/mailgun/client.rb +1 -1
  6. data/lib/mailgun/domains/domain_keys.rb +5 -5
  7. data/lib/mailgun/domains/domains.rb +12 -9
  8. data/lib/mailgun/events/events.rb +1 -1
  9. data/lib/mailgun/helpers/api_version_checker.rb +23 -12
  10. data/lib/mailgun/helpers/deprecation.rb +32 -0
  11. data/lib/mailgun/lists/mailing_lists.rb +250 -0
  12. data/lib/mailgun/messages/message_builder.rb +17 -7
  13. data/lib/mailgun/response.rb +1 -1
  14. data/lib/mailgun/routes/routes.rb +98 -0
  15. data/lib/mailgun/tags/analytics_tags.rb +2 -2
  16. data/lib/mailgun/tags/tags.rb +16 -8
  17. data/lib/mailgun/version.rb +1 -1
  18. data/lib/mailgun/webhooks/account_webhooks.rb +2 -2
  19. data/lib/mailgun/webhooks/webhooks.rb +17 -9
  20. data/lib/mailgun.rb +1 -0
  21. metadata +6 -326
  22. data/.github/workflows/ci.yml +0 -49
  23. data/.github_changelog_generator +0 -1
  24. data/.gitignore +0 -24
  25. data/.rubocop.yml +0 -68
  26. data/.ruby-env.yml.example +0 -13
  27. data/Gemfile +0 -9
  28. data/Rakefile +0 -32
  29. data/docs/AccountWebhooks.md +0 -55
  30. data/docs/AnalyticsTags.md +0 -63
  31. data/docs/ApiKeys.md +0 -65
  32. data/docs/DomainKeys.md +0 -49
  33. data/docs/Domains.md +0 -82
  34. data/docs/EmailValidation.md +0 -34
  35. data/docs/Events.md +0 -48
  36. data/docs/Logs.md +0 -67
  37. data/docs/MessageBuilder.md +0 -120
  38. data/docs/Metrics.md +0 -108
  39. data/docs/OptInHandler.md +0 -103
  40. data/docs/Snippets.md +0 -519
  41. data/docs/Subaccounts.md +0 -68
  42. data/docs/Suppressions.md +0 -92
  43. data/docs/Templates.md +0 -92
  44. data/docs/Webhooks.md +0 -65
  45. data/docs/railgun/EmailValidation.md +0 -34
  46. data/docs/railgun/Overview.md +0 -11
  47. data/docs/railgun/Parameters.md +0 -83
  48. data/mailgun.gemspec +0 -47
  49. data/spec/integration/account_webhooks_spec.rb +0 -57
  50. data/spec/integration/analytics_tags_spec.rb +0 -54
  51. data/spec/integration/api_keys_spec.rb +0 -50
  52. data/spec/integration/bounces_spec.rb +0 -45
  53. data/spec/integration/campaign_spec.rb +0 -62
  54. data/spec/integration/complaints_spec.rb +0 -40
  55. data/spec/integration/domain_keys_spec.rb +0 -124
  56. data/spec/integration/domains_spec.rb +0 -201
  57. data/spec/integration/email_validation_spec.rb +0 -73
  58. data/spec/integration/events_spec.rb +0 -28
  59. data/spec/integration/list_members_spec.rb +0 -64
  60. data/spec/integration/list_spec.rb +0 -59
  61. data/spec/integration/logs_spec.rb +0 -105
  62. data/spec/integration/mailer_spec.rb +0 -65
  63. data/spec/integration/mailgun_spec.rb +0 -198
  64. data/spec/integration/messages/sample_data/mime.txt +0 -38
  65. data/spec/integration/metrics_spec.rb +0 -224
  66. data/spec/integration/routes_spec.rb +0 -91
  67. data/spec/integration/stats_spec.rb +0 -17
  68. data/spec/integration/subaccounts_spec.rb +0 -57
  69. data/spec/integration/suppressions_spec.rb +0 -320
  70. data/spec/integration/templates_spec.rb +0 -137
  71. data/spec/integration/unsubscribes_spec.rb +0 -44
  72. data/spec/integration/webhook_spec.rb +0 -79
  73. data/spec/spec_helper.rb +0 -53
  74. data/spec/unit/client_spec.rb +0 -448
  75. data/spec/unit/connection/test_client.rb +0 -169
  76. data/spec/unit/events/events_spec.rb +0 -88
  77. data/spec/unit/exceptions/exceptions_spec.rb +0 -31
  78. data/spec/unit/helpers/api_version_checker_spec.rb +0 -206
  79. data/spec/unit/lists/opt_in_handler_spec.rb +0 -28
  80. data/spec/unit/mailgun_spec.rb +0 -171
  81. data/spec/unit/messages/batch_message_spec.rb +0 -148
  82. data/spec/unit/messages/message_builder_spec.rb +0 -745
  83. data/spec/unit/messages/sample_data/mailgun_icon.png +0 -0
  84. data/spec/unit/messages/sample_data/mime.txt +0 -38
  85. data/spec/unit/messages/sample_data/rackspace_logo.jpg +0 -0
  86. data/spec/unit/messages/sample_data/unknown.type +0 -0
  87. data/spec/unit/railgun/content_type_spec.rb +0 -89
  88. data/spec/unit/railgun/mailer_spec.rb +0 -391
  89. data/spec/unit/response_spec.rb +0 -225
  90. data/spec/unit/webhooks_spec.rb +0 -121
  91. data/vcr_cassettes/For_the_suppressions_handling_class/creates_a_single_bounce.yml +0 -55
  92. data/vcr_cassettes/account_webhooks.yml +0 -269
  93. data/vcr_cassettes/analytics_tags.yml +0 -187
  94. data/vcr_cassettes/api_keys.yml +0 -212
  95. data/vcr_cassettes/bounces.yml +0 -136
  96. data/vcr_cassettes/complaints.yml +0 -315
  97. data/vcr_cassettes/domains.todo.yml +0 -42
  98. data/vcr_cassettes/domains.yml +0 -1243
  99. data/vcr_cassettes/email_validation.yml +0 -152
  100. data/vcr_cassettes/events.yml +0 -69
  101. data/vcr_cassettes/exceptions-invalid-api-key.yml +0 -52
  102. data/vcr_cassettes/exceptions-invalid-data.yml +0 -52
  103. data/vcr_cassettes/exceptions-not-allowed.yml +0 -54
  104. data/vcr_cassettes/exceptions.yml +0 -92
  105. data/vcr_cassettes/list_members.yml +0 -328
  106. data/vcr_cassettes/logs.yml +0 -53
  107. data/vcr_cassettes/mailer_invalid_domain.yml +0 -109
  108. data/vcr_cassettes/mailing_list.todo.yml +0 -43
  109. data/vcr_cassettes/mailing_list.yml +0 -682
  110. data/vcr_cassettes/message_deliver.yml +0 -149
  111. data/vcr_cassettes/metrics.yml +0 -116
  112. data/vcr_cassettes/routes.yml +0 -359
  113. data/vcr_cassettes/send_message.yml +0 -158
  114. data/vcr_cassettes/stats.yml +0 -48
  115. data/vcr_cassettes/subaccounts.yml +0 -270
  116. data/vcr_cassettes/suppressions.yml +0 -1392
  117. data/vcr_cassettes/templates.yml +0 -1065
  118. data/vcr_cassettes/unsubscribes.yml +0 -401
  119. data/vcr_cassettes/webhooks.yml +0 -246
  120. data/vcr_cassettes/webhooks_v4.yml +0 -275
data/docs/Snippets.md DELETED
@@ -1,519 +0,0 @@
1
- Mailgun-Ruby Snippets
2
- =====================
3
-
4
- This page is filled with snippets that cover almost every API endpoint and action. Copy, Paste, Go! There will be little inline documentation in these samples, please consult Mailgun's official documentation for detailed information.
5
-
6
- If you haven't already installed the SDK, go to the README and follow the installation instructions.
7
-
8
- These snippets require that you pipe in a few parameters. "mg_client" is instantiated like so:
9
-
10
- ```ruby
11
- require 'mailgun'
12
- mg_client = Mailgun::Client.new "your-api-key"
13
- ```
14
-
15
- ### Messages:
16
- ____________________________________________________
17
- **Send a basic message: **
18
-
19
- ```ruby
20
- data = {:from => 'bob@sending_domain.com',
21
- :to => 'sally@example.com',
22
- :subject => 'The Ruby SDK is awesome!',
23
- :text => 'It is really easy to send a message!'}
24
-
25
- mg_client.send_message "sending_domain.com", data
26
- ```
27
-
28
- **Send a multipart text/html message:**
29
-
30
- ```ruby
31
- data = {:from => 'bob@sending_domain.com',
32
- :to => 'sally@example.com',
33
- :subject => 'The Ruby SDK is awesome!',
34
- :text => 'This is the text part.',
35
- :html => '<html><body><p>This is the HTML part.</p></body></html>'}
36
-
37
- mg_client.send_message "sending_domain.com", data
38
- ```
39
-
40
- **Send a custom MIME message:**
41
-
42
- ```ruby
43
- # Don't include a file, pull the file to a string
44
- mime_string = 'From: Bob Sample <example@example.com>
45
- MIME-Version: 1.0
46
- Content-Type: multipart/mixed;
47
- boundary="--boundary-goes-here--"
48
-
49
- Your Multipart MIME body
50
-
51
- --boundary-goes-here--
52
- Content-Type: text/plain
53
-
54
- This is the text part of your message.
55
-
56
- --boundary-goes-here--'
57
-
58
- # The envelope recipient is defined here, as well as your MIME string
59
- data = {:to => 'sally@example.com', :message => mime_string}
60
-
61
- mg_client.send_message "sending_domain.com", data
62
-
63
- ```
64
-
65
- **Build a message, part by part, with Message Builder:**
66
-
67
- ```ruby
68
- mb_obj = Mailgun::MessageBuilder.new
69
-
70
- mb_obj.set_from_address "sender@example.com", {'first' => 'Sending', 'last' => 'User'}
71
- mb_obj.add_recipient :to, "recipient@example.com", {'first' => 'Recipient', 'last' => 'User'}
72
- mb_obj.set_subject "This is the subject!"
73
- mb_obj.set_text_body "This is the text body."
74
-
75
- mg_client.send_message "sending_domain.com", mb_obj
76
- ```
77
-
78
- **Build a message with attachments, part by part, with Message Builder:**
79
-
80
- ```ruby
81
- mb_obj = Mailgun::MessageBuilder.new
82
-
83
- mb_obj.set_from_address "sender@example.com", {'first' => 'Sending', 'last' => 'User'}
84
- mb_obj.add_recipient :to, "recipient@example.com", {'first' => 'Recipient', 'last' => 'User'}
85
- mb_obj.set_subject "This is the subject!"
86
- mb_obj.set_text_body "This is the text body."
87
-
88
- # Add separate attachments
89
- mb_obj.add_attachment "/path/to/file/invoice_8675309.pdf", "Order Invoice - 8675309.pdf"
90
- mb_obj.add_attachment "/path/to/file/datasheet_00001.pdf", "Product Datasheet - 00001.pdf"
91
-
92
- # Attach inline image to message
93
- mb_obj.add_inline_image "/path/to/file/product_image_00001.png"
94
-
95
- mg_client.send_message "sending_domain.com", mb_obj
96
- ```
97
-
98
- **Send batches of 1000 messages per post:**
99
-
100
- ```ruby
101
- bm_obj = Mailgun::BatchMessage.new
102
-
103
- # Build message using Message Builder
104
- bm_obj.set_from_address "sender@example.com", {'first' => 'Sending', 'last' => 'User'}
105
- bm_obj.set_message_id("<20141014000000.11111.11111@example.com>") # optional
106
- bm_obj.set_subject "This is the subject!"
107
- bm_obj.set_text_body "This is the text body."
108
-
109
- # Loop and add unlimited recipients (batch jobs will fire when thresholds reached)
110
- bm_obj.add_recipient :to, "a_user@example.com"
111
-
112
- # All message IDs returned in finalize method return
113
- message_ids = bm_obj.finalize
114
- ```
115
-
116
- ### Domains:
117
- ____________________________________________________
118
- **Get a list of all domains:**
119
-
120
- ```ruby
121
- result = mg_client.get "domains", {:limit => 5, :skip => 0}
122
- ```
123
-
124
- **Get a single domain:**
125
-
126
- ```ruby
127
- result = mg_client.get "domains/#{domain}"
128
- ```
129
-
130
- **Add a domain:**
131
-
132
- ```ruby
133
- result = mg_client.post "domains", {:name => 'anothersample.mailgun.org',
134
- :smtp_password => 'super_secret',
135
- :spam_action => 'tag'}
136
- ```
137
- **Delete a Domain: **
138
-
139
- ```ruby
140
- result = mg_client.delete "domains/#{domain}"
141
- ```
142
- ### Unsubscribes:
143
- ____________________________________________________
144
- **Get List of Unsubscribes: **
145
-
146
- ```ruby
147
- result = mg_client.get "#{domain}/unsubscribes", {:limit => 50, :skip => 10}
148
- ```
149
-
150
- **Get Single Unsubscribe: **
151
-
152
- ```ruby
153
- result = mg_client.get "#{domain}/unsubscribes/#{email_address}"
154
- ```
155
-
156
- **Unsubscribe a Recipient: **
157
-
158
- ```ruby
159
- result = mg_client.post "#{domain}/unsubscribes", {:address => 'bob@example.com', :tag => 'mypromotion'}
160
- ```
161
-
162
- **Unsubscribe from all messages for a domain: **
163
-
164
- ```ruby
165
- result = mg_client.post "#{domain}/unsubscribes", {:address => 'bob@example.com', :tag => '*'}
166
- ```
167
-
168
- **Remove an unsubscribe: **
169
-
170
- ```ruby
171
- result = mg_client.delete "#{domain}/unsubscribes/#{email_address}"
172
- ```
173
-
174
- ### Complaints:
175
- ____________________________________________________
176
- **Get List of Complaints: **
177
-
178
- ```ruby
179
- result = mg_client.get "#{domain}/complaints", {:limit => 50, :skip => 10}
180
- ```
181
-
182
- **Get a Single Complaint: **
183
-
184
- ```ruby
185
- result = mg_client.get "#{domain}/complaints/#{email_address}"
186
- ```
187
- **Create a complaint: **
188
-
189
- ```ruby
190
- result = mg_client.post "#{domain}/complaint", {:address => 'bob@example.com'}
191
- ```
192
-
193
- **Remove a complaint: **
194
-
195
- ```ruby
196
- result = mg_client.delete "#{domain}/complaint/#{email_address}"
197
- ```
198
-
199
- ### Bounces:
200
- ____________________________________________________
201
- **Get List of Bounces: **
202
-
203
- ```ruby
204
- result = mg_client.get "#{domain}/bounces", {:limit => 50, :skip => 10}
205
- ```
206
-
207
- **Get a Single Bounce Event: **
208
-
209
- ```ruby
210
- result = mg_client.get "#{domain}/bounces/#{email_address}"
211
- ```
212
-
213
- **Create a Bounce: **
214
-
215
- ```ruby
216
- result = mg_client.post "#{domain}/bounces", {:address => 'bob@example.com',
217
- :code => 550,
218
- :error => 'Mailbox does not exist.'}
219
- ```
220
-
221
- **Remove a Bounced Address: **
222
-
223
- ```ruby
224
- result = mg_client.delete "#{domain}/bounces/#{email_address}"
225
- ```
226
-
227
- ### Statistics:
228
- ____________________________________________________
229
- **Get Statistics: **
230
-
231
- ```ruby
232
- result = mg_client.get "#{domain}/stats", {:limit => 50,
233
- :skip => 10,
234
- :event => 'sent',
235
- "start-date" => 'Mon, 13 Feb 2015 00:00:00 GMT'}
236
- ```
237
-
238
- **Remove a Tag: **
239
-
240
- ```ruby
241
- result = mg_client.delete "#{domain}/tags/#{tag}"
242
- ```
243
- ### Events:
244
- ____________________________________________________
245
- **Get Event: **
246
-
247
- ```ruby
248
- result = mg_client.get "#{domain}/events", {:event => 'rejected'}
249
- ```
250
-
251
- ### Routes:
252
- ____________________________________________________
253
- **Get List of Routes: **
254
-
255
- ```ruby
256
- result = mg_client.get "routes", {:limit => 50, :skip => 10}
257
- ```
258
-
259
- **Get a Single Route by ID: **
260
-
261
- ```ruby
262
- result = mg_client.get "routes/#{route_id}"
263
- ```
264
- **Create a Route: **
265
-
266
- ```ruby
267
- result = mg_client.post "routes", {:priority => 10,
268
- :description => 'This is a test route',
269
- :expression => 'match_recipient(".*@gmail.com")',
270
- :action => 'forward("alice@example.com")'}
271
- ```
272
- **Update a Route: **
273
-
274
- ```ruby
275
- result = mg_client.put "routes/#{route_id}", {:priority => 10,
276
- :description => 'This is a test route',
277
- :expression => 'match_recipient(".*@gmail.com")',
278
- :action => 'forward("alice@example.com")'}
279
- ```
280
- **Remove a Route: **
281
-
282
- ```ruby
283
- result = mg_client.delete "routes/#{route_id}"
284
- ```
285
- ### Campaigns:
286
- ____________________________________________________
287
- **Get List of Campaigns: **
288
-
289
- ```ruby
290
- result = mg_client.get "#{domain}/campaigns", {:limit => 50, :skip => 10}
291
- ```
292
-
293
- **Get a Single Campaign: **
294
-
295
- ```ruby
296
- result = mg_client.get "#{domain}/campaigns/#{campaign_id}"
297
- ```
298
-
299
- **Create a Campaign: **
300
-
301
- ```ruby
302
- result = mg_client.post "#{domain}/campaigns", {:name => 'My Campaign',
303
- :id => 'campaign_123_2014'}
304
- ```
305
-
306
- **Update a Campaign: **
307
-
308
- ```ruby
309
- result = mg_client.put "#{domain}/campaigns/#{campaign_id}", {:name => 'My Campaign',
310
- :id => 'campaign_123_2014'}
311
- ```
312
-
313
- **Remove a Campaign: **
314
-
315
- ```ruby
316
- result = mg_client.delete "#{domain}/campaigns/#{campaign_id}"
317
- ```
318
-
319
- **Get Campaign Events: **
320
-
321
- ```ruby
322
- result = mg_client.get "#{domain}/campaigns/#{campaign_id}/events", {:event => 'clicked',
323
- :recipient => 'test@example.com',
324
- :country => 'US',
325
- :region => 'TX',
326
- :limit => 100,
327
- :page => 1,
328
- :count => true}
329
- ```
330
-
331
- **Get a Single Campaign's Stats: **
332
-
333
- ```ruby
334
- result = mg_client.get "#{domain}/campaigns/#{campaign_id}/stats", {:groupby => 'domain'}
335
- ```
336
-
337
- **Get a Single Campaign's Click Stats: **
338
-
339
- ```ruby
340
- result = mg_client.get "#{domain}/campaigns/#{campaign_id}/clicks", {:groupby => 'hour',
341
- :country => 'US',
342
- :region => 'TX',
343
- :city => 'Austin',
344
- :limit => 100,
345
- :page => 1,
346
- :count => true}
347
- ```
348
-
349
- **Get a Single Campaign's Click Opens: **
350
-
351
- ```ruby
352
- result = mg_client.get "#{domain}/campaigns/#{campaign_id}/opens", {:groupby => 'hour',
353
- :country => 'US',
354
- :region => 'TX',
355
- :city => 'Austin',
356
- :limit => 100,
357
- :page => 1,
358
- :count => true}
359
- ```
360
-
361
- **Get a Single Campaign's Click Unsubscribes: **
362
-
363
- ```ruby
364
- result = mg_client.get "#{domain}/campaigns/#{campaign_id}/unsubscribes", {:groupby => 'hour',
365
- :country => 'US',
366
- :region => 'TX',
367
- :city => 'Austin',
368
- :limit => 100,
369
- :page => 1,
370
- :count => true}
371
- ```
372
-
373
- **Get a Single Campaign's Click Complaints: **
374
-
375
- ```ruby
376
- result = mg_client.get "#{domain}/campaigns/#{campaign_id}/complaints", {:groupby => 'hour',
377
- :limit => 100,
378
- :page => 1,
379
- :count => true}
380
- ```
381
-
382
- ### Webhooks:
383
- ____________________________________________________
384
-
385
- **Get List of Webhooks: **
386
-
387
- ```ruby
388
- result = mg_client.get "domains/#{domain}/webhooks"
389
- ```
390
-
391
- **Get a Webhook Properties: **
392
-
393
- ```ruby
394
- result = mg_client.get "domains/#{domain}/webhooks/#{webhook_id}"
395
- ```
396
-
397
- **Create a Webhook: **
398
-
399
- ```ruby
400
- result = mg_client.post "domains/#{domain}/webhooks", {:id => 'bounce',
401
- :url => 'http://example.com/mailgun/events/bounce'}
402
- ```
403
-
404
- **Update a Webhook: **
405
-
406
- ```ruby
407
- result = mg_client.put "domains/#{domain}/webhooks/#{webhook_id}", {:id => 'bounce',
408
- :url => 'http://example.com/mailgun/events/bounce'}
409
- ```
410
-
411
- **Remove a Webhook: **
412
-
413
- ```ruby
414
- result = mg_client.delete "domains/#{domain}/webhooks/#{webhook_id}"
415
- ```
416
-
417
- ### Mailing Lists:
418
- ____________________________________________________
419
-
420
- **Get list of Lists: **
421
-
422
- ```ruby
423
- result = mg_client.get "lists"
424
- ```
425
-
426
- **Get List Properties: **
427
-
428
- ```ruby
429
- result = mg_client.get "lists/#{list_address}"
430
- ```
431
-
432
- **Create a List: **
433
-
434
- ```ruby
435
- result = mg_client.post "lists", {:address => 'dev.group@samples.mailgun.org',
436
- :name => 'Development Group List',
437
- :description => 'List of all developers.',
438
- :access_level => 'members'}
439
- ```
440
-
441
- **Update a List: **
442
-
443
- ```ruby
444
- result = mg_client.put "lists/#{list_address}", {:address => 'dev.group@samples.mailgun.org',
445
- :name => 'Development Group List',
446
- :description => 'List of all developers.',
447
- :access_level => 'members'}
448
- ```
449
-
450
- **Remove a List: **
451
-
452
- ```ruby
453
- result = mg_client.delete "lists/#{list_address}"
454
- ```
455
-
456
- **Get List Members: **
457
-
458
- ```ruby
459
- result = mg_client.get "lists/#{list_address}/members"
460
- ```
461
-
462
- **Get List Member Properties: **
463
-
464
- ```ruby
465
- result = mg_client.get "lists/#{list_address}/members/#{member_address}"
466
- ```
467
-
468
- **Add Member to List: **
469
-
470
- ```ruby
471
- result = mg_client.post "lists/#{list_address}/members/#{member_address}", {:address => 'jane@samples.mailgun.org',
472
- :name => 'Jane Doe',
473
- :vars => '{"first": "Jane", "last": "Doe"}',
474
- :subscribed => true,
475
- :upsert => 'no'}
476
- ```
477
-
478
- **Update Member on List: **
479
-
480
- ```ruby
481
- result = mg_client.put "lists/#{list_address}/members/#{member_address}", {:address => 'jane@samples.mailgun.org',
482
- :name => 'Jane Doe',
483
- :vars => '{"first": "Jane", "last": "Doe"}',
484
- :subscribed => true}
485
- ```
486
-
487
- **Delete a Member from List: **
488
-
489
- ```ruby
490
- result = mg_client.delete "lists/#{list_address}/members/#{member_address}"
491
- ```
492
-
493
- **Get Stats for List: **
494
-
495
- ```ruby
496
- result = mg_client.get "lists/#{list_address}/stats"
497
- ```
498
-
499
- ### Email Validation:
500
- ____________________________________________________
501
- **Validate Single Address: **
502
-
503
- ```ruby
504
- result = mg_client.get "address/validate", {:address => 'test@example.com'}
505
- ```
506
-
507
-
508
- Support and Feedback
509
- --------------------
510
-
511
- Be sure to visit the Mailgun official
512
- [documentation website](https://documentation.mailgun.com/) for additional
513
- information about our API.
514
-
515
- If you find a bug, please submit the issue in Github directly.
516
- [Mailgun-Ruby Issues](https://github.com/mailgun/mailgun-ruby/issues)
517
-
518
- As always, if you need additional assistance, drop us a note at
519
- [support@mailgun.com](mailto:support@mailgun.com).
data/docs/Subaccounts.md DELETED
@@ -1,68 +0,0 @@
1
- Mailgun - [Subaccounts](https://help.mailgun.com/hc/en-us/articles/16380043681435-Subaccounts)
2
- ====================
3
-
4
- Rails
5
- -----
6
-
7
- The library can be initialized with a Rails initializer containing similar:
8
- ```ruby
9
- Mailgun.configure do |config|
10
- config.api_key = 'your-secret-api-key'
11
- end
12
- ```
13
- Or have the initializer read your environment setting if you prefer.
14
-
15
- ```ruby
16
- Mailgun.api_key = 'your-secret-api-key'
17
- ```
18
-
19
- ```ruby
20
- mb_obj = Mailgun::Subaccounts.new
21
-
22
- # Get subaccounts list
23
- mb_obj.get_subaccounts(limit: 10, skip: 0, sort: 'ask', enabled: true)
24
- => {"subaccounts"=>[{"id"=>"XYZ", "name"=>"test.subaccount1", "status"=>"open"}, {"id"=>"YYY", "name"=>"test.subaccount2", "status"=>"open"}], "total"=>2}
25
-
26
- # Get subaccount information
27
- mb_obj.info(subaccount_id)
28
- => {"subaccount"=>{"id"=>"XYZ", "name"=>"test.subaccount1", "status"=>"open"}
29
-
30
- # Add Subaccount
31
- mb_obj.create(name)
32
- => {"subaccount"=>{"id"=>"XYZ", "name"=>"test.subaccount1", "status"=>"open"}}
33
-
34
- # Disable
35
- mb_obj.disable(subaccount_id)
36
- => {"subaccount"=>{"id"=>"XYZ", "name"=>"test.subaccount1", "status"=>"disabled"}}
37
-
38
- # Enable
39
- mb_obj.enable(subaccount_id)
40
- => {"subaccount"=>{"id"=>"XYZ", "name"=>"test.subaccount1", "status"=>"open"}}
41
- ```
42
-
43
- Primary accounts can make API calls on behalf of their subaccounts.
44
- ```ruby
45
- # First, instantiate the Mailgun Client with your API key
46
- mg_client = Mailgun::Client.new 'your-api-key'
47
- mg_client.set_subaccount('SUBACCOUNT_ID')
48
-
49
- # Define your message parameters
50
- message_params = { from: 'bob@SUBACCOUNT_DOMAIN',
51
- to: 'sally@example.com',
52
- subject: 'The Ruby SDK is awesome!',
53
- text: 'It is really easy to send a message!'
54
- }
55
-
56
- # Send your message through the client
57
- # Note: This will not actually hit the API, and will return a generic OK response.
58
- mg_client.send_message('SUBACCOUNT_DOMAIN', message_params)
59
-
60
- # Reset subaccount for primary usage
61
- mg_client.reset_subaccount
62
- ```
63
-
64
-
65
- More Documentation
66
- ------------------
67
- See the official [Mailgun Docs](https://documentation.mailgun.com/en/latest/subaccounts.html#subaccounts)
68
- for more information.
data/docs/Suppressions.md DELETED
@@ -1,92 +0,0 @@
1
- Mailgun - Suppressions
2
- ====================
3
-
4
- This is the Mailgun Ruby *Suppressions* utilities.
5
-
6
- The below assumes you've already installed the Mailgun Ruby SDK in to your
7
- project. If not, go back to the master README for instructions. It currently supports
8
- all calls except credentials.
9
-
10
- ----
11
-
12
- The Suppressions client lets you manage bounces, unsubscribes, and complaints for a
13
- single domain.
14
-
15
- You can view additional samples in the [suppressions_spec.rb](/spec/integration/suppressions_spec.rb)
16
- or the Suppressions client API in [suppressions.rb](/lib/mailgun/suppressions.rb).
17
-
18
-
19
- Usage
20
- -----
21
-
22
- To get an instance of the Suppressions client:
23
-
24
- ```ruby
25
- mg_client = Mailgun::Client.new('api_key')
26
- supp_client = mg_client.suppressions('yourdomain.com')
27
- ```
28
-
29
- ----
30
-
31
- To get a list of bounces, unsubscribes, and/or complaints:
32
-
33
- ```ruby
34
- supp_client.list_bounces
35
- supp_client.list_unsubscribes
36
- supp_client.list_complaints
37
- ```
38
-
39
- ----
40
-
41
- To get the next or previous suppressions page:
42
-
43
- ```ruby
44
- supp_client.list_bounces # returns first *limit* records + next, previous pages urls
45
- supp_client.next # returns next *limit* records
46
- supp_client.prev # returns previous *limit* records
47
- ```
48
-
49
- ----
50
-
51
- To batch-add a set of bounces:
52
-
53
- ```ruby
54
- @addresses = <load or generate some addresses...>
55
-
56
- bounces = []
57
- @addresses.each do |addr|
58
- bounces.push({
59
- :address => addr,
60
- :code => 500,
61
- :error => 'some bounce because reasons',
62
- })
63
- end
64
-
65
- response, addt_responses = @supp_client.create_bounces bounces
66
- ```
67
-
68
- `create_bounces`, `create_unsubscribes`, and `create_complaints` will all
69
- return two values - first, a simple `Mailgun::Response` object. Second,
70
- a list containing any `Mailgun::Response` objects created recursively, if over 998
71
- bounces were provided to `create_*`.
72
-
73
- ----
74
-
75
- To delete bounces:
76
-
77
- ```ruby
78
- @addresses = <load addresses...>
79
-
80
- @addresses.each do |addr|
81
- @supp_client.delete_bounce addr
82
- end
83
- ```
84
-
85
- Or, alternatively, to remove *all* bounces:
86
-
87
- ```ruby
88
- @supp_client.delete_all_bounces
89
- ```
90
-
91
- The `delete_*` methods are similar for `bounces`, `unsubscribe`, and `complaints` -
92
- they all will return a `Mailgun::Response` object.