mailgun-ruby 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/docs/OptInHandler.md +1 -1
- data/lib/mailgun/exceptions/exceptions.rb +7 -1
- data/lib/mailgun/version.rb +1 -1
- data/lib/mailgun-ruby.rb +1 -1
- data/spec/unit/connection/test_client.rb +2 -1
- data/spec/unit/mailgun_spec.rb +19 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dd7b99f66b317ffcbf86172b1534cdcb0ccf4b0b25a7b2e58599f20ef021f11
|
4
|
+
data.tar.gz: 8b130d3344fe905d20d4230cb8b178d29b092ffa6d21c3dbb085376aa53b50a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34729e98ab4eb8cbfd04bdb5b7a090a30cb4a1961de9ef38e0adcab2d452e5873477d9b45de9703a6c5885b272a3d62429ece40ff6029bff2bbb0d8585a89410
|
7
|
+
data.tar.gz: 235e7aed52a937315019498bbb710e90b97128d9fdfad86bfb0995daf9d25f8185683769fd84b32e4eda4c64774b49a708a57da90ccd473e7d69f0e967eed581
|
data/README.md
CHANGED
data/docs/OptInHandler.md
CHANGED
@@ -100,4 +100,4 @@ Available Functions
|
|
100
100
|
|
101
101
|
More Documentation
|
102
102
|
------------------
|
103
|
-
See the official [Mailgun Docs](https://documentation.mailgun.com/api-sending.html) for more information.
|
103
|
+
See the official [Mailgun Docs](https://documentation.mailgun.com/en/latest/api-sending.html) for more information.
|
@@ -43,7 +43,11 @@ module Mailgun
|
|
43
43
|
#
|
44
44
|
def initialize(message = nil, response = nil)
|
45
45
|
@response = response
|
46
|
-
@code = response.
|
46
|
+
@code = if response.nil?
|
47
|
+
NOCODE
|
48
|
+
else
|
49
|
+
response.code
|
50
|
+
end
|
47
51
|
|
48
52
|
begin
|
49
53
|
api_message = JSON.parse(response.body)['message']
|
@@ -51,6 +55,8 @@ module Mailgun
|
|
51
55
|
api_message = response.body
|
52
56
|
rescue NoMethodError
|
53
57
|
api_message = "Unknown API error"
|
58
|
+
rescue
|
59
|
+
api_message = 'Unknown API error'
|
54
60
|
end
|
55
61
|
api_message = api_message + ' - Invalid Domain or API key' if api_message == FORBIDDEN
|
56
62
|
|
data/lib/mailgun/version.rb
CHANGED
data/lib/mailgun-ruby.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
require 'mailgun'
|
2
|
-
require 'railgun' if defined?(Rails)
|
2
|
+
require 'railgun' if defined?(Rails) && defined?(ActionMailer)
|
@@ -46,7 +46,8 @@ module Mailgun
|
|
46
46
|
Mailgun::Response.new(response_generator(@endpoint))
|
47
47
|
rescue => e
|
48
48
|
p e
|
49
|
-
raise CommunicationError.new(e), e.response
|
49
|
+
raise CommunicationError.new(e), e.response if e.respond_to? :response
|
50
|
+
raise CommunicationError.new(e.message)
|
50
51
|
end
|
51
52
|
end
|
52
53
|
|
data/spec/unit/mailgun_spec.rb
CHANGED
@@ -87,6 +87,25 @@ describe 'The method post()' do
|
|
87
87
|
expect(result.body).to include("message")
|
88
88
|
expect(result.body).to include("id")
|
89
89
|
end
|
90
|
+
|
91
|
+
context 'when Unknown API error is raised' do
|
92
|
+
before do
|
93
|
+
allow(Mailgun::Response).to receive(:new).and_raise(StandardError, "message")
|
94
|
+
allow(JSON).to receive(:parse).and_raise('Unknown')
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'adds Unknown API error to message' do
|
98
|
+
data = {'from' => 'joe@test.com',
|
99
|
+
'to' => 'bob@example.com',
|
100
|
+
'subject' => 'Test',
|
101
|
+
'text' => 'Test Data'}
|
102
|
+
@mg_obj.post("#{@domain}/messages", data)
|
103
|
+
rescue Mailgun::CommunicationError => err
|
104
|
+
expect(err.message).to eq('message: Unknown API error')
|
105
|
+
else
|
106
|
+
fail
|
107
|
+
end
|
108
|
+
end
|
90
109
|
end
|
91
110
|
|
92
111
|
describe 'The method put()' do
|
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.2.
|
4
|
+
version: 1.2.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:
|
12
|
+
date: 2022-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|