sendgrid4r 1.5.1 → 1.6.0
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/api.rb +3 -1
- data/lib/sendgrid4r/rest/ip_access_management.rb +123 -0
- data/lib/sendgrid4r/rest/settings/mail.rb +0 -39
- data/lib/sendgrid4r/rest/webhooks/event.rb +56 -0
- data/lib/sendgrid4r/rest/webhooks/parse.rb +51 -0
- data/lib/sendgrid4r/version.rb +1 -1
- data/lib/sendgrid4r.rb +4 -1
- data/spec/client_spec.rb +9 -1
- data/spec/rest/ip_access_management_spec.rb +262 -0
- data/spec/rest/settings/mail_spec.rb +0 -114
- data/spec/rest/webhooks/event_spec.rb +138 -0
- data/spec/rest/webhooks/{parse_api_spec.rb → parse_spec.rb} +33 -10
- metadata +11 -5
- data/lib/sendgrid4r/rest/webhooks/parse_api.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da33e4bfff93975445c5df1a4bc2d57f81aefef7
|
4
|
+
data.tar.gz: 89f466b9e9bc465e2556097b97f48cc4e2f6c152
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67f7b15b77bca858a933297bb46e3983ac6603623be4fa050f3972e5877facd3126a3a18ed3e855a5388cac43cc7ee9366b8e6a61c9319ed2bad5fc8ead801c6
|
7
|
+
data.tar.gz: d740abe0a3629826d8f97d503daecb2325b51f53a63c712b0623c67e91ec5f76ee15800f662a90fe10f1a78bd76c04ad42d051479d4525474c454f7d0631d3f1
|
data/lib/sendgrid4r/rest/api.rb
CHANGED
@@ -42,7 +42,9 @@ module SendGrid4r
|
|
42
42
|
include SendGrid4r::REST::Users
|
43
43
|
include SendGrid4r::REST::Bounces
|
44
44
|
include SendGrid4r::REST::CancelScheduledSends
|
45
|
-
include SendGrid4r::REST::Webhooks::
|
45
|
+
include SendGrid4r::REST::Webhooks::Event
|
46
|
+
include SendGrid4r::REST::Webhooks::Parse
|
47
|
+
include SendGrid4r::REST::IpAccessManagement
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module SendGrid4r
|
4
|
+
module REST
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 IpAccessManagement
|
7
|
+
#
|
8
|
+
module IpAccessManagement
|
9
|
+
include SendGrid4r::REST::Request
|
10
|
+
|
11
|
+
IpActivities = Struct.new(:result)
|
12
|
+
|
13
|
+
IpActivity = Struct.new(
|
14
|
+
:allowed, :auth_method, :first_at, :ip, :last_at, :location
|
15
|
+
)
|
16
|
+
|
17
|
+
WhitelistedIps = Struct.new(:result)
|
18
|
+
|
19
|
+
WhitelistedIp = Struct.new(:id, :ip, :created_at, :updated_at)
|
20
|
+
|
21
|
+
def self.url_activity
|
22
|
+
"#{BASE_URL}/access_settings/activity"
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.url_whitelist(rule_id = nil)
|
26
|
+
url = "#{BASE_URL}/access_settings/whitelist"
|
27
|
+
url = "#{url}/#{rule_id}" unless rule_id.nil?
|
28
|
+
url
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.create_ip_activities(resp)
|
32
|
+
return resp if resp.nil?
|
33
|
+
result = []
|
34
|
+
resp['result'].each do |activity|
|
35
|
+
result.push(
|
36
|
+
SendGrid4r::REST::IpAccessManagement.create_ip_activity(activity)
|
37
|
+
)
|
38
|
+
end
|
39
|
+
IpActivities.new(result)
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.create_ip_activity(resp)
|
43
|
+
return resp if resp.nil?
|
44
|
+
first_at = Time.at(resp['first_at']) unless resp['first_at'].nil?
|
45
|
+
last_at = Time.at(resp['last_at']) unless resp['last_at'].nil?
|
46
|
+
IpActivity.new(
|
47
|
+
resp['allowed'],
|
48
|
+
resp['auth_method'],
|
49
|
+
first_at,
|
50
|
+
resp['ip'],
|
51
|
+
last_at,
|
52
|
+
resp['location']
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.create_whitelisted_ips(resp)
|
57
|
+
return resp if resp.nil?
|
58
|
+
result = []
|
59
|
+
resp['result'].each do |whitelisted_ip|
|
60
|
+
result.push(
|
61
|
+
SendGrid4r::REST::IpAccessManagement.create_whitelisted_ip(
|
62
|
+
whitelisted_ip
|
63
|
+
)
|
64
|
+
)
|
65
|
+
end
|
66
|
+
WhitelistedIps.new(result)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.create_whitelisted_ip(resp)
|
70
|
+
return resp if resp.nil?
|
71
|
+
created_at = Time.at(resp['created_at']) unless resp['created_at'].nil?
|
72
|
+
updated_at = Time.at(resp['updated_at']) unless resp['updated_at'].nil?
|
73
|
+
WhitelistedIp.new(resp['id'], resp['ip'], created_at, updated_at)
|
74
|
+
end
|
75
|
+
|
76
|
+
def get_ip_activities(limit: nil, &block)
|
77
|
+
endpoint = SendGrid4r::REST::IpAccessManagement.url_activity
|
78
|
+
params = {}
|
79
|
+
params['limit'] = limit unless limit.nil?
|
80
|
+
resp = get(@auth, endpoint, params, &block)
|
81
|
+
SendGrid4r::REST::IpAccessManagement.create_ip_activities(resp)
|
82
|
+
end
|
83
|
+
|
84
|
+
def get_whitelisted_ips(&block)
|
85
|
+
endpoint = SendGrid4r::REST::IpAccessManagement.url_whitelist
|
86
|
+
resp = get(@auth, endpoint, &block)
|
87
|
+
SendGrid4r::REST::IpAccessManagement.create_whitelisted_ips(resp)
|
88
|
+
end
|
89
|
+
|
90
|
+
def post_whitelisted_ips(ips:, &block)
|
91
|
+
endpoint = SendGrid4r::REST::IpAccessManagement.url_whitelist
|
92
|
+
ips = []
|
93
|
+
ips.each do |ip|
|
94
|
+
ip = {}
|
95
|
+
ip['ip'] = ip
|
96
|
+
ip.push(ip)
|
97
|
+
end
|
98
|
+
params = {}
|
99
|
+
params['ips'] = ips
|
100
|
+
resp = post(@auth, endpoint, params, &block)
|
101
|
+
SendGrid4r::REST::IpAccessManagement.create_whitelisted_ips(resp)
|
102
|
+
end
|
103
|
+
|
104
|
+
def delete_whitelisted_ips(ids:, &block)
|
105
|
+
endpoint = SendGrid4r::REST::IpAccessManagement.url_whitelist
|
106
|
+
params = {}
|
107
|
+
params['ids'] = ids
|
108
|
+
delete(@auth, endpoint, params, &block)
|
109
|
+
end
|
110
|
+
|
111
|
+
def get_whitelisted_ip(rule_id:, &block)
|
112
|
+
endpoint = SendGrid4r::REST::IpAccessManagement.url_whitelist(rule_id)
|
113
|
+
resp = get(@auth, endpoint, nil, &block)
|
114
|
+
SendGrid4r::REST::IpAccessManagement.create_whitelisted_ip(resp)
|
115
|
+
end
|
116
|
+
|
117
|
+
def delete_whitelisted_ip(rule_id:, &block)
|
118
|
+
endpoint = SendGrid4r::REST::IpAccessManagement.url_whitelist(rule_id)
|
119
|
+
delete(@auth, endpoint, nil, &block)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -36,22 +36,6 @@ module SendGrid4r
|
|
36
36
|
)
|
37
37
|
end
|
38
38
|
|
39
|
-
EventNotification = Struct.new(
|
40
|
-
:enabled, :url, :group_resubscribe, :delivered, :group_unsubscribe,
|
41
|
-
:spam_report, :bounce, :deferred, :unsubscribe, :processed, :open,
|
42
|
-
:click, :dropped
|
43
|
-
)
|
44
|
-
|
45
|
-
def self.create_event_notification(resp)
|
46
|
-
return resp if resp.nil?
|
47
|
-
EventNotification.new(
|
48
|
-
resp['enabled'], resp['url'], resp['group_resubscribe'],
|
49
|
-
resp['delivered'], resp['group_unsubscribe'], resp['spam_report'],
|
50
|
-
resp['bounce'], resp['deferred'], resp['unsubscribe'],
|
51
|
-
resp['processed'], resp['open'], resp['click'], resp['dropped']
|
52
|
-
)
|
53
|
-
end
|
54
|
-
|
55
39
|
Footer = Struct.new(:enabled, :html_content, :plain_content)
|
56
40
|
|
57
41
|
def self.create_footer(resp)
|
@@ -95,10 +79,6 @@ module SendGrid4r
|
|
95
79
|
url
|
96
80
|
end
|
97
81
|
|
98
|
-
def self.url_event(path)
|
99
|
-
"#{BASE_URL}/user/webhooks/event/#{path}"
|
100
|
-
end
|
101
|
-
|
102
82
|
def get_mail_settings(limit: nil, offset: nil, &block)
|
103
83
|
params = {}
|
104
84
|
params['limit'] = limit unless limit.nil?
|
@@ -144,25 +124,6 @@ module SendGrid4r
|
|
144
124
|
SendGrid4r::REST::Settings::Mail.create_bounce_purge(resp)
|
145
125
|
end
|
146
126
|
|
147
|
-
def get_settings_event_notification(&block)
|
148
|
-
endpoint = SendGrid4r::REST::Settings::Mail.url_event('settings')
|
149
|
-
resp = get(@auth, endpoint, &block)
|
150
|
-
SendGrid4r::REST::Settings::Mail.create_event_notification(resp)
|
151
|
-
end
|
152
|
-
|
153
|
-
def patch_settings_event_notification(params:, &block)
|
154
|
-
endpoint = SendGrid4r::REST::Settings::Mail.url_event('settings')
|
155
|
-
resp = patch(@auth, endpoint, params.to_h, &block)
|
156
|
-
SendGrid4r::REST::Settings::Mail.create_event_notification(resp)
|
157
|
-
end
|
158
|
-
|
159
|
-
def test_settings_event_notification(url:, &block)
|
160
|
-
params = {}
|
161
|
-
params['url'] = url
|
162
|
-
endpoint = SendGrid4r::REST::Settings::Mail.url_event('test')
|
163
|
-
post(@auth, endpoint, params, &block)
|
164
|
-
end
|
165
|
-
|
166
127
|
def get_settings_footer(&block)
|
167
128
|
endpoint = SendGrid4r::REST::Settings::Mail.url('footer')
|
168
129
|
resp = get(@auth, endpoint, &block)
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module SendGrid4r
|
4
|
+
module REST
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 Webhooks
|
7
|
+
#
|
8
|
+
module Webhooks
|
9
|
+
#
|
10
|
+
# SendGrid Web API v3 Webhooks ParseApi
|
11
|
+
#
|
12
|
+
module Event
|
13
|
+
include SendGrid4r::REST::Request
|
14
|
+
|
15
|
+
def self.url_event(path)
|
16
|
+
"#{BASE_URL}/user/webhooks/event/#{path}"
|
17
|
+
end
|
18
|
+
|
19
|
+
EventNotification = Struct.new(
|
20
|
+
:enabled, :url, :group_resubscribe, :delivered, :group_unsubscribe,
|
21
|
+
:spam_report, :bounce, :deferred, :unsubscribe, :processed, :open,
|
22
|
+
:click, :dropped
|
23
|
+
)
|
24
|
+
|
25
|
+
def self.create_event_notification(resp)
|
26
|
+
return resp if resp.nil?
|
27
|
+
EventNotification.new(
|
28
|
+
resp['enabled'], resp['url'], resp['group_resubscribe'],
|
29
|
+
resp['delivered'], resp['group_unsubscribe'], resp['spam_report'],
|
30
|
+
resp['bounce'], resp['deferred'], resp['unsubscribe'],
|
31
|
+
resp['processed'], resp['open'], resp['click'], resp['dropped']
|
32
|
+
)
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_settings_event_notification(&block)
|
36
|
+
endpoint = SendGrid4r::REST::Webhooks::Event.url_event('settings')
|
37
|
+
resp = get(@auth, endpoint, &block)
|
38
|
+
SendGrid4r::REST::Webhooks::Event.create_event_notification(resp)
|
39
|
+
end
|
40
|
+
|
41
|
+
def patch_settings_event_notification(params:, &block)
|
42
|
+
endpoint = SendGrid4r::REST::Webhooks::Event.url_event('settings')
|
43
|
+
resp = patch(@auth, endpoint, params.to_h, &block)
|
44
|
+
SendGrid4r::REST::Webhooks::Event.create_event_notification(resp)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_settings_event_notification(url:, &block)
|
48
|
+
params = {}
|
49
|
+
params['url'] = url
|
50
|
+
endpoint = SendGrid4r::REST::Webhooks::Event.url_event('test')
|
51
|
+
post(@auth, endpoint, params, &block)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
module SendGrid4r
|
4
|
+
module REST
|
5
|
+
#
|
6
|
+
# SendGrid Web API v3 Webhooks
|
7
|
+
#
|
8
|
+
module Webhooks
|
9
|
+
#
|
10
|
+
# SendGrid Web API v3 Webhooks Parse
|
11
|
+
#
|
12
|
+
module Parse
|
13
|
+
include SendGrid4r::REST::Request
|
14
|
+
|
15
|
+
ParseSettings = Struct.new(:result)
|
16
|
+
ParseSetting = Struct.new(:url, :hostname, :spam_check_outgoing)
|
17
|
+
|
18
|
+
def self.url
|
19
|
+
"#{BASE_URL}/user/webhooks/parse/settings"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.create_parse_settings(resp)
|
23
|
+
return resp if resp.nil?
|
24
|
+
parse_settings = []
|
25
|
+
resp['result'].each do |setting|
|
26
|
+
parse_settings.push(
|
27
|
+
SendGrid4r::REST::Webhooks::Parse.create_parse_setting(
|
28
|
+
setting
|
29
|
+
)
|
30
|
+
)
|
31
|
+
end
|
32
|
+
ParseSettings.new(parse_settings)
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.create_parse_setting(resp)
|
36
|
+
return resp if resp.nil?
|
37
|
+
ParseSetting.new(
|
38
|
+
resp['url'],
|
39
|
+
resp['hostname'],
|
40
|
+
resp['spam_check_outgoing']
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_parse_settings(&block)
|
45
|
+
resp = get(@auth, SendGrid4r::REST::Webhooks::Parse.url, &block)
|
46
|
+
SendGrid4r::REST::Webhooks::Parse.create_parse_settings(resp)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/sendgrid4r/version.rb
CHANGED
data/lib/sendgrid4r.rb
CHANGED
@@ -32,6 +32,8 @@ require 'sendgrid4r/rest/contacts/segments'
|
|
32
32
|
|
33
33
|
require 'sendgrid4r/rest/email_activity/email_activity'
|
34
34
|
|
35
|
+
require 'sendgrid4r/rest/ip_access_management'
|
36
|
+
|
35
37
|
require 'sendgrid4r/rest/ips/addresses'
|
36
38
|
require 'sendgrid4r/rest/ips/pools'
|
37
39
|
require 'sendgrid4r/rest/ips/warmup'
|
@@ -49,7 +51,8 @@ require 'sendgrid4r/rest/stats/parse'
|
|
49
51
|
require 'sendgrid4r/rest/stats/stats'
|
50
52
|
require 'sendgrid4r/rest/stats/subuser'
|
51
53
|
|
52
|
-
require 'sendgrid4r/rest/webhooks/
|
54
|
+
require 'sendgrid4r/rest/webhooks/event'
|
55
|
+
require 'sendgrid4r/rest/webhooks/parse'
|
53
56
|
|
54
57
|
require 'sendgrid4r/rest/whitelabel/domains'
|
55
58
|
require 'sendgrid4r/rest/whitelabel/ips'
|
data/spec/client_spec.rb
CHANGED
@@ -277,12 +277,20 @@ describe SendGrid4r::Client do
|
|
277
277
|
|
278
278
|
# Permissions
|
279
279
|
expect(@client.respond_to?('get_permissions')).to eq(true)
|
280
|
+
|
281
|
+
# Ip Access Management
|
282
|
+
expect(@client.respond_to?('get_ip_activities')).to eq(true)
|
283
|
+
expect(@client.respond_to?('get_whitelisted_ips')).to eq(true)
|
284
|
+
expect(@client.respond_to?('post_whitelisted_ips')).to eq(true)
|
285
|
+
expect(@client.respond_to?('delete_whitelisted_ips')).to eq(true)
|
286
|
+
expect(@client.respond_to?('get_whitelisted_ip')).to eq(true)
|
287
|
+
expect(@client.respond_to?('delete_whitelisted_ip')).to eq(true)
|
280
288
|
end
|
281
289
|
end
|
282
290
|
|
283
291
|
describe 'VERSION' do
|
284
292
|
it 'returns VERSION value' do
|
285
|
-
expect(SendGrid4r::VERSION).to eq('1.
|
293
|
+
expect(SendGrid4r::VERSION).to eq('1.6.0')
|
286
294
|
end
|
287
295
|
end
|
288
296
|
end
|
@@ -0,0 +1,262 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
3
|
+
|
4
|
+
describe SendGrid4r::REST::IpAccessManagement do
|
5
|
+
describe 'integration test', :it do
|
6
|
+
before do
|
7
|
+
begin
|
8
|
+
pending('resource not found')
|
9
|
+
Dotenv.load
|
10
|
+
@client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
|
11
|
+
|
12
|
+
# clean up test env(whitelisted_ips)
|
13
|
+
ips = @client.get_whitelisted_ips
|
14
|
+
ips.result.each do |whitelisted_ip|
|
15
|
+
@client.delete_whitelisted_ip(rule_id: whitelisted_ip.id)
|
16
|
+
end
|
17
|
+
@ips = @client.post_whitelisted_ip('0.0.0.0')
|
18
|
+
@id1 = @ips.result[0].id
|
19
|
+
rescue RestClient::ExceptionWithResponse => e
|
20
|
+
puts e.inspect
|
21
|
+
raise e
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'without block call' do
|
26
|
+
it '#get_ip_activities without limit' do
|
27
|
+
begin
|
28
|
+
activities = @client.get_ip_activities
|
29
|
+
expect(activities).to be_a(
|
30
|
+
SendGrid4r::REST::IpAccessManagement::IpActivities
|
31
|
+
)
|
32
|
+
activities.result.each do |activity|
|
33
|
+
expect(activity).to be_a(
|
34
|
+
SendGrid4r::REST::IpAccessManagement::IpActivity
|
35
|
+
)
|
36
|
+
end
|
37
|
+
rescue RestClient::ExceptionWithResponse => e
|
38
|
+
puts e.inspect
|
39
|
+
raise e
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
it '#get_ip_activities with limit' do
|
44
|
+
begin
|
45
|
+
activities = @client.get_ip_activities(limit: 1)
|
46
|
+
expect(activities).to be_a(
|
47
|
+
SendGrid4r::REST::IpAccessManagement::IpActivities
|
48
|
+
)
|
49
|
+
activities.result.each do |activity|
|
50
|
+
expect(activity).to be_a(
|
51
|
+
SendGrid4r::REST::IpAccessManagement::IpActivity
|
52
|
+
)
|
53
|
+
end
|
54
|
+
rescue RestClient::ExceptionWithResponse => e
|
55
|
+
puts e.inspect
|
56
|
+
raise e
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
it '#get_whitelisted_ips' do
|
61
|
+
begin
|
62
|
+
ips = @client.get_whitelisted_ips
|
63
|
+
expect(ips).to be_a(
|
64
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIps
|
65
|
+
)
|
66
|
+
rescue RestClient::ExceptionWithResponse => e
|
67
|
+
puts e.inspect
|
68
|
+
raise e
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it '#post_whitelisted_ips' do
|
73
|
+
begin
|
74
|
+
ips = @client.post_whitelisted_ips(ips: ['127.0.0.1'])
|
75
|
+
expect(ips).to be_a(
|
76
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIps
|
77
|
+
)
|
78
|
+
rescue RestClient::ExceptionWithResponse => e
|
79
|
+
puts e.inspect
|
80
|
+
raise e
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it '#delete_whitelisted_ips' do
|
85
|
+
begin
|
86
|
+
@client.delete_whitelisted_ips(ids: [@id1])
|
87
|
+
rescue RestClient::ExceptionWithResponse => e
|
88
|
+
puts e.inspect
|
89
|
+
raise e
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it '#get_whitelisted_ip' do
|
94
|
+
begin
|
95
|
+
whitelisted_ip = @client.get_whitelisted_ip(rule_id: @id1)
|
96
|
+
expect(whitelisted_ip).to be_a(
|
97
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIp
|
98
|
+
)
|
99
|
+
rescue RestClient::ExceptionWithResponse => e
|
100
|
+
puts e.inspect
|
101
|
+
raise e
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
it '#delete_whitelisted_ip' do
|
106
|
+
begin
|
107
|
+
expect do
|
108
|
+
@client.delete_whitelisted_ip(rule_id: @id1)
|
109
|
+
end.to raise_error(RestClient::ResourceNotFound)
|
110
|
+
rescue RestClient::ExceptionWithResponse => e
|
111
|
+
puts e.inspect
|
112
|
+
raise e
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe 'unit test', :ut do
|
119
|
+
let(:client) do
|
120
|
+
SendGrid4r::Client.new(api_key: '')
|
121
|
+
end
|
122
|
+
|
123
|
+
let(:ip_activities) do
|
124
|
+
JSON.parse(
|
125
|
+
'{'\
|
126
|
+
'"result": ['\
|
127
|
+
'{'\
|
128
|
+
'"allowed": false,'\
|
129
|
+
'"auth_method": "basic",'\
|
130
|
+
'"first_at": 1444087966,'\
|
131
|
+
'"ip": "1.1.1.1",'\
|
132
|
+
'"last_at": 1444406672,'\
|
133
|
+
'"location": "Australia"'\
|
134
|
+
'}, {'\
|
135
|
+
'"allowed": false,'\
|
136
|
+
'"auth_method": "basic",'\
|
137
|
+
'"first_at": 1444087505,'\
|
138
|
+
'"ip": "1.2.3.48",'\
|
139
|
+
'"last_at": 1444087505,'\
|
140
|
+
'"location": "Mukilteo, Washington"'\
|
141
|
+
'}'\
|
142
|
+
']'\
|
143
|
+
'}'
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
let(:whitelisted_ips) do
|
148
|
+
JSON.parse(
|
149
|
+
'{'\
|
150
|
+
'"result": ['\
|
151
|
+
'{'\
|
152
|
+
'"id": 1, "ip": "192.168.1.1/32", '\
|
153
|
+
'"created_at": 1441824715, "updated_at": 1441824715'\
|
154
|
+
'},'\
|
155
|
+
'{'\
|
156
|
+
'"id": 2, "ip": "192.168.1.2/32", '\
|
157
|
+
'"created_at": 1441824715, "updated_at": 1441824715'\
|
158
|
+
'},'\
|
159
|
+
'{'\
|
160
|
+
'"id": 3, "ip": "192.168.1.3/32", '\
|
161
|
+
'"created_at": 1441824715, "updated_at": 1441824715'\
|
162
|
+
'}'\
|
163
|
+
']'\
|
164
|
+
'}'
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
168
|
+
let(:whitelisted_ip) do
|
169
|
+
JSON.parse(
|
170
|
+
'{'\
|
171
|
+
'"id": 1,'\
|
172
|
+
'"ip": "192.168.1.1",'\
|
173
|
+
'"created_at": 1441824715,'\
|
174
|
+
'"updated_at": 1441824715'\
|
175
|
+
'}'
|
176
|
+
)
|
177
|
+
end
|
178
|
+
|
179
|
+
it '#get_ip_activities' do
|
180
|
+
allow(client).to receive(:execute).and_return(ip_activities)
|
181
|
+
actual = client.get_ip_activities
|
182
|
+
expect(actual).to be_a(SendGrid4r::REST::IpAccessManagement::IpActivities)
|
183
|
+
actual.result.each do |activity|
|
184
|
+
expect(activity).to be_a(
|
185
|
+
SendGrid4r::REST::IpAccessManagement::IpActivity
|
186
|
+
)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
it '#get_whitelisted_ips' do
|
191
|
+
allow(client).to receive(:execute).and_return(whitelisted_ips)
|
192
|
+
actual = client.get_whitelisted_ips
|
193
|
+
expect(actual).to be_a(
|
194
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIps
|
195
|
+
)
|
196
|
+
actual.result.each do |whitelisted_ip|
|
197
|
+
expect(whitelisted_ip).to be_a(
|
198
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIp
|
199
|
+
)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
it '#post_whitelisted_ips' do
|
204
|
+
allow(client).to receive(:execute).and_return(whitelisted_ips)
|
205
|
+
actual = client.post_whitelisted_ips(ips: [''])
|
206
|
+
expect(actual).to be_a(
|
207
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIps
|
208
|
+
)
|
209
|
+
actual.result.each do |whitelisted_ip|
|
210
|
+
expect(whitelisted_ip).to be_a(
|
211
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIp
|
212
|
+
)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
it '#delete_whitelisted_ips' do
|
217
|
+
allow(client).to receive(:execute).and_return('')
|
218
|
+
actual = client.delete_whitelisted_ips(ids: [''])
|
219
|
+
expect(actual).to eq('')
|
220
|
+
end
|
221
|
+
|
222
|
+
it '#get_whitelisted_ip' do
|
223
|
+
allow(client).to receive(:execute).and_return(whitelisted_ip)
|
224
|
+
actual = client.get_whitelisted_ip(rule_id: '')
|
225
|
+
expect(actual).to be_a(
|
226
|
+
SendGrid4r::REST::IpAccessManagement::WhitelistedIp
|
227
|
+
)
|
228
|
+
end
|
229
|
+
|
230
|
+
it '#delete_whitelisted_ip' do
|
231
|
+
allow(client).to receive(:execute).and_return('')
|
232
|
+
actual = client.delete_whitelisted_ip(rule_id: '')
|
233
|
+
expect(actual).to eq('')
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'creates ip_activities instance' do
|
237
|
+
actual = SendGrid4r::REST::IpAccessManagement.create_ip_activities(
|
238
|
+
ip_activities
|
239
|
+
)
|
240
|
+
expect(actual.result.length).to eq(2)
|
241
|
+
activity0 = actual.result[0]
|
242
|
+
expect(activity0.allowed).to eq(false)
|
243
|
+
expect(activity0.auth_method).to eq('basic')
|
244
|
+
expect(activity0.first_at).to eq(Time.at(1444087966))
|
245
|
+
expect(activity0.ip).to eq('1.1.1.1')
|
246
|
+
expect(activity0.last_at).to eq(Time.at(1444406672))
|
247
|
+
expect(activity0.location).to eq('Australia')
|
248
|
+
end
|
249
|
+
|
250
|
+
it 'creates whitelisted_ips instance' do
|
251
|
+
actual = SendGrid4r::REST::IpAccessManagement.create_whitelisted_ips(
|
252
|
+
whitelisted_ips
|
253
|
+
)
|
254
|
+
expect(actual.result.length).to eq(3)
|
255
|
+
ip1 = actual.result[0]
|
256
|
+
expect(ip1.id).to eq(1)
|
257
|
+
expect(ip1.ip).to eq('192.168.1.1/32')
|
258
|
+
expect(ip1.created_at).to eq(Time.at(1441824715))
|
259
|
+
expect(ip1.updated_at).to eq(Time.at(1441824715))
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
@@ -104,65 +104,6 @@ describe SendGrid4r::REST::Settings::Mail do
|
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
|
-
it '#get_settings_event_notification' do
|
108
|
-
begin
|
109
|
-
actual = @client.get_settings_event_notification
|
110
|
-
expect(actual).to be_a(
|
111
|
-
SendGrid4r::REST::Settings::Mail::EventNotification
|
112
|
-
)
|
113
|
-
rescue RestClient::ExceptionWithResponse => e
|
114
|
-
puts e.inspect
|
115
|
-
raise e
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
it '#patch_settings_event_notification' do
|
120
|
-
begin
|
121
|
-
# get original settings
|
122
|
-
actual = @client.get_settings_event_notification
|
123
|
-
# patch the value
|
124
|
-
actual.enabled = false
|
125
|
-
actual.url = 'http://www.google.com/?=test@test.com'
|
126
|
-
actual.group_resubscribe = true
|
127
|
-
actual.delivered = true
|
128
|
-
actual.group_unsubscribe = true
|
129
|
-
actual.spam_report = true
|
130
|
-
actual.bounce = true
|
131
|
-
actual.deferred = true
|
132
|
-
actual.unsubscribe = true
|
133
|
-
actual.processed = true
|
134
|
-
actual.open = true
|
135
|
-
actual.click = true
|
136
|
-
actual.dropped = true
|
137
|
-
edit = @client.patch_settings_event_notification(params: actual)
|
138
|
-
expect(edit.enabled).to eq(false)
|
139
|
-
expect(edit.url).to eq('http://www.google.com/?=test@test.com')
|
140
|
-
expect(edit.group_resubscribe).to eq(true)
|
141
|
-
expect(edit.delivered).to eq(true)
|
142
|
-
expect(edit.group_unsubscribe).to eq(true)
|
143
|
-
expect(edit.spam_report).to eq(true)
|
144
|
-
expect(edit.bounce).to eq(true)
|
145
|
-
expect(edit.deferred).to eq(true)
|
146
|
-
expect(edit.unsubscribe).to eq(true)
|
147
|
-
expect(edit.processed).to eq(true)
|
148
|
-
expect(edit.open).to eq(true)
|
149
|
-
expect(edit.click).to eq(true)
|
150
|
-
expect(edit.dropped).to eq(true)
|
151
|
-
rescue RestClient::ExceptionWithResponse => e
|
152
|
-
puts e.inspect
|
153
|
-
raise e
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
it '#test_settings_event_notification' do
|
158
|
-
begin
|
159
|
-
@client.test_settings_event_notification(url: ENV['EVENT_URL'])
|
160
|
-
rescue RestClient::ExceptionWithResponse => e
|
161
|
-
puts e.inspect
|
162
|
-
raise e
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
107
|
it '#get_settings_footer' do
|
167
108
|
begin
|
168
109
|
actual = @client.get_settings_footer
|
@@ -397,61 +338,6 @@ describe SendGrid4r::REST::Settings::Mail do
|
|
397
338
|
expect(actual.soft_bounces).to eq(1)
|
398
339
|
end
|
399
340
|
|
400
|
-
let(:event_notification) do
|
401
|
-
JSON.parse(
|
402
|
-
'{'\
|
403
|
-
'"enabled": true,'\
|
404
|
-
'"url": "url",'\
|
405
|
-
'"group_resubscribe": true,'\
|
406
|
-
'"delivered": true,'\
|
407
|
-
'"group_unsubscribe": true,'\
|
408
|
-
'"spam_report": true,'\
|
409
|
-
'"bounce": true,'\
|
410
|
-
'"deferred": true,'\
|
411
|
-
'"unsubscribe": true,'\
|
412
|
-
'"processed": true,'\
|
413
|
-
'"open": true,'\
|
414
|
-
'"click": true,'\
|
415
|
-
'"dropped": true'\
|
416
|
-
'}'
|
417
|
-
)
|
418
|
-
end
|
419
|
-
|
420
|
-
it '#get_settings_event_notification' do
|
421
|
-
allow(client).to receive(:execute).and_return(event_notification)
|
422
|
-
actual = client.get_settings_event_notification
|
423
|
-
expect(actual).to be_a(
|
424
|
-
SendGrid4r::REST::Settings::Mail::EventNotification
|
425
|
-
)
|
426
|
-
end
|
427
|
-
|
428
|
-
it '#patch_settings_event_notification' do
|
429
|
-
allow(client).to receive(:execute).and_return(event_notification)
|
430
|
-
actual = client.patch_settings_event_notification(params: nil)
|
431
|
-
expect(actual).to be_a(
|
432
|
-
SendGrid4r::REST::Settings::Mail::EventNotification
|
433
|
-
)
|
434
|
-
end
|
435
|
-
|
436
|
-
it 'creates event_notification instance' do
|
437
|
-
actual = SendGrid4r::REST::Settings::Mail.create_event_notification(
|
438
|
-
event_notification
|
439
|
-
)
|
440
|
-
expect(actual.enabled).to eq(true)
|
441
|
-
expect(actual.url).to eq('url')
|
442
|
-
expect(actual.group_resubscribe).to eq(true)
|
443
|
-
expect(actual.delivered).to eq(true)
|
444
|
-
expect(actual.group_unsubscribe).to eq(true)
|
445
|
-
expect(actual.spam_report).to eq(true)
|
446
|
-
expect(actual.bounce).to eq(true)
|
447
|
-
expect(actual.deferred).to eq(true)
|
448
|
-
expect(actual.unsubscribe).to eq(true)
|
449
|
-
expect(actual.processed).to eq(true)
|
450
|
-
expect(actual.open).to eq(true)
|
451
|
-
expect(actual.click).to eq(true)
|
452
|
-
expect(actual.dropped).to eq(true)
|
453
|
-
end
|
454
|
-
|
455
341
|
let(:footer) do
|
456
342
|
JSON.parse(
|
457
343
|
'{'\
|
@@ -0,0 +1,138 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
|
+
|
4
|
+
describe SendGrid4r::REST::Webhooks::Event do
|
5
|
+
describe 'integration test', :it do
|
6
|
+
before do
|
7
|
+
begin
|
8
|
+
Dotenv.load
|
9
|
+
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
10
|
+
rescue RestClient::ExceptionWithResponse => e
|
11
|
+
puts e.inspect
|
12
|
+
raise e
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'without block call' do
|
17
|
+
it '#get_settings_event_notification' do
|
18
|
+
begin
|
19
|
+
actual = @client.get_settings_event_notification
|
20
|
+
expect(actual).to be_a(
|
21
|
+
SendGrid4r::REST::Webhooks::Event::EventNotification
|
22
|
+
)
|
23
|
+
rescue RestClient::ExceptionWithResponse => e
|
24
|
+
puts e.inspect
|
25
|
+
raise e
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it '#patch_settings_event_notification' do
|
30
|
+
begin
|
31
|
+
# get original settings
|
32
|
+
actual = @client.get_settings_event_notification
|
33
|
+
# patch the value
|
34
|
+
actual.enabled = false
|
35
|
+
actual.url = 'http://www.google.com/?=test@test.com'
|
36
|
+
actual.group_resubscribe = true
|
37
|
+
actual.delivered = true
|
38
|
+
actual.group_unsubscribe = true
|
39
|
+
actual.spam_report = true
|
40
|
+
actual.bounce = true
|
41
|
+
actual.deferred = true
|
42
|
+
actual.unsubscribe = true
|
43
|
+
actual.processed = true
|
44
|
+
actual.open = true
|
45
|
+
actual.click = true
|
46
|
+
actual.dropped = true
|
47
|
+
edit = @client.patch_settings_event_notification(params: actual)
|
48
|
+
expect(edit.enabled).to eq(false)
|
49
|
+
expect(edit.url).to eq('http://www.google.com/?=test@test.com')
|
50
|
+
expect(edit.group_resubscribe).to eq(true)
|
51
|
+
expect(edit.delivered).to eq(true)
|
52
|
+
expect(edit.group_unsubscribe).to eq(true)
|
53
|
+
expect(edit.spam_report).to eq(true)
|
54
|
+
expect(edit.bounce).to eq(true)
|
55
|
+
expect(edit.deferred).to eq(true)
|
56
|
+
expect(edit.unsubscribe).to eq(true)
|
57
|
+
expect(edit.processed).to eq(true)
|
58
|
+
expect(edit.open).to eq(true)
|
59
|
+
expect(edit.click).to eq(true)
|
60
|
+
expect(edit.dropped).to eq(true)
|
61
|
+
rescue RestClient::ExceptionWithResponse => e
|
62
|
+
puts e.inspect
|
63
|
+
raise e
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it '#test_settings_event_notification' do
|
68
|
+
begin
|
69
|
+
@client.test_settings_event_notification(url: ENV['EVENT_URL'])
|
70
|
+
rescue RestClient::ExceptionWithResponse => e
|
71
|
+
puts e.inspect
|
72
|
+
raise e
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe 'unit test', :ut do
|
79
|
+
let(:client) do
|
80
|
+
SendGrid4r::Client.new(api_key: '')
|
81
|
+
end
|
82
|
+
|
83
|
+
let(:event_notification) do
|
84
|
+
JSON.parse(
|
85
|
+
'{'\
|
86
|
+
'"enabled": true,'\
|
87
|
+
'"url": "url",'\
|
88
|
+
'"group_resubscribe": true,'\
|
89
|
+
'"delivered": true,'\
|
90
|
+
'"group_unsubscribe": true,'\
|
91
|
+
'"spam_report": true,'\
|
92
|
+
'"bounce": true,'\
|
93
|
+
'"deferred": true,'\
|
94
|
+
'"unsubscribe": true,'\
|
95
|
+
'"processed": true,'\
|
96
|
+
'"open": true,'\
|
97
|
+
'"click": true,'\
|
98
|
+
'"dropped": true'\
|
99
|
+
'}'
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
it '#get_settings_event_notification' do
|
104
|
+
allow(client).to receive(:execute).and_return(event_notification)
|
105
|
+
actual = client.get_settings_event_notification
|
106
|
+
expect(actual).to be_a(
|
107
|
+
SendGrid4r::REST::Webhooks::Event::EventNotification
|
108
|
+
)
|
109
|
+
end
|
110
|
+
|
111
|
+
it '#patch_settings_event_notification' do
|
112
|
+
allow(client).to receive(:execute).and_return(event_notification)
|
113
|
+
actual = client.patch_settings_event_notification(params: nil)
|
114
|
+
expect(actual).to be_a(
|
115
|
+
SendGrid4r::REST::Webhooks::Event::EventNotification
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'creates event_notification instance' do
|
120
|
+
actual = SendGrid4r::REST::Webhooks::Event.create_event_notification(
|
121
|
+
event_notification
|
122
|
+
)
|
123
|
+
expect(actual.enabled).to eq(true)
|
124
|
+
expect(actual.url).to eq('url')
|
125
|
+
expect(actual.group_resubscribe).to eq(true)
|
126
|
+
expect(actual.delivered).to eq(true)
|
127
|
+
expect(actual.group_unsubscribe).to eq(true)
|
128
|
+
expect(actual.spam_report).to eq(true)
|
129
|
+
expect(actual.bounce).to eq(true)
|
130
|
+
expect(actual.deferred).to eq(true)
|
131
|
+
expect(actual.unsubscribe).to eq(true)
|
132
|
+
expect(actual.processed).to eq(true)
|
133
|
+
expect(actual.open).to eq(true)
|
134
|
+
expect(actual.click).to eq(true)
|
135
|
+
expect(actual.dropped).to eq(true)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require File.dirname(__FILE__) + '/../../spec_helper'
|
3
3
|
|
4
|
-
describe SendGrid4r::REST::Webhooks::
|
4
|
+
describe SendGrid4r::REST::Webhooks::Parse do
|
5
5
|
describe 'integration test', :it do
|
6
6
|
before do
|
7
7
|
begin
|
@@ -15,13 +15,12 @@ describe SendGrid4r::REST::Webhooks::ParseApi do
|
|
15
15
|
|
16
16
|
context 'without block call' do
|
17
17
|
it '#get_parse_settings' do
|
18
|
-
pending 'resource not found'
|
19
18
|
begin
|
20
19
|
parse_settings = @client.get_parse_settings
|
21
20
|
expect(parse_settings).to be_a(
|
22
|
-
SendGrid4r::REST::Webhooks::
|
21
|
+
SendGrid4r::REST::Webhooks::Parse::ParseSettings
|
23
22
|
)
|
24
|
-
expect(parse_settings.
|
23
|
+
expect(parse_settings.result).to be_a(Array)
|
25
24
|
rescue RestClient::ExceptionWithResponse => e
|
26
25
|
puts e.inspect
|
27
26
|
raise e
|
@@ -36,12 +35,26 @@ describe SendGrid4r::REST::Webhooks::ParseApi do
|
|
36
35
|
end
|
37
36
|
|
38
37
|
let(:parse_settings) do
|
38
|
+
JSON.parse(
|
39
|
+
'{'\
|
40
|
+
'"result": ['\
|
41
|
+
'{'\
|
42
|
+
'"url": "http://mydomain.com/parse",'\
|
43
|
+
'"hostname": "mail.mydomain.com",'\
|
44
|
+
'"spam_check_outgoing": true'\
|
45
|
+
'}'\
|
46
|
+
']'\
|
47
|
+
'}'
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:parse_setting) do
|
39
52
|
JSON.parse(
|
40
53
|
'{'\
|
41
54
|
'"url": "http://mydomain.com/parse",'\
|
42
55
|
'"hostname": "mail.mydomain.com",'\
|
43
56
|
'"spam_check_outgoing": true'\
|
44
|
-
'}'
|
57
|
+
'}'\
|
45
58
|
)
|
46
59
|
end
|
47
60
|
|
@@ -49,20 +62,30 @@ describe SendGrid4r::REST::Webhooks::ParseApi do
|
|
49
62
|
allow(client).to receive(:execute).and_return(parse_settings)
|
50
63
|
actual = client.get_parse_settings
|
51
64
|
expect(actual).to be_a(
|
52
|
-
SendGrid4r::REST::Webhooks::
|
65
|
+
SendGrid4r::REST::Webhooks::Parse::ParseSettings
|
53
66
|
)
|
54
67
|
end
|
55
68
|
|
56
|
-
it 'creates
|
57
|
-
actual = SendGrid4r::REST::Webhooks::
|
58
|
-
|
69
|
+
it 'creates parse_setting instance' do
|
70
|
+
actual = SendGrid4r::REST::Webhooks::Parse.create_parse_setting(
|
71
|
+
parse_setting
|
59
72
|
)
|
60
73
|
expect(actual).to be_a(
|
61
|
-
SendGrid4r::REST::Webhooks::
|
74
|
+
SendGrid4r::REST::Webhooks::Parse::ParseSetting
|
62
75
|
)
|
63
76
|
expect(actual.url).to eq('http://mydomain.com/parse')
|
64
77
|
expect(actual.hostname).to eq('mail.mydomain.com')
|
65
78
|
expect(actual.spam_check_outgoing).to eq(true)
|
66
79
|
end
|
80
|
+
|
81
|
+
it 'creates parse_settings instance' do
|
82
|
+
actual = SendGrid4r::REST::Webhooks::Parse.create_parse_settings(
|
83
|
+
parse_settings
|
84
|
+
)
|
85
|
+
expect(actual).to be_a(
|
86
|
+
SendGrid4r::REST::Webhooks::Parse::ParseSettings
|
87
|
+
)
|
88
|
+
expect(actual.result).to be_a(Array)
|
89
|
+
end
|
67
90
|
end
|
68
91
|
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.
|
4
|
+
version: 1.6.0
|
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-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/sendgrid4r/rest/contacts/reserved_fields.rb
|
144
144
|
- lib/sendgrid4r/rest/contacts/segments.rb
|
145
145
|
- lib/sendgrid4r/rest/email_activity/email_activity.rb
|
146
|
+
- lib/sendgrid4r/rest/ip_access_management.rb
|
146
147
|
- lib/sendgrid4r/rest/ips/addresses.rb
|
147
148
|
- lib/sendgrid4r/rest/ips/pools.rb
|
148
149
|
- lib/sendgrid4r/rest/ips/warmup.rb
|
@@ -162,7 +163,8 @@ files:
|
|
162
163
|
- lib/sendgrid4r/rest/templates/templates.rb
|
163
164
|
- lib/sendgrid4r/rest/templates/versions.rb
|
164
165
|
- lib/sendgrid4r/rest/users.rb
|
165
|
-
- lib/sendgrid4r/rest/webhooks/
|
166
|
+
- lib/sendgrid4r/rest/webhooks/event.rb
|
167
|
+
- lib/sendgrid4r/rest/webhooks/parse.rb
|
166
168
|
- lib/sendgrid4r/rest/whitelabel/domains.rb
|
167
169
|
- lib/sendgrid4r/rest/whitelabel/ips.rb
|
168
170
|
- lib/sendgrid4r/rest/whitelabel/links.rb
|
@@ -189,6 +191,7 @@ files:
|
|
189
191
|
- spec/rest/contacts/reserved_fields_spec.rb
|
190
192
|
- spec/rest/contacts/segments_spec.rb
|
191
193
|
- spec/rest/email_activity/email_activity_spec.rb
|
194
|
+
- spec/rest/ip_access_management_spec.rb
|
192
195
|
- spec/rest/ips/addresses_spec.rb
|
193
196
|
- spec/rest/ips/pools_spec.rb
|
194
197
|
- spec/rest/ips/warmup_spec.rb
|
@@ -207,7 +210,8 @@ files:
|
|
207
210
|
- spec/rest/templates/templates_spec.rb
|
208
211
|
- spec/rest/templates/versions_spec.rb
|
209
212
|
- spec/rest/users_spec.rb
|
210
|
-
- spec/rest/webhooks/
|
213
|
+
- spec/rest/webhooks/event_spec.rb
|
214
|
+
- spec/rest/webhooks/parse_spec.rb
|
211
215
|
- spec/rest/whitelabel/domains_spec.rb
|
212
216
|
- spec/rest/whitelabel/ips_spec.rb
|
213
217
|
- spec/rest/whitelabel/links_spec.rb
|
@@ -258,6 +262,7 @@ test_files:
|
|
258
262
|
- spec/rest/contacts/reserved_fields_spec.rb
|
259
263
|
- spec/rest/contacts/segments_spec.rb
|
260
264
|
- spec/rest/email_activity/email_activity_spec.rb
|
265
|
+
- spec/rest/ip_access_management_spec.rb
|
261
266
|
- spec/rest/ips/addresses_spec.rb
|
262
267
|
- spec/rest/ips/pools_spec.rb
|
263
268
|
- spec/rest/ips/warmup_spec.rb
|
@@ -276,7 +281,8 @@ test_files:
|
|
276
281
|
- spec/rest/templates/templates_spec.rb
|
277
282
|
- spec/rest/templates/versions_spec.rb
|
278
283
|
- spec/rest/users_spec.rb
|
279
|
-
- spec/rest/webhooks/
|
284
|
+
- spec/rest/webhooks/event_spec.rb
|
285
|
+
- spec/rest/webhooks/parse_spec.rb
|
280
286
|
- spec/rest/whitelabel/domains_spec.rb
|
281
287
|
- spec/rest/whitelabel/ips_spec.rb
|
282
288
|
- spec/rest/whitelabel/links_spec.rb
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
module SendGrid4r
|
4
|
-
module REST
|
5
|
-
#
|
6
|
-
# SendGrid Web API v3 Webhooks
|
7
|
-
#
|
8
|
-
module Webhooks
|
9
|
-
#
|
10
|
-
# SendGrid Web API v3 Webhooks ParseApi
|
11
|
-
#
|
12
|
-
module ParseApi
|
13
|
-
include SendGrid4r::REST::Request
|
14
|
-
|
15
|
-
ParseSettings = Struct.new(:url, :hostname, :spam_check_outgoing)
|
16
|
-
|
17
|
-
def self.url
|
18
|
-
"#{BASE_URL}/webhooks/parse/settings"
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.create_parse_settings(resp)
|
22
|
-
return resp if resp.nil?
|
23
|
-
ParseSettings.new(
|
24
|
-
resp['url'],
|
25
|
-
resp['hostname'],
|
26
|
-
resp['spam_check_outgoing']
|
27
|
-
)
|
28
|
-
end
|
29
|
-
|
30
|
-
def get_parse_settings(&block)
|
31
|
-
resp = get(@auth, SendGrid4r::REST::Webhooks::ParseApi.url, &block)
|
32
|
-
SendGrid4r::REST::Webhooks::ParseApi.create_parse_settings(resp)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|