postmark 1.22.3 → 1.24.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 +4 -4
- data/CHANGELOG.rdoc +6 -0
- data/README.md +9 -0
- data/VERSION +1 -1
- data/lib/postmark/deprecations.rb +35 -0
- data/lib/postmark/error.rb +12 -7
- data/lib/postmark/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/unit/postmark/error_spec.rb +12 -6
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36d183adb014f24f30c12f04f65d01d9a4565e46bac544fcf499f1834d98b15f
|
4
|
+
data.tar.gz: 23d80a64a061b7bce98a7040a0b64b7e56611aea995894764d201e5ee71fdf69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a132d891995e587fc6324cbed9626799a7919f0314b4402910593e47afb02281b25fd6b8971a20197774dd37d48c7221389047699b9cbf98a2cdfecce3e247b6
|
7
|
+
data.tar.gz: 26b78de0eefb4c6055e2edee3f787ddab17c49f49fbbd4e8bf02100f85202cc46d57ff4c140617f0c1cd7c325875e602fc952c8b9a528a9ad9feed25ee9d76b1
|
data/CHANGELOG.rdoc
CHANGED
data/README.md
CHANGED
@@ -48,6 +48,15 @@ Without Bundler:
|
|
48
48
|
gem install postmark
|
49
49
|
```
|
50
50
|
|
51
|
+
## Deprecations
|
52
|
+
|
53
|
+
Deprecations can be either silenced or set to raise using:
|
54
|
+
|
55
|
+
```rb
|
56
|
+
Postmark::Deprecations.behavior = :silence
|
57
|
+
Postmark::Deprecations.behavior = :raise
|
58
|
+
```
|
59
|
+
|
51
60
|
## Note on Patches/Pull Requests
|
52
61
|
|
53
62
|
See [CONTRIBUTING.md](CONTRIBUTING.md) file for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.24.0
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Postmark
|
2
|
+
def self.const_missing(const_name)
|
3
|
+
replacement = Deprecations.deprecated_constants.fetch(const_name, nil) || super
|
4
|
+
Deprecations.report("DEPRECATION WARNING: the class #{const_name} is deprecated. Use #{replacement} instead.")
|
5
|
+
replacement
|
6
|
+
end
|
7
|
+
|
8
|
+
module Deprecations
|
9
|
+
DEFAULT_BEHAVIORS = {
|
10
|
+
:raise => lambda { |message| raise message },
|
11
|
+
:log => lambda { |message| warn message },
|
12
|
+
:silence => lambda { |message| },
|
13
|
+
}
|
14
|
+
|
15
|
+
def self.report(message)
|
16
|
+
DEFAULT_BEHAVIORS.fetch(behavior).call(message)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.deprecated_constants
|
20
|
+
@deprecated_constants ||= {}
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.behavior
|
24
|
+
@behavior ||= :log
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.behavior=(behavior)
|
28
|
+
@behavior = behavior
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.add_constants(mappings)
|
32
|
+
deprecated_constants.merge!(mappings)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/postmark/error.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'postmark/deprecations'
|
2
|
+
|
1
3
|
module Postmark
|
2
4
|
class Error < ::StandardError; end
|
3
5
|
|
@@ -43,7 +45,7 @@ module Postmark
|
|
43
45
|
|
44
46
|
class ApiInputError < HttpServerError
|
45
47
|
INACTIVE_RECIPIENT = 406
|
46
|
-
|
48
|
+
INVALID_EMAIL_REQUEST = 300
|
47
49
|
|
48
50
|
attr_accessor :error_code
|
49
51
|
|
@@ -53,8 +55,8 @@ module Postmark
|
|
53
55
|
case error_code
|
54
56
|
when INACTIVE_RECIPIENT
|
55
57
|
InactiveRecipientError.new(error_code, body, parsed_body)
|
56
|
-
when
|
57
|
-
|
58
|
+
when INVALID_EMAIL_REQUEST
|
59
|
+
InvalidEmailRequestError.new(error_code, body, parsed_body)
|
58
60
|
else
|
59
61
|
new(error_code, body, parsed_body)
|
60
62
|
end
|
@@ -70,7 +72,7 @@ module Postmark
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
|
73
|
-
class
|
75
|
+
class InvalidEmailRequestError < ApiInputError; end
|
74
76
|
|
75
77
|
class InactiveRecipientError < ApiInputError
|
76
78
|
attr_reader :recipients
|
@@ -126,7 +128,10 @@ module Postmark
|
|
126
128
|
class UnexpectedHttpResponseError < HttpServerError; end
|
127
129
|
|
128
130
|
# Backwards compatible aliases
|
129
|
-
|
130
|
-
|
131
|
-
|
131
|
+
Deprecations.add_constants(
|
132
|
+
:DeliveryError => Error,
|
133
|
+
:InvalidMessageError => ApiInputError,
|
134
|
+
:UnknownError => UnexpectedHttpResponseError,
|
135
|
+
:InvalidEmailAddressError => InvalidEmailRequestError
|
136
|
+
)
|
132
137
|
end
|
data/lib/postmark/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -15,6 +15,8 @@ require File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'shared_e
|
|
15
15
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'custom_matchers.rb')
|
16
16
|
require File.join(File.expand_path(File.dirname(__FILE__)), 'support', 'helpers.rb')
|
17
17
|
|
18
|
+
Postmark::Deprecations.behavior = :silence
|
19
|
+
|
18
20
|
if ENV['JSONGEM']
|
19
21
|
# `JSONGEM=Yajl rake spec`
|
20
22
|
Postmark.response_parser_class = ENV['JSONGEM'].to_sym
|
@@ -98,9 +98,9 @@ describe(Postmark::ApiInputError) do
|
|
98
98
|
end
|
99
99
|
|
100
100
|
context '300' do
|
101
|
-
let(:code) {Postmark::ApiInputError::
|
101
|
+
let(:code) {Postmark::ApiInputError::INVALID_EMAIL_REQUEST}
|
102
102
|
|
103
|
-
it {is_expected.to be_a(Postmark::
|
103
|
+
it {is_expected.to be_a(Postmark::InvalidEmailRequestError)}
|
104
104
|
it_behaves_like 'api input error'
|
105
105
|
end
|
106
106
|
|
@@ -149,13 +149,13 @@ describe(Postmark::MailAdapterError) do
|
|
149
149
|
it {is_expected.to be_a(Postmark::Error)}
|
150
150
|
end
|
151
151
|
|
152
|
-
describe(Postmark::
|
152
|
+
describe(Postmark::InvalidEmailRequestError) do
|
153
153
|
describe '.new' do
|
154
154
|
let(:response) {{'Message' => message}}
|
155
155
|
|
156
156
|
subject do
|
157
|
-
Postmark::
|
158
|
-
Postmark::ApiInputError::
|
157
|
+
Postmark::InvalidEmailRequestError.new(
|
158
|
+
Postmark::ApiInputError::INVALID_EMAIL_REQUEST, Postmark::Json.encode(response), response)
|
159
159
|
end
|
160
160
|
|
161
161
|
let(:message) do
|
@@ -171,7 +171,7 @@ describe(Postmark::InvalidEmailAddressError) do
|
|
171
171
|
end
|
172
172
|
|
173
173
|
it 'error code is set' do
|
174
|
-
expect(subject.error_code).to eq(Postmark::ApiInputError::
|
174
|
+
expect(subject.error_code).to eq(Postmark::ApiInputError::INVALID_EMAIL_REQUEST)
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
@@ -274,3 +274,9 @@ describe(Postmark::UnknownError) do
|
|
274
274
|
expect(subject.class).to eq(Postmark::UnexpectedHttpResponseError)
|
275
275
|
end
|
276
276
|
end
|
277
|
+
|
278
|
+
describe(Postmark::InvalidEmailAddressError) do
|
279
|
+
it 'is an alias for backwards compatibility' do
|
280
|
+
expect(subject.class).to eq(Postmark::InvalidEmailRequestError)
|
281
|
+
end
|
282
|
+
end
|
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.
|
4
|
+
version: 1.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomek Maszkowski
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2023-
|
16
|
+
date: 2023-04-07 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: json
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/postmark/api_client.rb
|
89
89
|
- lib/postmark/bounce.rb
|
90
90
|
- lib/postmark/client.rb
|
91
|
+
- lib/postmark/deprecations.rb
|
91
92
|
- lib/postmark/error.rb
|
92
93
|
- lib/postmark/handlers/mail.rb
|
93
94
|
- lib/postmark/helpers/hash_helper.rb
|