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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a161608ec972823219220afcff04f3f8ddf959190ab747a03983ebe108ccaba5
4
- data.tar.gz: 21f81c2a51f0b4e2c18f7ad309cd884561cb60120787d3cbe7140962d5fc717a
3
+ metadata.gz: 63fbab3c08481c2364ca4fef89def410a12672507954764103e900bb0f081858
4
+ data.tar.gz: e2fed301bb806d720b6e7f9f8707d415756ed92f5b841592ebc100eb53a71d74
5
5
  SHA512:
6
- metadata.gz: d24993f138c611967f0cf77498fedb464858e93afddb7d6e7e1288ca5351aee6902bd7bb4c449a738f55a775f1fd1849aec91323145a068e64b0bca79ca6db1e
7
- data.tar.gz: ea24ee662ee9c4dd91f5b73609cc4ae884c692a4876dfd96c30e4b1fdd18c213d37088db96936d3aba493e5eecf5fad66a73d1eb53fcee9831bfeeca4f6fefa0
6
+ metadata.gz: 69ad70a850bdb1cbc859647509315b118aa7508747c8af281eeb7ec4514156f1416aa16b4d0e10e07fa168adc705ba110d20b28aae3137b26c454cdf9115b191
7
+ data.tar.gz: e5f30539ca1dfd25ab6bd489c7544febd7b54ae00b407c3378e9ecd3c7166efd961d76f73943e931015436880eab72b607cea5629bf26fda811cbfec1dc1e787
data/.rubocop.yml CHANGED
File without changes
data/.rubocop_todo.yml CHANGED
File without changes
@@ -10,3 +10,4 @@
10
10
  MAILGUN_APIKEY : '<MAILGUN_APIKEY>'
11
11
  MAILGUN_PUB_APIKEY : '<MAILGUN_PUBLIC_APIKEY>'
12
12
  MAILGUN_TESTDOMAIN : '<MAILGUN_SANDBOX_DOMAIN>'
13
+
data/.travis.yml CHANGED
@@ -1,10 +1,11 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 2.0.0
5
- - 2.1
6
- - 2.2
7
- - 2.3.1
4
+ - 2.2.2
5
+ - 2.2.10
6
+ - 2.3.7
7
+ - 2.4.4
8
+ - 2.5.1
8
9
  script:
9
10
  - bundle install
10
11
  - bundle exec rake spec
@@ -17,7 +18,7 @@ deploy:
17
18
  gemspec: mailgun.gemspec
18
19
  on:
19
20
  tags: true
20
- condition: "$TRAVIS_RUBY_VERSION == 2.3.1"
21
+ condition: "$TRAVIS_RUBY_VERSION == 2.5.1"
21
22
  notifications:
22
23
  slack:
