mailgun-ruby 1.1.0 → 1.1.1
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 +13 -5
- data/.gitignore +1 -0
- data/.travis.yml +20 -7
- data/Gemfile +2 -0
- data/README.md +1 -8
- data/lib/mailgun-ruby.rb +1 -0
- data/lib/mailgun.rb +1 -0
- data/lib/mailgun/address.rb +45 -0
- data/lib/mailgun/lists/opt_in_handler.rb +0 -1
- data/lib/mailgun/messages/message_builder.rb +4 -5
- data/lib/mailgun/version.rb +1 -1
- data/mailgun.gemspec +2 -3
- data/spec/integration/email_validation_spec.rb +43 -15
- data/spec/unit/messages/message_builder_spec.rb +59 -58
- data/vcr_cassettes/email_validation.yml +84 -21
- metadata +31 -43
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjI5MjJkMTdmNGY4M2Q0OTRkY2I4MjY5YzRmNjBhYzVhYmUyNzNkMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGViNjllYzBlODY3NzhhZjc3OTczYzAyNTc0YTgxMDg4ODU1ZTZjNw==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
YWNmMmRjZTU1OTZiNzA0NzMwM2QwN2E5ZGFiM2NkNjZmOWVkY2Q3MmQ3MjU5
|
10
|
+
MDQxMjU4NzI4YjZkOGQ1NzRhMGY4NGE3NjE0ZWFhNTMxNWZiM2Y4Y2U2NDM5
|
11
|
+
MWJkMTJhNmZiZTczZDZlM2JhNGIzNjg2YzAwNzQ2NTNlZjIzNmM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
YTg1M2UwNzdiMWIwNGZhMGVjYzJmY2FjMjhkMjJmMjljZWRkYzY5NGRmYmY3
|
14
|
+
MDcxY2Q4MzVkY2M2NGQ4OWE1Mzc4ZTQyZGUyYTE4NjE5NzJiMGNiMjRlNTNi
|
15
|
+
YWM1Y2VmODBlMWFiZTU1NmQ4ZmJkMmJmZjFiYzliOTBmOGJmOGI=
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,9 +1,22 @@
|
|
1
1
|
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.2
|
4
|
-
- 2.1
|
5
|
-
- 2.0.0
|
6
|
-
- 1.9.3
|
7
2
|
sudo: false
|
8
|
-
|
9
|
-
|
3
|
+
rvm:
|
4
|
+
- 2.3.1
|
5
|
+
- 2.2
|
6
|
+
- 2.1
|
7
|
+
- 2.0.0
|
8
|
+
script:
|
9
|
+
- bundle exec rake spec
|
10
|
+
- '[[ "${TRAVIS_PULL_REQUEST}" == "false" ]] && ( bundle exec rake spec:integration
|
11
|
+
) || ( echo "Testing PR - No integration tests available")'
|
12
|
+
deploy:
|
13
|
+
provider: rubygems
|
14
|
+
api_key:
|
15
|
+
secure: QTNP+6720w38b8krtvXM25WDEOUxw9BlUwdXgWLrU0MGAOSvVFgnWTJs+7QvGWODjhrIqAfAm11zc+yEpzgD9P8np9cteWv5K7rMxsUMcb14kaGIA+MKO+RRJXlru4teBNX5jtp2GJiNS2mn7urzn5YhE9x9P7pMjcF+j5usoF0=
|
16
|
+
gemspec: mailgun.gemspec
|
17
|
+
on:
|
18
|
+
tags: true
|
19
|
+
notifications:
|
20
|
+
slack:
|
21
|
+
rooms:
|
22
|
+
secure: G4iBtDfFGeryQslfrKZK4hSPikOy9y3SDnpzwmN8SoB0uIAWE2mLfMUJZonKm7yoz+DbPU0u3c1SwiMLwHkXZhPdnJdC1fb1DpicXnVgGZYdiLGiY+OAwkvcBE9p3piWhpwigTjvmSqTaNSRL/VLhG4qwQbHU0fTl1M1zwU4e6c=
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/lib/mailgun-ruby.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mailgun'
|
data/lib/mailgun.rb
CHANGED
@@ -7,6 +7,7 @@ require 'mailgun/version'
|
|
7
7
|
require 'mailgun/client'
|
8
8
|
require 'mailgun/response'
|
9
9
|
require 'mailgun/chains'
|
10
|
+
require 'mailgun/address'
|
10
11
|
require 'mailgun/lists/opt_in_handler'
|
11
12
|
require 'mailgun/messages/batch_message'
|
12
13
|
require 'mailgun/messages/message_builder'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'mailgun/exceptions/exceptions'
|
2
|
+
|
3
|
+
module Mailgun
|
4
|
+
|
5
|
+
# Mailgun::Address is a simple interface to the Email Validation API.
|
6
|
+
class Address
|
7
|
+
|
8
|
+
# @param [String] api_key Mailgun API - public key
|
9
|
+
def initialize(api_key = "")
|
10
|
+
if api_key == "" then
|
11
|
+
fail ParameterError.new('Public API key is required for Mailgun::Address.initialize()', nil)
|
12
|
+
end
|
13
|
+
|
14
|
+
@api_key = api_key
|
15
|
+
@client = Mailgun::Client.new(api_key = api_key)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Given an arbitrary address, validates it based on defined checks.
|
19
|
+
#
|
20
|
+
# @param [String] address Email address to validate (max 512 chars.)
|
21
|
+
def validate(address)
|
22
|
+
res = @client.get "address/validate", {:address => address}
|
23
|
+
return res.to_h!
|
24
|
+
end
|
25
|
+
|
26
|
+
# Parses a delimiter separated list of email addresses into two lists:
|
27
|
+
# parsed addresses and unparsable portions. The parsed addresses are a
|
28
|
+
# list of addresses that are syntactically valid (and optionally have
|
29
|
+
# DNS and ESP specific grammar checks) the unparsable list is a list
|
30
|
+
# of characters sequences that the parser was not able to understand.
|
31
|
+
# These often align with invalid email addresses, but not always.
|
32
|
+
# Delimiter characters are comma (,) and semicolon (;).
|
33
|
+
#
|
34
|
+
# @param [Array] addresses Addresses to parse
|
35
|
+
# @param [TrueClass|FalseClass] syntax_only Perform only syntax checks
|
36
|
+
def parse(addresses, syntax_only = true)
|
37
|
+
validate_addrs = addresses.join(";")
|
38
|
+
|
39
|
+
res = @client.get "address/parse", {:addresses => validate_addrs,
|
40
|
+
:syntax_only => syntax_only.to_s}
|
41
|
+
return res.to_h!
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'time'
|
2
|
-
require 'json'
|
3
2
|
|
4
3
|
module Mailgun
|
5
4
|
|
@@ -334,10 +333,10 @@ module Mailgun
|
|
334
333
|
|
335
334
|
# Private: Adds a file to the message.
|
336
335
|
#
|
337
|
-
# disposition
|
338
|
-
#
|
339
|
-
#
|
340
|
-
#
|
336
|
+
# @param [Symbol] disposition The type of file: :attachment or :inline
|
337
|
+
# @param [String] attachment A file object for attaching as an attachment.
|
338
|
+
# @param [String] filename The filename you wish the attachment to be.
|
339
|
+
# @return [void]
|
341
340
|
#
|
342
341
|
# Returns nothing
|
343
342
|
def add_file(disposition, filedata, filename)
|
data/lib/mailgun/version.rb
CHANGED
data/mailgun.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.required_ruby_version = '>=
|
25
|
+
spec.required_ruby_version = '>= 2.0.0'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_development_dependency 'vcr', '~> 3.0'
|
33
33
|
spec.add_development_dependency 'simplecov', '~> 0.11'
|
34
34
|
|
35
|
-
spec.add_dependency 'rest-client', '~>
|
36
|
-
spec.add_dependency 'json', '~> 1.8'
|
35
|
+
spec.add_dependency 'rest-client', '~> 2.0'
|
37
36
|
|
38
37
|
end
|
@@ -1,29 +1,57 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
|
2
3
|
require 'mailgun'
|
4
|
+
require 'mailgun/address'
|
3
5
|
|
4
6
|
vcr_opts = { :cassette_name => "email_validation" }
|
5
7
|
|
6
|
-
describe 'For the
|
8
|
+
describe 'For the email validation endpoint', order: :defined, vcr: vcr_opts do
|
7
9
|
before(:all) do
|
8
|
-
@mg_obj = Mailgun::
|
10
|
+
@mg_obj = Mailgun::Address.new(PUB_APIKEY)
|
11
|
+
|
12
|
+
@valid = ["Alice <alice@example.com>", "bob@example.com"]
|
13
|
+
@invalid = ["example.org"]
|
14
|
+
|
15
|
+
@all_addrs = @valid + @invalid
|
9
16
|
end
|
10
17
|
|
11
|
-
it '
|
12
|
-
|
13
|
-
{:address => "test@#{TESTDOMAIN}"})
|
18
|
+
it 'returns parsed and unparsable lists' do
|
19
|
+
res = @mg_obj.parse(@all_addrs)
|
14
20
|
|
15
|
-
|
16
|
-
expect(
|
17
|
-
expect(result.body["address"]).to eq("test@#{TESTDOMAIN}")
|
21
|
+
expect(res["parsed"]).to eq(@valid)
|
22
|
+
expect(res["unparseable"]).to eq(@invalid)
|
18
23
|
end
|
19
24
|
|
20
|
-
it '
|
21
|
-
|
22
|
-
{:addresses => "Alice <alice@#{TESTDOMAIN}>,bob@#{TESTDOMAIN},#{TESTDOMAIN}"})
|
25
|
+
it 'validates alice@mailgun.net with info' do
|
26
|
+
res = @mg_obj.validate("alice@mailgun.net")
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
+
expected = {
|
29
|
+
"address" => "alice@mailgun.net",
|
30
|
+
"did_you_mean" => nil,
|
31
|
+
"is_valid" => true,
|
32
|
+
"parts" => {
|
33
|
+
"display_name" => nil,
|
34
|
+
"domain" => "mailgun.net",
|
35
|
+
"local_part" => "alice",
|
36
|
+
},
|
37
|
+
}
|
38
|
+
expect(res).to eq(expected)
|
28
39
|
end
|
40
|
+
|
41
|
+
it 'fails to validate example.org' do
|
42
|
+
res = @mg_obj.validate("example.org")
|
43
|
+
|
44
|
+
expected = {
|
45
|
+
"address" => "example.org",
|
46
|
+
"did_you_mean" => nil,
|
47
|
+
"is_valid" => false,
|
48
|
+
"parts" => {
|
49
|
+
"display_name" => nil,
|
50
|
+
"domain" => nil,
|
51
|
+
"local_part" => nil,
|
52
|
+
},
|
53
|
+
}
|
54
|
+
expect(res).to eq(expected)
|
55
|
+
end
|
56
|
+
|
29
57
|
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'stringio'
|
2
3
|
|
3
4
|
describe 'MessageBuilder attribute readers' do
|
4
5
|
it 'should be readable' do
|
5
6
|
@mb_obj = Mailgun::MessageBuilder.new()
|
6
|
-
|
7
|
+
|
7
8
|
expect(@mb_obj).to respond_to(:message)
|
8
9
|
expect(@mb_obj).to respond_to(:counters)
|
9
10
|
end
|
@@ -52,7 +53,7 @@ describe 'The method add_recipient' do
|
|
52
53
|
it 'adds a "cc" recipient type to the message body and counter is incremented' do
|
53
54
|
recipient_type = :cc
|
54
55
|
@mb_obj.add_recipient(recipient_type, @address, @variables)
|
55
|
-
|
56
|
+
|
56
57
|
expect(@mb_obj.message[recipient_type][0]).to eq("'#{@variables['first']} #{@variables['last']}' <#{@address}>")
|
57
58
|
expect(@mb_obj.counters[:recipients][recipient_type]).to eq(1)
|
58
59
|
end
|
@@ -60,7 +61,7 @@ describe 'The method add_recipient' do
|
|
60
61
|
it 'adds a "bcc" recipient type to the message body and counter is incremented' do
|
61
62
|
recipient_type = :bcc
|
62
63
|
@mb_obj.add_recipient(recipient_type, @address, @variables)
|
63
|
-
|
64
|
+
|
64
65
|
expect(@mb_obj.message[recipient_type][0]).to eq("'#{@variables['first']} #{@variables['last']}' <#{@address}>")
|
65
66
|
expect(@mb_obj.counters[:recipients][recipient_type]).to eq(1)
|
66
67
|
end
|
@@ -68,7 +69,7 @@ describe 'The method add_recipient' do
|
|
68
69
|
it 'adds a "h:reply-to" recipient type to the message body and counters are not incremented' do
|
69
70
|
recipient_type = 'h:reply-to'
|
70
71
|
@mb_obj.add_recipient(recipient_type, @address, @variables)
|
71
|
-
|
72
|
+
|
72
73
|
expect(@mb_obj.message[recipient_type][0]).to eq("'#{@variables['first']} #{@variables['last']}' <#{@address}>")
|
73
74
|
@mb_obj.counters[:recipients].each_value{|value| expect(value).to eq(0)}
|
74
75
|
end
|
@@ -76,13 +77,13 @@ describe 'The method add_recipient' do
|
|
76
77
|
it 'ensures a random recipient type is added to the message body and counters are not incremented' do
|
77
78
|
recipient_type = 'im-not-really-real'
|
78
79
|
@mb_obj.add_recipient(recipient_type, @address, @variables)
|
79
|
-
|
80
|
+
|
80
81
|
expect(@mb_obj.message[recipient_type][0]).to eq("'#{@variables['first']} #{@variables['last']}' <#{@address}>")
|
81
82
|
@mb_obj.counters[:recipients].each_value{|value| expect(value).to eq(0)}
|
82
83
|
end
|
83
84
|
it 'adds too many to recipients and raises an exception.' do
|
84
85
|
recipient_type = :to
|
85
|
-
|
86
|
+
|
86
87
|
expect{
|
87
88
|
1001.times do
|
88
89
|
@mb_obj.add_recipient(recipient_type, @address, @variables)
|
@@ -90,7 +91,7 @@ describe 'The method add_recipient' do
|
|
90
91
|
end
|
91
92
|
it 'adds too many cc recipients and raises an exception.' do
|
92
93
|
recipient_type = :cc
|
93
|
-
|
94
|
+
|
94
95
|
expect{
|
95
96
|
1001.times do
|
96
97
|
@mb_obj.add_recipient(recipient_type, @address, @variables)
|
@@ -98,7 +99,7 @@ describe 'The method add_recipient' do
|
|
98
99
|
end
|
99
100
|
it 'adds too many bcc recipients and raises an exception.' do
|
100
101
|
recipient_type = :bcc
|
101
|
-
|
102
|
+
|
102
103
|
expect{
|
103
104
|
1001.times do
|
104
105
|
@mb_obj.add_recipient(recipient_type, @address, @variables)
|
@@ -118,17 +119,17 @@ describe 'The method subject' do
|
|
118
119
|
before(:each) do
|
119
120
|
@mb_obj = Mailgun::MessageBuilder.new
|
120
121
|
end
|
121
|
-
|
122
|
+
|
122
123
|
it 'sets the message subject to blank if called and no parameters are provided' do
|
123
124
|
@mb_obj.subject
|
124
|
-
|
125
|
+
|
125
126
|
expect(@mb_obj.message[:subject][0]).to eq('')
|
126
127
|
end
|
127
|
-
|
128
|
+
|
128
129
|
it 'sets the message subject if called with the subject parameter' do
|
129
130
|
the_subject = 'This is my subject!'
|
130
131
|
@mb_obj.subject(the_subject)
|
131
|
-
|
132
|
+
|
132
133
|
expect(@mb_obj.message[:subject][0]).to eq(the_subject)
|
133
134
|
end
|
134
135
|
|
@@ -137,7 +138,7 @@ describe 'The method subject' do
|
|
137
138
|
the_second_subject = 'This is my second subject!'
|
138
139
|
@mb_obj.subject(the_first_subject)
|
139
140
|
@mb_obj.subject(the_second_subject)
|
140
|
-
|
141
|
+
|
141
142
|
expect(@mb_obj.message[:subject].length).to eq(1)
|
142
143
|
expect(@mb_obj.message[:subject][0]).to eq(the_second_subject)
|
143
144
|
end
|
@@ -169,7 +170,7 @@ describe 'The method body_text' do
|
|
169
170
|
the_second_text = 'Don\'t mess with Texas!'
|
170
171
|
@mb_obj.body_text(the_first_text)
|
171
172
|
@mb_obj.body_text(the_second_text)
|
172
|
-
|
173
|
+
|
173
174
|
expect(@mb_obj.message[:text].length).to eq(1)
|
174
175
|
expect(@mb_obj.message[:text][0]).to eq(the_second_text)
|
175
176
|
end
|
@@ -187,11 +188,11 @@ describe 'The method from' do
|
|
187
188
|
before(:each) do
|
188
189
|
@mb_obj = Mailgun::MessageBuilder.new
|
189
190
|
end
|
190
|
-
|
191
|
+
|
191
192
|
it 'sets the from address' do
|
192
193
|
the_from_address = 'test@mailgun.com'
|
193
194
|
@mb_obj.from(the_from_address)
|
194
|
-
|
195
|
+
|
195
196
|
expect(@mb_obj.message[:from]).to eq([the_from_address])
|
196
197
|
end
|
197
198
|
|
@@ -200,7 +201,7 @@ describe 'The method from' do
|
|
200
201
|
the_first_name = 'Magilla'
|
201
202
|
the_last_name = 'Gorilla'
|
202
203
|
@mb_obj.from(the_from_address, {'first' => the_first_name, 'last' => the_last_name})
|
203
|
-
|
204
|
+
|
204
205
|
expect(@mb_obj.message[:from]).to eq(["'#{the_first_name} #{the_last_name}' <#{the_from_address}>"])
|
205
206
|
end
|
206
207
|
end
|
@@ -217,7 +218,7 @@ describe 'The method add_attachment' do
|
|
217
218
|
file_paths = [file1, file2]
|
218
219
|
|
219
220
|
file_paths.each {|item| @mb_obj.add_attachment(item)}
|
220
|
-
|
221
|
+
|
221
222
|
expect(@mb_obj.message[:attachment].length).to eq(2)
|
222
223
|
end
|
223
224
|
|
@@ -243,7 +244,7 @@ describe 'The method add_inline_image' do
|
|
243
244
|
file_paths = [file1, file2]
|
244
245
|
|
245
246
|
file_paths.each {|item| @mb_obj.add_inline_image(item)}
|
246
|
-
|
247
|
+
|
247
248
|
expect(@mb_obj.message[:inline].length).to eq(2)
|
248
249
|
end
|
249
250
|
end
|
@@ -262,29 +263,29 @@ describe 'The method test_mode' do
|
|
262
263
|
end
|
263
264
|
it 'turns on test mode with boolean true' do
|
264
265
|
@mb_obj.test_mode(true)
|
265
|
-
|
266
|
+
|
266
267
|
expect(@mb_obj.message["o:testmode"][0]).to eq("yes")
|
267
268
|
end
|
268
269
|
it 'turns on test mode with string true' do
|
269
270
|
@mb_obj.test_mode("true")
|
270
|
-
|
271
|
+
|
271
272
|
expect(@mb_obj.message["o:testmode"][0]).to eq("yes")
|
272
273
|
end
|
273
274
|
it 'turns off test mode with boolean false' do
|
274
275
|
@mb_obj.test_mode(false)
|
275
|
-
|
276
|
+
|
276
277
|
expect(@mb_obj.message["o:testmode"][0]).to eq("no")
|
277
278
|
end
|
278
279
|
it 'turns off test mode with string false' do
|
279
280
|
@mb_obj.test_mode("false")
|
280
|
-
|
281
|
+
|
281
282
|
expect(@mb_obj.message["o:testmode"][0]).to eq("no")
|
282
283
|
end
|
283
284
|
it 'does not allow multiple values' do
|
284
285
|
@mb_obj.test_mode("false")
|
285
286
|
@mb_obj.test_mode("true")
|
286
287
|
@mb_obj.test_mode("false")
|
287
|
-
|
288
|
+
|
288
289
|
expect(@mb_obj.message["o:testmode"].length).to eq(1)
|
289
290
|
expect(@mb_obj.message["o:testmode"][0]).to eq("no")
|
290
291
|
end
|
@@ -304,29 +305,29 @@ describe 'The method dkim' do
|
|
304
305
|
end
|
305
306
|
it 'turns on dkim with boolean true' do
|
306
307
|
@mb_obj.dkim(true)
|
307
|
-
|
308
|
+
|
308
309
|
expect(@mb_obj.message["o:dkim"][0]).to eq("yes")
|
309
310
|
end
|
310
311
|
it 'turns on dkim with string true' do
|
311
312
|
@mb_obj.dkim("true")
|
312
|
-
|
313
|
+
|
313
314
|
expect(@mb_obj.message["o:dkim"][0]).to eq("yes")
|
314
315
|
end
|
315
316
|
it 'turns off dkim with boolean false' do
|
316
317
|
@mb_obj.dkim(false)
|
317
|
-
|
318
|
+
|
318
319
|
expect(@mb_obj.message["o:dkim"][0]).to eq("no")
|
319
320
|
end
|
320
321
|
it 'turns off dkim with string false' do
|
321
322
|
@mb_obj.dkim("false")
|
322
|
-
|
323
|
+
|
323
324
|
expect(@mb_obj.message["o:dkim"][0]).to eq("no")
|
324
325
|
end
|
325
326
|
it 'does not allow multiple values' do
|
326
327
|
@mb_obj.dkim("false")
|
327
328
|
@mb_obj.dkim("true")
|
328
329
|
@mb_obj.dkim("false")
|
329
|
-
|
330
|
+
|
330
331
|
expect(@mb_obj.message["o:dkim"].length).to eq(1)
|
331
332
|
expect(@mb_obj.message["o:dkim"][0]).to eq("no")
|
332
333
|
end
|
@@ -338,14 +339,14 @@ describe 'The method add_campaign_id' do
|
|
338
339
|
end
|
339
340
|
it 'adds a campaign ID to the message' do
|
340
341
|
@mb_obj.add_campaign_id('My-Campaign-Id-1')
|
341
|
-
|
342
|
+
|
342
343
|
expect(@mb_obj.message["o:campaign"][0]).to eq ("My-Campaign-Id-1")
|
343
344
|
end
|
344
345
|
it 'adds a few more campaign IDs to the message' do
|
345
346
|
@mb_obj.add_campaign_id('My-Campaign-Id-1')
|
346
347
|
@mb_obj.add_campaign_id('My-Campaign-Id-2')
|
347
348
|
@mb_obj.add_campaign_id('My-Campaign-Id-3')
|
348
|
-
|
349
|
+
|
349
350
|
expect(@mb_obj.message["o:campaign"][0]).to eq("My-Campaign-Id-1")
|
350
351
|
expect(@mb_obj.message["o:campaign"][1]).to eq("My-Campaign-Id-2")
|
351
352
|
expect(@mb_obj.message["o:campaign"][2]).to eq("My-Campaign-Id-3")
|
@@ -364,14 +365,14 @@ describe 'The method add_tag' do
|
|
364
365
|
end
|
365
366
|
it 'adds a tag to the message' do
|
366
367
|
@mb_obj.add_tag('My-Tag-1')
|
367
|
-
|
368
|
+
|
368
369
|
expect(@mb_obj.message["o:tag"][0]).to eq("My-Tag-1")
|
369
370
|
end
|
370
371
|
it 'adds a few more tags to the message' do
|
371
372
|
@mb_obj.add_tag('My-Tag-1')
|
372
373
|
@mb_obj.add_tag('My-Tag-2')
|
373
374
|
@mb_obj.add_tag('My-Tag-3')
|
374
|
-
|
375
|
+
|
375
376
|
expect(@mb_obj.message["o:tag"][0]).to eq("My-Tag-1")
|
376
377
|
expect(@mb_obj.message["o:tag"][1]).to eq("My-Tag-2")
|
377
378
|
expect(@mb_obj.message["o:tag"][2]).to eq("My-Tag-3")
|
@@ -398,19 +399,19 @@ describe 'The method track_opens' do
|
|
398
399
|
end
|
399
400
|
it 'enables/disables open tracking on a per message basis.' do
|
400
401
|
@mb_obj.track_opens('Yes')
|
401
|
-
|
402
|
+
|
402
403
|
expect(@mb_obj.message["o:tracking-opens"][0]).to eq("yes")
|
403
|
-
|
404
|
+
|
404
405
|
@mb_obj.track_opens('No')
|
405
|
-
|
406
|
+
|
406
407
|
expect(@mb_obj.message["o:tracking-opens"][0]).to eq("no")
|
407
|
-
|
408
|
+
|
408
409
|
@mb_obj.track_opens(true)
|
409
|
-
|
410
|
+
|
410
411
|
expect(@mb_obj.message["o:tracking-opens"][0]).to eq("yes")
|
411
|
-
|
412
|
+
|
412
413
|
@mb_obj.track_opens(false)
|
413
|
-
|
414
|
+
|
414
415
|
expect(@mb_obj.message["o:tracking-opens"][0]).to eq("no")
|
415
416
|
end
|
416
417
|
end
|
@@ -429,23 +430,23 @@ describe 'The method track_clicks' do
|
|
429
430
|
end
|
430
431
|
it 'enables/disables click tracking on a per message basis.' do
|
431
432
|
@mb_obj.track_clicks('Yes')
|
432
|
-
|
433
|
+
|
433
434
|
expect(@mb_obj.message["o:tracking-clicks"][0]).to eq("yes")
|
434
|
-
|
435
|
+
|
435
436
|
@mb_obj.track_clicks('No')
|
436
|
-
|
437
|
+
|
437
438
|
expect(@mb_obj.message["o:tracking-clicks"][0]).to eq("no")
|
438
|
-
|
439
|
+
|
439
440
|
@mb_obj.track_clicks(true)
|
440
|
-
|
441
|
+
|
441
442
|
expect(@mb_obj.message["o:tracking-clicks"][0]).to eq("yes")
|
442
|
-
|
443
|
+
|
443
444
|
@mb_obj.track_clicks(false)
|
444
|
-
|
445
|
+
|
445
446
|
expect(@mb_obj.message["o:tracking-clicks"][0]).to eq("no")
|
446
|
-
|
447
|
+
|
447
448
|
@mb_obj.track_clicks('html')
|
448
|
-
|
449
|
+
|
449
450
|
expect(@mb_obj.message["o:tracking-clicks"][0]).to eq("html")
|
450
451
|
end
|
451
452
|
end
|
@@ -464,7 +465,7 @@ describe 'The method deliver_at' do
|
|
464
465
|
end
|
465
466
|
it 'defines a time/date to deliver a message in RFC2822 format.' do
|
466
467
|
@mb_obj.deliver_at('October 25, 2013 10:00PM CST')
|
467
|
-
|
468
|
+
|
468
469
|
expect(@mb_obj.message["o:deliverytime"][0]).to eq("Fri, 25 Oct 2013 22:00:00 -0600")
|
469
470
|
end
|
470
471
|
end
|
@@ -483,14 +484,14 @@ describe 'The method header' do
|
|
483
484
|
end
|
484
485
|
it 'accepts valid JSON and appends as data to the message.' do
|
485
486
|
@mb_obj.header('my-data', '{"key":"value"}')
|
486
|
-
|
487
|
+
|
487
488
|
expect(@mb_obj.message["v:my-data"][0]).to be_kind_of(String)
|
488
489
|
expect(@mb_obj.message["v:my-data"][0].to_s).to eq('{"key"=>"value"}')
|
489
490
|
end
|
490
491
|
it 'accepts a hash and appends as data to the message.' do
|
491
492
|
data = {'key' => 'value'}
|
492
493
|
@mb_obj.header('my-data', data)
|
493
|
-
|
494
|
+
|
494
495
|
expect(@mb_obj.message["v:my-data"][0]).to be_kind_of(String)
|
495
496
|
expect(@mb_obj.message["v:my-data"][0].to_s).to eq('{"key"=>"value"}')
|
496
497
|
end
|
@@ -506,7 +507,7 @@ describe 'The method add_custom_parameter' do
|
|
506
507
|
end
|
507
508
|
it 'adds an undefined parameter to the message.' do
|
508
509
|
@mb_obj.add_custom_parameter('h:my-sweet-header', 'datagoeshere')
|
509
|
-
|
510
|
+
|
510
511
|
expect(@mb_obj.message["h:my-sweet-header"][0]).to eq("datagoeshere")
|
511
512
|
end
|
512
513
|
end
|
@@ -526,21 +527,21 @@ describe 'The method message_id' do
|
|
526
527
|
end
|
527
528
|
it 'correctly sets the Message-Id header' do
|
528
529
|
@mb_obj.message_id(@the_message_id)
|
529
|
-
|
530
|
+
|
530
531
|
expect(@mb_obj.message['h:Message-Id']).to eq(@the_message_id)
|
531
532
|
end
|
532
533
|
it 'correctly clears the Message-Id header when passed nil' do
|
533
534
|
@mb_obj.message_id(nil)
|
534
|
-
|
535
|
+
|
535
536
|
expect(@mb_obj.message.has_key?('h:Message-Id')).to eq(false)
|
536
537
|
end
|
537
538
|
it 'correctly sets the Message-Id header when passed an empty string' do
|
538
539
|
@mb_obj.message_id(@the_message_id)
|
539
|
-
|
540
|
+
|
540
541
|
expect(@mb_obj.message.has_key?('h:Message-Id')).to eq(true)
|
541
|
-
|
542
|
+
|
542
543
|
@mb_obj.message_id('')
|
543
|
-
|
544
|
+
|
544
545
|
expect(@mb_obj.message.has_key?('h:Message-Id')).to eq(false)
|
545
546
|
end
|
546
547
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
http_interactions:
|
3
3
|
- request:
|
4
4
|
method: get
|
5
|
-
uri: https://api:<PUBKEY>@api.mailgun.net/v3/address/
|
5
|
+
uri: https://api:<PUBKEY>@api.mailgun.net/v3/address/parse?addresses=Alice%20%3Calice@example.com%3E%3Bbob@example.com%3Bexample.org&syntax_only=true
|
6
6
|
body:
|
7
7
|
encoding: US-ASCII
|
8
8
|
string: ''
|
@@ -12,7 +12,9 @@ http_interactions:
|
|
12
12
|
Accept-Encoding:
|
13
13
|
- gzip, deflate
|
14
14
|
User-Agent:
|
15
|
-
-
|
15
|
+
- rest-client/2.0.0 (linux-gnu x86_64) ruby/2.3.1p112
|
16
|
+
Host:
|
17
|
+
- api.mailgun.net
|
16
18
|
response:
|
17
19
|
status:
|
18
20
|
code: 200
|
@@ -21,13 +23,15 @@ http_interactions:
|
|
21
23
|
Server:
|
22
24
|
- nginx
|
23
25
|
Date:
|
24
|
-
-
|
26
|
+
- Wed, 26 Oct 2016 22:44:07 GMT
|
25
27
|
Content-Type:
|
26
28
|
- application/json
|
27
29
|
Content-Length:
|
28
|
-
- '
|
30
|
+
- '118'
|
29
31
|
Connection:
|
30
32
|
- keep-alive
|
33
|
+
Content-Disposition:
|
34
|
+
- inline
|
31
35
|
Access-Control-Allow-Origin:
|
32
36
|
- "*"
|
33
37
|
Access-Control-Max-Age:
|
@@ -40,20 +44,74 @@ http_interactions:
|
|
40
44
|
encoding: UTF-8
|
41
45
|
string: |-
|
42
46
|
{
|
43
|
-
"
|
47
|
+
"parsed": [
|
48
|
+
"Alice <alice@example.com>",
|
49
|
+
"bob@example.com"
|
50
|
+
],
|
51
|
+
"unparseable": [
|
52
|
+
"example.org"
|
53
|
+
]
|
54
|
+
}
|
55
|
+
http_version:
|
56
|
+
recorded_at: Wed, 26 Oct 2016 22:44:50 GMT
|
57
|
+
- request:
|
58
|
+
method: get
|
59
|
+
uri: https://api:<PUBKEY>@api.mailgun.net/v3/address/validate?address=alice@mailgun.net
|
60
|
+
body:
|
61
|
+
encoding: US-ASCII
|
62
|
+
string: ''
|
63
|
+
headers:
|
64
|
+
Accept:
|
65
|
+
- "*/*"
|
66
|
+
Accept-Encoding:
|
67
|
+
- gzip, deflate
|
68
|
+
User-Agent:
|
69
|
+
- rest-client/2.0.0 (linux-gnu x86_64) ruby/2.3.1p112
|
70
|
+
Host:
|
71
|
+
- api.mailgun.net
|
72
|
+
response:
|
73
|
+
status:
|
74
|
+
code: 200
|
75
|
+
message: OK
|
76
|
+
headers:
|
77
|
+
Server:
|
78
|
+
- nginx
|
79
|
+
Date:
|
80
|
+
- Wed, 26 Oct 2016 22:44:08 GMT
|
81
|
+
Content-Type:
|
82
|
+
- application/json
|
83
|
+
Content-Length:
|
84
|
+
- '179'
|
85
|
+
Connection:
|
86
|
+
- keep-alive
|
87
|
+
Content-Disposition:
|
88
|
+
- inline
|
89
|
+
Access-Control-Allow-Origin:
|
90
|
+
- "*"
|
91
|
+
Access-Control-Max-Age:
|
92
|
+
- '600'
|
93
|
+
Access-Control-Allow-Methods:
|
94
|
+
- GET, POST, PUT, DELETE, OPTIONS
|
95
|
+
Access-Control-Allow-Headers:
|
96
|
+
- Content-Type, x-requested-with
|
97
|
+
body:
|
98
|
+
encoding: UTF-8
|
99
|
+
string: |-
|
100
|
+
{
|
101
|
+
"address": "alice@mailgun.net",
|
44
102
|
"did_you_mean": null,
|
45
103
|
"is_valid": true,
|
46
104
|
"parts": {
|
47
105
|
"display_name": null,
|
48
|
-
"domain": "
|
49
|
-
"local_part": "
|
106
|
+
"domain": "mailgun.net",
|
107
|
+
"local_part": "alice"
|
50
108
|
}
|
51
109
|
}
|
52
110
|
http_version:
|
53
|
-
recorded_at:
|
111
|
+
recorded_at: Wed, 26 Oct 2016 22:44:50 GMT
|
54
112
|
- request:
|
55
113
|
method: get
|
56
|
-
uri: https://api:<PUBKEY>@api.mailgun.net/v3/address/
|
114
|
+
uri: https://api:<PUBKEY>@api.mailgun.net/v3/address/validate?address=example.org
|
57
115
|
body:
|
58
116
|
encoding: US-ASCII
|
59
117
|
string: ''
|
@@ -63,7 +121,9 @@ http_interactions:
|
|
63
121
|
Accept-Encoding:
|
64
122
|
- gzip, deflate
|
65
123
|
User-Agent:
|
66
|
-
-
|
124
|
+
- rest-client/2.0.0 (linux-gnu x86_64) ruby/2.3.1p112
|
125
|
+
Host:
|
126
|
+
- api.mailgun.net
|
67
127
|
response:
|
68
128
|
status:
|
69
129
|
code: 200
|
@@ -72,13 +132,15 @@ http_interactions:
|
|
72
132
|
Server:
|
73
133
|
- nginx
|
74
134
|
Date:
|
75
|
-
-
|
135
|
+
- Wed, 26 Oct 2016 22:44:08 GMT
|
76
136
|
Content-Type:
|
77
137
|
- application/json
|
78
138
|
Content-Length:
|
79
|
-
- '
|
139
|
+
- '162'
|
80
140
|
Connection:
|
81
141
|
- keep-alive
|
142
|
+
Content-Disposition:
|
143
|
+
- inline
|
82
144
|
Access-Control-Allow-Origin:
|
83
145
|
- "*"
|
84
146
|
Access-Control-Max-Age:
|
@@ -91,14 +153,15 @@ http_interactions:
|
|
91
153
|
encoding: UTF-8
|
92
154
|
string: |-
|
93
155
|
{
|
94
|
-
"
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
"
|
100
|
-
|
156
|
+
"address": "example.org",
|
157
|
+
"did_you_mean": null,
|
158
|
+
"is_valid": false,
|
159
|
+
"parts": {
|
160
|
+
"display_name": null,
|
161
|
+
"domain": null,
|
162
|
+
"local_part": null
|
163
|
+
}
|
101
164
|
}
|
102
165
|
http_version:
|
103
|
-
recorded_at:
|
104
|
-
recorded_with: VCR 3.0.
|
166
|
+
recorded_at: Wed, 26 Oct 2016 22:44:50 GMT
|
167
|
+
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mailgun
|
@@ -9,145 +9,131 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-10-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.5'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.5'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rspec
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '3.0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '3.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '10.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '10.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: webmock
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '1.22'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ~>
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1.22'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: pry
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - ~>
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0.9'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ~>
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0.9'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: vcr
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - ~>
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '3.0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - ~>
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '3.0'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
99
|
name: simplecov
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- -
|
102
|
+
- - ~>
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0.11'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- -
|
109
|
+
- - ~>
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0.11'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: rest-client
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - ~>
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
118
|
+
version: '2.0'
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ~>
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: json
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
requirements:
|
130
|
-
- - "~>"
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: '1.8'
|
133
|
-
type: :runtime
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: !ruby/object:Gem::Requirement
|
136
|
-
requirements:
|
137
|
-
- - "~>"
|
138
|
-
- !ruby/object:Gem::Version
|
139
|
-
version: '1.8'
|
125
|
+
version: '2.0'
|
140
126
|
description: Mailgun's Official Ruby SDK for interacting with the Mailgun API.
|
141
127
|
email: support@mailgunhq.com
|
142
128
|
executables: []
|
143
129
|
extensions: []
|
144
130
|
extra_rdoc_files: []
|
145
131
|
files:
|
146
|
-
-
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
150
|
-
-
|
132
|
+
- .gitignore
|
133
|
+
- .rubocop.yml
|
134
|
+
- .rubocop_todo.yml
|
135
|
+
- .ruby-env.yml.example
|
136
|
+
- .travis.yml
|
151
137
|
- Domains.md
|
152
138
|
- Events.md
|
153
139
|
- Gemfile
|
@@ -159,7 +145,9 @@ files:
|
|
159
145
|
- Rakefile
|
160
146
|
- Snippets.md
|
161
147
|
- Webhooks.md
|
148
|
+
- lib/mailgun-ruby.rb
|
162
149
|
- lib/mailgun.rb
|
150
|
+
- lib/mailgun/address.rb
|
163
151
|
- lib/mailgun/chains.rb
|
164
152
|
- lib/mailgun/client.rb
|
165
153
|
- lib/mailgun/domains/domains.rb
|
@@ -220,17 +208,17 @@ require_paths:
|
|
220
208
|
- lib
|
221
209
|
required_ruby_version: !ruby/object:Gem::Requirement
|
222
210
|
requirements:
|
223
|
-
- -
|
211
|
+
- - ! '>='
|
224
212
|
- !ruby/object:Gem::Version
|
225
|
-
version:
|
213
|
+
version: 2.0.0
|
226
214
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
227
215
|
requirements:
|
228
|
-
- -
|
216
|
+
- - ! '>='
|
229
217
|
- !ruby/object:Gem::Version
|
230
218
|
version: '0'
|
231
219
|
requirements: []
|
232
220
|
rubyforge_project:
|
233
|
-
rubygems_version: 2.4.
|
221
|
+
rubygems_version: 2.4.5
|
234
222
|
signing_key:
|
235
223
|
specification_version: 4
|
236
224
|
summary: Mailgun's Official Ruby SDK
|