mailgunner 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -37,6 +37,14 @@ module Mailgunner
37
37
  @json = json
38
38
  end
39
39
 
40
+ def validate_address(value)
41
+ get('/v2/address/validate', address: value)
42
+ end
43
+
44
+ def parse_addresses(values)
45
+ get('/v2/address/parse', addresses: Array(values).join(','))
46
+ end
47
+
40
48
  def send_message(attributes = {})
41
49
  post("/v2/#{escape @domain}/messages", attributes)
42
50
  end
@@ -106,9 +114,15 @@ module Mailgunner
106
114
  end
107
115
 
108
116
  def get_log(params = {})
117
+ Kernel.warn 'Mailgunner::Client#get_log is deprecated'
118
+
109
119
  get("/v2/#{escape @domain}/log", params)
110
120
  end
111
121
 
122
+ def get_events(params = {})
123
+ get("/v2/#{escape @domain}/events", params)
124
+ end
125
+
112
126
  def get_routes(params = {})
113
127
  get('/v2/routes', params)
114
128
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'mailgunner'
3
- s.version = '1.1.0'
3
+ s.version = '1.2.0'
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.authors = ['Tim Craft']
6
6
  s.email = ['mail@timcraft.com']
@@ -65,6 +65,22 @@ describe 'Mailgunner::Client' do
65
65
  end
66
66
  end
67
67
 
68
+ describe 'validate_address method' do
69
+ it 'calls the address validate resource with the given email address and returns a response object' do
70
+ expect(Net::HTTP::Get, "/v2/address/validate?address=#{@encoded_address}")
71
+
72
+ @client.validate_address(@address).must_be_instance_of(Mailgunner::Response)
73
+ end
74
+ end
75
+
76
+ describe 'parse_addresses method' do
77
+ it 'calls the address parse resource with the given email addresses and returns a response object' do
78
+ expect(Net::HTTP::Get, "/v2/address/parse?addresses=bob%40example.com%2Ceve%40example.com")
79
+
80
+ @client.parse_addresses(['bob@example.com', 'eve@example.com']).must_be_instance_of(Mailgunner::Response)
81
+ end
82
+ end
83
+
68
84
  describe 'send_message method' do
69
85
  it 'posts to the domain messages resource and returns a response object' do
70
86
  expect(Net::HTTP::Post, "/v2/#@domain/messages")
@@ -266,7 +282,11 @@ describe 'Mailgunner::Client' do
266
282
  end
267
283
 
268
284
  describe 'get_log method' do
269
- it 'fetches the domain stats resource and returns a response object' do
285
+ before do
286
+ Kernel.stubs(:warn)
287
+ end
288
+
289
+ it 'fetches the domain log resource and returns a response object' do
270
290
  expect(Net::HTTP::Get, "/v2/#@domain/log")
271
291
 
272
292
  @client.get_log.must_be_instance_of(Mailgunner::Response)
@@ -277,6 +297,28 @@ describe 'Mailgunner::Client' do
277
297
 
278
298
  @client.get_log(skip: 1, limit: 2)
279
299
  end
300
+
301
+ it 'emits a deprecation warning' do
302
+ Kernel.expects(:warn).with(regexp_matches(/Mailgunner::Client#get_log is deprecated/))
303
+
304
+ @client.http.stubs(:request)
305
+
306
+ @client.get_log
307
+ end
308
+ end
309
+
310
+ describe 'get_events method' do
311
+ it 'fetches the domain events resource and returns a response object' do
312
+ expect(Net::HTTP::Get, "/v2/#@domain/events")
313
+
314
+ @client.get_events.must_be_instance_of(Mailgunner::Response)
315
+ end
316
+
317
+ it 'encodes optional parameters' do
318
+ expect(Net::HTTP::Get, "/v2/#@domain/events?event=accepted&limit=10")
319
+
320
+ @client.get_events(event: 'accepted', limit: 10)
321
+ end
280
322
  end
281
323
 
282
324
  describe 'get_routes method' do
@@ -342,7 +384,7 @@ describe 'Mailgunner::Client' do
342
384
  Kernel.stubs(:warn)
343
385
  end
344
386
 
345
- it 'emits a deprecation warning and fetches the domain mailboxes resource and returns a response object' do
387
+ it 'fetches the domain mailboxes resource and returns a response object' do
346
388
  expect(Net::HTTP::Get, "/v2/#@domain/mailboxes")
347
389
 
348
390
  @client.get_mailboxes.must_be_instance_of(Mailgunner::Response)
@@ -720,7 +762,7 @@ describe 'Mailgunner::Client' do
720
762
  describe 'when initialized with a different json implementation' do
721
763
  it 'emits a deprecation warning' do
722
764
  Kernel.expects(:warn).with(regexp_matches(/Mailgunner::Client :json option is deprecated/))
723
-
765
+
724
766
  Mailgunner::Client.new(domain: @domain, api_key: @api_key, json: stub)
725
767
  end
726
768
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailgunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-01 00:00:00.000000000 Z
12
+ date: 2013-09-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -90,9 +90,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project:
93
- rubygems_version: 1.8.25
93
+ rubygems_version: 1.8.23
94
94
  signing_key:
95
95
  specification_version: 3
96
96
  summary: See description
97
97
  test_files: []
98
- has_rdoc: