postmark 1.21.0 → 1.21.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ecfd4ac720289669cf67d8f13816bec20b985796dc9413e9e34271bbd3ece81
4
- data.tar.gz: f42b2d7331f764f3552cd002e0876ea8da8aad4ebc6f56d14504d5c80d96d8c2
3
+ metadata.gz: 4059e97def9c50a4070433c6f2232431627c9c72f43aba77c5bb1844df107708
4
+ data.tar.gz: 29454f806e17cdf57885a091035faea0354049ae9da78b81d8f40549fe276e76
5
5
  SHA512:
6
- metadata.gz: 2f7953e239dcb2b78970694e9c0423d1f2ca3439cafb418e83f47ba24dfe535fece7f7b853986b8f7bb460826f9af3517750cb7e919f71deec4b463734aaed42
7
- data.tar.gz: 18d9b5e906b072d8c7e9b832190637290b134ac06e1a66ec299294c07a0cbf1017f932bb65eb4de38448b33a9c245eced584e9eb0665f824be60c72f06ed1e75
6
+ metadata.gz: d9576dc4ed16f2b2926fae5a1ff7db1f87ea511f7f9dd7eb8a52d7690b5af84ddd79bd2f6e452196961378e65d9ff2c3a061003d1579430d2731fa20bad40d7d
7
+ data.tar.gz: 8077ed204c8678179e6e2a1932342d76da52618acd8bdc9d8df5513ae973088b1820f9b6bd4ff5b2575b0736a0fb2600e02938cf490da06b05492634eef15b94
@@ -1,5 +1,9 @@
1
1
  = Changelog
2
2
 
3
+ == 1.21.1
4
+
5
+ * Fixed Postmark::ApiClient#get_message_streams
6
+
3
7
  == 1.21.0
4
8
 
5
9
  * Added support for message streams and suppressions
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.20.0
1
+ 1.21.1
@@ -329,7 +329,12 @@ module Postmark
329
329
  end
330
330
 
331
331
  def get_message_streams(options = {})
332
- load_batch('message-streams', 'MessageStreams', 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)
333
338
  end
334
339
 
335
340
  def get_message_stream(id)
@@ -37,6 +37,10 @@ module Postmark
37
37
  do_request { |client| client.put(url_path(path), data, headers) }
38
38
  end
39
39
 
40
+ def patch(path, data = '')
41
+ do_request { |client| client.patch(url_path(path), data, headers) }
42
+ end
43
+
40
44
  def get(path, query = {})
41
45
  do_request { |client| client.get(url_path(path + to_query_string(query)), headers) }
42
46
  end
@@ -1,3 +1,3 @@
1
1
  module Postmark
2
- VERSION = '1.21.0'
2
+ VERSION = '1.21.1'
3
3
  end
@@ -1003,6 +1003,151 @@ describe Postmark::ApiClient do
1003
1003
  end
1004
1004
  end
1005
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
+ match_json({
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
+
1006
1151
  describe '#create_suppressions' do
1007
1152
  let(:email_addresses) { nil }
1008
1153
  let(:message_stream_id) { 'outbound' }
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.21.0
4
+ version: 1.21.1
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-04-06 00:00:00.000000000 Z
13
+ date: 2020-04-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json