mailgun-ruby 1.2.5 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeb68d33e0686c3074e829fa7c33c1a9300c31bd9db3b7fde74abfdbdd681a31
4
- data.tar.gz: dc0cd7912abb804476731ba487186a362595f7806d88f50bbbe2296da8eb0b5b
3
+ metadata.gz: 9dd7b99f66b317ffcbf86172b1534cdcb0ccf4b0b25a7b2e58599f20ef021f11
4
+ data.tar.gz: 8b130d3344fe905d20d4230cb8b178d29b092ffa6d21c3dbb085376aa53b50a0
5
5
  SHA512:
6
- metadata.gz: 9469121fbdd8341af7cc6ee395d35d8f487f556b67d8b6a0d2b6cd874f4bb1828384f9aff7c6751377fa56182b7c890947e40444f09d583d97aca8f90c41c642
7
- data.tar.gz: 2f2b70e53e187c28ea3fcf3d3abc3f208886baca01732af0bb233c154bd171565790279620fe392259f3fa74151276d4e281389606d35ce60047b6f9a922a7cf
6
+ metadata.gz: 34729e98ab4eb8cbfd04bdb5b7a090a30cb4a1961de9ef38e0adcab2d452e5873477d9b45de9703a6c5885b272a3d62429ece40ff6029bff2bbb0d8585a89410
7
+ data.tar.gz: 235e7aed52a937315019498bbb710e90b97128d9fdfad86bfb0995daf9d25f8185683769fd84b32e4eda4c64774b49a708a57da90ccd473e7d69f0e967eed581
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.2.5'
22
+ gem 'mailgun-ruby', '~>1.2.6'
23
23
  ```
24
24
 
25
25
  Usage
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.code || NOCODE
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
 
@@ -1,4 +1,4 @@
1
1
  # It's the version. Yeay!
2
2
  module Mailgun
3
- VERSION = '1.2.5'
3
+ VERSION = '1.2.6'
4
4
  end
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
 
@@ -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.5
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: 2021-06-10 00:00:00.000000000 Z
12
+ date: 2022-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler