postmark 1.23.0 → 1.24.1

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: dfce0fc58365a91800f896d2d16c8d62d1a601f7a1a8d5350c6270cae3f12be3
4
- data.tar.gz: 3d8b2761c884f6ca1f3c81efe7c30dda1432b6d7da740d18d6cc55f5cc062d23
3
+ metadata.gz: a058959694917a357c1620516b215963717924485075b241ce7ceb23115619bd
4
+ data.tar.gz: 672e034cbbaa506c5bca5ae7acc229a190d88abb061461f3ddb4e6613c8b2b0f
5
5
  SHA512:
6
- metadata.gz: 4082d74e41c4d74378f4e46bb43d0b8dd967489125865cd9379fbc3928dfd0be7369408cfcdcc6a979822739b8734045fba8a66021591848dff801286ef183d9
7
- data.tar.gz: 5c93b937e1749584f52c1a1f5e0a4a9eabc6ea579e02c26f20d709ea5b89873d666acd6b8c2e7733a5e18885df370c1f2ca26e9c96c23cc44448d95c4f0da309
6
+ metadata.gz: 4161edf7a3ef04545b54824271677f618ac691c3dc6c332d7f507585b338fd2878572b8f4e12102367266a5226b64d758f6a1ff26e426040c9c538b710ee622f
7
+ data.tar.gz: af9c996569b7e3a3b31bb37f2623803877ec84179fb8f791a53002730b513919077ad26e28e3fa544b0b1cff60b276d9d762966901ffdfbcf015080f59145b3c
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,11 @@
1
1
  = Changelog
2
2
 
3
+ == 1.24.1
4
+ * Fixed support for text/calendar attachments by using content_type instead of mime_type.
5
+
6
+ == 1.24.0
7
+ * Added configurable warnings when referencing deprecated classes.
8
+
3
9
  == 1.23.0
4
10
  * Deprecated `InvalidEmailAddressError`. New name is `InvalidEmailRequestError`.
