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 +4 -4
- data/CHANGELOG.rdoc +4 -0
- data/lib/postmark/error.rb +8 -4
- data/lib/postmark/version.rb +1 -1
- data/spec/unit/postmark/error_spec.rb +46 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b42f4ec6b9f264b0ecdd3b4f6189a68f85436af6953c869d4b5e20d4d08abde
|
4
|
+
data.tar.gz: a755605d53ffd4b8ba7f1707b42e97592eb93510968898854456e1ad368f40c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6a7eaec4d234210f99e12ab0bf2301a42e3fcd21f6a369640b3dd032a0a3ba25e1f6a3afd1bcbebceac227802c8e4cea945951923a83c7191154f66ec23512
|
7
|
+
data.tar.gz: 35d6d11418ad06fe1e363e9ac794c3cdab319d827a7f4f12b49a3572d04be0f115638880e6ac475b0a9298e2ada84b8055e247c7fe058c2bb3c4fbf6bb748506
|
data/CHANGELOG.rdoc
CHANGED
data/lib/postmark/error.rb
CHANGED
@@ -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
|
-
|
34
|
-
|
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(
|
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
|
|
data/lib/postmark/version.rb
CHANGED
@@ -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
|
|