sendgrid4r 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sendgrid4r/rest/ip_access_management.rb +22 -11
- data/lib/sendgrid4r/version.rb +1 -1
- data/spec/client_spec.rb +1 -1
- data/spec/rest/ip_access_management_spec.rb +29 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2df9fbdd15763250ba845eb33ef85f763c13de0b
|
4
|
+
data.tar.gz: 119cdeda58f5a1cc4b80141e55bafd6c7e48798c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 773ed665ffd716b13bd8d1ee2c97db3367f6c8d67422e911308da613407aa5e3f4221096dd8eaddc991745845c827ca64384e9bfe4541ca1855734b9fce31eae
|
7
|
+
data.tar.gz: fbc2f5bd38405a4e1ae287249d341c354080866313b4dd97d6e2c5d94b26da63637fb3ebb7922aff26b90daaa6105c545c5c6b81f24506cf682de3b9a771957e
|
@@ -16,7 +16,9 @@ module SendGrid4r
|
|
16
16
|
|
17
17
|
WhitelistedIps = Struct.new(:result)
|
18
18
|
|
19
|
-
WhitelistedIp = Struct.new(:
|
19
|
+
WhitelistedIp = Struct.new(:result)
|
20
|
+
|
21
|
+
WhitelistedIpResult = Struct.new(:id, :ip, :created_at, :updated_at)
|
20
22
|
|
21
23
|
def self.url_activity
|
22
24
|
"#{BASE_URL}/access_settings/activity"
|
@@ -58,7 +60,7 @@ module SendGrid4r
|
|
58
60
|
result = []
|
59
61
|
resp['result'].each do |whitelisted_ip|
|
60
62
|
result.push(
|
61
|
-
SendGrid4r::REST::IpAccessManagement.
|
63
|
+
SendGrid4r::REST::IpAccessManagement.create_whitelisted_ip_result(
|
62
64
|
whitelisted_ip
|
63
65
|
)
|
64
66
|
)
|
@@ -67,10 +69,19 @@ module SendGrid4r
|
|
67
69
|
end
|
68
70
|
|
69
71
|
def self.create_whitelisted_ip(resp)
|
72
|
+
return resp if resp.nil?
|
73
|
+
WhitelistedIp.new(
|
74
|
+
SendGrid4r::REST::IpAccessManagement.create_whitelisted_ip_result(
|
75
|
+
resp['result']
|
76
|
+
)
|
77
|
+
)
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.create_whitelisted_ip_result(resp)
|
70
81
|
return resp if resp.nil?
|
71
82
|
created_at = Time.at(resp['created_at']) unless resp['created_at'].nil?
|
72
83
|
updated_at = Time.at(resp['updated_at']) unless resp['updated_at'].nil?
|
73
|
-
|
84
|
+
WhitelistedIpResult.new(resp['id'], resp['ip'], created_at, updated_at)
|
74
85
|
end
|
75
86
|
|
76
87
|
def get_ip_activities(limit: nil, &block)
|
@@ -89,23 +100,23 @@ module SendGrid4r
|
|
89
100
|
|
90
101
|
def post_whitelisted_ips(ips:, &block)
|
91
102
|
endpoint = SendGrid4r::REST::IpAccessManagement.url_whitelist
|
92
|
-
|
103
|
+
ips_param = []
|
93
104
|
ips.each do |ip|
|
94
|
-
|
95
|
-
|
96
|
-
|
105
|
+
ip_param = {}
|
106
|
+
ip_param['ip'] = ip
|
107
|
+
ips_param.push(ip_param)
|
97
108
|
end
|
98
109
|
params = {}
|
99
|
-
params['ips'] =
|
110
|
+
params['ips'] = ips_param
|
100
111
|
resp = post(@auth, endpoint, params, &block)
|
101
112
|
SendGrid4r::REST::IpAccessManagement.create_whitelisted_ips(resp)
|
102
113
|
end
|
103
114
|
|
104
115
|
def delete_whitelisted_ips(ids:, &block)
|
105
116
|
endpoint = SendGrid4r::REST::IpAccessManagement.url_whitelist
|
106
|
-
|
107
|
-
|
108
|
-
delete(@auth, endpoint,
|
117
|
+
payload = {}
|
118
|
+
payload['ids'] = ids
|
119
|
+
delete(@auth, endpoint, nil, payload, &block)
|
109
120
|
end
|
110
121
|
|
111
122
|
def get_whitelisted_ip(rule_id:, &block)
|
data/lib/sendgrid4r/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -5,17 +5,22 @@ describe SendGrid4r::REST::IpAccessManagement do
|
|
5
5
|
describe 'integration test', :it do
|
6
6
|
before do
|
7
7
|
begin
|
8
|
-
pending('resource not found')
|
9
8
|
Dotenv.load
|
10
9
|
@client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
|
11
10
|
|
12
11
|
# clean up test env(whitelisted_ips)
|
12
|
+
@ip1 = '192.168.0.1/32'
|
13
|
+
@ip2 = '1.12.34.56/32'
|
13
14
|
ips = @client.get_whitelisted_ips
|
14
15
|
ips.result.each do |whitelisted_ip|
|
15
|
-
@client.delete_whitelisted_ip(
|
16
|
+
@client.delete_whitelisted_ip(
|
17
|
+
rule_id: whitelisted_ip.id
|
18
|
+
) if whitelisted_ip.ip == @ip1 || whitelisted_ip.ip == @ip2
|
19
|
+
end
|
20
|
+
@ips = @client.post_whitelisted_ips(ips: [@ip1])
|
21
|
+
@ips.result.each do |ip|
|
22
|
+
@id1 = ip.id if ip.ip == @ip1
|
16
23
|
end
|
17
|
-
@ips = @client.post_whitelisted_ip('0.0.0.0')
|
18
|
-
@id1 = @ips.result[0].id
|
19
24
|
rescue RestClient::ExceptionWithResponse => e
|
20
25
|
puts e.inspect
|
21
26
|
raise e
|
@@ -71,7 +76,7 @@ describe SendGrid4r::REST::IpAccessManagement do
|
|
71
76
|
|
72
77
|
it '#post_whitelisted_ips' do
|
73
78
|
begin
|
74
|
-
ips = @client.post_whitelisted_ips(ips: [
|
79
|
+
ips = @client.post_whitelisted_ips(ips: [@ip2])
|
75
80
|
expect(ips).to be_a(
|
76
81
|
SendGrid4r::REST::IpAccessManagement::WhitelistedIps
|
77
82
|
)
|
@@ -104,9 +109,7 @@ describe SendGrid4r::REST::IpAccessManagement do
|
|
104
109
|
|
105
110
|
it '#delete_whitelisted_ip' do
|
106
111
|
begin
|
107
|
-
|
108
|
-
@client.delete_whitelisted_ip(rule_id: @id1)
|
109
|
-
end.to raise_error(RestClient::ResourceNotFound)
|
112
|
+
@client.delete_whitelisted_ip(rule_id: @id1)
|
110
113
|
rescue RestClient::ExceptionWithResponse => e
|
111
114
|
puts e.inspect
|
112
115
|
raise e
|
@@ -168,10 +171,12 @@ describe SendGrid4r::REST::IpAccessManagement do
|
|
168
171
|
let(:whitelisted_ip) do
|
169
172
|
JSON.parse(
|
170
173
|
'{'\
|
171
|
-
'"
|
172
|
-
|
173
|
-
|
174
|
-
|
174
|
+
'"result": {'\
|
175
|
+
'"created_at": 1459011215,'\
|
176
|
+
'"id": 1,'\
|
177
|
+
'"ip": "192.168.1.1/32",'\
|
178
|
+
'"updated_at": 1459011215'\
|
179
|
+
'}'\
|
175
180
|
'}'
|
176
181
|
)
|
177
182
|
end
|
@@ -195,7 +200,7 @@ describe SendGrid4r::REST::IpAccessManagement do
|
|
195
200
|
)
|
196
201
|
actual.result.each do |whitelisted_ip|
|
197
202
|
expect(whitelisted_ip).to be_a(
|
198
|
-
SendGrid4r::REST::IpAccessManagement::
|
203
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIpResult
|
199
204
|
)
|
200
205
|
end
|
201
206
|
end
|
@@ -208,7 +213,7 @@ describe SendGrid4r::REST::IpAccessManagement do
|
|
208
213
|
)
|
209
214
|
actual.result.each do |whitelisted_ip|
|
210
215
|
expect(whitelisted_ip).to be_a(
|
211
|
-
SendGrid4r::REST::IpAccessManagement::
|
216
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIpResult
|
212
217
|
)
|
213
218
|
end
|
214
219
|
end
|
@@ -258,5 +263,15 @@ describe SendGrid4r::REST::IpAccessManagement do
|
|
258
263
|
expect(ip1.created_at).to eq(Time.at(1441824715))
|
259
264
|
expect(ip1.updated_at).to eq(Time.at(1441824715))
|
260
265
|
end
|
266
|
+
|
267
|
+
it 'creates whitelisted_ip instance' do
|
268
|
+
actual = SendGrid4r::REST::IpAccessManagement.create_whitelisted_ip(
|
269
|
+
whitelisted_ip
|
270
|
+
)
|
271
|
+
expect(actual.result.id).to eq(1)
|
272
|
+
expect(actual.result.ip).to eq('192.168.1.1/32')
|
273
|
+
expect(actual.result.created_at).to eq(Time.at(1459011215))
|
274
|
+
expect(actual.result.updated_at).to eq(Time.at(1459011215))
|
275
|
+
end
|
261
276
|
end
|
262
277
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sendgrid4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- awwa500@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|