postmark 1.18.0 → 1.19.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/lib/postmark/api_client.rb +26 -1
- data/lib/postmark/version.rb +1 -1
- data/spec/integration/api_client_hashes_spec.rb +29 -35
- data/spec/integration/api_client_messages_spec.rb +16 -16
- data/spec/integration/api_client_resources_spec.rb +15 -31
- data/spec/spec_helper.rb +1 -7
- data/spec/support/custom_matchers.rb +6 -0
- data/spec/support/shared_examples.rb +16 -16
- data/spec/unit/postmark/account_api_client_spec.rb +1 -50
- data/spec/unit/postmark/api_client_spec.rb +51 -66
- data/spec/unit/postmark/bounce_spec.rb +37 -49
- data/spec/unit/postmark/client_spec.rb +0 -6
- data/spec/unit/postmark/error_spec.rb +44 -44
- data/spec/unit/postmark/handlers/mail_spec.rb +3 -3
- data/spec/unit/postmark/helpers/hash_helper_spec.rb +5 -6
- data/spec/unit/postmark/http_client_spec.rb +47 -49
- data/spec/unit/postmark/inbound_spec.rb +34 -34
- data/spec/unit/postmark/inflector_spec.rb +11 -13
- data/spec/unit/postmark/json_spec.rb +2 -2
- data/spec/unit/postmark/mail_message_converter_spec.rb +79 -82
- data/spec/unit/postmark_spec.rb +32 -32
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e0a3923cc442e7d0ae9a961fc200640fa9e66b0ec915e2fa0b7e10954b4e018
|
4
|
+
data.tar.gz: d30ad966427f3e380488d87e3932acc71e574f649a297a62aefc80ff3a92cb8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba4a392149529ee77178e0659adbf49fa8dc448805ffb5cb85777e406dd1087dbb0c8609de142433b38f908183228833be449f3571b27fbcf2f265628fd4c377
|
7
|
+
data.tar.gz: 730b83c54860ed1564f2e09645090628f040228513074c02e63539c658d25848175f7783a5af05814a9e9ec9c196a696d21af8cd6b6bf332c756160d9b25a514
|
data/lib/postmark/api_client.rb
CHANGED
@@ -311,6 +311,32 @@ module Postmark
|
|
311
311
|
response
|
312
312
|
end
|
313
313
|
|
314
|
+
def get_webhooks(options = {})
|
315
|
+
options = HashHelper.to_postmark(options)
|
316
|
+
_, batch = load_batch('webhooks', 'Webhooks', options)
|
317
|
+
batch
|
318
|
+
end
|
319
|
+
|
320
|
+
def get_webhook(id)
|
321
|
+
format_response http_client.get("webhooks/#{id}")
|
322
|
+
end
|
323
|
+
|
324
|
+
def create_webhook(attributes = {})
|
325
|
+
data = serialize(HashHelper.to_postmark(attributes))
|
326
|
+
|
327
|
+
format_response http_client.post('webhooks', data)
|
328
|
+
end
|
329
|
+
|
330
|
+
def update_webhook(id, attributes = {})
|
331
|
+
data = serialize(HashHelper.to_postmark(attributes))
|
332
|
+
|
333
|
+
format_response http_client.put("webhooks/#{id}", data)
|
334
|
+
end
|
335
|
+
|
336
|
+
def delete_webhook(id)
|
337
|
+
format_response http_client.delete("webhooks/#{id}")
|
338
|
+
end
|
339
|
+
|
314
340
|
protected
|
315
341
|
|
316
342
|
def in_batches(messages)
|
@@ -339,6 +365,5 @@ module Postmark
|
|
339
365
|
path = options.delete(:inbound) ? 'messages/inbound' : 'messages/outbound'
|
340
366
|
[path, messages_key, options]
|
341
367
|
end
|
342
|
-
|
343
368
|
end
|
344
369
|
end
|
data/lib/postmark/version.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Sending messages as Ruby hashes with Postmark::ApiClient" do
|
4
|
-
let(:message_id_format) {
|
5
|
-
let(:postmark_message_id_format) {
|
6
|
-
let(:api_client) {
|
4
|
+
let(:message_id_format) {/<.+@.+>/}
|
5
|
+
let(:postmark_message_id_format) {/\w{8}\-\w{4}-\w{4}-\w{4}-\w{12}/}
|
6
|
+
let(:api_client) {Postmark::ApiClient.new('POSTMARK_API_TEST', :http_open_timeout => 15, :http_read_timeout => 15)}
|
7
7
|
|
8
8
|
let(:message) {
|
9
9
|
{
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
:from => "sender@postmarkapp.com",
|
11
|
+
:to => "recipient@postmarkapp.com",
|
12
|
+
:subject => "Mail::Message object",
|
13
|
+
:text_body => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " \
|
14
14
|
"sed do eiusmod tempor incididunt ut labore et dolore " \
|
15
15
|
"magna aliqua."
|
16
16
|
}
|
@@ -18,8 +18,8 @@ describe "Sending messages as Ruby hashes with Postmark::ApiClient" do
|
|
18
18
|
|
19
19
|
let(:message_with_no_body) {
|
20
20
|
{
|
21
|
-
|
22
|
-
|
21
|
+
:from => "sender@postmarkapp.com",
|
22
|
+
:to => "recipient@postmarkapp.com",
|
23
23
|
}
|
24
24
|
}
|
25
25
|
|
@@ -29,66 +29,60 @@ describe "Sending messages as Ruby hashes with Postmark::ApiClient" do
|
|
29
29
|
end
|
30
30
|
}
|
31
31
|
|
32
|
-
let(:message_with_invalid_to) {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
37
|
-
}
|
32
|
+
let(:message_with_invalid_to) {{:from => "sender@postmarkapp.com", :to => "@postmarkapp.com"}}
|
33
|
+
let(:valid_messages) {[message, message.dup]}
|
34
|
+
let(:partially_valid_messages) {[message, message.dup, message_with_no_body]}
|
35
|
+
let(:invalid_messages) {[message_with_no_body, message_with_no_body.dup]}
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
context "single message" do
|
38
|
+
it 'plain text message' do
|
39
|
+
expect(api_client.deliver(message)).to have_key(:message_id)
|
40
|
+
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
api_client.deliver(message).should have_key(:message_id)
|
42
|
+
it 'message with attachment' do
|
43
|
+
expect(api_client.deliver(message_with_attachment)).to have_key(:message_id)
|
46
44
|
end
|
47
45
|
|
48
|
-
it '
|
46
|
+
it 'response Message-ID' do
|
49
47
|
expect(api_client.deliver(message)[:message_id]).to be =~ postmark_message_id_format
|
50
48
|
end
|
51
49
|
|
52
|
-
it '
|
50
|
+
it 'response is Hash' do
|
53
51
|
expect(api_client.deliver(message)).to be_a Hash
|
54
52
|
end
|
55
53
|
|
56
|
-
it 'delivers a message with attachment' do
|
57
|
-
expect(api_client.deliver(message_with_attachment)).to have_key(:message_id)
|
58
|
-
end
|
59
|
-
|
60
54
|
it 'fails to deliver a message without body' do
|
61
|
-
expect {
|
55
|
+
expect {api_client.deliver(message_with_no_body)}.to raise_error(Postmark::InvalidMessageError)
|
62
56
|
end
|
63
57
|
|
64
58
|
it 'fails to deliver a message with invalid To address' do
|
65
|
-
expect {
|
59
|
+
expect {api_client.deliver(message_with_invalid_to)}.to raise_error(Postmark::InvalidMessageError)
|
66
60
|
end
|
67
61
|
end
|
68
62
|
|
69
|
-
context "
|
70
|
-
it '
|
63
|
+
context "batch message" do
|
64
|
+
it 'response messages count' do
|
71
65
|
expect(api_client.deliver_in_batches(valid_messages).count).to eq valid_messages.count
|
72
66
|
end
|
73
67
|
|
74
|
-
context "
|
68
|
+
context "custom max_batch_size" do
|
75
69
|
before do
|
76
70
|
api_client.max_batch_size = 1
|
77
71
|
end
|
78
72
|
|
79
|
-
it '
|
73
|
+
it 'response message count' do
|
80
74
|
expect(api_client.deliver_in_batches(valid_messages).count).to eq valid_messages.count
|
81
75
|
end
|
82
76
|
end
|
83
77
|
|
84
78
|
it 'partially delivers a batch of partially valid Mail::Message objects' do
|
85
79
|
response = api_client.deliver_in_batches(partially_valid_messages)
|
86
|
-
expect(response).to satisfy {
|
80
|
+
expect(response).to satisfy {|r| r.count {|mr| mr[:error_code].to_i.zero?} == 2}
|
87
81
|
end
|
88
82
|
|
89
83
|
it "doesn't deliver a batch of invalid Mail::Message objects" do
|
90
84
|
response = api_client.deliver_in_batches(invalid_messages)
|
91
|
-
expect(response).to satisfy {
|
85
|
+
expect(response).to satisfy {|r| r.all? {|mr| !!mr[:error_code]}}
|
92
86
|
end
|
93
87
|
end
|
94
88
|
end
|
@@ -42,21 +42,21 @@ describe "Sending Mail::Messages with Postmark::ApiClient" do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
context "
|
46
|
-
it '
|
45
|
+
context "single message" do
|
46
|
+
it 'plain text message' do
|
47
47
|
expect(api_client.deliver_message(message)).to have_key(:message_id)
|
48
48
|
end
|
49
49
|
|
50
|
-
it '
|
51
|
-
expect(api_client.deliver_message(
|
50
|
+
it 'message with attachment' do
|
51
|
+
expect(api_client.deliver_message(message_with_attachment)).to have_key(:message_id)
|
52
52
|
end
|
53
53
|
|
54
|
-
it '
|
55
|
-
expect(api_client.deliver_message(message)).to
|
54
|
+
it 'response Message-ID' do
|
55
|
+
expect(api_client.deliver_message(message)[:message_id]).to be =~ postmark_message_id_format
|
56
56
|
end
|
57
57
|
|
58
|
-
it '
|
59
|
-
expect(api_client.deliver_message(
|
58
|
+
it 'response is Hash' do
|
59
|
+
expect(api_client.deliver_message(message)).to be_a Hash
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'fails to deliver a message without body' do
|
@@ -68,37 +68,37 @@ describe "Sending Mail::Messages with Postmark::ApiClient" do
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
-
context "
|
72
|
-
it '
|
71
|
+
context "batch message" do
|
72
|
+
it 'response - valid Mail::Message objects' do
|
73
73
|
expect { api_client.deliver_messages(valid_messages) }.
|
74
74
|
to change{valid_messages.all? { |m| m.delivered? }}.to true
|
75
75
|
end
|
76
76
|
|
77
|
-
it '
|
77
|
+
it 'response - valid X-PM-Message-Ids' do
|
78
78
|
api_client.deliver_messages(valid_messages)
|
79
79
|
expect(valid_messages.all? { |m| m['X-PM-Message-Id'].to_s =~ postmark_message_id_format }).to be true
|
80
80
|
end
|
81
81
|
|
82
|
-
it '
|
82
|
+
it 'response - valid response objects' do
|
83
83
|
api_client.deliver_messages(valid_messages)
|
84
84
|
expect(valid_messages.all? { |m| m.postmark_response["To"] == m.to[0] }).to be true
|
85
85
|
end
|
86
86
|
|
87
|
-
it '
|
87
|
+
it 'response - message responses count' do
|
88
88
|
expect(api_client.deliver_messages(valid_messages).count).to eq valid_messages.count
|
89
89
|
end
|
90
90
|
|
91
|
-
context "
|
91
|
+
context "custom max_batch_size" do
|
92
92
|
before do
|
93
93
|
api_client.max_batch_size = 1
|
94
94
|
end
|
95
95
|
|
96
|
-
it '
|
96
|
+
it 'response - valid response objects' do
|
97
97
|
api_client.deliver_messages(valid_messages)
|
98
98
|
expect(valid_messages.all? { |m| m.postmark_response["To"] == m.to[0] }).to be true
|
99
99
|
end
|
100
100
|
|
101
|
-
it '
|
101
|
+
it 'response - message responses count' do
|
102
102
|
expect(api_client.deliver_messages(valid_messages).count).to eq valid_messages.count
|
103
103
|
end
|
104
104
|
end
|
@@ -1,46 +1,36 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Accessing server resources using the API' do
|
4
|
-
|
5
|
-
let(:
|
6
|
-
Postmark::ApiClient.new(ENV['POSTMARK_API_KEY'], :http_open_timeout => 15)
|
7
|
-
}
|
8
|
-
let(:recipient) { ENV['POSTMARK_CI_RECIPIENT'] }
|
4
|
+
let(:api_client) {Postmark::ApiClient.new(ENV['POSTMARK_API_KEY'], :http_open_timeout => 15)}
|
5
|
+
let(:recipient) {ENV['POSTMARK_CI_RECIPIENT']}
|
9
6
|
let(:message) {
|
10
7
|
{
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
:from => ENV['POSTMARK_CI_SENDER'],
|
9
|
+
:to => recipient,
|
10
|
+
:subject => "Mail::Message object",
|
11
|
+
:text_body => "Lorem ipsum dolor sit amet, consectetur adipisicing elit, " \
|
15
12
|
"sed do eiusmod tempor incididunt ut labore et dolore " \
|
16
13
|
"magna aliqua."
|
17
14
|
}
|
18
15
|
}
|
19
16
|
|
20
17
|
context 'Triggers API' do
|
21
|
-
|
22
|
-
let(:unique_token) { rand(36**32).to_s(36) }
|
18
|
+
let(:unique_token) {rand(36 ** 32).to_s(36)}
|
23
19
|
|
24
20
|
it 'can be used to manage tag triggers via the API' do
|
25
|
-
trigger = api_client.create_trigger(:tags,
|
26
|
-
|
27
|
-
:track_opens => true)
|
28
|
-
api_client.update_trigger(:tags,
|
29
|
-
trigger[:id],
|
30
|
-
:match_name => "pre_#{trigger[:match_name]}")
|
21
|
+
trigger = api_client.create_trigger(:tags, :match_name => "gemtest_#{unique_token}", :track_opens => true)
|
22
|
+
api_client.update_trigger(:tags, trigger[:id], :match_name => "pre_#{trigger[:match_name]}")
|
31
23
|
updated = api_client.get_trigger(:tags, trigger[:id])
|
32
24
|
|
33
25
|
expect(updated[:id]).to eq(trigger[:id])
|
34
26
|
expect(updated[:match_name]).not_to eq(trigger[:id])
|
35
|
-
expect(api_client.triggers(:tags).map {
|
27
|
+
expect(api_client.triggers(:tags).map {|t| t[:id]}).to include(trigger[:id])
|
36
28
|
|
37
29
|
api_client.delete_trigger(:tags, trigger[:id])
|
38
30
|
end
|
39
|
-
|
40
31
|
end
|
41
32
|
|
42
33
|
context 'Messages API' do
|
43
|
-
|
44
34
|
def with_retries(max_retries = 20, wait_seconds = 3)
|
45
35
|
yield
|
46
36
|
rescue => e
|
@@ -55,17 +45,13 @@ describe 'Accessing server resources using the API' do
|
|
55
45
|
|
56
46
|
it 'is possible to send a message and access its details via the Messages API' do
|
57
47
|
response = api_client.deliver(message)
|
58
|
-
message = with_retries {
|
59
|
-
api_client.get_message(response[:message_id])
|
60
|
-
}
|
48
|
+
message = with_retries {api_client.get_message(response[:message_id])}
|
61
49
|
expect(message[:recipients]).to include(recipient)
|
62
50
|
end
|
63
51
|
|
64
52
|
it 'is possible to send a message and dump it via the Messages API' do
|
65
53
|
response = api_client.deliver(message)
|
66
|
-
dump = with_retries {
|
67
|
-
api_client.dump_message(response[:message_id])
|
68
|
-
}
|
54
|
+
dump = with_retries {api_client.dump_message(response[:message_id])}
|
69
55
|
expect(dump[:body]).to include('Mail::Message object')
|
70
56
|
end
|
71
57
|
|
@@ -74,15 +60,13 @@ describe 'Accessing server resources using the API' do
|
|
74
60
|
expect {
|
75
61
|
with_retries {
|
76
62
|
messages = api_client.get_messages(:recipient => recipient,
|
77
|
-
|
78
|
-
|
79
|
-
unless messages.map {
|
63
|
+
:fromemail => message[:from],
|
64
|
+
:subject => message[:subject])
|
65
|
+
unless messages.map {|m| m[:message_id]}.include?(response[:message_id])
|
80
66
|
raise 'Message not found'
|
81
67
|
end
|
82
68
|
}
|
83
69
|
}.not_to raise_error
|
84
70
|
end
|
85
|
-
|
86
71
|
end
|
87
|
-
|
88
72
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -24,7 +24,7 @@ end
|
|
24
24
|
RSpec.configure do |config|
|
25
25
|
include Postmark::RSpecHelpers
|
26
26
|
|
27
|
-
config.expect_with(:rspec) { |c| c.syntax =
|
27
|
+
config.expect_with(:rspec) { |c| c.syntax = :expect }
|
28
28
|
|
29
29
|
config.filter_run_excluding :skip_for_platform => lambda { |platform|
|
30
30
|
RUBY_PLATFORM.to_s =~ /^#{platform.to_s}/
|
@@ -49,9 +49,3 @@ RSpec.configure do |config|
|
|
49
49
|
Postmark.response_parser_class = nil
|
50
50
|
end
|
51
51
|
end
|
52
|
-
|
53
|
-
RSpec::Matchers.define :be_serialized_to do |json|
|
54
|
-
match do |mail_message|
|
55
|
-
Postmark.convert_message_to_options_hash(mail_message).should == JSON.parse(json)
|
56
|
-
end
|
57
|
-
end
|
@@ -32,3 +32,9 @@ end
|
|
32
32
|
RSpec::Matchers.define :json_representation_of do |x|
|
33
33
|
match { |actual| Postmark::Json.decode(actual) == x }
|
34
34
|
end
|
35
|
+
|
36
|
+
RSpec::Matchers.define :be_serialized_to do |json|
|
37
|
+
match do |mail_message|
|
38
|
+
Postmark.convert_message_to_options_hash(mail_message) == JSON.parse(json)
|
39
|
+
end
|
40
|
+
end
|
@@ -1,40 +1,40 @@
|
|
1
1
|
shared_examples :mail do
|
2
|
-
it "
|
3
|
-
Postmark.send(:convert_message_to_options_hash, subject)['TextBody'].
|
2
|
+
it "set text body for plain message" do
|
3
|
+
expect(Postmark.send(:convert_message_to_options_hash, subject)['TextBody']).not_to be_nil
|
4
4
|
end
|
5
5
|
|
6
|
-
it "
|
6
|
+
it "encode from properly when name is used" do
|
7
7
|
subject.from = "Sheldon Lee Cooper <sheldon@bigbangtheory.com>"
|
8
|
-
subject.
|
8
|
+
expect(subject).to be_serialized_to %q[{"Subject":"Hello!", "From":"Sheldon Lee Cooper <sheldon@bigbangtheory.com>", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
11
|
+
it "encode reply to" do
|
12
12
|
subject.reply_to = ['a@a.com', 'b@b.com']
|
13
|
-
subject.
|
13
|
+
expect(subject).to be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "ReplyTo":"a@a.com, b@b.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "encode tag" do
|
17
17
|
subject.tag = "invite"
|
18
|
-
subject.
|
18
|
+
expect(subject).to be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "Tag":"invite", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
21
|
+
it "encode multiple recepients (TO)" do
|
22
22
|
subject.to = ['a@a.com', 'b@b.com']
|
23
|
-
subject.
|
23
|
+
expect(subject).to be_serialized_to %q[{"Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"a@a.com, b@b.com", "TextBody":"Hello Sheldon!"}]
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "encode multiple recepients (CC)" do
|
27
27
|
subject.cc = ['a@a.com', 'b@b.com']
|
28
|
-
subject.
|
28
|
+
expect(subject).to be_serialized_to %q[{"Cc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "encode multiple recepients (BCC)" do
|
32
32
|
subject.bcc = ['a@a.com', 'b@b.com']
|
33
|
-
subject.
|
33
|
+
expect(subject).to be_serialized_to %q[{"Bcc":"a@a.com, b@b.com", "Subject":"Hello!", "From":"sheldon@bigbangtheory.com", "To":"lenard@bigbangtheory.com", "TextBody":"Hello Sheldon!"}]
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
36
|
+
it "accept string as reply_to field" do
|
37
37
|
subject.reply_to = ['Anton Astashov <b@b.com>']
|
38
|
-
subject.
|
38
|
+
expect(subject).to be_serialized_to %q[{"From": "sheldon@bigbangtheory.com", "ReplyTo": "b@b.com", "To": "lenard@bigbangtheory.com", "Subject": "Hello!", "TextBody": "Hello Sheldon!"}]
|
39
39
|
end
|
40
40
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Postmark::AccountApiClient do
|
4
|
-
|
5
4
|
let(:api_token) { 'abcd-efgh' }
|
6
5
|
subject { Postmark::AccountApiClient}
|
7
6
|
|
@@ -14,7 +13,6 @@ describe Postmark::AccountApiClient do
|
|
14
13
|
end
|
15
14
|
|
16
15
|
context 'instance' do
|
17
|
-
|
18
16
|
subject { Postmark::AccountApiClient.new(api_token) }
|
19
17
|
|
20
18
|
it 'uses the auth header specific for Account API' do
|
@@ -23,7 +21,6 @@ describe Postmark::AccountApiClient do
|
|
23
21
|
end
|
24
22
|
|
25
23
|
describe '#senders' do
|
26
|
-
|
27
24
|
let(:response) {
|
28
25
|
{
|
29
26
|
'TotalCount' => 10, 'SenderSignatures' => [{}, {}]
|
@@ -44,11 +41,9 @@ describe Postmark::AccountApiClient do
|
|
44
41
|
with('senders', an_instance_of(Hash)).and_return(response)
|
45
42
|
subject.senders.take(1000)
|
46
43
|
end
|
47
|
-
|
48
44
|
end
|
49
45
|
|
50
46
|
describe '#get_senders' do
|
51
|
-
|
52
47
|
let(:response) {
|
53
48
|
{
|
54
49
|
"TotalCount" => 1,
|
@@ -86,11 +81,9 @@ describe Postmark::AccountApiClient do
|
|
86
81
|
and_return(response)
|
87
82
|
subject.get_senders(:offset => 10, :count => 42)
|
88
83
|
end
|
89
|
-
|
90
84
|
end
|
91
85
|
|
92
86
|
describe '#get_senders_count' do
|
93
|
-
|
94
87
|
let(:response) { {'TotalCount' => 42} }
|
95
88
|
|
96
89
|
it 'is aliased as #get_signatures_count' do
|
@@ -103,11 +96,9 @@ describe Postmark::AccountApiClient do
|
|
103
96
|
with('senders', an_instance_of(Hash)).and_return(response)
|
104
97
|
expect(subject.get_senders_count).to eq(42)
|
105
98
|
end
|
106
|
-
|
107
99
|
end
|
108
100
|
|
109
101
|
describe '#get_sender' do
|
110
|
-
|
111
102
|
let(:response) {
|
112
103
|
{
|
113
104
|
"Domain" => "example.com",
|
@@ -137,7 +128,6 @@ describe Postmark::AccountApiClient do
|
|
137
128
|
end
|
138
129
|
|
139
130
|
describe '#create_sender' do
|
140
|
-
|
141
131
|
let(:response) {
|
142
132
|
{
|
143
133
|
"Domain" => "example.com",
|
@@ -173,7 +163,6 @@ describe Postmark::AccountApiClient do
|
|
173
163
|
end
|
174
164
|
|
175
165
|
describe '#update_sender' do
|
176
|
-
|
177
166
|
let(:response) {
|
178
167
|
{
|
179
168
|
"Domain" => "example.com",
|
@@ -207,11 +196,9 @@ describe Postmark::AccountApiClient do
|
|
207
196
|
keys = subject.update_sender(42, :foo => 'bar').keys
|
208
197
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
209
198
|
end
|
210
|
-
|
211
199
|
end
|
212
200
|
|
213
201
|
describe '#resend_sender_confirmation' do
|
214
|
-
|
215
202
|
let(:response) {
|
216
203
|
{
|
217
204
|
"ErrorCode" => 0,
|
@@ -235,11 +222,9 @@ describe Postmark::AccountApiClient do
|
|
235
222
|
keys = subject.resend_sender_confirmation(42).keys
|
236
223
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
237
224
|
end
|
238
|
-
|
239
225
|
end
|
240
226
|
|
241
227
|
describe '#verified_sender_spf?' do
|
242
|
-
|
243
228
|
let(:response) { {"SPFVerified" => true} }
|
244
229
|
let(:false_response) { {"SPFVerified" => false} }
|
245
230
|
|
@@ -262,11 +247,9 @@ describe Postmark::AccountApiClient do
|
|
262
247
|
allow(subject.http_client).to receive(:post).and_return(response)
|
263
248
|
expect(subject.verified_sender_spf?(42)).to be true
|
264
249
|
end
|
265
|
-
|
266
250
|
end
|
267
251
|
|
268
252
|
describe '#request_new_sender_dkim' do
|
269
|
-
|
270
253
|
let(:response) {
|
271
254
|
{
|
272
255
|
"Domain" => "example.com",
|
@@ -294,11 +277,9 @@ describe Postmark::AccountApiClient do
|
|
294
277
|
keys = subject.request_new_sender_dkim(42).keys
|
295
278
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
296
279
|
end
|
297
|
-
|
298
280
|
end
|
299
281
|
|
300
282
|
describe '#delete_sender' do
|
301
|
-
|
302
283
|
let(:response) {
|
303
284
|
{
|
304
285
|
"ErrorCode" => 0,
|
@@ -321,16 +302,10 @@ describe Postmark::AccountApiClient do
|
|
321
302
|
keys = subject.delete_sender(42).keys
|
322
303
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
323
304
|
end
|
324
|
-
|
325
305
|
end
|
326
306
|
|
327
307
|
describe '#domains' do
|
328
|
-
|
329
|
-
let(:response) {
|
330
|
-
{
|
331
|
-
'TotalCount' => 10, 'Domains' => [{}, {}]
|
332
|
-
}
|
333
|
-
}
|
308
|
+
let(:response) {{'TotalCount' => 10, 'Domains' => [{}, {}]}}
|
334
309
|
|
335
310
|
it 'returns an enumerator' do
|
336
311
|
expect(subject.domains).to be_kind_of(Enumerable)
|
@@ -379,7 +354,6 @@ describe Postmark::AccountApiClient do
|
|
379
354
|
end
|
380
355
|
|
381
356
|
describe '#get_domains_count' do
|
382
|
-
|
383
357
|
let(:response) { {'TotalCount' => 42} }
|
384
358
|
|
385
359
|
it 'returns a total number of domains' do
|
@@ -387,11 +361,9 @@ describe Postmark::AccountApiClient do
|
|
387
361
|
with('domains', an_instance_of(Hash)).and_return(response)
|
388
362
|
expect(subject.get_domains_count).to eq(42)
|
389
363
|
end
|
390
|
-
|
391
364
|
end
|
392
365
|
|
393
366
|
describe '#get_domain' do
|
394
|
-
|
395
367
|
let(:response) {
|
396
368
|
{
|
397
369
|
"Name" => "example.com",
|
@@ -413,7 +385,6 @@ describe Postmark::AccountApiClient do
|
|
413
385
|
end
|
414
386
|
|
415
387
|
describe '#create_domain' do
|
416
|
-
|
417
388
|
let(:response) {
|
418
389
|
{
|
419
390
|
"Name" => "example.com",
|
@@ -441,7 +412,6 @@ describe Postmark::AccountApiClient do
|
|
441
412
|
end
|
442
413
|
|
443
414
|
describe '#update_domain' do
|
444
|
-
|
445
415
|
let(:response) {
|
446
416
|
{
|
447
417
|
"Name" => "example.com",
|
@@ -467,11 +437,9 @@ describe Postmark::AccountApiClient do
|
|
467
437
|
keys = subject.update_domain(42, :foo => 'bar').keys
|
468
438
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
469
439
|
end
|
470
|
-
|
471
440
|
end
|
472
441
|
|
473
442
|
describe '#verified_domain_spf?' do
|
474
|
-
|
475
443
|
let(:response) { {"SPFVerified" => true} }
|
476
444
|
let(:false_response) { {"SPFVerified" => false} }
|
477
445
|
|
@@ -490,11 +458,9 @@ describe Postmark::AccountApiClient do
|
|
490
458
|
allow(subject.http_client).to receive(:post).and_return(response)
|
491
459
|
expect(subject.verified_domain_spf?(42)).to be true
|
492
460
|
end
|
493
|
-
|
494
461
|
end
|
495
462
|
|
496
463
|
describe '#rotate_domain_dkim' do
|
497
|
-
|
498
464
|
let(:response) {
|
499
465
|
{
|
500
466
|
"Name" => "example.com",
|
@@ -513,11 +479,9 @@ describe Postmark::AccountApiClient do
|
|
513
479
|
keys = subject.rotate_domain_dkim(42).keys
|
514
480
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
515
481
|
end
|
516
|
-
|
517
482
|
end
|
518
483
|
|
519
484
|
describe '#delete_domain' do
|
520
|
-
|
521
485
|
let(:response) {
|
522
486
|
{
|
523
487
|
"ErrorCode" => 0,
|
@@ -536,11 +500,9 @@ describe Postmark::AccountApiClient do
|
|
536
500
|
keys = subject.delete_sender(42).keys
|
537
501
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
538
502
|
end
|
539
|
-
|
540
503
|
end
|
541
504
|
|
542
505
|
describe '#servers' do
|
543
|
-
|
544
506
|
let(:response) { {'TotalCount' => 10, 'Servers' => [{}, {}]} }
|
545
507
|
|
546
508
|
it 'returns an enumerator' do
|
@@ -552,11 +514,9 @@ describe Postmark::AccountApiClient do
|
|
552
514
|
with('servers', an_instance_of(Hash)).and_return(response)
|
553
515
|
subject.servers.take(100)
|
554
516
|
end
|
555
|
-
|
556
517
|
end
|
557
518
|
|
558
519
|
describe '#get_servers' do
|
559
|
-
|
560
520
|
let(:response) {
|
561
521
|
{
|
562
522
|
'TotalCount' => 1,
|
@@ -602,7 +562,6 @@ describe Postmark::AccountApiClient do
|
|
602
562
|
end
|
603
563
|
|
604
564
|
describe '#get_server' do
|
605
|
-
|
606
565
|
let(:response) {
|
607
566
|
{
|
608
567
|
"ID" => 7438,
|
@@ -633,11 +592,9 @@ describe Postmark::AccountApiClient do
|
|
633
592
|
keys = subject.get_server(42).keys
|
634
593
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
635
594
|
end
|
636
|
-
|
637
595
|
end
|
638
596
|
|
639
597
|
describe '#get_servers_count' do
|
640
|
-
|
641
598
|
let(:response) { {'TotalCount' => 42} }
|
642
599
|
|
643
600
|
it 'returns a total number of servers' do
|
@@ -649,7 +606,6 @@ describe Postmark::AccountApiClient do
|
|
649
606
|
end
|
650
607
|
|
651
608
|
describe '#create_server' do
|
652
|
-
|
653
609
|
let(:response) {
|
654
610
|
{
|
655
611
|
"Name" => "Staging Testing",
|
@@ -680,7 +636,6 @@ describe Postmark::AccountApiClient do
|
|
680
636
|
keys = subject.create_server(:foo => 'bar').keys
|
681
637
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
682
638
|
end
|
683
|
-
|
684
639
|
end
|
685
640
|
|
686
641
|
describe '#update_server' do
|
@@ -722,11 +677,9 @@ describe Postmark::AccountApiClient do
|
|
722
677
|
keys = subject.update_server(42, :foo => 'bar').keys
|
723
678
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
724
679
|
end
|
725
|
-
|
726
680
|
end
|
727
681
|
|
728
682
|
describe '#delete_server' do
|
729
|
-
|
730
683
|
let(:response) {
|
731
684
|
{
|
732
685
|
"ErrorCode" => "0",
|
@@ -745,7 +698,6 @@ describe Postmark::AccountApiClient do
|
|
745
698
|
keys = subject.delete_server(42).keys
|
746
699
|
expect(keys.all? { |k| k.is_a?(Symbol) }).to be true
|
747
700
|
end
|
748
|
-
|
749
701
|
end
|
750
702
|
|
751
703
|
describe '#push_templates' do
|
@@ -777,5 +729,4 @@ describe Postmark::AccountApiClient do
|
|
777
729
|
end
|
778
730
|
|
779
731
|
end
|
780
|
-
|
781
732
|
end
|