postmark 1.21.5 → 1.21.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: 5f37af7becb4542a52b09dac6ddbf4f8dd9a0e8865f58c09d09d589a4df99d52
4
- data.tar.gz: b1f0853ddb0d5df6ed028b73f838cc23ed4438955280c3374b94bb4d4dd1d002
3
+ metadata.gz: 6b42f4ec6b9f264b0ecdd3b4f6189a68f85436af6953c869d4b5e20d4d08abde
4
+ data.tar.gz: a755605d53ffd4b8ba7f1707b42e97592eb93510968898854456e1ad368f40c2
5
5
  SHA512:
6
- metadata.gz: 5fff0cb52f3fa2368e7e930b480cc020a5f7783c5b946be06b39537f4c4673c191b7861083ddadfdbed395767377ad885c8ef218f8af6801cb3d9e84fdf94826
7
- data.tar.gz: e649bf1192c4669f22622427cf986f6b53369f0a0c1c0bf3e97b6e782b6c4400d53b2d2e06f87cf2c24d853317c601c8b72c3a607f6b23ac7142fa517c566799
6
+ metadata.gz: 5b6a7eaec4d234210f99e12ab0bf2301a42e3fcd21f6a369640b3dd032a0a3ba25e1f6a3afd1bcbebceac227802c8e4cea945951923a83c7191154f66ec23512
7
+ data.tar.gz: 35d6d11418ad06fe1e363e9ac794c3cdab319d827a7f4f12b49a3572d04be0f115638880e6ac475b0a9298e2ada84b8055e247c7fe058c2bb3c4fbf6bb748506
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,9 @@
1
1
  = Changelog
2
2
 
3
+ == 1.21.6
4
+
5
+ * Improved error handling for email sending related to invalid email addresses
6
+
3
7
  == 1.21.5
4
8
 
5
9
  * Added support for archiving/unarchiving message streams
@@ -30,9 +30,8 @@ module Postmark
30
30
  def initialize(status_code = 500, body = '', parsed_body = {})
31
31
  self.parsed_body = parsed_body
32
32
  self.status_code = status_code.to_i
33
- message = parsed_body.fetch(
34
- 'Message',
35
- "The Postmark API responded with HTTP status #{status_code}.")
33
+ self.body = body
34
+ message = parsed_body.fetch('Message', "The Postmark API responded with HTTP status #{status_code}.")
36
35
 
37
36
  super(message)
38
37
  end
@@ -44,6 +43,7 @@ module Postmark
44
43
 
45
44
  class ApiInputError < HttpServerError
46
45
  INACTIVE_RECIPIENT = 406
46
+ INVALID_EMAIL_ADDRESS = 300
47
47
 
48
48
  attr_accessor :error_code
49
49
 
@@ -52,7 +52,9 @@ module Postmark
52
52
 
53
53
  case error_code
54
54
  when INACTIVE_RECIPIENT
55
- InactiveRecipientError.new(INACTIVE_RECIPIENT, body, parsed_body)
55
+ InactiveRecipientError.new(error_code, body, parsed_body)
56
+ when INVALID_EMAIL_ADDRESS
57
+ InvalidEmailAddressError.new(error_code, body, parsed_body)
56
58
  else
57
59
  new(error_code, body, parsed_body)
58
60
  end
@@ -68,6 +70,8 @@ module Postmark
68
70
  end
69
71
  end
70
72
 
73
+ class InvalidEmailAddressError < ApiInputError; end
74
+
71
75
  class InactiveRecipientError < ApiInputError
72
76
  attr_reader :recipients
73
77
 
@@ -1,3 +1,3 @@
1
1
  module Postmark
2
- VERSION = '1.21.5'
2
+ VERSION = '1.21.6'
3
3
  end
@@ -97,6 +97,13 @@ describe(Postmark::ApiInputError) do
97
97
  it_behaves_like 'api input error'
98
98
  end
99
99
 
100
+ context '300' do
101
+ let(:code) {Postmark::ApiInputError::INVALID_EMAIL_ADDRESS}
102
+
103
+ it {is_expected.to be_a(Postmark::InvalidEmailAddressError)}
104
+ it_behaves_like 'api input error'
105
+ end
106
+
100
107
  context 'others' do
101
108
  let(:code) {'9999'}
102
109
 
@@ -142,6 +149,33 @@ describe(Postmark::MailAdapterError) do
142
149
  it {is_expected.to be_a(Postmark::Error)}
143
150
  end
144
151
 
152
+ describe(Postmark::InvalidEmailAddressError) do
153
+ describe '.new' do
154
+ let(:response) {{'Message' => message}}
155
+
156
+ subject do
157
+ Postmark::InvalidEmailAddressError.new(
158
+ Postmark::ApiInputError::INVALID_EMAIL_ADDRESS, Postmark::Json.encode(response), response)
159
+ end
160
+
161
+ let(:message) do
162
+ "Error parsing 'To': Illegal email address 'johne.xample.com'. It must contain the '@' symbol."
163
+ end
164
+
165
+ it 'body is set' do
166
+ expect(subject.body).to eq(Postmark::Json.encode(response))
167
+ end
168
+
169
+ it 'parsed body is set' do
170
+ expect(subject.parsed_body).to eq(response)
171
+ end
172
+
173
+ it 'error code is set' do
174
+ expect(subject.error_code).to eq(Postmark::ApiInputError::INVALID_EMAIL_ADDRESS)
175
+ end
176
+ end
177
+ end
178
+
145
179
  describe(Postmark::InactiveRecipientError) do
146
180
  describe '.parse_recipients' do
147
181
  let(:recipients) do
@@ -209,6 +243,18 @@ describe(Postmark::InactiveRecipientError) do
209
243
  it 'parses recipients from json payload' do
210
244
  expect(subject.recipients).to eq([address])
211
245
  end
246
+
247
+ it 'body is set' do
248
+ expect(subject.body).to eq(Postmark::Json.encode(response))
249
+ end
250
+
251
+ it 'parsed body is set' do
252
+ expect(subject.parsed_body).to eq(response)
253
+ end
254
+
255
+ it 'error code is set' do
256
+ expect(subject.error_code).to eq(Postmark::ApiInputError::INACTIVE_RECIPIENT)
257
+ end
212
258
  end
213
259
  end
214
260
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmark
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.21.5
4
+ version: 1.21.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomek Maszkowski