mailgunner 1.3.0 → 2.0.0
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 +7 -0
- data/README.md +0 -6
- data/lib/mailgunner.rb +45 -20
- data/lib/mailgunner/delivery_method.rb +1 -12
- data/mailgunner.gemspec +6 -6
- data/spec/mailgunner_delivery_method_spec.rb +3 -1
- data/spec/mailgunner_spec.rb +196 -153
- metadata +27 -56
- data/lib/mailgunner/response.rb +0 -37
- data/spec/mailgunner_response_spec.rb +0 -101
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16c8da4bf004d3e8b0ce0b398815294a6d5e801d
|
4
|
+
data.tar.gz: c2fa0a69df8ec9a64648dd3a8979d0bef4bbb593
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a6464e5137f28e412ba186dab76d85927b12e59362896a4e7cf9da57cffa02aa575d020221ab3f37154204432a4f03eb99c2390425a664d95d0c9bb0ccc645f
|
7
|
+
data.tar.gz: b7ca7c319178f0c893111a14778e1c4266d12d14b49fe514e47152489a61ed5e1328fc00e7cecc4fe578110cd3edbd4819b554782b9cc41b3644705fd52e5e89
|
data/README.md
CHANGED
data/lib/mailgunner.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'json'
|
3
3
|
require 'cgi'
|
4
|
-
require 'mailgunner/response'
|
5
4
|
require 'mailgunner/delivery_method' if defined?(ActionMailer)
|
6
5
|
|
7
6
|
module Mailgunner
|
7
|
+
class Error < StandardError; end
|
8
|
+
|
8
9
|
class Client
|
9
10
|
attr_accessor :domain, :api_key, :http
|
10
11
|
|
@@ -13,14 +14,6 @@ module Mailgunner
|
|
13
14
|
|
14
15
|
@api_key = options.fetch(:api_key) { ENV.fetch('MAILGUN_API_KEY') }
|
15
16
|
|
16
|
-
if options.has_key?(:json)
|
17
|
-
Kernel.warn 'Mailgunner::Client :json option is deprecated'
|
18
|
-
|
19
|
-
@json = options[:json]
|
20
|
-
else
|
21
|
-
@json = JSON
|
22
|
-
end
|
23
|
-
|
24
17
|
@http = Net::HTTP.new('api.mailgun.net', Net::HTTP.https_default_port)
|
25
18
|
|
26
19
|
@http.use_ssl = true
|
@@ -58,6 +51,26 @@ module Mailgunner
|
|
58
51
|
post('/v2/domains', attributes)
|
59
52
|
end
|
60
53
|
|
54
|
+
def delete_domain(name)
|
55
|
+
delete("/v2/domains/#{escape name}")
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_credentials
|
59
|
+
get("/v2/domains/#{escape @domain}/credentials")
|
60
|
+
end
|
61
|
+
|
62
|
+
def add_credentials(attributes)
|
63
|
+
post("/v2/domains/#{escape @domain}/credentials", attributes)
|
64
|
+
end
|
65
|
+
|
66
|
+
def update_credentials(login, attributes)
|
67
|
+
put("/v2/domains/#{escape @domain}/credentials/#{escape login}", attributes)
|
68
|
+
end
|
69
|
+
|
70
|
+
def delete_credentials(login)
|
71
|
+
delete("/v2/domains/#{escape @domain}/credentials/#{escape login}")
|
72
|
+
end
|
73
|
+
|
61
74
|
def get_unsubscribes(params = {})
|
62
75
|
get("/v2/#{escape @domain}/unsubscribes", params)
|
63
76
|
end
|
@@ -249,23 +262,35 @@ module Mailgunner
|
|
249
262
|
|
250
263
|
yield message if block_given?
|
251
264
|
|
252
|
-
|
265
|
+
parse(@http.request(message))
|
253
266
|
end
|
254
267
|
|
255
|
-
def
|
256
|
-
if
|
257
|
-
|
268
|
+
def parse(response)
|
269
|
+
if Net::HTTPSuccess === response
|
270
|
+
json?(response) ? JSON.parse(response.body) : response.body
|
258
271
|
else
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
tmp << "#{escape(key)}=#{escape(value)}"
|
264
|
-
end
|
272
|
+
if json?(response)
|
273
|
+
raise Error, "HTTP #{response.code}: #{JSON.parse(response.body).fetch('message')}"
|
274
|
+
else
|
275
|
+
raise Error, "HTTP #{response.code}"
|
265
276
|
end
|
277
|
+
end
|
278
|
+
end
|
266
279
|
|
267
|
-
|
280
|
+
def json?(response)
|
281
|
+
content_type = response['Content-Type']
|
282
|
+
|
283
|
+
content_type && content_type.split(';').first == 'application/json'
|
284
|
+
end
|
285
|
+
|
286
|
+
def request_uri(path, hash)
|
287
|
+
return path if hash.empty?
|
288
|
+
|
289
|
+
query_params = hash.map do |key, values|
|
290
|
+
Array(values).map { |value| "#{escape(key)}=#{escape(value)}" }
|
268
291
|
end
|
292
|
+
|
293
|
+
path + '?' + query_params.flatten.join('&')
|
269
294
|
end
|
270
295
|
|
271
296
|
def escape(component)
|
@@ -1,9 +1,6 @@
|
|
1
1
|
require 'mail/check_delivery_params'
|
2
2
|
|
3
3
|
module Mailgunner
|
4
|
-
class DeliveryFailed < StandardError
|
5
|
-
end
|
6
|
-
|
7
4
|
class DeliveryMethod
|
8
5
|
include Mail::CheckDeliveryParams
|
9
6
|
|
@@ -22,15 +19,7 @@ module Mailgunner
|
|
22
19
|
def deliver!(mail)
|
23
20
|
check_delivery_params(mail)
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
if response.ok?
|
28
|
-
return response
|
29
|
-
elsif response.json? && response.object.has_key?('message')
|
30
|
-
raise DeliveryFailed, response.object['message']
|
31
|
-
else
|
32
|
-
raise DeliveryFailed, "#{response.code} #{response.message}"
|
33
|
-
end
|
22
|
+
@client.send_mime(mail)
|
34
23
|
end
|
35
24
|
end
|
36
25
|
|
data/mailgunner.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'mailgunner'
|
3
|
-
s.version = '
|
3
|
+
s.version = '2.0.0'
|
4
4
|
s.platform = Gem::Platform::RUBY
|
5
5
|
s.authors = ['Tim Craft']
|
6
6
|
s.email = ['mail@timcraft.com']
|
@@ -8,10 +8,10 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.description = 'A Ruby wrapper for the Mailgun API'
|
9
9
|
s.summary = 'See description'
|
10
10
|
s.files = Dir.glob('{lib,spec}/**/*') + %w(README.md mailgunner.gemspec)
|
11
|
-
s.
|
12
|
-
s.add_development_dependency('
|
13
|
-
s.add_development_dependency('webmock', '~> 1.
|
14
|
-
s.add_development_dependency('mail', '~> 2.5
|
15
|
-
s.add_development_dependency('actionmailer', '~> 4.0
|
11
|
+
s.required_ruby_version = '>= 1.9.3'
|
12
|
+
s.add_development_dependency('rake', '~> 10.1')
|
13
|
+
s.add_development_dependency('webmock', '~> 1.18')
|
14
|
+
s.add_development_dependency('mail', '~> 2.5')
|
15
|
+
s.add_development_dependency('actionmailer', '~> 4.0')
|
16
16
|
s.require_path = 'lib'
|
17
17
|
end
|
@@ -42,7 +42,9 @@ describe 'Mailgunner::DeliveryMethod' do
|
|
42
42
|
body: '{"message": "Invalid API key"}'
|
43
43
|
})
|
44
44
|
|
45
|
-
proc { ExampleMailer.registration_confirmation(email: @address).deliver }.must_raise(Mailgunner::
|
45
|
+
exception = proc { ExampleMailer.registration_confirmation(email: @address).deliver }.must_raise(Mailgunner::Error)
|
46
|
+
|
47
|
+
exception.message.must_include('Invalid API key')
|
46
48
|
end
|
47
49
|
|
48
50
|
it 'allows the domain to be specified explicitly via the delivery method settings' do
|
data/spec/mailgunner_spec.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'minitest/autorun'
|
2
2
|
require 'webmock/minitest'
|
3
|
-
require 'mocha/setup'
|
4
3
|
require 'mailgunner'
|
5
4
|
require 'json'
|
6
5
|
require 'mail'
|
@@ -13,11 +12,17 @@ describe 'Mailgunner::Client' do
|
|
13
12
|
|
14
13
|
@base_url = "https://api:#{@api_key}@api.mailgun.net/v2"
|
15
14
|
|
15
|
+
@json_response = {headers: {'Content-Type' => 'application/json;charset=utf-8'}, body: '{"key":"value"}'}
|
16
|
+
|
17
|
+
@json_response_object = {'key' => 'value'}
|
18
|
+
|
16
19
|
@client = Mailgunner::Client.new(domain: @domain, api_key: @api_key)
|
17
20
|
|
18
21
|
@address = 'user@example.com'
|
19
22
|
|
20
23
|
@encoded_address = 'user%40example.com'
|
24
|
+
|
25
|
+
@login = 'bob.bar'
|
21
26
|
end
|
22
27
|
|
23
28
|
describe 'http method' do
|
@@ -59,26 +64,26 @@ describe 'Mailgunner::Client' do
|
|
59
64
|
end
|
60
65
|
|
61
66
|
describe 'validate_address method' do
|
62
|
-
it 'calls the address validate resource with the given email address and returns
|
63
|
-
stub_request(:get, "#@base_url/address/validate?address=#@encoded_address")
|
67
|
+
it 'calls the address validate resource with the given email address and returns the response object' do
|
68
|
+
stub_request(:get, "#@base_url/address/validate?address=#@encoded_address").to_return(@json_response)
|
64
69
|
|
65
|
-
@client.validate_address(@address).
|
70
|
+
@client.validate_address(@address).must_equal(@json_response_object)
|
66
71
|
end
|
67
72
|
end
|
68
73
|
|
69
74
|
describe 'parse_addresses method' do
|
70
|
-
it 'calls the address parse resource with the given email addresses and returns
|
71
|
-
stub_request(:get, "#@base_url/address/parse?addresses=bob%40example.com%2Ceve%40example.com")
|
75
|
+
it 'calls the address parse resource with the given email addresses and returns the response object' do
|
76
|
+
stub_request(:get, "#@base_url/address/parse?addresses=bob%40example.com%2Ceve%40example.com").to_return(@json_response)
|
72
77
|
|
73
|
-
@client.parse_addresses(['bob@example.com', 'eve@example.com']).
|
78
|
+
@client.parse_addresses(['bob@example.com', 'eve@example.com']).must_equal(@json_response_object)
|
74
79
|
end
|
75
80
|
end
|
76
81
|
|
77
82
|
describe 'send_message method' do
|
78
|
-
it 'posts to the domain messages resource and returns
|
79
|
-
stub_request(:post, "#@base_url/#@domain/messages")
|
83
|
+
it 'posts to the domain messages resource and returns the response object' do
|
84
|
+
stub_request(:post, "#@base_url/#@domain/messages").to_return(@json_response)
|
80
85
|
|
81
|
-
@client.send_message({}).
|
86
|
+
@client.send_message({}).must_equal(@json_response_object)
|
82
87
|
end
|
83
88
|
|
84
89
|
it 'encodes the message attributes' do
|
@@ -102,34 +107,34 @@ describe 'Mailgunner::Client' do
|
|
102
107
|
})
|
103
108
|
end
|
104
109
|
|
105
|
-
it 'posts to the domain messages resource and returns
|
106
|
-
stub_request(:post, "#@base_url/#@domain/messages.mime")
|
110
|
+
it 'posts to the domain messages resource and returns the response object' do
|
111
|
+
stub_request(:post, "#@base_url/#@domain/messages.mime").to_return(@json_response)
|
107
112
|
|
108
|
-
@client.send_mime(@mail).
|
113
|
+
@client.send_mime(@mail).must_equal(@json_response_object)
|
109
114
|
end
|
110
115
|
end
|
111
116
|
|
112
117
|
describe 'get_domains method' do
|
113
|
-
it 'fetches the domains resource and returns
|
114
|
-
stub_request(:get, "#@base_url/domains")
|
118
|
+
it 'fetches the domains resource and returns the response object' do
|
119
|
+
stub_request(:get, "#@base_url/domains").to_return(@json_response)
|
115
120
|
|
116
|
-
@client.get_domains.
|
121
|
+
@client.get_domains.must_equal(@json_response_object)
|
117
122
|
end
|
118
123
|
end
|
119
124
|
|
120
125
|
describe 'get_domain method' do
|
121
|
-
it 'fetches the domain resource and returns
|
122
|
-
stub_request(:get, "#@base_url/domains/#@domain")
|
126
|
+
it 'fetches the domain resource and returns the response object' do
|
127
|
+
stub_request(:get, "#@base_url/domains/#@domain").to_return(@json_response)
|
123
128
|
|
124
|
-
@client.get_domain(@domain).
|
129
|
+
@client.get_domain(@domain).must_equal(@json_response_object)
|
125
130
|
end
|
126
131
|
end
|
127
132
|
|
128
133
|
describe 'add_domain method' do
|
129
|
-
it 'posts to the domains resource and returns
|
130
|
-
stub_request(:post, "#@base_url/domains")
|
134
|
+
it 'posts to the domains resource and returns the response object' do
|
135
|
+
stub_request(:post, "#@base_url/domains").to_return(@json_response)
|
131
136
|
|
132
|
-
@client.add_domain({}).
|
137
|
+
@client.add_domain({}).must_equal(@json_response_object)
|
133
138
|
end
|
134
139
|
|
135
140
|
it 'encodes the domain attributes' do
|
@@ -139,11 +144,57 @@ describe 'Mailgunner::Client' do
|
|
139
144
|
end
|
140
145
|
end
|
141
146
|
|
147
|
+
describe 'delete_domain method' do
|
148
|
+
it 'deletes the domain resource with the given name and returns the response object' do
|
149
|
+
stub_request(:delete, "#@base_url/domains/#@domain").to_return(@json_response)
|
150
|
+
|
151
|
+
@client.delete_domain(@domain).must_equal(@json_response_object)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe 'get_credentials method' do
|
156
|
+
it 'fetches the domain credentials resource and returns the response object' do
|
157
|
+
stub_request(:get, "#@base_url/domains/#@domain/credentials").to_return(@json_response)
|
158
|
+
|
159
|
+
@client.get_credentials.must_equal(@json_response_object)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe 'add_credentials method' do
|
164
|
+
it 'posts to the domain credentials resource and returns the response object' do
|
165
|
+
stub_request(:post, "#@base_url/domains/#@domain/credentials").with(body: "login=#@login").to_return(@json_response)
|
166
|
+
|
167
|
+
@client.add_credentials(login: @login).must_equal(@json_response_object)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe 'update_credentials method' do
|
172
|
+
it 'updates the domain credentials resource with the given login and returns the response object' do
|
173
|
+
stub_request(:put, "#@base_url/domains/#@domain/credentials/#@login").to_return(@json_response)
|
174
|
+
|
175
|
+
@client.update_credentials(@login, {}).must_equal(@json_response_object)
|
176
|
+
end
|
177
|
+
|
178
|
+
it 'encodes the password attribute' do
|
179
|
+
stub_request(:put, "#@base_url/domains/#@domain/credentials/#@login").with(body: 'password=secret')
|
180
|
+
|
181
|
+
@client.update_credentials(@login, password: 'secret')
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe 'delete_credentials method' do
|
186
|
+
it 'deletes the domain credentials resource with the given login and returns the response object' do
|
187
|
+
stub_request(:delete, "#@base_url/domains/#@domain/credentials/#@login").to_return(@json_response)
|
188
|
+
|
189
|
+
@client.delete_credentials(@login).must_equal(@json_response_object)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
142
193
|
describe 'get_unsubscribes method' do
|
143
|
-
it 'fetches the domain unsubscribes resource and returns
|
144
|
-
stub_request(:get, "#@base_url/#@domain/unsubscribes")
|
194
|
+
it 'fetches the domain unsubscribes resource and returns the response object' do
|
195
|
+
stub_request(:get, "#@base_url/#@domain/unsubscribes").to_return(@json_response)
|
145
196
|
|
146
|
-
@client.get_unsubscribes.
|
197
|
+
@client.get_unsubscribes.must_equal(@json_response_object)
|
147
198
|
end
|
148
199
|
|
149
200
|
it 'encodes skip and limit parameters' do
|
@@ -154,26 +205,26 @@ describe 'Mailgunner::Client' do
|
|
154
205
|
end
|
155
206
|
|
156
207
|
describe 'get_unsubscribe method' do
|
157
|
-
it 'fetches the unsubscribe resource with the given address and returns
|
158
|
-
stub_request(:get, "#@base_url/#@domain/unsubscribes/#@encoded_address")
|
208
|
+
it 'fetches the unsubscribe resource with the given address and returns the response object' do
|
209
|
+
stub_request(:get, "#@base_url/#@domain/unsubscribes/#@encoded_address").to_return(@json_response)
|
159
210
|
|
160
|
-
@client.get_unsubscribe(@address).
|
211
|
+
@client.get_unsubscribe(@address).must_equal(@json_response_object)
|
161
212
|
end
|
162
213
|
end
|
163
214
|
|
164
215
|
describe 'delete_unsubscribe method' do
|
165
|
-
it 'deletes the domain unsubscribe resource with the given address and returns
|
166
|
-
stub_request(:delete, "#@base_url/#@domain/unsubscribes/#@encoded_address")
|
216
|
+
it 'deletes the domain unsubscribe resource with the given address and returns the response object' do
|
217
|
+
stub_request(:delete, "#@base_url/#@domain/unsubscribes/#@encoded_address").to_return(@json_response)
|
167
218
|
|
168
|
-
@client.delete_unsubscribe(@address).
|
219
|
+
@client.delete_unsubscribe(@address).must_equal(@json_response_object)
|
169
220
|
end
|
170
221
|
end
|
171
222
|
|
172
223
|
describe 'add_unsubscribe method' do
|
173
|
-
it 'posts to the domain unsubscribes resource and returns
|
174
|
-
stub_request(:post, "#@base_url/#@domain/unsubscribes")
|
224
|
+
it 'posts to the domain unsubscribes resource and returns the response object' do
|
225
|
+
stub_request(:post, "#@base_url/#@domain/unsubscribes").to_return(@json_response)
|
175
226
|
|
176
|
-
@client.add_unsubscribe({}).
|
227
|
+
@client.add_unsubscribe({}).must_equal(@json_response_object)
|
177
228
|
end
|
178
229
|
|
179
230
|
it 'encodes the unsubscribe attributes' do
|
@@ -184,10 +235,10 @@ describe 'Mailgunner::Client' do
|
|
184
235
|
end
|
185
236
|
|
186
237
|
describe 'get_complaints method' do
|
187
|
-
it 'fetches the domain complaints resource and returns
|
188
|
-
stub_request(:get, "#@base_url/#@domain/complaints")
|
238
|
+
it 'fetches the domain complaints resource and returns the response object' do
|
239
|
+
stub_request(:get, "#@base_url/#@domain/complaints").to_return(@json_response)
|
189
240
|
|
190
|
-
@client.get_complaints.
|
241
|
+
@client.get_complaints.must_equal(@json_response_object)
|
191
242
|
end
|
192
243
|
|
193
244
|
it 'encodes skip and limit parameters' do
|
@@ -198,18 +249,18 @@ describe 'Mailgunner::Client' do
|
|
198
249
|
end
|
199
250
|
|
200
251
|
describe 'get_complaint method' do
|
201
|
-
it 'fetches the complaint resource with the given address and returns
|
202
|
-
stub_request(:get, "#@base_url/#@domain/complaints/#@encoded_address")
|
252
|
+
it 'fetches the complaint resource with the given address and returns the response object' do
|
253
|
+
stub_request(:get, "#@base_url/#@domain/complaints/#@encoded_address").to_return(@json_response)
|
203
254
|
|
204
|
-
@client.get_complaint(@address).
|
255
|
+
@client.get_complaint(@address).must_equal(@json_response_object)
|
205
256
|
end
|
206
257
|
end
|
207
258
|
|
208
259
|
describe 'add_complaint method' do
|
209
|
-
it 'posts to the domain complaints resource and returns
|
210
|
-
stub_request(:post, "#@base_url/#@domain/complaints")
|
260
|
+
it 'posts to the domain complaints resource and returns the response object' do
|
261
|
+
stub_request(:post, "#@base_url/#@domain/complaints").to_return(@json_response)
|
211
262
|
|
212
|
-
@client.add_complaint({}).
|
263
|
+
@client.add_complaint({}).must_equal(@json_response_object)
|
213
264
|
end
|
214
265
|
|
215
266
|
it 'encodes the complaint attributes' do
|
@@ -220,18 +271,18 @@ describe 'Mailgunner::Client' do
|
|
220
271
|
end
|
221
272
|
|
222
273
|
describe 'delete_complaint method' do
|
223
|
-
it 'deletes the domain complaint resource with the given address and returns
|
224
|
-
stub_request(:delete, "#@base_url/#@domain/complaints/#@encoded_address")
|
274
|
+
it 'deletes the domain complaint resource with the given address and returns the response object' do
|
275
|
+
stub_request(:delete, "#@base_url/#@domain/complaints/#@encoded_address").to_return(@json_response)
|
225
276
|
|
226
|
-
@client.delete_complaint(@address).
|
277
|
+
@client.delete_complaint(@address).must_equal(@json_response_object)
|
227
278
|
end
|
228
279
|
end
|
229
280
|
|
230
281
|
describe 'get_bounces method' do
|
231
|
-
it 'fetches the domain bounces resource and returns
|
232
|
-
stub_request(:get, "#@base_url/#@domain/bounces")
|
282
|
+
it 'fetches the domain bounces resource and returns the response object' do
|
283
|
+
stub_request(:get, "#@base_url/#@domain/bounces").to_return(@json_response)
|
233
284
|
|
234
|
-
@client.get_bounces.
|
285
|
+
@client.get_bounces.must_equal(@json_response_object)
|
235
286
|
end
|
236
287
|
|
237
288
|
it 'encodes skip and limit parameters' do
|
@@ -242,18 +293,18 @@ describe 'Mailgunner::Client' do
|
|
242
293
|
end
|
243
294
|
|
244
295
|
describe 'get_bounce method' do
|
245
|
-
it 'fetches the bounce resource with the given address and returns
|
246
|
-
stub_request(:get, "#@base_url/#@domain/bounces/#@encoded_address")
|
296
|
+
it 'fetches the bounce resource with the given address and returns the response object' do
|
297
|
+
stub_request(:get, "#@base_url/#@domain/bounces/#@encoded_address").to_return(@json_response)
|
247
298
|
|
248
|
-
@client.get_bounce(@address).
|
299
|
+
@client.get_bounce(@address).must_equal(@json_response_object)
|
249
300
|
end
|
250
301
|
end
|
251
302
|
|
252
303
|
describe 'add_bounce method' do
|
253
|
-
it 'posts to the domain bounces resource and returns
|
254
|
-
stub_request(:post, "#@base_url/#@domain/bounces")
|
304
|
+
it 'posts to the domain bounces resource and returns the response object' do
|
305
|
+
stub_request(:post, "#@base_url/#@domain/bounces").to_return(@json_response)
|
255
306
|
|
256
|
-
@client.add_bounce({}).
|
307
|
+
@client.add_bounce({}).must_equal(@json_response_object)
|
257
308
|
end
|
258
309
|
|
259
310
|
it 'encodes the bounce attributes' do
|
@@ -264,18 +315,18 @@ describe 'Mailgunner::Client' do
|
|
264
315
|
end
|
265
316
|
|
266
317
|
describe 'delete_bounce method' do
|
267
|
-
it 'deletes the domain bounce resource with the given address and returns
|
268
|
-
stub_request(:delete, "#@base_url/#@domain/bounces/#@encoded_address")
|
318
|
+
it 'deletes the domain bounce resource with the given address and returns the response object' do
|
319
|
+
stub_request(:delete, "#@base_url/#@domain/bounces/#@encoded_address").to_return(@json_response)
|
269
320
|
|
270
|
-
@client.delete_bounce(@address).
|
321
|
+
@client.delete_bounce(@address).must_equal(@json_response_object)
|
271
322
|
end
|
272
323
|
end
|
273
324
|
|
274
325
|
describe 'get_stats method' do
|
275
|
-
it 'fetches the domain stats resource and returns
|
276
|
-
stub_request(:get, "#@base_url/#@domain/stats")
|
326
|
+
it 'fetches the domain stats resource and returns the response object' do
|
327
|
+
stub_request(:get, "#@base_url/#@domain/stats").to_return(@json_response)
|
277
328
|
|
278
|
-
@client.get_stats.
|
329
|
+
@client.get_stats.must_equal(@json_response_object)
|
279
330
|
end
|
280
331
|
|
281
332
|
it 'encodes skip and limit parameters' do
|
@@ -292,10 +343,10 @@ describe 'Mailgunner::Client' do
|
|
292
343
|
end
|
293
344
|
|
294
345
|
describe 'get_events method' do
|
295
|
-
it 'fetches the domain events resource and returns
|
296
|
-
stub_request(:get, "#@base_url/#@domain/events")
|
346
|
+
it 'fetches the domain events resource and returns the response object' do
|
347
|
+
stub_request(:get, "#@base_url/#@domain/events").to_return(@json_response)
|
297
348
|
|
298
|
-
@client.get_events.
|
349
|
+
@client.get_events.must_equal(@json_response_object)
|
299
350
|
end
|
300
351
|
|
301
352
|
it 'encodes optional parameters' do
|
@@ -306,10 +357,10 @@ describe 'Mailgunner::Client' do
|
|
306
357
|
end
|
307
358
|
|
308
359
|
describe 'get_routes method' do
|
309
|
-
it 'fetches the routes resource and returns
|
310
|
-
stub_request(:get, "#@base_url/routes")
|
360
|
+
it 'fetches the routes resource and returns the response object' do
|
361
|
+
stub_request(:get, "#@base_url/routes").to_return(@json_response)
|
311
362
|
|
312
|
-
@client.get_routes.
|
363
|
+
@client.get_routes.must_equal(@json_response_object)
|
313
364
|
end
|
314
365
|
|
315
366
|
it 'encodes skip and limit parameters' do
|
@@ -320,18 +371,18 @@ describe 'Mailgunner::Client' do
|
|
320
371
|
end
|
321
372
|
|
322
373
|
describe 'get_route method' do
|
323
|
-
it 'fetches the route resource with the given id and returns
|
324
|
-
stub_request(:get, "#@base_url/routes/4f3bad2335335426750048c6")
|
374
|
+
it 'fetches the route resource with the given id and returns the response object' do
|
375
|
+
stub_request(:get, "#@base_url/routes/4f3bad2335335426750048c6").to_return(@json_response)
|
325
376
|
|
326
|
-
@client.get_route('4f3bad2335335426750048c6').
|
377
|
+
@client.get_route('4f3bad2335335426750048c6').must_equal(@json_response_object)
|
327
378
|
end
|
328
379
|
end
|
329
380
|
|
330
381
|
describe 'add_route method' do
|
331
|
-
it 'posts to the routes resource and returns
|
332
|
-
stub_request(:post, "#@base_url/routes")
|
382
|
+
it 'posts to the routes resource and returns the response object' do
|
383
|
+
stub_request(:post, "#@base_url/routes").to_return(@json_response)
|
333
384
|
|
334
|
-
@client.add_route({}).
|
385
|
+
@client.add_route({}).must_equal(@json_response_object)
|
335
386
|
end
|
336
387
|
|
337
388
|
it 'encodes the route attributes' do
|
@@ -342,10 +393,10 @@ describe 'Mailgunner::Client' do
|
|
342
393
|
end
|
343
394
|
|
344
395
|
describe 'update_route method' do
|
345
|
-
it 'updates the route resource with the given id and returns
|
346
|
-
stub_request(:put, "#@base_url/routes/4f3bad2335335426750048c6")
|
396
|
+
it 'updates the route resource with the given id and returns the response object' do
|
397
|
+
stub_request(:put, "#@base_url/routes/4f3bad2335335426750048c6").to_return(@json_response)
|
347
398
|
|
348
|
-
@client.update_route('4f3bad2335335426750048c6', {}).
|
399
|
+
@client.update_route('4f3bad2335335426750048c6', {}).must_equal(@json_response_object)
|
349
400
|
end
|
350
401
|
|
351
402
|
it 'encodes the route attributes' do
|
@@ -356,18 +407,18 @@ describe 'Mailgunner::Client' do
|
|
356
407
|
end
|
357
408
|
|
358
409
|
describe 'delete_route method' do
|
359
|
-
it 'deletes the route resource with the given id and returns
|
360
|
-
stub_request(:delete, "#@base_url/routes/4f3bad2335335426750048c6")
|
410
|
+
it 'deletes the route resource with the given id and returns the response object' do
|
411
|
+
stub_request(:delete, "#@base_url/routes/4f3bad2335335426750048c6").to_return(@json_response)
|
361
412
|
|
362
|
-
@client.delete_route('4f3bad2335335426750048c6').
|
413
|
+
@client.delete_route('4f3bad2335335426750048c6').must_equal(@json_response_object)
|
363
414
|
end
|
364
415
|
end
|
365
416
|
|
366
417
|
describe 'get_campaigns method' do
|
367
|
-
it 'fetches the domain campaigns resource and returns
|
368
|
-
stub_request(:get, "#@base_url/#@domain/campaigns")
|
418
|
+
it 'fetches the domain campaigns resource and returns the response object' do
|
419
|
+
stub_request(:get, "#@base_url/#@domain/campaigns").to_return(@json_response)
|
369
420
|
|
370
|
-
@client.get_campaigns.
|
421
|
+
@client.get_campaigns.must_equal(@json_response_object)
|
371
422
|
end
|
372
423
|
|
373
424
|
it 'encodes skip and limit parameters' do
|
@@ -378,18 +429,18 @@ describe 'Mailgunner::Client' do
|
|
378
429
|
end
|
379
430
|
|
380
431
|
describe 'get_campaign method' do
|
381
|
-
it 'fetches the campaign resource with the given id and returns
|
382
|
-
stub_request(:get, "#@base_url/#@domain/campaigns/id")
|
432
|
+
it 'fetches the campaign resource with the given id and returns the response object' do
|
433
|
+
stub_request(:get, "#@base_url/#@domain/campaigns/id").to_return(@json_response)
|
383
434
|
|
384
|
-
@client.get_campaign('id').
|
435
|
+
@client.get_campaign('id').must_equal(@json_response_object)
|
385
436
|
end
|
386
437
|
end
|
387
438
|
|
388
439
|
describe 'add_campaign method' do
|
389
|
-
it 'posts to the domain campaigns resource and returns
|
390
|
-
stub_request(:post, "#@base_url/#@domain/campaigns")
|
440
|
+
it 'posts to the domain campaigns resource and returns the response object' do
|
441
|
+
stub_request(:post, "#@base_url/#@domain/campaigns").to_return(@json_response)
|
391
442
|
|
392
|
-
@client.add_campaign({}).
|
443
|
+
@client.add_campaign({}).must_equal(@json_response_object)
|
393
444
|
end
|
394
445
|
|
395
446
|
it 'encodes the campaign attributes' do
|
@@ -400,10 +451,10 @@ describe 'Mailgunner::Client' do
|
|
400
451
|
end
|
401
452
|
|
402
453
|
describe 'update_campaign method' do
|
403
|
-
it 'updates the campaign resource and returns
|
404
|
-
stub_request(:put, "#@base_url/#@domain/campaigns/id")
|
454
|
+
it 'updates the campaign resource and returns the response object' do
|
455
|
+
stub_request(:put, "#@base_url/#@domain/campaigns/id").to_return(@json_response)
|
405
456
|
|
406
|
-
@client.update_campaign('id', {}).
|
457
|
+
@client.update_campaign('id', {}).must_equal(@json_response_object)
|
407
458
|
end
|
408
459
|
|
409
460
|
it 'encodes the campaign attributes' do
|
@@ -414,18 +465,18 @@ describe 'Mailgunner::Client' do
|
|
414
465
|
end
|
415
466
|
|
416
467
|
describe 'delete_campaign method' do
|
417
|
-
it 'deletes the domain campaign resource with the given id and returns
|
418
|
-
stub_request(:delete, "#@base_url/#@domain/campaigns/id")
|
468
|
+
it 'deletes the domain campaign resource with the given id and returns the response object' do
|
469
|
+
stub_request(:delete, "#@base_url/#@domain/campaigns/id").to_return(@json_response)
|
419
470
|
|
420
|
-
@client.delete_campaign('id').
|
471
|
+
@client.delete_campaign('id').must_equal(@json_response_object)
|
421
472
|
end
|
422
473
|
end
|
423
474
|
|
424
475
|
describe 'get_campaign_events method' do
|
425
|
-
it 'fetches the domain campaign events resource and returns
|
426
|
-
stub_request(:get, "#@base_url/#@domain/campaigns/id/events")
|
476
|
+
it 'fetches the domain campaign events resource and returns the response object' do
|
477
|
+
stub_request(:get, "#@base_url/#@domain/campaigns/id/events").to_return(@json_response)
|
427
478
|
|
428
|
-
@client.get_campaign_events('id').
|
479
|
+
@client.get_campaign_events('id').must_equal(@json_response_object)
|
429
480
|
end
|
430
481
|
|
431
482
|
it 'encodes the optional parameters' do
|
@@ -436,10 +487,10 @@ describe 'Mailgunner::Client' do
|
|
436
487
|
end
|
437
488
|
|
438
489
|
describe 'get_campaign_stats method' do
|
439
|
-
it 'fetches the domain campaign stats resource and returns
|
440
|
-
stub_request(:get, "#@base_url/#@domain/campaigns/id/stats")
|
490
|
+
it 'fetches the domain campaign stats resource and returns the response object' do
|
491
|
+
stub_request(:get, "#@base_url/#@domain/campaigns/id/stats").to_return(@json_response)
|
441
492
|
|
442
|
-
@client.get_campaign_stats('id').
|
493
|
+
@client.get_campaign_stats('id').must_equal(@json_response_object)
|
443
494
|
end
|
444
495
|
|
445
496
|
it 'encodes the optional parameters' do
|
@@ -450,10 +501,10 @@ describe 'Mailgunner::Client' do
|
|
450
501
|
end
|
451
502
|
|
452
503
|
describe 'get_campaign_clicks method' do
|
453
|
-
it 'fetches the domain campaign clicks resource and returns
|
454
|
-
stub_request(:get, "#@base_url/#@domain/campaigns/id/clicks")
|
504
|
+
it 'fetches the domain campaign clicks resource and returns the response object' do
|
505
|
+
stub_request(:get, "#@base_url/#@domain/campaigns/id/clicks").to_return(@json_response)
|
455
506
|
|
456
|
-
@client.get_campaign_clicks('id').
|
507
|
+
@client.get_campaign_clicks('id').must_equal(@json_response_object)
|
457
508
|
end
|
458
509
|
|
459
510
|
it 'encodes the optional parameters' do
|
@@ -464,10 +515,10 @@ describe 'Mailgunner::Client' do
|
|
464
515
|
end
|
465
516
|
|
466
517
|
describe 'get_campaign_opens method' do
|
467
|
-
it 'fetches the domain campaign opens resource and returns
|
468
|
-
stub_request(:get, "#@base_url/#@domain/campaigns/id/opens")
|
518
|
+
it 'fetches the domain campaign opens resource and returns the response object' do
|
519
|
+
stub_request(:get, "#@base_url/#@domain/campaigns/id/opens").to_return(@json_response)
|
469
520
|
|
470
|
-
@client.get_campaign_opens('id').
|
521
|
+
@client.get_campaign_opens('id').must_equal(@json_response_object)
|
471
522
|
end
|
472
523
|
|
473
524
|
it 'encodes the optional parameters' do
|
@@ -478,10 +529,10 @@ describe 'Mailgunner::Client' do
|
|
478
529
|
end
|
479
530
|
|
480
531
|
describe 'get_campaign_unsubscribes method' do
|
481
|
-
it 'fetches the domain campaign unsubscribes resource and returns
|
482
|
-
stub_request(:get, "#@base_url/#@domain/campaigns/id/unsubscribes")
|
532
|
+
it 'fetches the domain campaign unsubscribes resource and returns the response object' do
|
533
|
+
stub_request(:get, "#@base_url/#@domain/campaigns/id/unsubscribes").to_return(@json_response)
|
483
534
|
|
484
|
-
@client.get_campaign_unsubscribes('id').
|
535
|
+
@client.get_campaign_unsubscribes('id').must_equal(@json_response_object)
|
485
536
|
end
|
486
537
|
|
487
538
|
it 'encodes the optional parameters' do
|
@@ -492,10 +543,10 @@ describe 'Mailgunner::Client' do
|
|
492
543
|
end
|
493
544
|
|
494
545
|
describe 'get_campaign_complaints method' do
|
495
|
-
it 'fetches the domain campaign complaints resource and returns
|
496
|
-
stub_request(:get, "#@base_url/#@domain/campaigns/id/complaints")
|
546
|
+
it 'fetches the domain campaign complaints resource and returns the response object' do
|
547
|
+
stub_request(:get, "#@base_url/#@domain/campaigns/id/complaints").to_return(@json_response)
|
497
548
|
|
498
|
-
@client.get_campaign_complaints('id').
|
549
|
+
@client.get_campaign_complaints('id').must_equal(@json_response_object)
|
499
550
|
end
|
500
551
|
|
501
552
|
it 'encodes the optional parameters' do
|
@@ -506,10 +557,10 @@ describe 'Mailgunner::Client' do
|
|
506
557
|
end
|
507
558
|
|
508
559
|
describe 'get_lists method' do
|
509
|
-
it 'fetches the lists resource and returns
|
510
|
-
stub_request(:get, "#@base_url/lists")
|
560
|
+
it 'fetches the lists resource and returns the response object' do
|
561
|
+
stub_request(:get, "#@base_url/lists").to_return(@json_response)
|
511
562
|
|
512
|
-
@client.get_lists.
|
563
|
+
@client.get_lists.must_equal(@json_response_object)
|
513
564
|
end
|
514
565
|
|
515
566
|
it 'encodes skip and limit parameters' do
|
@@ -520,18 +571,18 @@ describe 'Mailgunner::Client' do
|
|
520
571
|
end
|
521
572
|
|
522
573
|
describe 'get_list method' do
|
523
|
-
it 'fetches the list resource with the given address and returns
|
524
|
-
stub_request(:get, "#@base_url/lists/developers%40mailgun.net")
|
574
|
+
it 'fetches the list resource with the given address and returns the response object' do
|
575
|
+
stub_request(:get, "#@base_url/lists/developers%40mailgun.net").to_return(@json_response)
|
525
576
|
|
526
|
-
@client.get_list('developers@mailgun.net').
|
577
|
+
@client.get_list('developers@mailgun.net').must_equal(@json_response_object)
|
527
578
|
end
|
528
579
|
end
|
529
580
|
|
530
581
|
describe 'add_list method' do
|
531
|
-
it 'posts to the lists resource and returns
|
532
|
-
stub_request(:post, "#@base_url/lists")
|
582
|
+
it 'posts to the lists resource and returns the response object' do
|
583
|
+
stub_request(:post, "#@base_url/lists").to_return(@json_response)
|
533
584
|
|
534
|
-
@client.add_list({}).
|
585
|
+
@client.add_list({}).must_equal(@json_response_object)
|
535
586
|
end
|
536
587
|
|
537
588
|
it 'encodes the list attributes' do
|
@@ -542,10 +593,10 @@ describe 'Mailgunner::Client' do
|
|
542
593
|
end
|
543
594
|
|
544
595
|
describe 'update_list method' do
|
545
|
-
it 'updates the list resource and returns
|
546
|
-
stub_request(:put, "#@base_url/lists/developers%40mailgun.net")
|
596
|
+
it 'updates the list resource and returns the response object' do
|
597
|
+
stub_request(:put, "#@base_url/lists/developers%40mailgun.net").to_return(@json_response)
|
547
598
|
|
548
|
-
@client.update_list('developers@mailgun.net', {}).
|
599
|
+
@client.update_list('developers@mailgun.net', {}).must_equal(@json_response_object)
|
549
600
|
end
|
550
601
|
|
551
602
|
it 'encodes the list attributes' do
|
@@ -556,18 +607,18 @@ describe 'Mailgunner::Client' do
|
|
556
607
|
end
|
557
608
|
|
558
609
|
describe 'delete_list method' do
|
559
|
-
it 'deletes the list resource with the given address and returns
|
560
|
-
stub_request(:delete, "#@base_url/lists/developers%40mailgun.net")
|
610
|
+
it 'deletes the list resource with the given address and returns the response object' do
|
611
|
+
stub_request(:delete, "#@base_url/lists/developers%40mailgun.net").to_return(@json_response)
|
561
612
|
|
562
|
-
@client.delete_list('developers@mailgun.net').
|
613
|
+
@client.delete_list('developers@mailgun.net').must_equal(@json_response_object)
|
563
614
|
end
|
564
615
|
end
|
565
616
|
|
566
617
|
describe 'get_list_members method' do
|
567
|
-
it 'fetches the list members resource and returns
|
568
|
-
stub_request(:get, "#@base_url/lists/developers%40mailgun.net/members")
|
618
|
+
it 'fetches the list members resource and returns the response object' do
|
619
|
+
stub_request(:get, "#@base_url/lists/developers%40mailgun.net/members").to_return(@json_response)
|
569
620
|
|
570
|
-
@client.get_list_members('developers@mailgun.net').
|
621
|
+
@client.get_list_members('developers@mailgun.net').must_equal(@json_response_object)
|
571
622
|
end
|
572
623
|
|
573
624
|
it 'encodes skip and limit parameters' do
|
@@ -578,18 +629,18 @@ describe 'Mailgunner::Client' do
|
|
578
629
|
end
|
579
630
|
|
580
631
|
describe 'get_list_member method' do
|
581
|
-
it 'fetches the list member resource with the given address and returns
|
582
|
-
stub_request(:get, "#@base_url/lists/developers%40mailgun.net/members/#@encoded_address")
|
632
|
+
it 'fetches the list member resource with the given address and returns the response object' do
|
633
|
+
stub_request(:get, "#@base_url/lists/developers%40mailgun.net/members/#@encoded_address").to_return(@json_response)
|
583
634
|
|
584
|
-
@client.get_list_member('developers@mailgun.net', @address).
|
635
|
+
@client.get_list_member('developers@mailgun.net', @address).must_equal(@json_response_object)
|
585
636
|
end
|
586
637
|
end
|
587
638
|
|
588
639
|
describe 'add_list_member method' do
|
589
|
-
it 'posts to the list members resource and returns
|
590
|
-
stub_request(:post, "#@base_url/lists/developers%40mailgun.net/members")
|
640
|
+
it 'posts to the list members resource and returns the response object' do
|
641
|
+
stub_request(:post, "#@base_url/lists/developers%40mailgun.net/members").to_return(@json_response)
|
591
642
|
|
592
|
-
@client.add_list_member('developers@mailgun.net', {}).
|
643
|
+
@client.add_list_member('developers@mailgun.net', {}).must_equal(@json_response_object)
|
593
644
|
end
|
594
645
|
|
595
646
|
it 'encodes the list attributes' do
|
@@ -600,10 +651,10 @@ describe 'Mailgunner::Client' do
|
|
600
651
|
end
|
601
652
|
|
602
653
|
describe 'update_list_member method' do
|
603
|
-
it 'updates the list member resource with the given address and returns
|
604
|
-
stub_request(:put, "#@base_url/lists/developers%40mailgun.net/members/#@encoded_address")
|
654
|
+
it 'updates the list member resource with the given address and returns the response object' do
|
655
|
+
stub_request(:put, "#@base_url/lists/developers%40mailgun.net/members/#@encoded_address").to_return(@json_response)
|
605
656
|
|
606
|
-
@client.update_list_member('developers@mailgun.net', @address, {}).
|
657
|
+
@client.update_list_member('developers@mailgun.net', @address, {}).must_equal(@json_response_object)
|
607
658
|
end
|
608
659
|
|
609
660
|
it 'encodes the list member attributes' do
|
@@ -614,26 +665,18 @@ describe 'Mailgunner::Client' do
|
|
614
665
|
end
|
615
666
|
|
616
667
|
describe 'delete_list_member method' do
|
617
|
-
it 'deletes the list member resource with the given address and returns
|
618
|
-
stub_request(:delete, "#@base_url/lists/developers%40mailgun.net/members/#@encoded_address")
|
668
|
+
it 'deletes the list member resource with the given address and returns the response object' do
|
669
|
+
stub_request(:delete, "#@base_url/lists/developers%40mailgun.net/members/#@encoded_address").to_return(@json_response)
|
619
670
|
|
620
|
-
@client.delete_list_member('developers@mailgun.net', @address).
|
671
|
+
@client.delete_list_member('developers@mailgun.net', @address).must_equal(@json_response_object)
|
621
672
|
end
|
622
673
|
end
|
623
674
|
|
624
675
|
describe 'get_list_stats method' do
|
625
|
-
it 'fetches the list stats resource and returns
|
626
|
-
stub_request(:get, "#@base_url/lists/developers%40mailgun.net/stats")
|
627
|
-
|
628
|
-
@client.get_list_stats('developers@mailgun.net').must_be_instance_of(Mailgunner::Response)
|
629
|
-
end
|
630
|
-
end
|
631
|
-
|
632
|
-
describe 'when initialized with a different json implementation' do
|
633
|
-
it 'emits a deprecation warning' do
|
634
|
-
Kernel.expects(:warn).with(regexp_matches(/Mailgunner::Client :json option is deprecated/))
|
676
|
+
it 'fetches the list stats resource and returns the response object' do
|
677
|
+
stub_request(:get, "#@base_url/lists/developers%40mailgun.net/stats").to_return(@json_response)
|
635
678
|
|
636
|
-
|
679
|
+
@client.get_list_stats('developers@mailgun.net').must_equal(@json_response_object)
|
637
680
|
end
|
638
681
|
end
|
639
682
|
end
|
metadata
CHANGED
@@ -1,96 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailgunner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tim Craft
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-07-29 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
19
|
+
version: '10.1'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: mocha
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 0.13.2
|
38
|
-
type: :development
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 0.13.2
|
26
|
+
version: '10.1'
|
46
27
|
- !ruby/object:Gem::Dependency
|
47
28
|
name: webmock
|
48
29
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
30
|
requirements:
|
51
|
-
- - ~>
|
31
|
+
- - "~>"
|
52
32
|
- !ruby/object:Gem::Version
|
53
|
-
version: 1.
|
33
|
+
version: '1.18'
|
54
34
|
type: :development
|
55
35
|
prerelease: false
|
56
36
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
37
|
requirements:
|
59
|
-
- - ~>
|
38
|
+
- - "~>"
|
60
39
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
40
|
+
version: '1.18'
|
62
41
|
- !ruby/object:Gem::Dependency
|
63
42
|
name: mail
|
64
43
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
44
|
requirements:
|
67
|
-
- - ~>
|
45
|
+
- - "~>"
|
68
46
|
- !ruby/object:Gem::Version
|
69
|
-
version: 2.5
|
47
|
+
version: '2.5'
|
70
48
|
type: :development
|
71
49
|
prerelease: false
|
72
50
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
51
|
requirements:
|
75
|
-
- - ~>
|
52
|
+
- - "~>"
|
76
53
|
- !ruby/object:Gem::Version
|
77
|
-
version: 2.5
|
54
|
+
version: '2.5'
|
78
55
|
- !ruby/object:Gem::Dependency
|
79
56
|
name: actionmailer
|
80
57
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
58
|
requirements:
|
83
|
-
- - ~>
|
59
|
+
- - "~>"
|
84
60
|
- !ruby/object:Gem::Version
|
85
|
-
version: 4.0
|
61
|
+
version: '4.0'
|
86
62
|
type: :development
|
87
63
|
prerelease: false
|
88
64
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
65
|
requirements:
|
91
|
-
- - ~>
|
66
|
+
- - "~>"
|
92
67
|
- !ruby/object:Gem::Version
|
93
|
-
version: 4.0
|
68
|
+
version: '4.0'
|
94
69
|
description: A Ruby wrapper for the Mailgun API
|
95
70
|
email:
|
96
71
|
- mail@timcraft.com
|
@@ -98,37 +73,33 @@ executables: []
|
|
98
73
|
extensions: []
|
99
74
|
extra_rdoc_files: []
|
100
75
|
files:
|
101
|
-
-
|
102
|
-
- lib/mailgunner/response.rb
|
76
|
+
- README.md
|
103
77
|
- lib/mailgunner.rb
|
78
|
+
- lib/mailgunner/delivery_method.rb
|
79
|
+
- mailgunner.gemspec
|
104
80
|
- spec/mailgunner_delivery_method_spec.rb
|
105
|
-
- spec/mailgunner_response_spec.rb
|
106
81
|
- spec/mailgunner_spec.rb
|
107
|
-
- README.md
|
108
|
-
- mailgunner.gemspec
|
109
82
|
homepage: http://github.com/timcraft/mailgunner
|
110
83
|
licenses: []
|
84
|
+
metadata: {}
|
111
85
|
post_install_message:
|
112
86
|
rdoc_options: []
|
113
87
|
require_paths:
|
114
88
|
- lib
|
115
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
116
|
-
none: false
|
117
90
|
requirements:
|
118
|
-
- -
|
91
|
+
- - ">="
|
119
92
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
93
|
+
version: 1.9.3
|
121
94
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
95
|
requirements:
|
124
|
-
- -
|
96
|
+
- - ">="
|
125
97
|
- !ruby/object:Gem::Version
|
126
98
|
version: '0'
|
127
99
|
requirements: []
|
128
100
|
rubyforge_project:
|
129
|
-
rubygems_version:
|
101
|
+
rubygems_version: 2.2.2
|
130
102
|
signing_key:
|
131
|
-
specification_version:
|
103
|
+
specification_version: 4
|
132
104
|
summary: See description
|
133
105
|
test_files: []
|
134
|
-
has_rdoc:
|
data/lib/mailgunner/response.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
module Mailgunner
|
2
|
-
class Response
|
3
|
-
def initialize(http_response, options = {})
|
4
|
-
@http_response = http_response
|
5
|
-
|
6
|
-
@json = options.fetch(:json) { JSON }
|
7
|
-
end
|
8
|
-
|
9
|
-
def method_missing(name, *args, &block)
|
10
|
-
@http_response.send(name, *args, &block)
|
11
|
-
end
|
12
|
-
|
13
|
-
def respond_to_missing?(name, include_private = false)
|
14
|
-
@http_response.respond_to?(name)
|
15
|
-
end
|
16
|
-
|
17
|
-
def ok?
|
18
|
-
code.to_i == 200
|
19
|
-
end
|
20
|
-
|
21
|
-
def client_error?
|
22
|
-
(400 .. 499).include?(code.to_i)
|
23
|
-
end
|
24
|
-
|
25
|
-
def server_error?
|
26
|
-
(500 .. 599).include?(code.to_i)
|
27
|
-
end
|
28
|
-
|
29
|
-
def json?
|
30
|
-
self['Content-Type'].split(';').first == 'application/json'
|
31
|
-
end
|
32
|
-
|
33
|
-
def object
|
34
|
-
@object ||= @json.parse(body)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
require 'minitest/autorun'
|
2
|
-
require 'mocha/setup'
|
3
|
-
require 'mailgunner'
|
4
|
-
|
5
|
-
describe 'Mailgunner::Response' do
|
6
|
-
before do
|
7
|
-
@http_response = mock()
|
8
|
-
|
9
|
-
@response = Mailgunner::Response.new(@http_response)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'delegates missing methods to the http response object' do
|
13
|
-
@http_response.stubs(:code).returns('200')
|
14
|
-
|
15
|
-
@response.code.must_equal('200')
|
16
|
-
end
|
17
|
-
|
18
|
-
describe 'ok query method' do
|
19
|
-
it 'returns true if the status code is 200' do
|
20
|
-
@http_response.expects(:code).returns('200')
|
21
|
-
|
22
|
-
@response.ok?.must_equal(true)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'returns false otherwise' do
|
26
|
-
@http_response.expects(:code).returns('400')
|
27
|
-
|
28
|
-
@response.ok?.must_equal(false)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe 'client_error query method' do
|
33
|
-
it 'returns true if the status code is 4xx' do
|
34
|
-
@http_response.stubs(:code).returns(%w(400 401 402 404).sample)
|
35
|
-
|
36
|
-
@response.client_error?.must_equal(true)
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'returns false otherwise' do
|
40
|
-
@http_response.stubs(:code).returns('200')
|
41
|
-
|
42
|
-
@response.client_error?.must_equal(false)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe 'server_error query method' do
|
47
|
-
it 'returns true if the status code is 5xx' do
|
48
|
-
@http_response.stubs(:code).returns(%w(500 502 503 504).sample)
|
49
|
-
|
50
|
-
@response.server_error?.must_equal(true)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'returns false otherwise' do
|
54
|
-
@http_response.stubs(:code).returns('200')
|
55
|
-
|
56
|
-
@response.server_error?.must_equal(false)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'json query method' do
|
61
|
-
it 'returns true if the response has a json content type' do
|
62
|
-
@http_response.expects(:[]).with('Content-Type').returns('application/json;charset=utf-8')
|
63
|
-
|
64
|
-
@response.json?.must_equal(true)
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'returns false otherwise' do
|
68
|
-
@http_response.expects(:[]).with('Content-Type').returns('text/html')
|
69
|
-
|
70
|
-
@response.json?.must_equal(false)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe 'object method' do
|
75
|
-
it 'decodes the response body as json and returns a hash' do
|
76
|
-
@http_response.expects(:body).returns('{"foo":"bar"}')
|
77
|
-
|
78
|
-
@response.object.must_equal({'foo' => 'bar'})
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe 'Mailgunner::Response initialized with an alternative json implementation' do
|
84
|
-
before do
|
85
|
-
@json = mock()
|
86
|
-
|
87
|
-
@http_response = stub
|
88
|
-
|
89
|
-
@response = Mailgunner::Response.new(@http_response, :json => @json)
|
90
|
-
end
|
91
|
-
|
92
|
-
describe 'object method' do
|
93
|
-
it 'uses the alternative json implementation to parse the response body' do
|
94
|
-
@http_response.stubs(:body).returns(response_body = '{"foo":"bar"}')
|
95
|
-
|
96
|
-
@json.expects(:parse).with(response_body)
|
97
|
-
|
98
|
-
@response.object
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|