postmark 1.20.0 → 1.21.0
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/CHANGELOG.rdoc +4 -0
- data/README.md +1 -1
- data/lib/postmark/api_client.rb +33 -0
- data/lib/postmark/mail_message_converter.rb +2 -1
- data/lib/postmark/message_extensions/mail.rb +6 -0
- data/lib/postmark/version.rb +1 -1
- data/spec/support/custom_matchers.rb +4 -0
- data/spec/unit/postmark/api_client_spec.rb +148 -40
- data/spec/unit/postmark/mail_message_converter_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ecfd4ac720289669cf67d8f13816bec20b985796dc9413e9e34271bbd3ece81
|
4
|
+
data.tar.gz: f42b2d7331f764f3552cd002e0876ea8da8aad4ebc6f56d14504d5c80d96d8c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f7953e239dcb2b78970694e9c0423d1f2ca3439cafb418e83f47ba24dfe535fece7f7b853986b8f7bb460826f9af3517750cb7e919f71deec4b463734aaed42
|
7
|
+
data.tar.gz: 18d9b5e906b072d8c7e9b832190637290b134ac06e1a66ec299294c07a0cbf1017f932bb65eb4de38448b33a9c245eced584e9eb0665f824be60c72f06ed1e75
|
data/.gitignore
CHANGED
data/CHANGELOG.rdoc
CHANGED
data/README.md
CHANGED
data/lib/postmark/api_client.rb
CHANGED
@@ -328,6 +328,39 @@ module Postmark
|
|
328
328
|
format_response http_client.delete("webhooks/#{id}")
|
329
329
|
end
|
330
330
|
|
331
|
+
def get_message_streams(options = {})
|
332
|
+
load_batch('message-streams', 'MessageStreams', options)
|
333
|
+
end
|
334
|
+
|
335
|
+
def get_message_stream(id)
|
336
|
+
format_response(http_client.get("message-streams/#{id}"))
|
337
|
+
end
|
338
|
+
|
339
|
+
def create_message_stream(attributes = {})
|
340
|
+
data = serialize(HashHelper.to_postmark(attributes))
|
341
|
+
format_response(http_client.post('message-streams', data))
|
342
|
+
end
|
343
|
+
|
344
|
+
def update_message_stream(id, attributes)
|
345
|
+
data = serialize(HashHelper.to_postmark(attributes))
|
346
|
+
format_response(http_client.patch("message-streams/#{id}", data))
|
347
|
+
end
|
348
|
+
|
349
|
+
def dump_suppressions(stream_id, options = {})
|
350
|
+
_, batch = load_batch("message-streams/#{stream_id}/suppressions/dump", 'Suppressions', options)
|
351
|
+
batch
|
352
|
+
end
|
353
|
+
|
354
|
+
def create_suppressions(stream_id, email_addresses)
|
355
|
+
data = serialize(:Suppressions => Array(email_addresses).map { |e| HashHelper.to_postmark(:email_address => e) })
|
356
|
+
format_response(http_client.post("message-streams/#{stream_id}/suppressions", data))
|
357
|
+
end
|
358
|
+
|
359
|
+
def delete_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/delete", data))
|
362
|
+
end
|
363
|
+
|
331
364
|
protected
|
332
365
|
|
333
366
|
def in_batches(messages)
|
@@ -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
|
|
data/lib/postmark/version.rb
CHANGED
@@ -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,8 +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
520
|
context 'inbound rules' do
|
542
521
|
let(:options) {{:rule => 'example.com'}}
|
543
522
|
let(:response) {{'Rule' => 'example.com'}}
|
@@ -556,7 +535,6 @@ describe Postmark::ApiClient do
|
|
556
535
|
end
|
557
536
|
|
558
537
|
describe '#get_trigger' do
|
559
|
-
let(:http_client) {subject.http_client}
|
560
538
|
let(:id) {42}
|
561
539
|
|
562
540
|
it 'performs a GET request to /triggers/tags/:id' do
|
@@ -571,8 +549,6 @@ describe Postmark::ApiClient do
|
|
571
549
|
end
|
572
550
|
|
573
551
|
describe '#delete_trigger' do
|
574
|
-
let(:http_client) {subject.http_client}
|
575
|
-
|
576
552
|
context 'tags' do
|
577
553
|
let(:id) {42}
|
578
554
|
|
@@ -603,7 +579,6 @@ describe Postmark::ApiClient do
|
|
603
579
|
end
|
604
580
|
|
605
581
|
describe '#get_triggers' do
|
606
|
-
let(:http_client) {subject.http_client}
|
607
582
|
let(:options) {{:offset => 5}}
|
608
583
|
|
609
584
|
context 'inbound rules' do
|
@@ -631,7 +606,6 @@ describe Postmark::ApiClient do
|
|
631
606
|
end
|
632
607
|
|
633
608
|
describe "#server_info" do
|
634
|
-
let(:http_client) {subject.http_client}
|
635
609
|
let(:response) {{"Name" => "Testing",
|
636
610
|
"Color" => "blue",
|
637
611
|
"InboundHash" => "c2425d77f74f8643e5f6237438086c81",
|
@@ -644,7 +618,6 @@ describe Postmark::ApiClient do
|
|
644
618
|
end
|
645
619
|
|
646
620
|
describe "#update_server_info" do
|
647
|
-
let(:http_client) {subject.http_client}
|
648
621
|
let(:response) {{"Name" => "Testing",
|
649
622
|
"Color" => "blue",
|
650
623
|
"InboundHash" => "c2425d77f74f8643e5f6237438086c81",
|
@@ -658,7 +631,6 @@ describe Postmark::ApiClient do
|
|
658
631
|
end
|
659
632
|
|
660
633
|
describe '#get_templates' do
|
661
|
-
let(:http_client) {subject.http_client}
|
662
634
|
let(:response) do
|
663
635
|
{
|
664
636
|
'TotalCount' => 31,
|
@@ -702,7 +674,6 @@ describe Postmark::ApiClient do
|
|
702
674
|
end
|
703
675
|
|
704
676
|
describe '#get_template' do
|
705
|
-
let(:http_client) {subject.http_client}
|
706
677
|
let(:response) do
|
707
678
|
{
|
708
679
|
'Name' => 'Template Name',
|
@@ -727,7 +698,6 @@ describe Postmark::ApiClient do
|
|
727
698
|
end
|
728
699
|
|
729
700
|
describe '#create_template' do
|
730
|
-
let(:http_client) {subject.http_client}
|
731
701
|
let(:response) do
|
732
702
|
{
|
733
703
|
'TemplateId' => 123,
|
@@ -749,7 +719,6 @@ describe Postmark::ApiClient do
|
|
749
719
|
end
|
750
720
|
|
751
721
|
describe '#update_template' do
|
752
|
-
let(:http_client) {subject.http_client}
|
753
722
|
let(:response) do
|
754
723
|
{
|
755
724
|
'TemplateId' => 123,
|
@@ -771,7 +740,6 @@ describe Postmark::ApiClient do
|
|
771
740
|
end
|
772
741
|
|
773
742
|
describe '#delete_template' do
|
774
|
-
let(:http_client) {subject.http_client}
|
775
743
|
let(:response) do
|
776
744
|
{
|
777
745
|
'ErrorCode' => 0,
|
@@ -789,8 +757,6 @@ describe Postmark::ApiClient do
|
|
789
757
|
end
|
790
758
|
|
791
759
|
describe '#validate_template' do
|
792
|
-
let(:http_client) {subject.http_client}
|
793
|
-
|
794
760
|
context 'when template is valid' do
|
795
761
|
let(:response) do
|
796
762
|
{
|
@@ -886,7 +852,6 @@ describe Postmark::ApiClient do
|
|
886
852
|
|
887
853
|
describe "#deliver_with_template" do
|
888
854
|
let(:email) {Postmark::MessageHelper.to_postmark(message_hash)}
|
889
|
-
let(:http_client) {subject.http_client}
|
890
855
|
let(:response) {{"MessageID" => 42}}
|
891
856
|
|
892
857
|
it 'converts message hash to Postmark format and posts it to /email/withTemplate' do
|
@@ -911,7 +876,6 @@ describe Postmark::ApiClient do
|
|
911
876
|
describe '#deliver_in_batches_with_templates' do
|
912
877
|
let(:max_batch_size) {50}
|
913
878
|
let(:factor) {3.5}
|
914
|
-
let(:http_client) {subject.http_client}
|
915
879
|
let(:postmark_response) do
|
916
880
|
{
|
917
881
|
'ErrorCode' => 0,
|
@@ -971,7 +935,6 @@ describe Postmark::ApiClient do
|
|
971
935
|
"BounceRate" => 10.406,
|
972
936
|
}
|
973
937
|
end
|
974
|
-
let(:http_client) {subject.http_client}
|
975
938
|
|
976
939
|
it 'converts response to ruby format' do
|
977
940
|
expect(http_client).to receive(:get).with('stats/outbound', {:tag => 'foo'}) {response}
|
@@ -1005,7 +968,6 @@ describe Postmark::ApiClient do
|
|
1005
968
|
"Sent" => 615
|
1006
969
|
}
|
1007
970
|
end
|
1008
|
-
let(:http_client) {subject.http_client}
|
1009
971
|
|
1010
972
|
it 'converts response to ruby format' do
|
1011
973
|
expect(http_client).to receive(:get).with('stats/outbound/sends', {:tag => 'foo'}) {response}
|
@@ -1040,4 +1002,150 @@ describe Postmark::ApiClient do
|
|
1040
1002
|
expect(first_day).to have_key(:sent)
|
1041
1003
|
end
|
1042
1004
|
end
|
1005
|
+
|
1006
|
+
describe '#create_suppressions' do
|
1007
|
+
let(:email_addresses) { nil }
|
1008
|
+
let(:message_stream_id) { 'outbound' }
|
1009
|
+
|
1010
|
+
subject { api_client.create_suppressions(message_stream_id, email_addresses) }
|
1011
|
+
|
1012
|
+
context '1 email address as string' do
|
1013
|
+
let(:email_addresses) { 'A@example.com' }
|
1014
|
+
|
1015
|
+
specify do
|
1016
|
+
expect(http_client).to receive(:post).
|
1017
|
+
with('message-streams/outbound/suppressions',
|
1018
|
+
match_json({
|
1019
|
+
:Suppressions => [
|
1020
|
+
{ :EmailAddress => 'A@example.com' }
|
1021
|
+
]}))
|
1022
|
+
subject
|
1023
|
+
end
|
1024
|
+
end
|
1025
|
+
|
1026
|
+
context '1 email address as string & non-default stream' do
|
1027
|
+
let(:email_addresses) { 'A@example.com' }
|
1028
|
+
let(:message_stream_id) { 'xxxx' }
|
1029
|
+
|
1030
|
+
specify do
|
1031
|
+
expect(http_client).to receive(:post).
|
1032
|
+
with('message-streams/xxxx/suppressions',
|
1033
|
+
match_json({
|
1034
|
+
:Suppressions => [
|
1035
|
+
{ :EmailAddress => 'A@example.com' }
|
1036
|
+
]}))
|
1037
|
+
subject
|
1038
|
+
end
|
1039
|
+
end
|
1040
|
+
|
1041
|
+
context '1 email address as array of strings' do
|
1042
|
+
let(:email_addresses) { ['A@example.com'] }
|
1043
|
+
|
1044
|
+
specify do
|
1045
|
+
expect(http_client).to receive(:post).
|
1046
|
+
with('message-streams/outbound/suppressions',
|
1047
|
+
match_json({
|
1048
|
+
:Suppressions => [
|
1049
|
+
{ :EmailAddress => 'A@example.com' }
|
1050
|
+
]}))
|
1051
|
+
subject
|
1052
|
+
end
|
1053
|
+
end
|
1054
|
+
|
1055
|
+
context 'many email addresses as array of strings' do
|
1056
|
+
let(:email_addresses) { ['A@example.com', 'B@example.com'] }
|
1057
|
+
|
1058
|
+
specify do
|
1059
|
+
expect(http_client).to receive(:post).
|
1060
|
+
with('message-streams/outbound/suppressions',
|
1061
|
+
match_json({
|
1062
|
+
:Suppressions => [
|
1063
|
+
{ :EmailAddress => 'A@example.com' },
|
1064
|
+
{ :EmailAddress => 'B@example.com' }
|
1065
|
+
]}))
|
1066
|
+
subject
|
1067
|
+
end
|
1068
|
+
end
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
describe '#delete_suppressions' do
|
1072
|
+
let(:email_addresses) { nil }
|
1073
|
+
let(:message_stream_id) { 'outbound' }
|
1074
|
+
|
1075
|
+
subject { api_client.delete_suppressions(message_stream_id, email_addresses) }
|
1076
|
+
|
1077
|
+
context '1 email address as string' do
|
1078
|
+
let(:email_addresses) { 'A@example.com' }
|
1079
|
+
|
1080
|
+
specify do
|
1081
|
+
expect(http_client).to receive(:post).
|
1082
|
+
with('message-streams/outbound/suppressions/delete',
|
1083
|
+
match_json({
|
1084
|
+
:Suppressions => [
|
1085
|
+
{ :EmailAddress => 'A@example.com' },
|
1086
|
+
]}))
|
1087
|
+
subject
|
1088
|
+
end
|
1089
|
+
end
|
1090
|
+
|
1091
|
+
context '1 email address as string & non-default stream' do
|
1092
|
+
let(:email_addresses) { 'A@example.com' }
|
1093
|
+
let(:message_stream_id) { 'xxxx' }
|
1094
|
+
|
1095
|
+
specify do
|
1096
|
+
expect(http_client).to receive(:post).
|
1097
|
+
with('message-streams/xxxx/suppressions/delete',
|
1098
|
+
match_json({
|
1099
|
+
:Suppressions => [
|
1100
|
+
{ :EmailAddress => 'A@example.com' }
|
1101
|
+
]}))
|
1102
|
+
subject
|
1103
|
+
end
|
1104
|
+
end
|
1105
|
+
|
1106
|
+
context '1 email address as array of strings' do
|
1107
|
+
let(:email_addresses) { ['A@example.com'] }
|
1108
|
+
|
1109
|
+
specify do
|
1110
|
+
expect(http_client).to receive(:post).
|
1111
|
+
with('message-streams/outbound/suppressions/delete',
|
1112
|
+
match_json({
|
1113
|
+
:Suppressions => [
|
1114
|
+
{ :EmailAddress => 'A@example.com' }
|
1115
|
+
]}))
|
1116
|
+
subject
|
1117
|
+
end
|
1118
|
+
end
|
1119
|
+
|
1120
|
+
context 'many email addresses as array of strings' do
|
1121
|
+
let(:email_addresses) { ['A@example.com', 'B@example.com'] }
|
1122
|
+
|
1123
|
+
specify do
|
1124
|
+
expect(http_client).to receive(:post).
|
1125
|
+
with('message-streams/outbound/suppressions/delete',
|
1126
|
+
match_json({
|
1127
|
+
:Suppressions => [
|
1128
|
+
{ :EmailAddress => 'A@example.com' },
|
1129
|
+
{ :EmailAddress => 'B@example.com' }
|
1130
|
+
]}))
|
1131
|
+
subject
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
end
|
1135
|
+
|
1136
|
+
describe '#dump_suppressions' do
|
1137
|
+
let(:message_stream_id) { 'xxxx' }
|
1138
|
+
|
1139
|
+
subject { api_client.dump_suppressions(message_stream_id, :count => 123) }
|
1140
|
+
|
1141
|
+
before do
|
1142
|
+
allow(http_client).to receive(:get).and_return({'TotalCount' => 0, 'Suppressions' => []})
|
1143
|
+
end
|
1144
|
+
|
1145
|
+
specify do
|
1146
|
+
expect(http_client).to receive(:get).
|
1147
|
+
with('message-streams/xxxx/suppressions/dump', { :count => 123, :offset => 0 })
|
1148
|
+
subject
|
1149
|
+
end
|
1150
|
+
end
|
1043
1151
|
end
|
@@ -374,4 +374,16 @@ 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(mail_message.to_postmark_hash.keys).not_to include('MessageStream') }
|
381
|
+
end
|
382
|
+
|
383
|
+
context 'when set' do
|
384
|
+
before { mail_message.message_stream = 'weekly-newsletter' }
|
385
|
+
|
386
|
+
specify { expect(mail_message.to_postmark_hash).to include('MessageStream' => 'weekly-newsletter') }
|
387
|
+
end
|
388
|
+
end
|
377
389
|
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.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petyo Ivanov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2020-
|
13
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|