mailgun-ruby 1.1.5 → 1.1.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.
- checksums.yaml +4 -4
- data/.ruby-env.yml.example +1 -1
- data/README.md +28 -1
- data/docs/Domains.md +18 -0
- data/docs/MessageBuilder.md +1 -1
- data/docs/Messages.md +1 -1
- data/docs/Suppressions.md +82 -0
- data/lib/mailgun/client.rb +17 -0
- data/lib/mailgun/events/events.rb +23 -6
- data/lib/mailgun/messages/message_builder.rb +8 -0
- data/lib/mailgun/suppressions.rb +12 -9
- data/lib/mailgun/version.rb +1 -1
- data/lib/railgun/mailer.rb +2 -1
- data/spec/integration/events_spec.rb +9 -1
- data/spec/integration/mailgun_spec.rb +0 -0
- data/spec/integration/suppressions_spec.rb +0 -0
- data/spec/unit/events/events_spec.rb +17 -2
- data/spec/unit/messages/message_builder_spec.rb +25 -0
- data/vcr_cassettes/events.yml +48 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e16b23def5c2076ebf90803c69e67c11275dd4cf
|
4
|
+
data.tar.gz: 538a0a0aa99f037d0ef044fc9d427483eb4073b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c76cf234af827e8280e5eaa466d961817d30c3875345f4c481871ac8ca5083f11d4257ab06531c12dd693eab09e70910e6feaa13576766cd689caa32653c1f6
|
7
|
+
data.tar.gz: 305a1d5edc83fef3006682c884d9abee4ecf190e40919008b8985e6a86e5dd4f1506c3344a7641f67a435a5a3f510f1e350fb63daccb25fbcdec5cbfc1a20617
|
data/.ruby-env.yml.example
CHANGED
@@ -7,6 +7,6 @@
|
|
7
7
|
# Replace <THESE_VALUES> with yours from
|
8
8
|
# https://mailgun.com/app/dashboard (don't include <brackets>)
|
9
9
|
# and rename to/save as: .ruby-env.yml
|
10
|
-
MAILGUN_APIKEY : '<MAILGUN_APIKEY'
|
10
|
+
MAILGUN_APIKEY : '<MAILGUN_APIKEY>'
|
11
11
|
MAILGUN_PUB_APIKEY : '<MAILGUN_PUBLIC_APIKEY>'
|
12
12
|
MAILGUN_TESTDOMAIN : '<MAILGUN_SANDBOX_DOMAIN>'
|
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.
|
22
|
+
gem 'mailgun-ruby', '~>1.1.6'
|
23
23
|
```
|
24
24
|
|
25
25
|
Usage
|
@@ -150,12 +150,14 @@ For usage examples on each API endpoint, head over to our official documentation
|
|
150
150
|
pages. Or the [Snippets](docs/Snippets.md) file.
|
151
151
|
|
152
152
|
This SDK includes the following components:
|
153
|
+
- [Messages](docs/Messages.md)
|
153
154
|
- [Message Builder](docs/MessageBuilder.md)
|
154
155
|
- [Batch Message](docs/MessageBuilder.md)
|
155
156
|
- [Opt-In Handler](docs/OptInHandler.md)
|
156
157
|
- [Domains](docs/Domains.md)
|
157
158
|
- [Webhooks](docs/Webhooks.md)
|
158
159
|
- [Events](docs/Events.md)
|
160
|
+
- [Suppressions](docs/Suppressions.md)
|
159
161
|
|
160
162
|
Message Builder allows you to quickly create the array of parameters, required
|
161
163
|
to send a message, by calling a methods for each parameter.
|
@@ -163,6 +165,31 @@ Batch Message is an extension of Message Builder, and allows you to easily send
|
|
163
165
|
a batch message job within a few seconds. The complexity of
|
164
166
|
batch messaging is eliminated!
|
165
167
|
|
168
|
+
Testing mail deliveries
|
169
|
+
----------------------
|
170
|
+
|
171
|
+
```ruby
|
172
|
+
# First, instantiate the Mailgun Client with your API key
|
173
|
+
mg_client = Mailgun::Client.new 'your-api-key'
|
174
|
+
|
175
|
+
# Put the client in test mode
|
176
|
+
mg_client.enable_test_mode!
|
177
|
+
|
178
|
+
# Define your message parameters
|
179
|
+
message_params = { from: 'bob@sending_domain.com',
|
180
|
+
to: 'sally@example.com',
|
181
|
+
subject: 'The Ruby SDK is awesome!',
|
182
|
+
text: 'It is really easy to send a message!'
|
183
|
+
}
|
184
|
+
|
185
|
+
# Send your message through the client
|
186
|
+
# Note: This will not actually hit the API, and will return a generic OK response.
|
187
|
+
mg_client.send_message('sending_domain.com', message_params)
|
188
|
+
|
189
|
+
# You can now access a copy of message_params
|
190
|
+
Mailgun::Client.deliveries.first[:from] # => 'bob@sending_domain.com'
|
191
|
+
```
|
192
|
+
|
166
193
|
Testing
|
167
194
|
-------
|
168
195
|
|
data/docs/Domains.md
CHANGED
@@ -30,6 +30,24 @@ domainer.create 'my.new.moreness', { some: 'options' }
|
|
30
30
|
domainer.remove 'this.one.is.not.needed.'
|
31
31
|
```
|
32
32
|
|
33
|
+
Suppressions for a Domain
|
34
|
+
-------------------------
|
35
|
+
|
36
|
+
You can manage domain suppressions (bounces, unsubscribes, complaints) using the
|
37
|
+
[`Mailgun::Suppressions`](/docs/Suppressions.md) client:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
# Instantiate the Mailgun Client with your API key
|
41
|
+
mg_client = Mailgun::Client.new('your-api-key')
|
42
|
+
supp_client = mg_client.suppressions('example.org')
|
43
|
+
|
44
|
+
# ...
|
45
|
+
```
|
46
|
+
|
47
|
+
See the [Suppressions](/docs/Suppressions.md) for usage samples and
|
48
|
+
[suppressions.rb](/lib/mailgun/suppressions.rb) for suppressions client API.
|
49
|
+
|
50
|
+
|
33
51
|
More Documentation
|
34
52
|
------------------
|
35
53
|
See the official [Mailgun Domain Docs](https://documentation.mailgun.com/api-domains.html)
|
data/docs/MessageBuilder.md
CHANGED
@@ -78,7 +78,7 @@ mg_client = Mailgun::Client.new("your-api-key")
|
|
78
78
|
mb_obj = Mailgun::BatchMessage.new(mg_client, "example.com")
|
79
79
|
|
80
80
|
# Define the from address.
|
81
|
-
mb_obj.from("me@example.com", {"first"=>"Ruby", "last" => "SDK"});
|
81
|
+
mb_obj.from("me@example.com", {"first" => "Ruby", "last" => "SDK"});
|
82
82
|
|
83
83
|
# Define the subject.
|
84
84
|
mb_obj.subject("A message from the Ruby SDK using Message Builder!");
|
data/docs/Messages.md
CHANGED
@@ -79,7 +79,7 @@ mb_obj.set_text_body("Hello %recipient.first%,
|
|
79
79
|
This is the text body of the message
|
80
80
|
using recipient variables!
|
81
81
|
If you need to include custom data,
|
82
|
-
you could do it like this: %account-id%.")
|
82
|
+
you could do it like this: %recipient.account-id%.")
|
83
83
|
|
84
84
|
mb_obj.add_recipient(:to, "john.doe@example.com", {"first" => "John",
|
85
85
|
"last" => "Doe",
|
@@ -0,0 +1,82 @@
|
|
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 batch-add a set of bounces:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
@addresses = <load or generate some addresses...>
|
45
|
+
|
46
|
+
bounces = []
|
47
|
+
@addresses.each do |addr|
|
48
|
+
bounces.push({
|
49
|
+
:address => addr,
|
50
|
+
:code => 500,
|
51
|
+
:error => 'some bounce because reasons',
|
52
|
+
})
|
53
|
+
end
|
54
|
+
|
55
|
+
response, addt_responses = @supp_client.create_bounces bounces
|
56
|
+
```
|
57
|
+
|
58
|
+
`create_bounces`, `create_unsubscribes`, and `create_complaints` will all
|
59
|
+
return two values - first, a simple `Mailgun::Response` object. Second,
|
60
|
+
a list containing any `Mailgun::Response` objects created recursively, if over 998
|
61
|
+
bounces were provided to `create_*`.
|
62
|
+
|
63
|
+
----
|
64
|
+
|
65
|
+
To delete bounces:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
@addresses = <load addresses...>
|
69
|
+
|
70
|
+
@addresses.each do |addr|
|
71
|
+
@supp_client.delete_bounce addr
|
72
|
+
end
|
73
|
+
```
|
74
|
+
|
75
|
+
Or, alternatively, to remove *all* bounces:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
@supp_client.delete_all_bounces
|
79
|
+
```
|
80
|
+
|
81
|
+
The `delete_*` methods are similar for `bounces`, `unsubscribe`, and `complaints` -
|
82
|
+
they all will return a `Mailgun::Response` object.
|
data/lib/mailgun/client.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mailgun/chains'
|
2
|
+
require 'mailgun/suppressions'
|
2
3
|
require 'mailgun/exceptions/exceptions'
|
3
4
|
|
4
5
|
module Mailgun
|
@@ -44,6 +45,13 @@ module Mailgun
|
|
44
45
|
@test_mode
|
45
46
|
end
|
46
47
|
|
48
|
+
# Provides a store of all the emails sent in test mode so you can check them.
|
49
|
+
#
|
50
|
+
# @return [Hash]
|
51
|
+
def self.deliveries
|
52
|
+
@@deliveries ||= []
|
53
|
+
end
|
54
|
+
|
47
55
|
# Simple Message Sending
|
48
56
|
#
|
49
57
|
# @param [String] working_domain This is the domain you wish to send from.
|
@@ -52,6 +60,7 @@ module Mailgun
|
|
52
60
|
# @return [Mailgun::Response] A Mailgun::Response object.
|
53
61
|
def send_message(working_domain, data)
|
54
62
|
if test_mode? then
|
63
|
+
Mailgun::Client.deliveries << data
|
55
64
|
return Response.from_hash(
|
56
65
|
{
|
57
66
|
:body => '{"id": "test-mode-mail@localhost", "message": "Queued. Thank you."}',
|
@@ -141,6 +150,14 @@ module Mailgun
|
|
141
150
|
raise communication_error err
|
142
151
|
end
|
143
152
|
|
153
|
+
# Constructs a Suppressions client for the given domain.
|
154
|
+
#
|
155
|
+
# @param [String] domain Domain which suppressions requests will be made for
|
156
|
+
# @return [Mailgun::Suppressions]
|
157
|
+
def suppressions(domain)
|
158
|
+
Suppressions.new(self, domain)
|
159
|
+
end
|
160
|
+
|
144
161
|
private
|
145
162
|
|
146
163
|
# Converts MIME string to file for easy uploading to API
|
@@ -11,6 +11,7 @@ module Mailgun
|
|
11
11
|
#
|
12
12
|
# See the Github documentation for full examples.
|
13
13
|
class Events
|
14
|
+
include Enumerable
|
14
15
|
|
15
16
|
# Public: event initializer
|
16
17
|
#
|
@@ -23,31 +24,47 @@ module Mailgun
|
|
23
24
|
@paging_previous = nil
|
24
25
|
end
|
25
26
|
|
26
|
-
# Public: Issues a simple get against the client.
|
27
|
+
# Public: Issues a simple get against the client. Alias of `next`.
|
27
28
|
#
|
28
29
|
# params - a Hash of query options and/or filters.
|
29
30
|
#
|
30
31
|
# Returns a Mailgun::Response object.
|
31
32
|
def get(params = nil)
|
32
|
-
|
33
|
+
self.next(params)
|
33
34
|
end
|
34
35
|
|
35
36
|
# Public: Using built in paging, obtains the next set of data.
|
36
37
|
# If an events request hasn't been sent previously, this will send one
|
37
38
|
# without parameters
|
38
39
|
#
|
40
|
+
# params - a Hash of query options and/or filters.
|
41
|
+
#
|
39
42
|
# Returns a Mailgun::Response object.
|
40
|
-
def next
|
41
|
-
get_events(
|
43
|
+
def next(params = nil)
|
44
|
+
get_events(params, @paging_next)
|
42
45
|
end
|
43
46
|
|
44
47
|
# Public: Using built in paging, obtains the previous set of data.
|
45
48
|
# If an events request hasn't been sent previously, this will send one
|
46
49
|
# without parameters
|
47
50
|
#
|
51
|
+
# params - a Hash of query options and/or filters.
|
52
|
+
#
|
48
53
|
# Returns Mailgun::Response object.
|
49
|
-
def previous
|
50
|
-
get_events(
|
54
|
+
def previous(params = nil)
|
55
|
+
get_events(params, @paging_previous)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Public: Allows iterating through all events and performs automatic paging.
|
59
|
+
#
|
60
|
+
# &block - Block to execute on items.
|
61
|
+
def each(&block)
|
62
|
+
items = self.next.to_h['items']
|
63
|
+
|
64
|
+
until items.empty?
|
65
|
+
items.each(&block)
|
66
|
+
items = self.next.to_h['items']
|
67
|
+
end
|
51
68
|
end
|
52
69
|
|
53
70
|
private
|
@@ -133,6 +133,14 @@ module Mailgun
|
|
133
133
|
add_file(:inline, inline_image, filename)
|
134
134
|
end
|
135
135
|
|
136
|
+
# Adds a List-Unsubscribe for the message header.
|
137
|
+
#
|
138
|
+
# @param [Array<String>] *variables Any number of url or mailto
|
139
|
+
# @return [void]
|
140
|
+
def list_unsubscribe(*variables)
|
141
|
+
set_single('h:List-Unsubscribe', variables.map { |var| "<#{var}>" }.join(','))
|
142
|
+
end
|
143
|
+
|
136
144
|
# Send a message in test mode. (The message won't really be sent to the recipient)
|
137
145
|
#
|
138
146
|
# @param [Boolean] mode The boolean or string value (will fix itself)
|
data/lib/mailgun/suppressions.rb
CHANGED
@@ -60,16 +60,17 @@ module Mailgun
|
|
60
60
|
#
|
61
61
|
# @param [Array] data Array of bounce hashes
|
62
62
|
# @return [Response] Mailgun API response
|
63
|
-
# @return [Array] Array of invalid bounce hashes.
|
64
63
|
# @return [Array] Return values from recursive call for list split.
|
65
64
|
def create_bounces(data)
|
66
65
|
# `data` should be a list of hashes, with each hash containing *at least* an `address` key.
|
67
66
|
split_return = []
|
68
67
|
if data.length >= 1000 then
|
69
|
-
|
68
|
+
resp, resp_l = create_bounces data[999..-1]
|
69
|
+
split_return.push(resp)
|
70
|
+
split_return.concat(resp_l)
|
70
71
|
data = data[0..998]
|
71
72
|
elsif data.length == 0 then
|
72
|
-
[]
|
73
|
+
return nil, []
|
73
74
|
end
|
74
75
|
|
75
76
|
valid = []
|
@@ -132,16 +133,17 @@ module Mailgun
|
|
132
133
|
#
|
133
134
|
# @param [Array] data Array of unsubscribe hashes
|
134
135
|
# @return [Response] Mailgun API response
|
135
|
-
# @return [Array] Array of invalid unsubscribe hashes.
|
136
136
|
# @return [Array] Return values from recursive call for list split.
|
137
137
|
def create_unsubscribes(data)
|
138
138
|
# `data` should be a list of hashes, with each hash containing *at least* an `address` key.
|
139
139
|
split_return = []
|
140
140
|
if data.length >= 1000 then
|
141
|
-
|
141
|
+
resp, resp_l = create_unsubscribes data[999..-1]
|
142
|
+
split_return.push(resp)
|
143
|
+
split_return.concat(resp_l)
|
142
144
|
data = data[0..998]
|
143
145
|
elsif data.length == 0 then
|
144
|
-
[]
|
146
|
+
return nil, []
|
145
147
|
end
|
146
148
|
|
147
149
|
valid = []
|
@@ -197,16 +199,17 @@ module Mailgun
|
|
197
199
|
#
|
198
200
|
# @param [Array] data Array of complaint hashes
|
199
201
|
# @return [Response] Mailgun API response
|
200
|
-
# @return [Array] Array of invalid complaint hashes.
|
201
202
|
# @return [Array] Return values from recursive call for list split.
|
202
203
|
def create_complaints(data)
|
203
204
|
# `data` should be a list of hashes, with each hash containing *at least* an `address` key.
|
204
205
|
split_return = []
|
205
206
|
if data.length >= 1000 then
|
206
|
-
|
207
|
+
resp, resp_l = create_complaints data[999..-1]
|
208
|
+
split_return.push(resp)
|
209
|
+
split_return.concat(resp_l)
|
207
210
|
data = data[0..998]
|
208
211
|
elsif data.length == 0 then
|
209
|
-
[]
|
212
|
+
return nil, []
|
210
213
|
end
|
211
214
|
|
212
215
|
valid = []
|
data/lib/mailgun/version.rb
CHANGED
data/lib/railgun/mailer.rb
CHANGED
@@ -20,7 +20,7 @@ module Railgun
|
|
20
20
|
@config = config
|
21
21
|
|
22
22
|
[:api_key, :domain].each do |k|
|
23
|
-
raise Railgun::ConfigurationError("Config requires `#{k}` key", @config) unless @config.has_key?
|
23
|
+
raise Railgun::ConfigurationError.new("Config requires `#{k}` key", @config) unless @config.has_key?(k)
|
24
24
|
end
|
25
25
|
|
26
26
|
@mg_client = Mailgun::Client.new(config[:api_key])
|
@@ -97,6 +97,7 @@ module Railgun
|
|
97
97
|
mb = Mailgun::MessageBuilder.new
|
98
98
|
|
99
99
|
mb.from mail[:from]
|
100
|
+
mb.reply_to(mail[:reply_to].to_s) if mail[:reply_to].present?
|
100
101
|
mb.subject mail.subject
|
101
102
|
mb.body_html extract_body_html(mail)
|
102
103
|
mb.body_text extract_body_text(mail)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'mailgun'
|
3
|
+
require 'mailgun/events/events'
|
3
4
|
|
4
5
|
vcr_opts = { :cassette_name => "events" }
|
5
6
|
|
@@ -7,9 +8,10 @@ describe 'For the Events endpoint', vcr: vcr_opts do
|
|
7
8
|
before(:all) do
|
8
9
|
@mg_obj = Mailgun::Client.new(APIKEY, APIHOST, APIVERSION, SSL)
|
9
10
|
@domain = TESTDOMAIN
|
11
|
+
@events = Mailgun::Events.new(@mg_obj, @domain)
|
10
12
|
end
|
11
13
|
|
12
|
-
it 'get an event.' do
|
14
|
+
it 'can get an event.' do
|
13
15
|
result = @mg_obj.get("#{@domain}/events", {:limit => 1})
|
14
16
|
|
15
17
|
result.to_h!
|
@@ -17,4 +19,10 @@ describe 'For the Events endpoint', vcr: vcr_opts do
|
|
17
19
|
expect(result.body["paging"]).to include("next")
|
18
20
|
expect(result.body["paging"]).to include("previous")
|
19
21
|
end
|
22
|
+
|
23
|
+
it 'can iterate over all events with `each`' do
|
24
|
+
@events.each do |e|
|
25
|
+
expect(e.id).to eq("JAx9z641TuGGUyaJlD9sCQ")
|
26
|
+
end
|
27
|
+
end
|
20
28
|
end
|
File without changes
|
File without changes
|
@@ -5,7 +5,7 @@ describe 'The method get' do
|
|
5
5
|
@mg_obj = Mailgun::UnitClient.new('events')
|
6
6
|
events = Mailgun::Events.new(@mg_obj, "samples.mailgun.org")
|
7
7
|
result = events.get()
|
8
|
-
|
8
|
+
|
9
9
|
expect(result.body).to include("items")
|
10
10
|
expect(result.body).to include("paging")
|
11
11
|
end
|
@@ -17,7 +17,7 @@ describe 'The method next' do
|
|
17
17
|
@mg_obj = Mailgun::UnitClient.new('events')
|
18
18
|
events = Mailgun::Events.new(@mg_obj, "samples.mailgun.org")
|
19
19
|
result = events.next()
|
20
|
-
|
20
|
+
|
21
21
|
expect(result.body).to include("items")
|
22
22
|
expect(result.body).to include("paging")
|
23
23
|
end
|
@@ -33,3 +33,18 @@ describe 'The method previous' do
|
|
33
33
|
expect(result.body).to include("paging")
|
34
34
|
end
|
35
35
|
end
|
36
|
+
|
37
|
+
describe 'The method each' do
|
38
|
+
it 'should iterate over all event items.' do
|
39
|
+
@mg_obj = Mailgun::UnitClient.new('events')
|
40
|
+
events = Mailgun::Events.new(@mg_obj, "samples.mailgun.org")
|
41
|
+
# Events from the UnitClient are actually empty.
|
42
|
+
count = 0
|
43
|
+
events.each do |e|
|
44
|
+
count = count + 1
|
45
|
+
end
|
46
|
+
|
47
|
+
# Better than nothing..
|
48
|
+
expect(count).to eq(0)
|
49
|
+
end
|
50
|
+
end
|
@@ -249,6 +249,31 @@ describe 'The method add_inline_image' do
|
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
|
+
describe 'The method list_unsubscribe' do
|
253
|
+
before(:each) do
|
254
|
+
@mb_obj = Mailgun::MessageBuilder.new
|
255
|
+
end
|
256
|
+
|
257
|
+
it 'sets the message list_unsubscribe to blank if called and no parameters are provided' do
|
258
|
+
@mb_obj.list_unsubscribe
|
259
|
+
expect(@mb_obj.message['h:List-Unsubscribe']).to eq('')
|
260
|
+
end
|
261
|
+
|
262
|
+
it 'sets the message list_unsubscribe if called with one list_unsubscribe parameter' do
|
263
|
+
unsubscribe_to = 'http://example.com/stop-hassle'
|
264
|
+
@mb_obj.list_unsubscribe(unsubscribe_to)
|
265
|
+
expect(@mb_obj.message['h:List-Unsubscribe']).to eq("<#{unsubscribe_to}>")
|
266
|
+
end
|
267
|
+
|
268
|
+
it 'sets the message list_unsubscribe if called with many list_unsubscribe parameters' do
|
269
|
+
unsubscribe_to = %w(http://example.com/stop-hassle mailto:stop-hassle@example.com)
|
270
|
+
@mb_obj.list_unsubscribe(*unsubscribe_to)
|
271
|
+
expect(@mb_obj.message['h:List-Unsubscribe']).to eq(
|
272
|
+
unsubscribe_to.map { |var| "<#{var}>" }.join(',')
|
273
|
+
)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
252
277
|
describe 'The method set_test_mode' do
|
253
278
|
it 'warns of set_test_mode deprecation' do
|
254
279
|
@mb_obj = Mailgun::MessageBuilder.new
|
data/vcr_cassettes/events.yml
CHANGED
@@ -58,4 +58,51 @@ http_interactions:
|
|
58
58
|
\ }\n}"
|
59
59
|
http_version:
|
60
60
|
recorded_at: Thu, 07 Jan 2016 22:08:06 GMT
|
61
|
-
|
61
|
+
- request:
|
62
|
+
method: get
|
63
|
+
uri: https://api:<APIKEY>@api.mailgun.net/v3/DOMAIN.TEST/events
|
64
|
+
body:
|
65
|
+
encoding: US-ASCII
|
66
|
+
string: ''
|
67
|
+
headers:
|
68
|
+
Accept:
|
69
|
+
- "*/*"
|
70
|
+
Accept-Encoding:
|
71
|
+
- gzip, deflate
|
72
|
+
User-Agent:
|
73
|
+
- rest-client/2.0.1 (linux-gnu x86_64) ruby/2.3.3p222
|
74
|
+
Host:
|
75
|
+
- api.mailgun.net
|
76
|
+
response:
|
77
|
+
status:
|
78
|
+
code: 200
|
79
|
+
message: OK
|
80
|
+
headers:
|
81
|
+
Access-Control-Allow-Headers:
|
82
|
+
- Content-Type, x-requested-with
|
83
|
+
Access-Control-Allow-Methods:
|
84
|
+
- GET, POST, PUT, DELETE, OPTIONS
|
85
|
+
Access-Control-Allow-Origin:
|
86
|
+
- "*"
|
87
|
+
Access-Control-Max-Age:
|
88
|
+
- '600'
|
89
|
+
Content-Type:
|
90
|
+
- application/json
|
91
|
+
Date:
|
92
|
+
- Wed, 10 May 2017 20:06:54 GMT
|
93
|
+
Server:
|
94
|
+
- nginx
|
95
|
+
Content-Length:
|
96
|
+
- '2060'
|
97
|
+
Connection:
|
98
|
+
- keep-alive
|
99
|
+
body:
|
100
|
+
encoding: UTF-8
|
101
|
+
string: "{\n \"items\": [], \n \"paging\": {\n \"next\": \"https://api.mailgun.net/v3/DOMAIN.TEST/events/W3siYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIHsiYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIFsiZiJdLCBudWxsLCBbWyJhY2NvdW50LmlkIiwgIjU4MDUyMTg2NzhmYTE2MTNjNzkwYjUwZiJdLCBbImRvbWFpbi5uYW1lIiwgInNhbmRib3gyOTcwMTUyYWYzZDM0NTU5YmZjN2U3MTcwM2E2Y2YyNC5tYWlsZ3VuLm9yZyJdXSwgMTAwLCBudWxsXQ==\",
|
102
|
+
\n \"last\": \"https://api.mailgun.net/v3/DOMAIN.TEST/events/W3siYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIHsiYiI6ICIyMDE3LTA1LTA4VDIwOjA2OjU0LjU3NyswMDowMCIsICJlIjogIjIwMTctMDUtMTBUMjA6MDY6NTQuNTc2KzAwOjAwIn0sIFsicCIsICJmIl0sIG51bGwsIFtbImFjY291bnQuaWQiLCAiNTgwNTIxODY3OGZhMTYxM2M3OTBiNTBmIl0sIFsiZG9tYWluLm5hbWUiLCAic2FuZGJveDI5NzAxNTJhZjNkMzQ1NTliZmM3ZTcxNzAzYTZjZjI0Lm1haWxndW4ub3JnIl1dLCAxMDAsIG51bGxd\",
|
103
|
+
\n \"first\": \"https://api.mailgun.net/v3/DOMAIN.TEST/events/W3siYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIHsiYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIFsiZiJdLCBudWxsLCBbWyJhY2NvdW50LmlkIiwgIjU4MDUyMTg2NzhmYTE2MTNjNzkwYjUwZiJdLCBbImRvbWFpbi5uYW1lIiwgInNhbmRib3gyOTcwMTUyYWYzZDM0NTU5YmZjN2U3MTcwM2E2Y2YyNC5tYWlsZ3VuLm9yZyJdXSwgMTAwLCBudWxsXQ==\",
|
104
|
+
\n \"previous\": \"https://api.mailgun.net/v3/DOMAIN.TEST/events/W3siYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMDhUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIHsiYiI6ICIyMDE3LTA1LTEwVDIwOjA2OjU0LjU3NiswMDowMCIsICJlIjogIjIwMTctMDUtMTBUMjA6MDY6NTQuNTc3KzAwOjAwIn0sIFsicCIsICJmIl0sIG51bGwsIFtbImFjY291bnQuaWQiLCAiNTgwNTIxODY3OGZhMTYxM2M3OTBiNTBmIl0sIFsiZG9tYWluLm5hbWUiLCAic2FuZGJveDI5NzAxNTJhZjNkMzQ1NTliZmM3ZTcxNzAzYTZjZjI0Lm1haWxndW4ub3JnIl1dLCAxMDAsIG51bGxd\"\n
|
105
|
+
\ }\n}"
|
106
|
+
http_version:
|
107
|
+
recorded_at: Wed, 10 May 2017 20:06:54 GMT
|
108
|
+
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.1.
|
4
|
+
version: 1.1.6
|
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: 2017-
|
12
|
+
date: 2017-05-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- docs/Messages.md
|
145
145
|
- docs/OptInHandler.md
|
146
146
|
- docs/Snippets.md
|
147
|
+
- docs/Suppressions.md
|
147
148
|
- docs/Webhooks.md
|
148
149
|
- lib/mailgun-ruby.rb
|
149
150
|
- lib/mailgun.rb
|