postmark 1.21.7 → 1.22.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.rdoc +11 -0
- data/LICENSE +1 -1
- data/README.md +15 -14
- data/RELEASE.md +5 -4
- data/VERSION +1 -1
- data/lib/postmark/api_client.rb +7 -7
- data/lib/postmark/client.rb +7 -4
- data/lib/postmark/helpers/hash_helper.rb +36 -11
- data/lib/postmark/version.rb +1 -1
- data/postmark.gemspec +0 -1
- data/spec/unit/postmark/api_client_spec.rb +243 -209
- data/spec/unit/postmark/error_spec.rb +1 -1
- data/spec/unit/postmark/helpers/hash_helper_spec.rb +101 -14
- data/spec/unit/postmark/inbound_spec.rb +1 -1
- data/spec/unit/postmark/message_extensions/mail_spec.rb +3 -3
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd4bf518075f6e5a7eafaa982c34b95cb3cd5eebee2cf059ad5743b182a6a533
|
4
|
+
data.tar.gz: f34c3ddc69336854ca6a964b66eb4c393a4e630756b4e2a8dc637121e5c43a3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6020d8ad751fd18f3e706d42c3c16938f04e517de4653121e1efb83ce9e1db9d33578cef954edd615c3f56c0151e9c4ee154a7cb7e8f2e738cb57cd6ffa227dc
|
7
|
+
data.tar.gz: c0ccc572d15ab61da1647c7c4abcbd4a0d180d0aa21cda7a580a798880f03f1ede1759a40db2bb269b15d9cf3dc39bbe2a641d6c12211cec2901db9e2034a925
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
postmark-gem
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.6
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
|
+
== 1.22.1
|
4
|
+
* Migrated to ActiveCampaign
|
5
|
+
|
6
|
+
== 1.22.0
|
7
|
+
|
8
|
+
* Disabled automatic retries of failed requests by default. You can enabled it by passing `max_retries` option to the client constructor.
|
9
|
+
|
10
|
+
== 1.21.8
|
11
|
+
|
12
|
+
* Fixed passing and receiving SubscriptionManagementConfiguration when creating/updating message streams (#94).
|
13
|
+
|
3
14
|
== 1.21.7
|
4
15
|
|
5
16
|
* Improved parsing recipients with Postmark::InactiveRecipientError.parse_recipients method
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -3,31 +3,32 @@
|
|
3
3
|
</a>
|
4
4
|
|
5
5
|
# Postmark Ruby Gem
|
6
|
-
|
7
|
-
[![
|
6
|
+
|
7
|
+
[![Build Status](https://circleci.com/gh/ActiveCampaign/postmark-gem.svg?style=shield)](https://circleci.com/gh/ActiveCampaign/postmark-gem)
|
8
|
+
[![Code Climate](https://codeclimate.com/github/ActiveCampaign/postmark-gem/badges/gpa.svg)](https://codeclimate.com/github/ActiveCampaign/postmark-gem)
|
8
9
|
[![License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](http://www.opensource.org/licenses/MIT)
|
9
10
|
[![Gem Version](https://badge.fury.io/rb/postmark.svg)](https://badge.fury.io/rb/postmark)
|
10
11
|
|
11
12
|
Postmark allows you to send your emails with high delivery rates. It also includes detailed statistics. In addition, Postmark can parse incoming emails which are forwarded back to your application.
|
12
13
|
|
13
|
-
This gem is the official wrapper for the [Postmark HTTP API](http://postmarkapp.com).
|
14
|
+
This gem is the official wrapper for the [Postmark HTTP API](http://postmarkapp.com).
|
14
15
|
|
15
16
|
## Usage
|
16
17
|
|
17
|
-
Please see the [wiki](https://github.com/
|
18
|
+
Please see the [wiki](https://github.com/ActiveCampaign/postmark-gem/wiki) for detailed instructions about sending email, using the bounce api and other Postmark API features.
|
18
19
|
For details about Postmark API in general, please check out [Postmark developer docs](https://postmarkapp.com/developer).
|
19
20
|
|
20
21
|
## Requirements
|
21
22
|
|
22
|
-
You will need a Postmark account, server and sender signature (or verified domain) set up to use it. For details about setup, check out [wiki pages](https://github.com/
|
23
|
+
You will need a Postmark account, server and sender signature (or verified domain) set up to use it. For details about setup, check out [wiki pages](https://github.com/ActiveCampaign/postmark-gem/wiki/Getting-Started).
|
23
24
|
|
24
|
-
If you plan using the library in a Rails project, check out the [postmark-rails](https://github.com/
|
25
|
+
If you plan using the library in a Rails project, check out the [postmark-rails](https://github.com/ActiveCampaign/postmark-rails/) gem, which
|
25
26
|
is meant to integrate with ActionMailer. The plugin will try to use ActiveSupport JSon if it is already included. If not,
|
26
27
|
it will attempt to use the built-in Ruby JSon library.
|
27
28
|
|
28
29
|
You can also explicitly specify which one to be used, using following code:
|
29
30
|
|
30
|
-
```
|
31
|
+
```ruby
|
31
32
|
Postmark.response_parser_class = :Json # :ActiveSupport or :Yajl are also supported.
|
32
33
|
```
|
33
34
|
|
@@ -37,13 +38,13 @@ You can use the library with or without a Bundler.
|
|
37
38
|
|
38
39
|
With Bundler:
|
39
40
|
|
40
|
-
```
|
41
|
+
```ruby
|
41
42
|
gem 'postmark'
|
42
43
|
```
|
43
44
|
|
44
45
|
Without Bundler:
|
45
46
|
|
46
|
-
```
|
47
|
+
```bash
|
47
48
|
gem install postmark
|
48
49
|
```
|
49
50
|
|
@@ -53,14 +54,14 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) file for details.
|
|
53
54
|
|
54
55
|
## Issues & Comments
|
55
56
|
|
56
|
-
Feel free to contact us if you encounter any issues with the library or Postmark API.
|
57
|
-
Please leave all comments, bugs, requests and issues on the Issues page.
|
57
|
+
Feel free to contact us if you encounter any issues with the library or Postmark API.
|
58
|
+
Please leave all comments, bugs, requests and issues on the Issues page.
|
58
59
|
|
59
60
|
## License
|
60
61
|
|
61
|
-
The Postmark Ruby library is licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) license.
|
62
|
-
Refer to the [LICENSE](https://github.com/
|
62
|
+
The Postmark Ruby library is licensed under the [MIT](http://www.opensource.org/licenses/mit-license.php) license.
|
63
|
+
Refer to the [LICENSE](https://github.com/ActiveCampaign/postmark-gem/blob/main/LICENSE) file for more information.
|
63
64
|
|
64
65
|
## Copyright
|
65
66
|
|
66
|
-
Copyright ©
|
67
|
+
Copyright © 2022 ActiveCampaign LLC.
|
data/RELEASE.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
New versions of the gem are cut by the Postmark team, this is a quick guide to ensuring a smooth release.
|
2
2
|
|
3
|
+
1. Determine the next version of the gem by following the [SemVer](https://semver.org/) guidelines.
|
3
4
|
1. Verify all builds are passing on CircleCI for your branch.
|
4
|
-
1. Merge in your branch to
|
5
|
+
1. Merge in your branch to main.
|
5
6
|
1. Update VERSION and lib/postmark/version.rb with the new version.
|
6
7
|
1. Update CHANGELOG.rdoc with a brief description of the changes.
|
7
8
|
1. Commit to git with a comment of "Bump version to x.y.z".
|
8
9
|
1. run `rake release` - This will push to github(with the version tag) and rubygems with the version in lib/postmark/version.rb.
|
9
10
|
*Note that if you're on Bundler 1.17 there's a bug that hides the prompt for your OTP. If it hangs after adding the tag then it's asking for your OTP, enter your OTP and press Enter. Bundler 2.x and beyond resolved this issue. *
|
10
|
-
1. Verify the new version is on [github](https://github.com/
|
11
|
-
1. Create a new release for the version on [Github releases](https://github.com/
|
12
|
-
1. Add or update any related content to the [wiki](https://github.com/
|
11
|
+
1. Verify the new version is on [github](https://github.com/ActiveCampaign/postmark-gem) and [rubygems](https://rubygems.org/gems/postmark).
|
12
|
+
1. Create a new release for the version on [Github releases](https://github.com/ActiveCampaign/postmark-gem/releases).
|
13
|
+
1. Add or update any related content to the [wiki](https://github.com/ActiveCampaign/postmark-gem/wiki).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.22.1
|
data/lib/postmark/api_client.rb
CHANGED
@@ -38,7 +38,7 @@ module Postmark
|
|
38
38
|
response, error = take_response_of { http_client.post("email", data) }
|
39
39
|
update_message(message, response)
|
40
40
|
raise error if error
|
41
|
-
format_response(response, true)
|
41
|
+
format_response(response, :compatible => true)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
@@ -51,7 +51,7 @@ module Postmark
|
|
51
51
|
response, error = take_response_of { http_client.post("email/withTemplate", data) }
|
52
52
|
update_message(message, response)
|
53
53
|
raise error if error
|
54
|
-
format_response(response, true)
|
54
|
+
format_response(response, :compatible => true)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -95,7 +95,7 @@ module Postmark
|
|
95
95
|
end
|
96
96
|
|
97
97
|
def delivery_stats
|
98
|
-
response = format_response(http_client.get("deliverystats"), true)
|
98
|
+
response = format_response(http_client.get("deliverystats"), :compatible => true)
|
99
99
|
|
100
100
|
if response[:bounces]
|
101
101
|
response[:bounces] = format_response(response[:bounces])
|
@@ -343,13 +343,13 @@ module Postmark
|
|
343
343
|
end
|
344
344
|
|
345
345
|
def create_message_stream(attributes = {})
|
346
|
-
data = serialize(HashHelper.to_postmark(attributes))
|
347
|
-
format_response(http_client.post('message-streams', data))
|
346
|
+
data = serialize(HashHelper.to_postmark(attributes, :deep => true))
|
347
|
+
format_response(http_client.post('message-streams', data), :deep => true)
|
348
348
|
end
|
349
349
|
|
350
350
|
def update_message_stream(id, attributes)
|
351
|
-
data = serialize(HashHelper.to_postmark(attributes))
|
352
|
-
format_response(http_client.patch("message-streams/#{id}", data))
|
351
|
+
data = serialize(HashHelper.to_postmark(attributes, :deep => true))
|
352
|
+
format_response(http_client.patch("message-streams/#{id}", data), :deep => true)
|
353
353
|
end
|
354
354
|
|
355
355
|
def archive_message_stream(id)
|
data/lib/postmark/client.rb
CHANGED
@@ -6,7 +6,7 @@ module Postmark
|
|
6
6
|
|
7
7
|
def initialize(api_token, options = {})
|
8
8
|
options = options.dup
|
9
|
-
@max_retries = options.delete(:max_retries) ||
|
9
|
+
@max_retries = options.delete(:max_retries) || 0
|
10
10
|
@http_client = HttpClient.new(api_token, options)
|
11
11
|
end
|
12
12
|
|
@@ -60,13 +60,16 @@ module Postmark
|
|
60
60
|
[e.full_response || {}, e]
|
61
61
|
end
|
62
62
|
|
63
|
-
def format_response(response,
|
63
|
+
def format_response(response, options = {})
|
64
64
|
return {} unless response
|
65
65
|
|
66
|
+
compatible = options.fetch(:compatible, false)
|
67
|
+
deep = options.fetch(:deep, false)
|
68
|
+
|
66
69
|
if response.kind_of? Array
|
67
|
-
response.map { |entry| Postmark::HashHelper.to_ruby(entry, compatible) }
|
70
|
+
response.map { |entry| Postmark::HashHelper.to_ruby(entry, :compatible => compatible, :deep => deep) }
|
68
71
|
else
|
69
|
-
Postmark::HashHelper.to_ruby(response, compatible)
|
72
|
+
Postmark::HashHelper.to_ruby(response, :compatible => compatible, :deep => deep)
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
@@ -3,22 +3,47 @@ module Postmark
|
|
3
3
|
|
4
4
|
extend self
|
5
5
|
|
6
|
-
def to_postmark(
|
7
|
-
|
6
|
+
def to_postmark(object, options = {})
|
7
|
+
deep = options.fetch(:deep, false)
|
8
|
+
|
9
|
+
case object
|
10
|
+
when Hash
|
11
|
+
object.reduce({}) do |m, (k, v)|
|
12
|
+
m.tap do |h|
|
13
|
+
h[Inflector.to_postmark(k)] = deep ? to_postmark(v, options) : v
|
14
|
+
end
|
15
|
+
end
|
16
|
+
when Array
|
17
|
+
deep ? object.map { |v| to_postmark(v, options) } : object
|
18
|
+
else
|
19
|
+
object
|
20
|
+
end
|
8
21
|
end
|
9
22
|
|
10
|
-
def to_ruby(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
23
|
+
def to_ruby(object, options = {})
|
24
|
+
compatible = options.fetch(:compatible, false)
|
25
|
+
deep = options.fetch(:deep, false)
|
26
|
+
|
27
|
+
case object
|
28
|
+
when Hash
|
29
|
+
object.reduce({}) do |m, (k, v)|
|
30
|
+
m.tap do |h|
|
31
|
+
h[Inflector.to_ruby(k)] = deep ? to_ruby(v, options) : v
|
32
|
+
end
|
33
|
+
end.tap do |result|
|
34
|
+
if compatible
|
35
|
+
result.merge!(object)
|
36
|
+
enhance_with_compatibility_warning(result)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
when Array
|
40
|
+
deep ? object.map { |v| to_ruby(v, options) } : object
|
41
|
+
else
|
42
|
+
object
|
16
43
|
end
|
17
|
-
|
18
|
-
formatted
|
19
44
|
end
|
20
45
|
|
21
|
-
|
46
|
+
private
|
22
47
|
|
23
48
|
def enhance_with_compatibility_warning(hash)
|
24
49
|
def hash.[](key)
|
data/lib/postmark/version.rb
CHANGED
data/postmark.gemspec
CHANGED
@@ -10,7 +10,6 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.license = 'MIT'
|
11
11
|
|
12
12
|
s.authors = ["Tomek Maszkowski", "Igor Balos", "Artem Chistyakov", "Nick Hammond", "Petyo Ivanov", "Ilya Sabanin"]
|
13
|
-
s.email = "tomek@wildbit.com"
|
14
13
|
s.extra_rdoc_files = ["LICENSE", "README.md"]
|
15
14
|
s.rdoc_options = ["--charset=UTF-8"]
|
16
15
|
|