23
24
  rooms:
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [Unreleased]
6
+
7
+ ## [1.2.13] - 2023-11-25
8
+
9
+ ### Added
10
+
11
+ - Subaccounts API support (https://github.com/mailgun/mailgun-ruby/pull/300).
12
+
13
+ ### Fixed
14
+
15
+ - transform_for_mailgun block iteration issue (https://github.com/mailgun/mailgun-ruby/pull/298).
16
+ - Typos in several files (https://github.com/mailgun/mailgun-ruby/pull/297).
data/Gemfile CHANGED
@@ -3,4 +3,4 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in mailgun.gemspec
4
4
  gemspec
5
5
 
6
- gem 'json', '~> 1.8', platform: :mri_19
6
+ gem 'json', '~> 2.1', platform: :mri_19
data/README.md CHANGED
@@ -19,7 +19,7 @@ gem install mailgun-ruby
19
19
  Gemfile:
20
20
 
21
21
  ```ruby
22
- gem 'mailgun-ruby', '~>1.1.6'
22
+ gem 'mailgun-ruby', '~>1.2.12'
23
23
  ```
24
24
 
25
25
  Usage
@@ -27,7 +27,7 @@ Usage
27
27
  Here's how to send a message using the library:
28
28
 
29
29
  ```ruby
30
- require 'mailgun'
30
+ require 'mailgun-ruby'
31
31
 
32
32
  # First, instantiate the Mailgun Client with your API key
33
33
  mg_client = Mailgun::Client.new 'your-api-key'
@@ -56,6 +56,12 @@ domain = 'example.com'
56
56
  result = mg_client.get("#{domain}/events", {:event => 'delivered'})
57
57
  ```
58
58
 
59
+ If you're using the EU domains, make sure you specify it when creating the client:
60
+
61
+ ```
62
+ mg_client = Mailgun::Client.new 'your-api-key', 'api.eu.mailgun.net'
63
+ ```
64
+
59
65
  Rails
60
66
  -----
61
67
 
@@ -74,9 +80,26 @@ and replace `api-myapikey` and `mydomain.com` with your secret API key and domai
74
80
  config.action_mailer.mailgun_settings = {
75
81
  api_key: 'api-myapikey',
76
82
  domain: 'mydomain.com',
83
+ # api_host: 'api.eu.mailgun.net' # Uncomment this line for EU region domains
84
+ # timeout: 20 # Default depends on rest-client, whose default is 60s. Added in 1.2.3.
77
85
  }
78
86
  ```
79
87
 
88
+ To specify Mailgun options such as campaign or tags:
89
+ ```ruby
90
+ class UserMailer < ApplicationMailer
91
+ def welcome_email
92
+ mail(to: params[:to], subject: "Welcome!").tap do |message|
93
+ message.mailgun_options = {
94
+ "tag" => ["abtest-option-a", "beta-user"],
95
+ "tracking-opens" => true,
96
+ "tracking-clicks" => "htmlonly"
97
+ }
98
+ end
99
+ end
100
+ end
101
+ ```
102
+
80
103
  To get the Mailgun `message_id` after ActionMailer has successfully delivered the email:
81
104
 
82
105
  ```ruby
@@ -160,12 +183,16 @@ pages. Or the [Snippets](docs/Snippets.md) file.
160
183
  This SDK includes the following components:
161
184
  - [Messages](docs/Messages.md)
162
185
  - [Message Builder](docs/MessageBuilder.md)
163
- - [Batch Message](docs/MessageBuilder.md)
186
+ - [Batch Message](docs/MessageBuilder.md#usage---batch-message)
164
187
  - [Opt-In Handler](docs/OptInHandler.md)
165
188
  - [Domains](docs/Domains.md)
166
189
  - [Webhooks](docs/Webhooks.md)
167
190
  - [Events](docs/Events.md)
191
+ - [Snippets](docs/Snippets.md)
192
+ - [Subaccounts](docs/Subaccounts.md)
168
193
  - [Suppressions](docs/Suppressions.md)
194
+ - [Templates](docs/Templates.md)
195
+ - [EmailValidation](docs/EmailValidation.md)
169
196
 
170
197
  Message Builder allows you to quickly create the array of parameters, required
171
198
  to send a message, by calling a methods for each parameter.
data/docs/Domains.md CHANGED
@@ -28,6 +28,9 @@ domainer.create 'my.new.moreness', { some: 'options' }
28
28
 
29
29
  # Remove a domain
30
30
  domainer.remove 'this.one.is.not.needed.'
31
+
32
+ # Update a domain
33
+ domainer.update 'my.new.moreness', { some: 'options' }
31
34
  ```
32
35
 
33
36
  Suppressions for a Domain
@@ -0,0 +1,34 @@
1
+ Mailgun - Email Validation
2
+ ====================
3
+
4
+ This is the Mailgun Ruby *Email Validation* 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.
8
+
9
+ Usage - Email Validation
10
+ -----------------------
11
+
12
+ ```ruby
13
+ # First, instantiate the Mailgun Address. It pulls api key for Client from Mailgun.api_key variable.
14
+ email_validator = Mailgun::Address.new
15
+
16
+ # Given an arbitrary address, validates address based off defined checks.
17
+ # Response Example:
18
+ # {
19
+ # "address": "existingemail@realdomain.com",
20
+ # "is_disposable_address": false,
21
+ # "is_role_address": false,
22
+ # "reason": [],
23
+ # "result": "deliverable",
24
+ # "risk": "low"
25
+ # }
26
+ email_validator.validate('email@example.com')
27
+
28
+
29
+ ```
30
+
31
+ More Documentation
32
+ ------------------
33
+ See the official [Mailgun Email Validation Docs](https://documentation.mailgun.com/en/latest/api-email-validation.html)
34
+ for more information
data/docs/OptInHandler.md CHANGED
@@ -100,4 +100,4 @@ Available Functions
100
100
 
101
101
  More Documentation
102
102
  ------------------
103
- See the official [Mailgun Docs](https://documentation.mailgun.com/api-sending.html) for more information.
103
+ See the official [Mailgun Docs](https://documentation.mailgun.com/en/latest/api-sending.html) for more information.
data/docs/Snippets.md CHANGED
@@ -110,7 +110,7 @@ bm_obj.set_text_body "This is the text body."
110
110
  bm_obj.add_recipient :to, "a_user@example.com"
111
111
 
112
112
  # All message IDs returned in finalize method return
113
- message_ids = @bm_obj.finalize
113
+ message_ids = bm_obj.finalize
114
114
  ```
115
115
 
116
116
  ### Domains:
@@ -118,57 +118,57 @@ ____________________________________________________
118
118
  **Get a list of all domains:**
119
119
 
120
120
  ```ruby
121
- result = @mg_client.get "domains", {:limit => 5, :skip => 0}
121
+ result = mg_client.get "domains", {:limit => 5, :skip => 0}
122
122
  ```
123
123
 
124
124
  **Get a single domain:**
125
125
 
126
126
  ```ruby
127
- result = @mg_client.get "domains/#{domain}"
127
+ result = mg_client.get "domains/#{domain}"
128
128
  ```
129
129
 
130
130
  **Add a domain:**
131
131
 
132
132
  ```ruby
133
- result = @mg_client.post "domains", {:name => 'anothersample.mailgun.org',
133
+ result = mg_client.post "domains", {:name => 'anothersample.mailgun.org',
134
134
  :smtp_password => 'super_secret',
135
135
  :spam_action => 'tag'}
136
136
  ```
137
137
  **Delete a Domain: **
138
138
 
139
139
  ```ruby
140
- result = @mg_client.delete "domains/#{domain}"
140
+ result = mg_client.delete "domains/#{domain}"
141
141
  ```
142
142
  ### Unsubscribes:
143
143
  ____________________________________________________
144
144
  **Get List of Unsubscribes: **
145
145
 
146
146
  ```ruby
147
- result = @mg_client.get "#{domain}/unsubscribes", {:limit => 50, :skip => 10}
147
+ result = mg_client.get "#{domain}/unsubscribes", {:limit => 50, :skip => 10}
148
148
  ```
149
149
 
150
150
  **Get Single Unsubscribe: **
151
151
 
152
152
  ```ruby
153
- result = @mg_client.get "#{domain}/unsubscribes/#{email_address}"
153
+ result = mg_client.get "#{domain}/unsubscribes/#{email_address}"
154
154
  ```
155
155
 
156
156
  **Unsubscribe a Recipient: **
157
157
 
158
158
  ```ruby
159
- result = @mg_client.post "#{domain}/unsubscribes", {:address => 'bob@example.com', :tag => 'mypromotion'}
159
+ result = mg_client.post "#{domain}/unsubscribes", {:address => 'bob@example.com', :tag => 'mypromotion'}
160
160
  ```
161
161
 
162
162
  **Unsubscribe from all messages for a domain: **
163
163
 
164
164
  ```ruby
165
- result = @mg_client.post "#{domain}/unsubscribes", {:address => 'bob@example.com', :tag => '*'}
165
+ result = mg_client.post "#{domain}/unsubscribes", {:address => 'bob@example.com', :tag => '*'}
166
166
  ```
167
167
 
168
168
  **Remove an unsubscribe: **
169
169
 
170
170
  ```ruby
171
- result = @mg_client.delete "#{domain}/unsubscribes/#{email_address}"
171
+ result = mg_client.delete "#{domain}/unsubscribes/#{email_address}"
172
172
  ```
173
173
 
174
174
  ### Complaints:
@@ -176,24 +176,24 @@ ____________________________________________________
176
176
  **Get List of Complaints: **
177
177
 
178
178
  ```ruby
179
- result = @mg_client.get "#{domain}/complaints", {:limit => 50, :skip => 10}
179
+ result = mg_client.get "#{domain}/complaints", {:limit => 50, :skip => 10}
180
180
  ```
181
181
 
182
182
  **Get a Single Complaint: **
183
183
 
184
184
  ```ruby
185
- result = @mg_client.get "#{domain}/complaints/#{email_address}"
185
+ result = mg_client.get "#{domain}/complaints/#{email_address}"
186
186
  ```
187
187
  **Create a complaint: **
188
188
 
189
189
  ```ruby
190
- result = @mg_client.post "#{domain}/complaint", {:address => 'bob@example.com'}
190
+ result = mg_client.post "#{domain}/complaint", {:address => 'bob@example.com'}
191
191
  ```
192
192
 
193
193
  **Remove a complaint: **
194
194
 
195
195
  ```ruby
196
- result = @mg_client.delete "#{domain}/complaint/#{email_address}"
196
+ result = mg_client.delete "#{domain}/complaint/#{email_address}"
197
197
  ```
198
198
 
199
199
  ### Bounces:
@@ -201,19 +201,19 @@ ____________________________________________________
201
201
  **Get List of Bounces: **
202
202
 
203
203
  ```ruby
204
- result = @mg_client.get "#{domain}/bounces", {:limit => 50, :skip => 10}
204
+ result = mg_client.get "#{domain}/bounces", {:limit => 50, :skip => 10}
205
205
  ```
206
206
 
207
207
  **Get a Single Bounce Event: **
208
208
 
209
209
  ```ruby
210
- result = @mg_client.get "#{domain}/bounces/#{email_address}"
210
+ result = mg_client.get "#{domain}/bounces/#{email_address}"
211
211
  ```
212
212
 
213
213
  **Create a Bounce: **
214
214
 
215
215
  ```ruby
216
- result = @mg_client.post "#{domain}/bounces", {:address => 'bob@example.com',
216
+ result = mg_client.post "#{domain}/bounces", {:address => 'bob@example.com',
217
217
  :code => 550,
218
218
  :error => 'Mailbox does not exist.'}
219
219
  ```
@@ -221,7 +221,7 @@ result = @mg_client.post "#{domain}/bounces", {:address => 'bob@example.com',
221
221
  **Remove a Bounced Address: **
222
222
 
223
223
  ```ruby
224
- result = @mg_client.delete "#{domain}/bounces/#{email_address}"
224
+ result = mg_client.delete "#{domain}/bounces/#{email_address}"
225
225
  ```
226
226
 
227
227
  ### Statistics:
@@ -229,7 +229,7 @@ ____________________________________________________
229
229
  **Get Statistics: **
230
230
 
231
231
  ```ruby
232
- result = @mg_client.get "#{domain}/stats", {:limit => 50,
232
+ result = mg_client.get "#{domain}/stats", {:limit => 50,
233
233
  :skip => 10,
234
234
  :event => 'sent',
235
235
  "start-date" => 'Mon, 13 Feb 2015 00:00:00 GMT'}
@@ -238,14 +238,14 @@ result = @mg_client.get "#{domain}/stats", {:limit => 50,
238
238
  **Remove a Tag: **
239
239
 
240
240
  ```ruby
241
- result = @mg_client.delete "#{domain}/tags/#{tag}"
241
+ result = mg_client.delete "#{domain}/tags/#{tag}"
242
242
  ```
243
243
  ### Events:
244
244
  ____________________________________________________
245
245
  **Get Event: **
246
246
 
247
247
  ```ruby
248
- result = @mg_client.get "#{domain}/events", {:event => 'rejected'}
248
+ result = mg_client.get "#{domain}/events", {:event => 'rejected'}
249
249
  ```
250
250
 
251
251
  ### Routes:
@@ -253,18 +253,18 @@ ____________________________________________________
253
253
  **Get List of Routes: **
254
254
 
255
255
  ```ruby
256
- result = @mg_client.get "routes", {:limit => 50, :skip => 10}
256
+ result = mg_client.get "routes", {:limit => 50, :skip => 10}
257
257
  ```
258
258
 
259
259
  **Get a Single Route by ID: **
260
260
 
261
261
  ```ruby
262
- result = @mg_client.get "routes/#{route_id}"
262
+ result = mg_client.get "routes/#{route_id}"
263
263
  ```
264
264
  **Create a Route: **
265
265
 
266
266
  ```ruby
267
- result = @mg_client.post "routes", {:priority => 10,
267
+ result = mg_client.post "routes", {:priority => 10,
268
268
  :description => 'This is a test route',
269
269
  :expression => 'match_recipient(".*@gmail.com")',
270
270
  :action => 'forward("alice@example.com")'}
@@ -272,7 +272,7 @@ result = @mg_client.post "routes", {:priority => 10,
272
272
  **Update a Route: **
273
273
 
274
274
  ```ruby
275
- result = @mg_client.put "routes/#{route_id}", {:priority => 10,
275
+ result = mg_client.put "routes/#{route_id}", {:priority => 10,
276
276
  :description => 'This is a test route',
277
277
  :expression => 'match_recipient(".*@gmail.com")',
278
278
  :action => 'forward("alice@example.com")'}
@@ -280,46 +280,46 @@ result = @mg_client.put "routes/#{route_id}", {:priority => 10,
280
280
  **Remove a Route: **
281
281
 
282
282
  ```ruby
283
- result = @mg_client.delete "routes/#{route_id}"
283
+ result = mg_client.delete "routes/#{route_id}"
284
284
  ```
285
285
  ### Campaigns:
286
286
  ____________________________________________________
287
287
  **Get List of Campaigns: **
288
288
 
289
289
  ```ruby
290
- result = @mg_client.get "#{domain}/campaigns", {:limit => 50, :skip => 10}
290
+ result = mg_client.get "#{domain}/campaigns", {:limit => 50, :skip => 10}
291
291
  ```
292
292
 
293
293
  **Get a Single Campaign: **
294
294
 
295
295
  ```ruby
296
- result = @mg_client.get "#{domain}/campaigns/#{campaign_id}"
296
+ result = mg_client.get "#{domain}/campaigns/#{campaign_id}"
297
297
  ```
298
298
 
299
299
  **Create a Campaign: **
300
300
 
301
301
  ```ruby
302
- result = @mg_client.post "#{domain}/campaigns", {:name => 'My Campaign',
302
+ result = mg_client.post "#{domain}/campaigns", {:name => 'My Campaign',
303
303
  :id => 'campaign_123_2014'}
304
304
  ```
305
305
 
306
306
  **Update a Campaign: **
307
307
 
308
308
  ```ruby
309
- result = @mg_client.put "#{domain}/campaigns/#{campaign_id}", {:name => 'My Campaign',
309
+ result = mg_client.put "#{domain}/campaigns/#{campaign_id}", {:name => 'My Campaign',
310
310
  :id => 'campaign_123_2014'}
311
311
  ```
312
312
 
313
313
  **Remove a Campaign: **
314
314
 
315
315
  ```ruby
316
- result = @mg_client.delete "#{domain}/campaigns/#{campaign_id}"
316
+ result = mg_client.delete "#{domain}/campaigns/#{campaign_id}"
317
317
  ```
318
318
 
319
319
  **Get Campaign Events: **
320
320
 
321
321
  ```ruby
322
- result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/events", {:event => 'clicked',
322
+ result = mg_client.get "#{domain}/campaigns/#{campaign_id}/events", {:event => 'clicked',
323
323
  :recipient => 'test@example.com',
324
324
  :country => 'US',
325
325
  :region => 'TX',
@@ -331,13 +331,13 @@ result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/events", {:event =>
331
331
  **Get a Single Campaign's Stats: **
332
332
 
333
333
  ```ruby
334
- result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/stats", {:groupby => 'domain'}
334
+ result = mg_client.get "#{domain}/campaigns/#{campaign_id}/stats", {:groupby => 'domain'}
335
335
  ```
336
336
 
337
337
  **Get a Single Campaign's Click Stats: **
338
338
 
339
339
  ```ruby
340
- result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/clicks", {:groupby => 'hour',
340
+ result = mg_client.get "#{domain}/campaigns/#{campaign_id}/clicks", {:groupby => 'hour',
341
341
  :country => 'US',
342
342
  :region => 'TX',
343
343
  :city => 'Austin',
@@ -349,7 +349,7 @@ result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/clicks", {:groupby =
349
349
  **Get a Single Campaign's Click Opens: **
350
350
 
351
351
  ```ruby
352
- result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/opens", {:groupby => 'hour',
352
+ result = mg_client.get "#{domain}/campaigns/#{campaign_id}/opens", {:groupby => 'hour',
353
353
  :country => 'US',
354
354
  :region => 'TX',
355
355
  :city => 'Austin',
@@ -361,7 +361,7 @@ result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/opens", {:groupby =>
361
361
  **Get a Single Campaign's Click Unsubscribes: **
362
362
 
363
363
  ```ruby
364
- result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/unsubscribes", {:groupby => 'hour',
364
+ result = mg_client.get "#{domain}/campaigns/#{campaign_id}/unsubscribes", {:groupby => 'hour',
365
365
  :country => 'US',
366
366
  :region => 'TX',
367
367
  :city => 'Austin',
@@ -373,7 +373,7 @@ result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/unsubscribes", {:gro
373
373
  **Get a Single Campaign's Click Complaints: **
374
374
 
375
375
  ```ruby
376
- result = @mg_client.get "#{domain}/campaigns/#{campaign_id}/complaints", {:groupby => 'hour',
376
+ result = mg_client.get "#{domain}/campaigns/#{campaign_id}/complaints", {:groupby => 'hour',
377
377
  :limit => 100,
378
378
  :page => 1,
379
379
  :count => true}
@@ -385,33 +385,33 @@ ____________________________________________________
385
385
  **Get List of Webhooks: **
386
386
 
387
387
  ```ruby
388
- result = @mg_client.get "domains/#{domain}/webhooks"
388
+ result = mg_client.get "domains/#{domain}/webhooks"
389
389
  ```
390
390
 
391
391
  **Get a Webhook Properties: **
392
392
 
393
393
  ```ruby
394
- result = @mg_client.get "domains/#{domain}/webhooks/#{webhook_id}"
394
+ result = mg_client.get "domains/#{domain}/webhooks/#{webhook_id}"
395
395
  ```
396
396
 
397
397
  **Create a Webhook: **
398
398
 
399
399
  ```ruby
400
- result = @mg_client.post "domains/#{domain}/webhooks", {:id => 'bounce',
400
+ result = mg_client.post "domains/#{domain}/webhooks", {:id => 'bounce',
401
401
  :url => 'http://example.com/mailgun/events/bounce'}
402
402
  ```
403
403
 
404
404
  **Update a Webhook: **
405
405
 
406
406
  ```ruby
407
- result = @mg_client.put "domains/#{domain}/webhooks/#{webhook_id}", {:id => 'bounce',
407
+ result = mg_client.put "domains/#{domain}/webhooks/#{webhook_id}", {:id => 'bounce',
408
408
  :url => 'http://example.com/mailgun/events/bounce'}
409
409
  ```
410
410
 
411
411
  **Remove a Webhook: **
412
412
 
413
413
  ```ruby
414
- result = @mg_client.delete "domains/#{domain}/webhooks/#{webhook_id}"
414
+ result = mg_client.delete "domains/#{domain}/webhooks/#{webhook_id}"
415
415
  ```
416
416
 
417
417
  ### Mailing Lists:
@@ -420,19 +420,19 @@ ____________________________________________________
420
420
  **Get list of Lists: **
421
421
 
422
422
  ```ruby
423
- result = @mg_client.get "lists"
423
+ result = mg_client.get "lists"
424
424
  ```
425
425
 
426
426
  **Get List Properties: **
427
427
 
428
428
  ```ruby
429
- result = @mg_client.get "lists/#{list_address}"
429
+ result = mg_client.get "lists/#{list_address}"
430
430
  ```
431
431
 
432
432
  **Create a List: **
433
433
 
434
434
  ```ruby
435
- result = @mg_client.post "lists", {:address => 'dev.group@samples.mailgun.org',
435
+ result = mg_client.post "lists", {:address => 'dev.group@samples.mailgun.org',
436
436
  :name => 'Development Group List',
437
437
  :description => 'List of all developers.',
438
438
  :access_level => 'members'}
@@ -441,7 +441,7 @@ result = @mg_client.post "lists", {:address => 'dev.group@samples.mailgun.org',
441
441
  **Update a List: **
442
442
 
443
443
  ```ruby
444
- result = @mg_client.put "lists/#{list_address}", {:address => 'dev.group@samples.mailgun.org',
444
+ result = mg_client.put "lists/#{list_address}", {:address => 'dev.group@samples.mailgun.org',
445
445
  :name => 'Development Group List',
446
446
  :description => 'List of all developers.',
447
447
  :access_level => 'members'}
@@ -450,25 +450,25 @@ result = @mg_client.put "lists/#{list_address}", {:address => 'dev.group@samples
450
450
  **Remove a List: **
451
451
 
452
452
  ```ruby
453
- result = @mg_client.delete "lists/#{list_address}"
453
+ result = mg_client.delete "lists/#{list_address}"
454
454
  ```
455
455
 
456
456
  **Get List Members: **
457
457
 
458
458
  ```ruby
459
- result = @mg_client.get "lists/#{list_address}/members"
459
+ result = mg_client.get "lists/#{list_address}/members"
460
460
  ```
461
461
 
462
462
  **Get List Member Properties: **
463
463
 
464
464
  ```ruby
465
- result = @mg_client.get "lists/#{list_address}/members/#{member_address}"
465
+ result = mg_client.get "lists/#{list_address}/members/#{member_address}"
466
466
  ```
467
467
 
468
468
  **Add Member to List: **
469
469
 
470
470
  ```ruby
471
- result = @mg_client.post "lists/#{list_address}/members/#{member_address}", {:address => 'jane@samples.mailgun.org',
471
+ result = mg_client.post "lists/#{list_address}/members/#{member_address}", {:address => 'jane@samples.mailgun.org',
472
472
  :name => 'Jane Doe',
473
473
  :vars => '{"first": "Jane", "last": "Doe"}',
474
474
  :subscribed => true,
@@ -478,7 +478,7 @@ result = @mg_client.post "lists/#{list_address}/members/#{member_address}", {:ad
478
478
  **Update Member on List: **
479
479
 
480
480
  ```ruby
481
- result = @mg_client.put "lists/#{list_address}/members/#{member_address}", {:address => 'jane@samples.mailgun.org',
481
+ result = mg_client.put "lists/#{list_address}/members/#{member_address}", {:address => 'jane@samples.mailgun.org',
482
482
  :name => 'Jane Doe',
483
483
  :vars => '{"first": "Jane", "last": "Doe"}',
484
484
  :subscribed => true}
@@ -487,13 +487,13 @@ result = @mg_client.put "lists/#{list_address}/members/#{member_address}", {:add
487
487
  **Delete a Member from List: **
488
488
 
489
489
  ```ruby
490
- result = @mg_client.delete "lists/#{list_address}/members/#{member_address}"
490
+ result = mg_client.delete "lists/#{list_address}/members/#{member_address}"
491
491
  ```
492
492
 
493
493
  **Get Stats for List: **
494
494
 
495
495
  ```ruby
496
- result = @mg_client.get "lists/#{list_address}/stats"
496
+ result = mg_client.get "lists/#{list_address}/stats"
497
497
  ```
498
498
 
499
499
  ### Email Validation:
@@ -501,14 +501,7 @@ ____________________________________________________
501
501
  **Validate Single Address: **
502
502
 
503
503
  ```ruby
504
- result = @mg_client.get "address/validate", {:address => 'test@example.com'}
505
- ```
506
-
507
- **Parse Addresses: **
508
-
509
- ```ruby
510
- result = @mg_client.get "address/parse", {:addresses => 'test@example.com, "First Last <first.last@example.com>',
511
- :syntax_only => true}
504
+ result = mg_client.get "address/validate", {:address => 'test@example.com'}
512
505
  ```
513
506
 
514
507