postmark 1.19.2 → 1.21.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +5 -2
- data/CHANGELOG.rdoc +20 -0
- data/README.md +1 -1
- data/RELEASE.md +12 -0
- data/VERSION +1 -1
- data/lib/postmark/api_client.rb +38 -5
- data/lib/postmark/http_client.rb +6 -3
- data/lib/postmark/mail_message_converter.rb +2 -1
- data/lib/postmark/message_extensions/mail.rb +10 -0
- data/lib/postmark/version.rb +1 -1
- data/spec/integration/api_client_resources_spec.rb +1 -18
- data/spec/support/custom_matchers.rb +4 -0
- data/spec/unit/postmark/api_client_spec.rb +294 -84
- data/spec/unit/postmark/http_client_spec.rb +5 -5
- data/spec/unit/postmark/mail_message_converter_spec.rb +30 -14
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb0f51e437e4831ac7fe011e089ac51c00984a614f48f31e94cce6233331f3bd
|
4
|
+
data.tar.gz: 599f2b99b5a8bca7a5761c560feddac36cd252a2232431008c3eabc1ef3375b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f16405603d847f6e8b4124a7da3c478db38555196016d59cb743c4d63f154e512ffac6d9db74702340e19cfa2afdb04965fdcb3436ab92c62f031d2d2b7ba0b
|
7
|
+
data.tar.gz: 6429f12e770e5a305f2bcb705cff501c48ebeb45be85dbd78f44e32cc4b5312abd0d6d9789c5c29e7cb3fca411a4e1a748a34fdc35e703862202e7c72851a0be
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -5,15 +5,18 @@ env:
|
|
5
5
|
# POSTMARK_ACCOUNT_API_KEY=?
|
6
6
|
- secure: "lau1m+ws6T5LBiRXwd+Q0b20Wjh62W/nHnCmzOSZc2+V97XTldl3MCJdXNV7J6X7O9CzFabcAG8FSbGGwPRiyhY/qhxkYSc/9pWE8RUjyCjbw5q2RzZQelMKizyKU92eOjd6jQw/wDSZcww1OceW/pgdRjqEo21Pk6XH2yzLAd8="
|
7
7
|
# POSTMARK_CI_RECIPIENT=?
|
8
|
-
- secure: "
|
8
|
+
- secure: "XJkpUbAC1N6vcL/bUvqX2Mx8OKXpr/3zwqhjGiWhrSGKmQJUNnK4TEGFjnb1TBncZvW5cBRD0oX1Tt7gAu4o8C6sldVf35hB5FQsEyQrgSN4s95uLHuTW9EQisiQS6kzPLbkUmsMIQhIlfNGKQ5tRzRQstip81E8a0Emth3Y9EQ="
|
9
9
|
# POSTMARK_CI_SENDER=?
|
10
|
-
- secure: "
|
10
|
+
- secure: "bOoU3WEFur/SqwTY0m0aGqy8v8AZfZtFFHNYsU/BtAppZXj378CiktvJGj+cz/KMqFEWyJKNzchFOfZa45Q9Xor/QbTqkBriTOz3Ff7gQpmuPfLSvWRQSLRmbRFgr0Dk8QCTTtfnNtnajxMUyGfxwCiMo+l3EEAqjtLpN+Gja20="
|
11
11
|
language: ruby
|
12
12
|
rvm:
|
13
13
|
- 2.0.0
|
14
14
|
- 2.1.9
|
15
15
|
- 2.2.5
|
16
16
|
- 2.3.1
|
17
|
+
- 2.5.7
|
18
|
+
- 2.6.5
|
19
|
+
- 2.7.0
|
17
20
|
matrix:
|
18
21
|
include:
|
19
22
|
- rvm: 1.8.7
|
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,25 @@
|
|
1
1
|
= Changelog
|
2
2
|
|
3
|
+
== 1.21.3
|
4
|
+
|
5
|
+
* Remove default SSL version setting and rely on Net::HTTP/OpenSSL default.
|
6
|
+
|
7
|
+
== 1.21.2
|
8
|
+
|
9
|
+
* Ensure sending via message stream uses the correct message stream
|
10
|
+
|
11
|
+
== 1.21.1
|
12
|
+
|
13
|
+
* Fixed Postmark::ApiClient#get_message_streams
|
14
|
+
|
15
|
+
== 1.21.0
|
16
|
+
|
17
|
+
* Added support for message streams and suppressions
|
18
|
+
|
19
|
+
== 1.20.0
|
20
|
+
|
21
|
+
* Removed deprecated trigger endpoints
|
22
|
+
|
3
23
|
== 1.19.2
|
4
24
|
|
5
25
|
Allow possibility to change TLS version for HTTP client.
|
data/README.md
CHANGED
data/RELEASE.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
New versions of the gem are cut by the Postmark team, this is a quick guide to ensuring a smooth release.
|
2
|
+
|
3
|
+
1. Verify all builds are passing on Travis for your branch.
|
4
|
+
1. Merge in your branch to master.
|
5
|
+
1. Update VERSION and lib/postmark/version.rb with the new version.
|
6
|
+
1. Update CHANGELOG.rdoc with a brief description of the changes.
|
7
|
+
1. Commit to git with a comment of "Bump version to x.y.z".
|
8
|
+
1. run `rake release` - This will push to github(with the version tag) and rubygems with the version in lib/postmark/version.rb.
|
9
|
+
*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/wildbit/postmark-gem) and [rubygems](https://rubygems.org/gems/postmark).
|
11
|
+
1. Create a new release for the version on [Github releases](https://github.com/wildbit/postmark-gem/releases).
|
12
|
+
1. Add or update any related content to the [wiki](https://github.com/wildbit/postmark-gem/wiki).
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.21.3
|
data/lib/postmark/api_client.rb
CHANGED
@@ -197,11 +197,6 @@ module Postmark
|
|
197
197
|
format_response http_client.get("triggers/#{type}/#{id}")
|
198
198
|
end
|
199
199
|
|
200
|
-
def update_trigger(type, id, options)
|
201
|
-
data = serialize(HashHelper.to_postmark(options))
|
202
|
-
format_response http_client.put("triggers/#{type}/#{id}", data)
|
203
|
-
end
|
204
|
-
|
205
200
|
def delete_trigger(type, id)
|
206
201
|
type = Postmark::Inflector.to_postmark(type).downcase
|
207
202
|
format_response http_client.delete("triggers/#{type}/#{id}")
|
@@ -333,6 +328,44 @@ module Postmark
|
|
333
328
|
format_response http_client.delete("webhooks/#{id}")
|
334
329
|
end
|
335
330
|
|
331
|
+
def get_message_streams(options = {})
|
332
|
+
_, batch = load_batch('message-streams', 'MessageStreams', options)
|
333
|
+
batch
|
334
|
+
end
|
335
|
+
|
336
|
+
def message_streams(options = {})
|
337
|
+
find_each('message-streams', 'MessageStreams', options)
|
338
|
+
end
|
339
|
+
|
340
|
+
def get_message_stream(id)
|
341
|
+
format_response(http_client.get("message-streams/#{id}"))
|
342
|
+
end
|
343
|
+
|
344
|
+
def create_message_stream(attributes = {})
|
345
|
+
data = serialize(HashHelper.to_postmark(attributes))
|
346
|
+
format_response(http_client.post('message-streams', data))
|
347
|
+
end
|
348
|
+
|
349
|
+
def update_message_stream(id, attributes)
|
350
|
+
data = serialize(HashHelper.to_postmark(attributes))
|
351
|
+
format_response(http_client.patch("message-streams/#{id}", data))
|
352
|
+
end
|
353
|
+
|
354
|
+
def dump_suppressions(stream_id, options = {})
|
355
|
+
_, batch = load_batch("message-streams/#{stream_id}/suppressions/dump", 'Suppressions', options)
|
356
|
+
batch
|
357
|
+
end
|
358
|
+
|
359
|
+
def create_suppressions(stream_id, email_addresses)
|
360
|
+
data = serialize(:Suppressions => Array(email_addresses).map { |e| HashHelper.to_postmark(:email_address => e) })
|
361
|
+
format_response(http_client.post("message-streams/#{stream_id}/suppressions", data))
|
362
|
+
end
|
363
|
+
|
364
|
+
def delete_suppressions(stream_id, email_addresses)
|
365
|
+
data = serialize(:Suppressions => Array(email_addresses).map { |e| HashHelper.to_postmark(:email_address => e) })
|
366
|
+
format_response(http_client.post("message-streams/#{stream_id}/suppressions/delete", data))
|
367
|
+
end
|
368
|
+
|
336
369
|
protected
|
337
370
|
|
338
371
|
def in_batches(messages)
|
data/lib/postmark/http_client.rb
CHANGED
@@ -18,8 +18,7 @@ module Postmark
|
|
18
18
|
:secure => true,
|
19
19
|
:path_prefix => '/',
|
20
20
|
:http_read_timeout => 15,
|
21
|
-
:http_open_timeout => 5
|
22
|
-
:http_ssl_version => :TLSv1
|
21
|
+
:http_open_timeout => 5
|
23
22
|
}
|
24
23
|
|
25
24
|
def initialize(api_token, options = {})
|
@@ -37,6 +36,10 @@ module Postmark
|
|
37
36
|
do_request { |client| client.put(url_path(path), data, headers) }
|
38
37
|
end
|
39
38
|
|
39
|
+
def patch(path, data = '')
|
40
|
+
do_request { |client| client.patch(url_path(path), data, headers) }
|
41
|
+
end
|
42
|
+
|
40
43
|
def get(path, query = {})
|
41
44
|
do_request { |client| client.get(url_path(path + to_query_string(query)), headers) }
|
42
45
|
end
|
@@ -103,7 +106,7 @@ module Postmark
|
|
103
106
|
http.read_timeout = self.http_read_timeout
|
104
107
|
http.open_timeout = self.http_open_timeout
|
105
108
|
http.use_ssl = !!self.secure
|
106
|
-
http.ssl_version = self.http_ssl_version if http.respond_to?(:ssl_version=)
|
109
|
+
http.ssl_version = self.http_ssl_version if self.http_ssl_version && http.respond_to?(:ssl_version=)
|
107
110
|
http
|
108
111
|
end
|
109
112
|
end
|
@@ -34,7 +34,8 @@ module Postmark
|
|
34
34
|
'TrackLinks' => (::Postmark::Inflector.to_postmark(@message.track_links) unless @message.track_links.empty?),
|
35
35
|
'Metadata' => @message.metadata,
|
36
36
|
'TemplateAlias' => @message.template_alias,
|
37
|
-
'TemplateModel' => @message.template_model
|
37
|
+
'TemplateModel' => @message.template_model,
|
38
|
+
'MessageStream' => @message.message_stream
|
38
39
|
}
|
39
40
|
end
|
40
41
|
|
@@ -72,6 +72,15 @@ module Mail
|
|
72
72
|
@template_model = model
|
73
73
|
end
|
74
74
|
|
75
|
+
def message_stream(val = nil)
|
76
|
+
self.message_stream = val unless val.nil?
|
77
|
+
header['MESSAGE-STREAM'].to_s
|
78
|
+
end
|
79
|
+
|
80
|
+
def message_stream=(val)
|
81
|
+
header['MESSAGE-STREAM'] = val
|
82
|
+
end
|
83
|
+
|
75
84
|
def templated?
|
76
85
|
!!template_alias
|
77
86
|
end
|
@@ -182,6 +191,7 @@ module Mail
|
|
182
191
|
attachment to
|
183
192
|
track-opens track-links
|
184
193
|
postmark-template-alias
|
194
|
+
message-stream
|
185
195
|
]
|
186
196
|
end
|
187
197
|
|
data/lib/postmark/version.rb
CHANGED
@@ -14,23 +14,6 @@ describe 'Accessing server resources using the API' do
|
|
14
14
|
}
|
15
15
|
}
|
16
16
|
|
17
|
-
context 'Triggers API' do
|
18
|
-
let(:unique_token) {rand(36 ** 32).to_s(36)}
|
19
|
-
|
20
|
-
it 'can be used to manage tag triggers via the API' do
|
21
|
-
skip("Endpoint removed")
|
22
|
-
trigger = api_client.create_trigger(:tags, :match_name => "gemtest_#{unique_token}", :track_opens => true)
|
23
|
-
api_client.update_trigger(:tags, trigger[:id], :match_name => "pre_#{trigger[:match_name]}")
|
24
|
-
updated = api_client.get_trigger(:tags, trigger[:id])
|
25
|
-
|
26
|
-
expect(updated[:id]).to eq(trigger[:id])
|
27
|
-
expect(updated[:match_name]).not_to eq(trigger[:id])
|
28
|
-
expect(api_client.triggers(:tags).map {|t| t[:id]}).to include(trigger[:id])
|
29
|
-
|
30
|
-
api_client.delete_trigger(:tags, trigger[:id])
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
17
|
context 'Messages API' do
|
35
18
|
def with_retries(max_retries = 20, wait_seconds = 3)
|
36
19
|
yield
|
@@ -70,4 +53,4 @@ describe 'Accessing server resources using the API' do
|
|
70
53
|
}.not_to raise_error
|
71
54
|
end
|
72
55
|
end
|
73
|
-
end
|
56
|
+
end
|
@@ -33,6 +33,10 @@ RSpec::Matchers.define :json_representation_of do |x|
|
|
33
33
|
match { |actual| Postmark::Json.decode(actual) == x }
|
34
34
|
end
|
35
35
|
|
36
|
+
RSpec::Matchers.define :match_json do |x|
|
37
|
+
match { |actual| Postmark::Json.encode(x) == actual }
|
38
|
+
end
|
39
|
+
|
36
40
|
RSpec::Matchers.define :be_serialized_to do |json|
|
37
41
|
match do |mail_message|
|
38
42
|
Postmark.convert_message_to_options_hash(mail_message) == JSON.parse(json)
|
@@ -18,9 +18,9 @@ describe Postmark::ApiClient do
|
|
18
18
|
template_model :name => "Sheldon"
|
19
19
|
end
|
20
20
|
end
|
21
|
+
let(:http_client) {api_client.http_client}
|
21
22
|
|
22
|
-
|
23
|
-
subject {api_client}
|
23
|
+
subject(:api_client) {Postmark::ApiClient.new(api_token)}
|
24
24
|
|
25
25
|
context "attr readers" do
|
26
26
|
it { expect(subject).to respond_to(:http_client) }
|
@@ -62,7 +62,6 @@ describe Postmark::ApiClient do
|
|
62
62
|
describe "#deliver" do
|
63
63
|
let(:email) {Postmark::MessageHelper.to_postmark(message_hash)}
|
64
64
|
let(:email_json) {Postmark::Json.encode(email)}
|
65
|
-
let(:http_client) {subject.http_client}
|
66
65
|
let(:response) {{"MessageID" => 42}}
|
67
66
|
|
68
67
|
it 'converts message hash to Postmark format and posts it to /email' do
|
@@ -86,7 +85,6 @@ describe Postmark::ApiClient do
|
|
86
85
|
let(:email) {Postmark::MessageHelper.to_postmark(message_hash)}
|
87
86
|
let(:emails) {[email, email, email]}
|
88
87
|
let(:emails_json) {Postmark::Json.encode(emails)}
|
89
|
-
let(:http_client) {subject.http_client}
|
90
88
|
let(:response) {[{'ErrorCode' => 0}, {'ErrorCode' => 0}, {'ErrorCode' => 0}]}
|
91
89
|
|
92
90
|
it 'turns array of messages into a JSON document and posts it to /email/batch' do
|
@@ -104,7 +102,6 @@ describe Postmark::ApiClient do
|
|
104
102
|
describe "#deliver_message" do
|
105
103
|
let(:email) {message.to_postmark_hash}
|
106
104
|
let(:email_json) {Postmark::Json.encode(email)}
|
107
|
-
let(:http_client) {subject.http_client}
|
108
105
|
|
109
106
|
it 'raises an error when given a templated message' do
|
110
107
|
expect { subject.deliver_message(templated_message) }.
|
@@ -139,7 +136,6 @@ describe Postmark::ApiClient do
|
|
139
136
|
describe "#deliver_message_with_template" do
|
140
137
|
let(:email) {templated_message.to_postmark_hash}
|
141
138
|
let(:email_json) {Postmark::Json.encode(email)}
|
142
|
-
let(:http_client) {subject.http_client}
|
143
139
|
|
144
140
|
it 'raises an error when given a non-templated message' do
|
145
141
|
expect { subject.deliver_message_with_template(message) }.
|
@@ -175,7 +171,6 @@ describe Postmark::ApiClient do
|
|
175
171
|
let(:email) {message.to_postmark_hash}
|
176
172
|
let(:emails) {[email, email, email]}
|
177
173
|
let(:emails_json) {Postmark::Json.encode(emails)}
|
178
|
-
let(:http_client) {subject.http_client}
|
179
174
|
let(:response) {[{}, {}, {}]}
|
180
175
|
|
181
176
|
it 'raises an error when given a templated message' do
|
@@ -207,7 +202,6 @@ describe Postmark::ApiClient do
|
|
207
202
|
let(:email) {templated_message.to_postmark_hash}
|
208
203
|
let(:emails) {[email, email, email]}
|
209
204
|
let(:emails_json) {Postmark::Json.encode(emails)}
|
210
|
-
let(:http_client) {subject.http_client}
|
211
205
|
let(:response) {[{}, {}, {}]}
|
212
206
|
let(:messages) { Array.new(3) { templated_message } }
|
213
207
|
|
@@ -237,7 +231,6 @@ describe Postmark::ApiClient do
|
|
237
231
|
end
|
238
232
|
|
239
233
|
describe "#delivery_stats" do
|
240
|
-
let(:http_client) {subject.http_client}
|
241
234
|
let(:response) {{"Bounces" => [{"Foo" => "Bar"}]}}
|
242
235
|
|
243
236
|
it 'requests data at /deliverystats' do
|
@@ -276,8 +269,6 @@ describe Postmark::ApiClient do
|
|
276
269
|
end
|
277
270
|
|
278
271
|
describe '#get_messages' do
|
279
|
-
let(:http_client) {subject.http_client}
|
280
|
-
|
281
272
|
context 'given outbound' do
|
282
273
|
let(:response) {{"TotalCount" => 1, "Messages" => [{}]}}
|
283
274
|
|
@@ -325,7 +316,6 @@ describe Postmark::ApiClient do
|
|
325
316
|
|
326
317
|
describe '#get_message' do
|
327
318
|
let(:id) {'8ad0e8b0-xxxx-xxxx-951d-223c581bb467'}
|
328
|
-
let(:http_client) {subject.http_client}
|
329
319
|
let(:response) {{"To" => "leonard@bigbangtheory.com"}}
|
330
320
|
|
331
321
|
context 'given outbound' do
|
@@ -349,7 +339,6 @@ describe Postmark::ApiClient do
|
|
349
339
|
|
350
340
|
describe '#dump_message' do
|
351
341
|
let(:id) {'8ad0e8b0-xxxx-xxxx-951d-223c581bb467'}
|
352
|
-
let(:http_client) {subject.http_client}
|
353
342
|
let(:response) {{"Body" => "From: <leonard@bigbangtheory.com> \r\n ..."}}
|
354
343
|
|
355
344
|
context 'given outbound' do
|
@@ -387,7 +376,6 @@ describe Postmark::ApiClient do
|
|
387
376
|
end
|
388
377
|
|
389
378
|
describe "#get_bounces" do
|
390
|
-
let(:http_client) {subject.http_client}
|
391
379
|
let(:options) {{:foo => :bar}}
|
392
380
|
let(:response) {{"Bounces" => []}}
|
393
381
|
|
@@ -399,7 +387,6 @@ describe Postmark::ApiClient do
|
|
399
387
|
end
|
400
388
|
|
401
389
|
describe "#get_bounce" do
|
402
|
-
let(:http_client) {subject.http_client}
|
403
390
|
let(:id) {42}
|
404
391
|
|
405
392
|
it 'requests a single bounce by ID at /bounces/:id' do
|
@@ -409,7 +396,6 @@ describe Postmark::ApiClient do
|
|
409
396
|
end
|
410
397
|
|
411
398
|
describe "#dump_bounce" do
|
412
|
-
let(:http_client) {subject.http_client}
|
413
399
|
let(:id) {42}
|
414
400
|
|
415
401
|
it 'requests a specific bounce data at /bounces/:id/dump' do
|
@@ -419,7 +405,6 @@ describe Postmark::ApiClient do
|
|
419
405
|
end
|
420
406
|
|
421
407
|
describe "#activate_bounce" do
|
422
|
-
let(:http_client) {subject.http_client}
|
423
408
|
let(:id) {42}
|
424
409
|
let(:response) {{"Bounce" => {}}}
|
425
410
|
|
@@ -456,7 +441,6 @@ describe Postmark::ApiClient do
|
|
456
441
|
end
|
457
442
|
|
458
443
|
describe '#get_opens' do
|
459
|
-
let(:http_client) {subject.http_client}
|
460
444
|
let(:options) {{:offset => 5}}
|
461
445
|
let(:response) {{'Opens' => [], 'TotalCount' => 0}}
|
462
446
|
|
@@ -468,7 +452,6 @@ describe Postmark::ApiClient do
|
|
468
452
|
end
|
469
453
|
|
470
454
|
describe '#get_clicks' do
|
471
|
-
let(:http_client) {subject.http_client}
|
472
455
|
let(:options) {{:offset => 5}}
|
473
456
|
let(:response) {{'Clicks' => [], 'TotalCount' => 0}}
|
474
457
|
|
@@ -480,7 +463,6 @@ describe Postmark::ApiClient do
|
|
480
463
|
end
|
481
464
|
|
482
465
|
describe '#get_opens_by_message_id' do
|
483
|
-
let(:http_client) {subject.http_client}
|
484
466
|
let(:message_id) {42}
|
485
467
|
let(:options) {{:offset => 5}}
|
486
468
|
let(:response) {{'Opens' => [], 'TotalCount' => 0}}
|
@@ -493,7 +475,6 @@ describe Postmark::ApiClient do
|
|
493
475
|
end
|
494
476
|
|
495
477
|
describe '#get_clicks_by_message_id' do
|
496
|
-
let(:http_client) {subject.http_client}
|
497
478
|
let(:message_id) {42}
|
498
479
|
let(:options) {{:offset => 5}}
|
499
480
|
let(:response) {{'Clicks' => [], 'TotalCount' => 0}}
|
@@ -536,24 +517,6 @@ describe Postmark::ApiClient do
|
|
536
517
|
end
|
537
518
|
|
538
519
|
describe '#create_trigger' do
|
539
|
-
let(:http_client) {subject.http_client}
|
540
|
-
|
541
|
-
context 'tags' do
|
542
|
-
let(:options) {{:foo => 'bar'}}
|
543
|
-
let(:response) {{'Foo' => 'Bar'}}
|
544
|
-
|
545
|
-
it 'performs a POST request to /triggers/tags with given options' do
|
546
|
-
allow(http_client).to receive(:post).with('triggers/tags',
|
547
|
-
{'Foo' => 'bar'}.to_json)
|
548
|
-
subject.create_trigger(:tags, options)
|
549
|
-
end
|
550
|
-
|
551
|
-
it 'symbolizes response keys' do
|
552
|
-
allow(http_client).to receive(:post).and_return(response)
|
553
|
-
expect(subject.create_trigger(:tags, options)).to eq(:foo => 'Bar')
|
554
|
-
end
|
555
|
-
end
|
556
|
-
|
557
520
|
context 'inbound rules' do
|
558
521
|
let(:options) {{:rule => 'example.com'}}
|
559
522
|
let(:response) {{'Rule' => 'example.com'}}
|
@@ -572,7 +535,6 @@ describe Postmark::ApiClient do
|
|
572
535
|
end
|
573
536
|
|
574
537
|
describe '#get_trigger' do
|
575
|
-
let(:http_client) {subject.http_client}
|
576
538
|
let(:id) {42}
|
577
539
|
|
578
540
|
it 'performs a GET request to /triggers/tags/:id' do
|
@@ -586,26 +548,7 @@ describe Postmark::ApiClient do
|
|
586
548
|
end
|
587
549
|
end
|
588
550
|
|
589
|
-
describe '#update_trigger' do
|
590
|
-
let(:http_client) {subject.http_client}
|
591
|
-
let(:options) {{:foo => 'bar'}}
|
592
|
-
let(:id) {42}
|
593
|
-
|
594
|
-
it 'performs a PUT request to /triggers/tags/:id' do
|
595
|
-
allow(http_client).to receive(:put).with("triggers/tags/#{id}",
|
596
|
-
{'Foo' => 'bar'}.to_json)
|
597
|
-
subject.update_trigger(:tags, id, options)
|
598
|
-
end
|
599
|
-
|
600
|
-
it 'symbolizes response keys' do
|
601
|
-
allow(http_client).to receive(:put).and_return('Foo' => 'Bar')
|
602
|
-
expect(subject.update_trigger(:tags, id, options)).to eq(:foo => 'Bar')
|
603
|
-
end
|
604
|
-
end
|
605
|
-
|
606
551
|
describe '#delete_trigger' do
|
607
|
-
let(:http_client) {subject.http_client}
|
608
|
-
|
609
552
|
context 'tags' do
|
610
553
|
let(:id) {42}
|
611
554
|
|
@@ -619,7 +562,7 @@ describe Postmark::ApiClient do
|
|
619
562
|
expect(subject.delete_trigger(:tags, id)).to eq(:foo => 'Bar')
|
620
563
|
end
|
621
564
|
end
|
622
|
-
|
565
|
+
|
623
566
|
context 'inbound rules' do
|
624
567
|
let(:id) {42}
|
625
568
|
|
@@ -636,19 +579,8 @@ describe Postmark::ApiClient do
|
|
636
579
|
end
|
637
580
|
|
638
581
|
describe '#get_triggers' do
|
639
|
-
let(:http_client) {subject.http_client}
|
640
582
|
let(:options) {{:offset => 5}}
|
641
583
|
|
642
|
-
context 'tags' do
|
643
|
-
let(:response) {{'Tags' => [], 'TotalCount' => 0}}
|
644
|
-
|
645
|
-
it 'performs a GET request to /triggers/tags' do
|
646
|
-
allow(http_client).to receive(:get).with('triggers/tags', options) {response}
|
647
|
-
expect(subject.get_triggers(:tags, options)).to be_an(Array)
|
648
|
-
expect(subject.get_triggers(:tags, options).count).to be_zero
|
649
|
-
end
|
650
|
-
end
|
651
|
-
|
652
584
|
context 'inbound rules' do
|
653
585
|
let(:response) {{'InboundRules' => [], 'TotalCount' => 0}}
|
654
586
|
|
@@ -674,7 +606,6 @@ describe Postmark::ApiClient do
|
|
674
606
|
end
|
675
607
|
|
676
608
|
describe "#server_info" do
|
677
|
-
let(:http_client) {subject.http_client}
|
678
609
|
let(:response) {{"Name" => "Testing",
|
679
610
|
"Color" => "blue",
|
680
611
|
"InboundHash" => "c2425d77f74f8643e5f6237438086c81",
|
@@ -687,7 +618,6 @@ describe Postmark::ApiClient do
|
|
687
618
|
end
|
688
619
|
|
689
620
|
describe "#update_server_info" do
|
690
|
-
let(:http_client) {subject.http_client}
|
691
621
|
let(:response) {{"Name" => "Testing",
|
692
622
|
"Color" => "blue",
|
693
623
|
"InboundHash" => "c2425d77f74f8643e5f6237438086c81",
|
@@ -701,7 +631,6 @@ describe Postmark::ApiClient do
|
|
701
631
|
end
|
702
632
|
|
703
633
|
describe '#get_templates' do
|
704
|
-
let(:http_client) {subject.http_client}
|
705
634
|
let(:response) do
|
706
635
|
{
|
707
636
|
'TotalCount' => 31,
|
@@ -745,7 +674,6 @@ describe Postmark::ApiClient do
|
|
745
674
|
end
|
746
675
|
|
747
676
|
describe '#get_template' do
|
748
|
-
let(:http_client) {subject.http_client}
|
749
677
|
let(:response) do
|
750
678
|
{
|
751
679
|
'Name' => 'Template Name',
|
@@ -770,7 +698,6 @@ describe Postmark::ApiClient do
|
|
770
698
|
end
|
771
699
|
|
772
700
|
describe '#create_template' do
|
773
|
-
let(:http_client) {subject.http_client}
|
774
701
|
let(:response) do
|
775
702
|
{
|
776
703
|
'TemplateId' => 123,
|
@@ -792,7 +719,6 @@ describe Postmark::ApiClient do
|
|
792
719
|
end
|
793
720
|
|
794
721
|
describe '#update_template' do
|
795
|
-
let(:http_client) {subject.http_client}
|
796
722
|
let(:response) do
|
797
723
|
{
|
798
724
|
'TemplateId' => 123,
|
@@ -814,7 +740,6 @@ describe Postmark::ApiClient do
|
|
814
740
|
end
|
815
741
|
|
816
742
|
describe '#delete_template' do
|
817
|
-
let(:http_client) {subject.http_client}
|
818
743
|
let(:response) do
|
819
744
|
{
|
820
745
|
'ErrorCode' => 0,
|
@@ -832,8 +757,6 @@ describe Postmark::ApiClient do
|
|
832
757
|
end
|
833
758
|
|
834
759
|
describe '#validate_template' do
|
835
|
-
let(:http_client) {subject.http_client}
|
836
|
-
|
837
760
|
context 'when template is valid' do
|
838
761
|
let(:response) do
|
839
762
|
{
|
@@ -929,7 +852,6 @@ describe Postmark::ApiClient do
|
|
929
852
|
|
930
853
|
describe "#deliver_with_template" do
|
931
854
|
let(:email) {Postmark::MessageHelper.to_postmark(message_hash)}
|
932
|
-
let(:http_client) {subject.http_client}
|
933
855
|
let(:response) {{"MessageID" => 42}}
|
934
856
|
|
935
857
|
it 'converts message hash to Postmark format and posts it to /email/withTemplate' do
|
@@ -954,7 +876,6 @@ describe Postmark::ApiClient do
|
|
954
876
|
describe '#deliver_in_batches_with_templates' do
|
955
877
|
let(:max_batch_size) {50}
|
956
878
|
let(:factor) {3.5}
|
957
|
-
let(:http_client) {subject.http_client}
|
958
879
|
let(:postmark_response) do
|
959
880
|
{
|
960
881
|
'ErrorCode' => 0,
|
@@ -1014,7 +935,6 @@ describe Postmark::ApiClient do
|
|
1014
935
|
"BounceRate" => 10.406,
|
1015
936
|
}
|
1016
937
|
end
|
1017
|
-
let(:http_client) {subject.http_client}
|
1018
938
|
|
1019
939
|
it 'converts response to ruby format' do
|
1020
940
|
expect(http_client).to receive(:get).with('stats/outbound', {:tag => 'foo'}) {response}
|
@@ -1048,7 +968,6 @@ describe Postmark::ApiClient do
|
|
1048
968
|
"Sent" => 615
|
1049
969
|
}
|
1050
970
|
end
|
1051
|
-
let(:http_client) {subject.http_client}
|
1052
971
|
|
1053
972
|
it 'converts response to ruby format' do
|
1054
973
|
expect(http_client).to receive(:get).with('stats/outbound/sends', {:tag => 'foo'}) {response}
|
@@ -1083,4 +1002,295 @@ describe Postmark::ApiClient do
|
|
1083
1002
|
expect(first_day).to have_key(:sent)
|
1084
1003
|
end
|
1085
1004
|
end
|
1005
|
+
|
1006
|
+
describe '#get_message_streams' do
|
1007
|
+
subject(:result) { api_client.get_message_streams(:offset => 22, :count => 33) }
|
1008
|
+
|
1009
|
+
before do
|
1010
|
+
allow(http_client).to receive(:get).
|
1011
|
+
with('message-streams', :offset => 22, :count => 33).
|
1012
|
+
and_return({ 'TotalCount' => 1, 'MessageStreams' => [{'Name' => 'abc'}]})
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
it { is_expected.to be_an(Array) }
|
1016
|
+
|
1017
|
+
describe 'returned item' do
|
1018
|
+
subject { result.first }
|
1019
|
+
|
1020
|
+
it { is_expected.to match(:name => 'abc') }
|
1021
|
+
end
|
1022
|
+
end
|
1023
|
+
|
1024
|
+
describe '#message_streams' do
|
1025
|
+
subject { api_client.message_streams }
|
1026
|
+
|
1027
|
+
it { is_expected.to be_kind_of(Enumerable) }
|
1028
|
+
|
1029
|
+
it 'requests data at /message-streams' do
|
1030
|
+
allow(http_client).to receive(:get).
|
1031
|
+
with('message-streams', anything).
|
1032
|
+
and_return('TotalCount' => 1, 'MessageStreams' => [{}])
|
1033
|
+
expect(subject.first(5).count).to eq(1)
|
1034
|
+
end
|
1035
|
+
end
|
1036
|
+
|
1037
|
+
describe '#get_message_stream' do
|
1038
|
+
subject(:result) { api_client.get_message_stream(123) }
|
1039
|
+
|
1040
|
+
before do
|
1041
|
+
allow(http_client).to receive(:get).
|
1042
|
+
with('message-streams/123').
|
1043
|
+
and_return({
|
1044
|
+
'Id' => 'xxx',
|
1045
|
+
'Name' => 'My Stream',
|
1046
|
+
'ServerID' => 321,
|
1047
|
+
'MessageStreamType' => 'Transactional'
|
1048
|
+
})
|
1049
|
+
end
|
1050
|
+
|
1051
|
+
it {
|
1052
|
+
is_expected.to match(
|
1053
|
+
:id => 'xxx',
|
1054
|
+
:name => 'My Stream',
|
1055
|
+
:server_id => 321,
|
1056
|
+
:message_stream_type => 'Transactional'
|
1057
|
+
)
|
1058
|
+
}
|
1059
|
+
end
|
1060
|
+
|
1061
|
+
describe '#create_message_stream' do
|
1062
|
+
subject { api_client.create_message_stream(attrs) }
|
1063
|
+
|
1064
|
+
let(:attrs) do
|
1065
|
+
{
|
1066
|
+
:name => 'My Stream',
|
1067
|
+
:id => 'my-stream',
|
1068
|
+
:message_stream_type => 'Broadcasts'
|
1069
|
+
}
|
1070
|
+
end
|
1071
|
+
|
1072
|
+
let(:response) do
|
1073
|
+
{
|
1074
|
+
'Name' => 'My Stream',
|
1075
|
+
'Id' => 'my-stream',
|
1076
|
+
'MessageStreamType' => 'Broadcasts',
|
1077
|
+
'ServerId' => 222,
|
1078
|
+
'CreatedAt' => '2020-04-01T03:33:33.333-03:00'
|
1079
|
+
}
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
before do
|
1083
|
+
allow(http_client).to receive(:post) { response }
|
1084
|
+
end
|
1085
|
+
|
1086
|
+
specify do
|
1087
|
+
expect(http_client).to receive(:post).
|
1088
|
+
with('message-streams',
|
1089
|
+
json_representation_of({
|
1090
|
+
'Name' => 'My Stream',
|
1091
|
+
'Id' => 'my-stream',
|
1092
|
+
'MessageStreamType' => 'Broadcasts'
|
1093
|
+
}))
|
1094
|
+
subject
|
1095
|
+
end
|
1096
|
+
|
1097
|
+
it {
|
1098
|
+
is_expected.to match(
|
1099
|
+
:id => 'my-stream',
|
1100
|
+
:name => 'My Stream',
|
1101
|
+
:server_id => 222,
|
1102
|
+
:message_stream_type => 'Broadcasts',
|
1103
|
+
:created_at => '2020-04-01T03:33:33.333-03:00'
|
1104
|
+
)
|
1105
|
+
}
|
1106
|
+
end
|
1107
|
+
|
1108
|
+
describe '#update_message_stream' do
|
1109
|
+
subject { api_client.update_message_stream('xxx', attrs) }
|
1110
|
+
|
1111
|
+
let(:attrs) do
|
1112
|
+
{
|
1113
|
+
:name => 'My Stream XXX'
|
1114
|
+
}
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
let(:response) do
|
1118
|
+
{
|
1119
|
+
'Name' => 'My Stream XXX',
|
1120
|
+
'Id' => 'xxx',
|
1121
|
+
'MessageStreamType' => 'Broadcasts',
|
1122
|
+
'ServerId' => 222,
|
1123
|
+
'CreatedAt' => '2020-04-01T03:33:33.333-03:00'
|
1124
|
+
}
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
before do
|
1128
|
+
allow(http_client).to receive(:patch) { response }
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
specify do
|
1132
|
+
expect(http_client).to receive(:patch).
|
1133
|
+
with('message-streams/xxx',
|
1134
|
+
match_json({
|
1135
|
+
:Name => 'My Stream XXX',
|
1136
|
+
}))
|
1137
|
+
subject
|
1138
|
+
end
|
1139
|
+
|
1140
|
+
it {
|
1141
|
+
is_expected.to match(
|
1142
|
+
:id => 'xxx',
|
1143
|
+
:name => 'My Stream XXX',
|
1144
|
+
:server_id => 222,
|
1145
|
+
:message_stream_type => 'Broadcasts',
|
1146
|
+
:created_at => '2020-04-01T03:33:33.333-03:00'
|
1147
|
+
)
|
1148
|
+
}
|
1149
|
+
end
|
1150
|
+
|
1151
|
+
describe '#create_suppressions' do
|
1152
|
+
let(:email_addresses) { nil }
|
1153
|
+
let(:message_stream_id) { 'outbound' }
|
1154
|
+
|
1155
|
+
subject { api_client.create_suppressions(message_stream_id, email_addresses) }
|
1156
|
+
|
1157
|
+
context '1 email address as string' do
|
1158
|
+
let(:email_addresses) { 'A@example.com' }
|
1159
|
+
|
1160
|
+
specify do
|
1161
|
+
expect(http_client).to receive(:post).
|
1162
|
+
with('message-streams/outbound/suppressions',
|
1163
|
+
match_json({
|
1164
|
+
:Suppressions => [
|
1165
|
+
{ :EmailAddress => 'A@example.com' }
|
1166
|
+
]}))
|
1167
|
+
subject
|
1168
|
+
end
|
1169
|
+
end
|
1170
|
+
|
1171
|
+
context '1 email address as string & non-default stream' do
|
1172
|
+
let(:email_addresses) { 'A@example.com' }
|
1173
|
+
let(:message_stream_id) { 'xxxx' }
|
1174
|
+
|
1175
|
+
specify do
|
1176
|
+
expect(http_client).to receive(:post).
|
1177
|
+
with('message-streams/xxxx/suppressions',
|
1178
|
+
match_json({
|
1179
|
+
:Suppressions => [
|
1180
|
+
{ :EmailAddress => 'A@example.com' }
|
1181
|
+
]}))
|
1182
|
+
subject
|
1183
|
+
end
|
1184
|
+
end
|
1185
|
+
|
1186
|
+
context '1 email address as array of strings' do
|
1187
|
+
let(:email_addresses) { ['A@example.com'] }
|
1188
|
+
|
1189
|
+
specify do
|
1190
|
+
expect(http_client).to receive(:post).
|
1191
|
+
with('message-streams/outbound/suppressions',
|
1192
|
+
match_json({
|
1193
|
+
:Suppressions => [
|
1194
|
+
{ :EmailAddress => 'A@example.com' }
|
1195
|
+
]}))
|
1196
|
+
subject
|
1197
|
+
end
|
1198
|
+
end
|
1199
|
+
|
1200
|
+
context 'many email addresses as array of strings' do
|
1201
|
+
let(:email_addresses) { ['A@example.com', 'B@example.com'] }
|
1202
|
+
|
1203
|
+
specify do
|
1204
|
+
expect(http_client).to receive(:post).
|
1205
|
+
with('message-streams/outbound/suppressions',
|
1206
|
+
match_json({
|
1207
|
+
:Suppressions => [
|
1208
|
+
{ :EmailAddress => 'A@example.com' },
|
1209
|
+
{ :EmailAddress => 'B@example.com' }
|
1210
|
+
]}))
|
1211
|
+
subject
|
1212
|
+
end
|
1213
|
+
end
|
1214
|
+
end
|
1215
|
+
|
1216
|
+
describe '#delete_suppressions' do
|
1217
|
+
let(:email_addresses) { nil }
|
1218
|
+
let(:message_stream_id) { 'outbound' }
|
1219
|
+
|
1220
|
+
subject { api_client.delete_suppressions(message_stream_id, email_addresses) }
|
1221
|
+
|
1222
|
+
context '1 email address as string' do
|
1223
|
+
let(:email_addresses) { 'A@example.com' }
|
1224
|
+
|
1225
|
+
specify do
|
1226
|
+
expect(http_client).to receive(:post).
|
1227
|
+
with('message-streams/outbound/suppressions/delete',
|
1228
|
+
match_json({
|
1229
|
+
:Suppressions => [
|
1230
|
+
{ :EmailAddress => 'A@example.com' },
|
1231
|
+
]}))
|
1232
|
+
subject
|
1233
|
+
end
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
context '1 email address as string & non-default stream' do
|
1237
|
+
let(:email_addresses) { 'A@example.com' }
|
1238
|
+
let(:message_stream_id) { 'xxxx' }
|
1239
|
+
|
1240
|
+
specify do
|
1241
|
+
expect(http_client).to receive(:post).
|
1242
|
+
with('message-streams/xxxx/suppressions/delete',
|
1243
|
+
match_json({
|
1244
|
+
:Suppressions => [
|
1245
|
+
{ :EmailAddress => 'A@example.com' }
|
1246
|
+
]}))
|
1247
|
+
subject
|
1248
|
+
end
|
1249
|
+
end
|
1250
|
+
|
1251
|
+
context '1 email address as array of strings' do
|
1252
|
+
let(:email_addresses) { ['A@example.com'] }
|
1253
|
+
|
1254
|
+
specify do
|
1255
|
+
expect(http_client).to receive(:post).
|
1256
|
+
with('message-streams/outbound/suppressions/delete',
|
1257
|
+
match_json({
|
1258
|
+
:Suppressions => [
|
1259
|
+
{ :EmailAddress => 'A@example.com' }
|
1260
|
+
]}))
|
1261
|
+
subject
|
1262
|
+
end
|
1263
|
+
end
|
1264
|
+
|
1265
|
+
context 'many email addresses as array of strings' do
|
1266
|
+
let(:email_addresses) { ['A@example.com', 'B@example.com'] }
|
1267
|
+
|
1268
|
+
specify do
|
1269
|
+
expect(http_client).to receive(:post).
|
1270
|
+
with('message-streams/outbound/suppressions/delete',
|
1271
|
+
match_json({
|
1272
|
+
:Suppressions => [
|
1273
|
+
{ :EmailAddress => 'A@example.com' },
|
1274
|
+
{ :EmailAddress => 'B@example.com' }
|
1275
|
+
]}))
|
1276
|
+
subject
|
1277
|
+
end
|
1278
|
+
end
|
1279
|
+
end
|
1280
|
+
|
1281
|
+
describe '#dump_suppressions' do
|
1282
|
+
let(:message_stream_id) { 'xxxx' }
|
1283
|
+
|
1284
|
+
subject { api_client.dump_suppressions(message_stream_id, :count => 123) }
|
1285
|
+
|
1286
|
+
before do
|
1287
|
+
allow(http_client).to receive(:get).and_return({'TotalCount' => 0, 'Suppressions' => []})
|
1288
|
+
end
|
1289
|
+
|
1290
|
+
specify do
|
1291
|
+
expect(http_client).to receive(:get).
|
1292
|
+
with('message-streams/xxxx/suppressions/dump', { :count => 123, :offset => 0 })
|
1293
|
+
subject
|
1294
|
+
end
|
1295
|
+
end
|
1086
1296
|
end
|
@@ -42,9 +42,9 @@ describe Postmark::HttpClient do
|
|
42
42
|
its(:http_read_timeout) { is_expected.to eq 15 }
|
43
43
|
its(:http_open_timeout) { is_expected.to eq 5 }
|
44
44
|
|
45
|
-
it '
|
45
|
+
it 'does not provide a default which utilizes the Net::HTTP default', :skip_ruby_version => ['1.8.7'] do
|
46
46
|
http_client = subject.http
|
47
|
-
expect(http_client.ssl_version).to eq
|
47
|
+
expect(http_client.ssl_version).to eq nil
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
@@ -140,7 +140,7 @@ describe Postmark::HttpClient do
|
|
140
140
|
:status => [ "485", "Custom HTTP response status" ])
|
141
141
|
expect { subject.post(target_path) }.to raise_error Postmark::UnknownError
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
end
|
145
145
|
|
146
146
|
describe "#get" do
|
@@ -180,7 +180,7 @@ describe Postmark::HttpClient do
|
|
180
180
|
:status => [ "485", "Custom HTTP response status" ])
|
181
181
|
expect { subject.get(target_path) }.to raise_error Postmark::UnknownError
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
end
|
185
185
|
|
186
186
|
describe "#put" do
|
@@ -223,4 +223,4 @@ describe Postmark::HttpClient do
|
|
223
223
|
expect { subject.put(target_path) }.to raise_error Postmark::UnknownError
|
224
224
|
end
|
225
225
|
end
|
226
|
-
end
|
226
|
+
end
|
@@ -173,7 +173,7 @@ describe Postmark::MailMessageConverter do
|
|
173
173
|
end
|
174
174
|
|
175
175
|
it 'converts plain text messages correctly' do
|
176
|
-
expect(subject.new(mail_message).run).to eq
|
176
|
+
expect(subject.new(mail_message).run).to eq({
|
177
177
|
"From" => "sheldon@bigbangtheory.com",
|
178
178
|
"Subject" => "Hello!",
|
179
179
|
"TextBody" => "Hello Sheldon!",
|
@@ -181,7 +181,7 @@ describe Postmark::MailMessageConverter do
|
|
181
181
|
end
|
182
182
|
|
183
183
|
it 'converts tagged text messages correctly' do
|
184
|
-
expect(subject.new(tagged_mail_message).run).to eq
|
184
|
+
expect(subject.new(tagged_mail_message).run).to eq({
|
185
185
|
"From" => "sheldon@bigbangtheory.com",
|
186
186
|
"Subject" => "Hello!",
|
187
187
|
"TextBody" => "Hello Sheldon!",
|
@@ -190,14 +190,14 @@ describe Postmark::MailMessageConverter do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
it 'converts plain text messages without body correctly' do
|
193
|
-
expect(subject.new(mail_message_without_body).run).to eq
|
193
|
+
expect(subject.new(mail_message_without_body).run).to eq({
|
194
194
|
"From" => "sheldon@bigbangtheory.com",
|
195
195
|
"Subject" => "Hello!",
|
196
196
|
"To" => "lenard@bigbangtheory.com"})
|
197
197
|
end
|
198
198
|
|
199
199
|
it 'converts html messages correctly' do
|
200
|
-
expect(subject.new(mail_html_message).run).to eq
|
200
|
+
expect(subject.new(mail_html_message).run).to eq({
|
201
201
|
"From" => "sheldon@bigbangtheory.com",
|
202
202
|
"Subject" => "Hello!",
|
203
203
|
"HtmlBody" => "<b>Hello Sheldon!</b>",
|
@@ -205,7 +205,7 @@ describe Postmark::MailMessageConverter do
|
|
205
205
|
end
|
206
206
|
|
207
207
|
it 'converts multipart messages correctly' do
|
208
|
-
expect(subject.new(mail_multipart_message).run).to eq
|
208
|
+
expect(subject.new(mail_multipart_message).run).to eq({
|
209
209
|
"From" => "sheldon@bigbangtheory.com",
|
210
210
|
"Subject" => "Hello!",
|
211
211
|
"HtmlBody" => "<b>Hello Sheldon!</b>",
|
@@ -214,7 +214,7 @@ describe Postmark::MailMessageConverter do
|
|
214
214
|
end
|
215
215
|
|
216
216
|
it 'converts messages with attachments correctly' do
|
217
|
-
expect(subject.new(mail_message_with_attachment).run).to eq
|
217
|
+
expect(subject.new(mail_message_with_attachment).run).to eq({
|
218
218
|
"From" => "sheldon@bigbangtheory.com",
|
219
219
|
"Subject" => "Hello!",
|
220
220
|
"Attachments" => [{"Name" => "empty.gif",
|
@@ -225,7 +225,7 @@ describe Postmark::MailMessageConverter do
|
|
225
225
|
end
|
226
226
|
|
227
227
|
it 'converts messages with named addresses correctly' do
|
228
|
-
expect(subject.new(mail_message_with_named_addresses).run).to eq
|
228
|
+
expect(subject.new(mail_message_with_named_addresses).run).to eq({
|
229
229
|
"From" => "Sheldon <sheldon@bigbangtheory.com>",
|
230
230
|
"Subject" => "Hello!",
|
231
231
|
"TextBody" => "Hello Sheldon!",
|
@@ -244,7 +244,7 @@ describe Postmark::MailMessageConverter do
|
|
244
244
|
context 'open tracking' do
|
245
245
|
context 'setup inside of mail' do
|
246
246
|
it 'converts open tracking enabled messages correctly' do
|
247
|
-
expect(subject.new(mail_message_with_open_tracking).run).to eq
|
247
|
+
expect(subject.new(mail_message_with_open_tracking).run).to eq({
|
248
248
|
"From" => "sheldon@bigbangtheory.com",
|
249
249
|
"Subject" => "Hello!",
|
250
250
|
"HtmlBody" => "<b>Hello Sheldon!</b>",
|
@@ -253,7 +253,7 @@ describe Postmark::MailMessageConverter do
|
|
253
253
|
end
|
254
254
|
|
255
255
|
it 'converts open tracking disabled messages correctly' do
|
256
|
-
expect(subject.new(mail_message_with_open_tracking_disabled).run).to eq
|
256
|
+
expect(subject.new(mail_message_with_open_tracking_disabled).run).to eq({
|
257
257
|
"From" => "sheldon@bigbangtheory.com",
|
258
258
|
"Subject" => "Hello!",
|
259
259
|
"HtmlBody" => "<b>Hello Sheldon!</b>",
|
@@ -264,7 +264,7 @@ describe Postmark::MailMessageConverter do
|
|
264
264
|
|
265
265
|
context 'setup with tracking variable' do
|
266
266
|
it 'converts open tracking enabled messages correctly' do
|
267
|
-
expect(subject.new(mail_message_with_open_tracking_set_variable).run).to eq
|
267
|
+
expect(subject.new(mail_message_with_open_tracking_set_variable).run).to eq({
|
268
268
|
"From" => "sheldon@bigbangtheory.com",
|
269
269
|
"Subject" => "Hello!",
|
270
270
|
"HtmlBody" => "<b>Hello Sheldon!</b>",
|
@@ -273,7 +273,7 @@ describe Postmark::MailMessageConverter do
|
|
273
273
|
end
|
274
274
|
|
275
275
|
it 'converts open tracking disabled messages correctly' do
|
276
|
-
expect(subject.new(mail_message_with_open_tracking_disabled_set_variable).run).to eq
|
276
|
+
expect(subject.new(mail_message_with_open_tracking_disabled_set_variable).run).to eq({
|
277
277
|
"From" => "sheldon@bigbangtheory.com",
|
278
278
|
"Subject" => "Hello!",
|
279
279
|
"HtmlBody" => "<b>Hello Sheldon!</b>",
|
@@ -285,7 +285,7 @@ describe Postmark::MailMessageConverter do
|
|
285
285
|
|
286
286
|
context 'link tracking' do
|
287
287
|
it 'converts html and text link tracking enabled messages correctly' do
|
288
|
-
expect(subject.new(mail_message_with_link_tracking_all).run).to eq
|
288
|
+
expect(subject.new(mail_message_with_link_tracking_all).run).to eq({
|
289
289
|
"From" => "sheldon@bigbangtheory.com",
|
290
290
|
"Subject" => "Hello!",
|
291
291
|
"HtmlBody" => "<b>Hello Sheldon!</b>",
|
@@ -294,7 +294,7 @@ describe Postmark::MailMessageConverter do
|
|
294
294
|
end
|
295
295
|
|
296
296
|
it 'converts html only link tracking enabled messages correctly' do
|
297
|
-
expect(subject.new(mail_message_with_link_tracking_html).run).to eq
|
297
|
+
expect(subject.new(mail_message_with_link_tracking_html).run).to eq({
|
298
298
|
"From" => "sheldon@bigbangtheory.com",
|
299
299
|
"Subject" => "Hello!",
|
300
300
|
"HtmlBody" => "<b>Hello Sheldon!</b>",
|
@@ -303,7 +303,7 @@ describe Postmark::MailMessageConverter do
|
|
303
303
|
end
|
304
304
|
|
305
305
|
it 'converts text only link tracking enabled messages correctly' do
|
306
|
-
expect(subject.new(mail_message_with_link_tracking_text).run).to eq
|
306
|
+
expect(subject.new(mail_message_with_link_tracking_text).run).to eq({
|
307
307
|
"From" => "sheldon@bigbangtheory.com",
|
308
308
|
"Subject" => "Hello!",
|
309
309
|
"HtmlBody" => "<b>Hello Sheldon!</b>",
|
@@ -374,4 +374,20 @@ describe Postmark::MailMessageConverter do
|
|
374
374
|
expect(mail_message.to_postmark_hash.keys).not_to include('Cc')
|
375
375
|
end
|
376
376
|
end
|
377
|
+
|
378
|
+
describe 'passing message stream' do
|
379
|
+
context 'when not set' do
|
380
|
+
specify { expect(subject.new(mail_message).run).not_to include('MessageStream') }
|
381
|
+
end
|
382
|
+
|
383
|
+
context 'when set' do
|
384
|
+
before do
|
385
|
+
mail_message.message_stream = 'weekly-newsletter'
|
386
|
+
end
|
387
|
+
|
388
|
+
it 'passes message stream to the API call' do
|
389
|
+
expect(subject.new(mail_message).run).to include('MessageStream' => 'weekly-newsletter')
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
377
393
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postmark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.21.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petyo Ivanov
|
8
8
|
- Ilya Sabanin
|
9
9
|
- Artem Chistyakov
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-03
|
13
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- Gemfile
|
74
74
|
- LICENSE
|
75
75
|
- README.md
|
76
|
+
- RELEASE.md
|
76
77
|
- Rakefile
|
77
78
|
- VERSION
|
78
79
|
- gemfiles/Gemfile.legacy
|
@@ -146,8 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
147
|
- !ruby/object:Gem::Version
|
147
148
|
version: 1.3.7
|
148
149
|
requirements: []
|
149
|
-
rubygems_version: 3.1.
|
150
|
-
signing_key:
|
150
|
+
rubygems_version: 3.1.4
|
151
|
+
signing_key:
|
151
152
|
specification_version: 4
|
152
153
|
summary: Official Postmark API wrapper.
|
153
154
|
test_files:
|