5
11
 
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.
@@ -64,8 +73,8 @@ Refer to the [LICENSE](https://github.com/ActiveCampaign/postmark-gem/blob/main/
64
73
 
65
74
  ## Tests
66
75
 
67
- The [integration tests](https://github.com/ActiveCampaign/postmark-gem/tree/main/spec/integration) currently use a real test email address, configured via `POSTMARK_CI_RECIPIENT`. The credentials for it can be found in the internal 1password vault under `Postmark - Ruby - Client Library - Account`.
76
+ The [integration tests](https://github.com/ActiveCampaign/postmark-gem/tree/main/spec/integration) currently use a real test email address, configured via `POSTMARK_CI_RECIPIENT`.
68
77
 
69
78
  ## Copyright
70
79
 
71
- Copyright © 2022 ActiveCampaign LLC.
80
+ Copyright © 2023 ActiveCampaign LLC.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.23.0
1
+ 1.24.1
@@ -3,7 +3,8 @@ require 'time'
3
3
  module Postmark
4
4
  class Bounce
5
5
 
6
- attr_reader :email, :bounced_at, :type, :description, :details, :name, :id, :server_id, :tag, :message_id, :subject
6
+ attr_reader :email, :bounced_at, :type, :description, :details, :name, :id, :server_id, :tag, :message_id, :subject,
7
+ :message_stream, :content
7
8
 
8
9
  def initialize(values = {})
9
10
  values = Postmark::HashHelper.to_ruby(values)
@@ -20,6 +21,9 @@ module Postmark
20
21
  @can_activate = values[:can_activate]
21
22
  @message_id = values[:message_id]
22
23
  @subject = values[:subject]
24
+ @server_id = values[:server_id]
25
+ @message_stream = values[:message_stream]
26
+ @content = values[:content]
23
27
  end
24
28
 
25
29
  def inactive?
@@ -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
@@ -1,3 +1,5 @@
1
+ require 'postmark/deprecations'
2
+
1
3
  module Postmark
2
4
  class Error < ::StandardError; end
3
5
 
@@ -126,8 +128,10 @@ module Postmark
126
128
  class UnexpectedHttpResponseError < HttpServerError; end
127
129
 
128
130
  # Backwards compatible aliases
129
- DeliveryError = Error
130
- InvalidMessageError = ApiInputError
131
- UnknownError = UnexpectedHttpResponseError
132
- InvalidEmailAddressError = InvalidEmailRequestError
131
+ Deprecations.add_constants(
132
+ :DeliveryError => Error,
133
+ :InvalidMessageError => ApiInputError,
134
+ :UnknownError => UnexpectedHttpResponseError,
135
+ :InvalidEmailAddressError => InvalidEmailRequestError
136
+ )
133
137
  end
@@ -171,12 +171,12 @@ module Mail
171
171
 
172
172
  def export_native_attachments
173
173
  attachments.map do |attachment|
174
- basics = {"Name" => attachment.filename,
175
- "Content" => pack_attachment_data(attachment.body.decoded),
176
- "ContentType" => attachment.mime_type}
177
- specials = attachment.inline? ? {'ContentID' => attachment.url} : {}
178
-
179
- basics.update(specials)
174
+ {
175
+ "Name" => attachment.filename,
176
+ "Content" => pack_attachment_data(attachment.body.decoded),
177
+ "ContentType" => attachment.content_type,
178
+ "ContentID" => attachment.inline? ? attachment.url : nil
179
+ }.delete_if { |_k, v| v.nil? }
180
180
  end
181
181
  end
182
182
 
@@ -1,3 +1,3 @@
1
1
  module Postmark
2
- VERSION = '1.23.0'
2
+ VERSION = '1.24.1'
3
3
  end
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
@@ -12,6 +12,10 @@ describe Postmark::Bounce do
12
12
  :inactive => false,
13
13
  :can_activate => true,
14
14
  :id => 42,
15
+ :server_id => 12345,
16
+ :tag => "TEST_TAG",
17
+ :message_stream => "my-message-stream",
18
+ :content => "THE CONTENT",
15
19
  :subject => "Hello from our app!"} }
16
20
  let(:bounce_data_postmark) { Postmark::HashHelper.to_postmark(bounce_data) }
17
21
  let(:bounces_data) { [bounce_data, bounce_data, bounce_data] }
@@ -31,6 +35,8 @@ describe Postmark::Bounce do
31
35
  it { expect(subject).to respond_to(:tag) }
32
36
  it { expect(subject).to respond_to(:message_id) }
33
37
  it { expect(subject).to respond_to(:subject) }
38
+ it { expect(subject).to respond_to(:message_stream) }
39
+ it { expect(subject).to respond_to(:content) }
34
40
  end
35
41
 
36
42
  context "given a bounce created from bounce_data" do
@@ -55,6 +61,10 @@ describe Postmark::Bounce do
55
61
  its(:bounced_at) { is_expected.to eq Time.parse(bounce_data[:bounced_at]) }
56
62
  its(:id) { is_expected.to eq bounce_data[:id] }
57
63
  its(:subject) { is_expected.to eq bounce_data[:subject] }
64
+ its(:message_stream) { is_expected.to eq bounce_data[:message_stream] }
65
+ its(:server_id) { is_expected.to eq bounce_data[:server_id] }
66
+ its(:tag) { is_expected.to eq bounce_data[:tag] }
67
+ its(:content) { is_expected.to eq bounce_data[:content] }
58
68
 
59
69
  end
60
70
 
@@ -219,7 +219,7 @@ describe Postmark::MailMessageConverter do
219
219
  "Subject" => "Hello!",
220
220
  "Attachments" => [{"Name" => "empty.gif",
221
221
  "Content" => encoded_empty_gif_data,
222
- "ContentType" => "image/gif"}],
222
+ "ContentType" => "image/gif; filename=empty.gif"}],
223
223
  "TextBody" => "Hello Sheldon!",
224
224
  "To" => "lenard@bigbangtheory.com"})
225
225
  end
@@ -183,7 +183,7 @@ describe Mail::Message do
183
183
  let(:exported_data) {
184
184
  {'Name' => 'face.jpeg',
185
185
  'Content' => "YmluYXJ5ZGF0YWhlcmU=\n",
186
- 'ContentType' => 'image/jpeg'}
186
+ 'ContentType' => 'image/jpeg; filename=face.jpeg'}
187
187
  }
188
188
 
189
189
  context 'given a regular attachment' do
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.23.0
4
+ version: 1.24.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomek Maszkowski
@@ -10,10 +10,10 @@ authors:
10
10
  - Nick Hammond
11
11
  - Petyo Ivanov
12
12
  - Ilya Sabanin
13
- autorequire:
13
+ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2023-01-23 00:00:00.000000000 Z
16
+ date: 2023-09-18 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: json
@@ -59,7 +59,7 @@ dependencies:
59
59
  version: '0'
60
60
  description: Use this gem to send emails through Postmark HTTP API and retrieve info
61
61
  about bounces.
62
- email:
62
+ email:
63
63
  executables: []
64
64
  extensions: []
65
65
  extra_rdoc_files:
@@ -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
@@ -153,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
154
  version: 1.3.7
154
155
  requirements: []
155
156
  rubygems_version: 3.1.6
156
- signing_key:
157
+ signing_key:
157
158
  specification_version: 4
158
159
  summary: Official Postmark API wrapper.
159
160
  test_files: