sendgrid4r 0.5.0 → 1.0.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/.env.example +6 -8
- data/.rubocop.yml +1 -1
- data/README.md +0 -2
- data/lib/sendgrid4r/rest/api.rb +6 -0
- data/lib/sendgrid4r/rest/api_keys/api_keys.rb +5 -5
- data/lib/sendgrid4r/rest/asm/global_suppressions.rb +3 -3
- data/lib/sendgrid4r/rest/asm/groups.rb +4 -4
- data/lib/sendgrid4r/rest/asm/suppressions.rb +4 -4
- data/lib/sendgrid4r/rest/categories/categories.rb +1 -1
- data/lib/sendgrid4r/rest/contacts/custom_fields.rb +3 -3
- data/lib/sendgrid4r/rest/contacts/lists.rb +10 -10
- data/lib/sendgrid4r/rest/contacts/recipients.rb +10 -10
- data/lib/sendgrid4r/rest/contacts/segments.rb +5 -5
- data/lib/sendgrid4r/rest/ips/addresses.rb +3 -3
- data/lib/sendgrid4r/rest/ips/pools.rb +4 -4
- data/lib/sendgrid4r/rest/ips/warmup.rb +6 -6
- data/lib/sendgrid4r/rest/request.rb +2 -2
- data/lib/sendgrid4r/rest/subusers/subusers.rb +63 -3
- data/lib/sendgrid4r/rest/templates/templates.rb +14 -9
- data/lib/sendgrid4r/rest/templates/versions.rb +12 -10
- data/lib/sendgrid4r/rest/whitelabel/domains.rb +257 -0
- data/lib/sendgrid4r/rest/whitelabel/ips.rb +140 -0
- data/lib/sendgrid4r/rest/whitelabel/links.rb +185 -0
- data/lib/sendgrid4r/version.rb +1 -1
- data/sendgrid4r.gemspec +1 -1
- data/spec/client_spec.rb +93 -1
- data/spec/rest/api_keys/api_keys_spec.rb +23 -55
- data/spec/rest/asm/global_suppressions_spec.rb +40 -68
- data/spec/rest/asm/groups_spec.rb +31 -82
- data/spec/rest/asm/suppressions_spec.rb +33 -76
- data/spec/rest/categories/categories_spec.rb +8 -27
- data/spec/rest/contacts/custom_fields_spec.rb +18 -71
- data/spec/rest/contacts/lists_spec.rb +64 -187
- data/spec/rest/contacts/recipients_spec.rb +41 -196
- data/spec/rest/contacts/reserved_fields_spec.rb +2 -20
- data/spec/rest/contacts/segments_spec.rb +47 -33
- data/spec/rest/email_activity/email_activity_spec.rb +8 -21
- data/spec/rest/ips/addresses_spec.rb +18 -77
- data/spec/rest/ips/pools_spec.rb +21 -80
- data/spec/rest/ips/warmup_spec.rb +11 -58
- data/spec/rest/settings/enforced_tls_spec.rb +3 -40
- data/spec/rest/settings/mail_spec.rb +21 -294
- data/spec/rest/settings/partner_spec.rb +6 -79
- data/spec/rest/settings/tracking_spec.rb +10 -147
- data/spec/rest/stats/advanced_spec.rb +13 -135
- data/spec/rest/stats/category_spec.rb +5 -48
- data/spec/rest/stats/global_spec.rb +3 -5
- data/spec/rest/stats/parse_spec.rb +1 -24
- data/spec/rest/stats/subuser_spec.rb +6 -49
- data/spec/rest/subusers/subusers_spec.rb +156 -81
- data/spec/rest/templates/templates_spec.rb +32 -81
- data/spec/rest/templates/versions_spec.rb +50 -28
- data/spec/rest/whitelabel/domains_spec.rb +637 -0
- data/spec/rest/whitelabel/ips_spec.rb +231 -0
- data/spec/rest/whitelabel/links_spec.rb +359 -0
- metadata +22 -8
|
@@ -5,9 +5,7 @@ describe SendGrid4r::REST::Stats::Global do
|
|
|
5
5
|
describe 'integration test', :it do
|
|
6
6
|
before do
|
|
7
7
|
Dotenv.load
|
|
8
|
-
@client = SendGrid4r::Client.new(
|
|
9
|
-
username: ENV['SENDGRID_USERNAME'],
|
|
10
|
-
password: ENV['SENDGRID_PASSWORD'])
|
|
8
|
+
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
context 'without block call' do
|
|
@@ -38,7 +36,7 @@ describe SendGrid4r::REST::Stats::Global do
|
|
|
38
36
|
expect(stat.metrics.unsubscribes.nil?).to be(false)
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
|
-
rescue => e
|
|
39
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
42
40
|
puts e.inspect
|
|
43
41
|
raise e
|
|
44
42
|
end
|
|
@@ -60,7 +58,7 @@ describe SendGrid4r::REST::Stats::Global do
|
|
|
60
58
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
|
61
59
|
end
|
|
62
60
|
end
|
|
63
|
-
rescue => e
|
|
61
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
64
62
|
puts e.inspect
|
|
65
63
|
raise e
|
|
66
64
|
end
|
|
@@ -5,9 +5,7 @@ describe SendGrid4r::REST::Stats::Parse do
|
|
|
5
5
|
describe 'integration test', :it do
|
|
6
6
|
before do
|
|
7
7
|
Dotenv.load
|
|
8
|
-
@client = SendGrid4r::Client.new(
|
|
9
|
-
username: ENV['SENDGRID_USERNAME'],
|
|
10
|
-
password: ENV['SENDGRID_PASSWORD'])
|
|
8
|
+
@client = SendGrid4r::Client.new(api_key: ENV['API_KEY'])
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
context 'without block call' do
|
|
@@ -41,26 +39,5 @@ describe SendGrid4r::REST::Stats::Parse do
|
|
|
41
39
|
end
|
|
42
40
|
end
|
|
43
41
|
end
|
|
44
|
-
|
|
45
|
-
context 'with block call' do
|
|
46
|
-
it '#get_parse_stats with all params' do
|
|
47
|
-
@client.get_parse_stats(
|
|
48
|
-
start_date: '2015-01-01',
|
|
49
|
-
end_date: '2015-01-02',
|
|
50
|
-
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK
|
|
51
|
-
) do |resp, req, res|
|
|
52
|
-
resp =
|
|
53
|
-
SendGrid4r::REST::Stats.create_top_stats(
|
|
54
|
-
JSON.parse(resp)
|
|
55
|
-
)
|
|
56
|
-
expect(resp).to be_a(Array)
|
|
57
|
-
resp.each do |stat|
|
|
58
|
-
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
|
59
|
-
end
|
|
60
|
-
expect(req).to be_a(RestClient::Request)
|
|
61
|
-
expect(res).to be_a(Net::HTTPOK)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
42
|
end
|
|
66
43
|
end
|
|
@@ -5,10 +5,8 @@ describe SendGrid4r::REST::Stats::Subuser do
|
|
|
5
5
|
describe 'integration test', :it do
|
|
6
6
|
before do
|
|
7
7
|
Dotenv.load
|
|
8
|
-
@client = SendGrid4r::Client.new(
|
|
9
|
-
|
|
10
|
-
password: ENV['SILVER_SENDGRID_PASSWORD'])
|
|
11
|
-
@subuser = ENV['SILVER_SUBUSER']
|
|
8
|
+
@client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
|
|
9
|
+
@subuser = ENV['SUBUSER2']
|
|
12
10
|
end
|
|
13
11
|
|
|
14
12
|
context 'without block call' do
|
|
@@ -42,7 +40,7 @@ describe SendGrid4r::REST::Stats::Subuser do
|
|
|
42
40
|
expect(stat.metrics.unsubscribes.nil?).to be(false)
|
|
43
41
|
end
|
|
44
42
|
end
|
|
45
|
-
rescue => e
|
|
43
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
46
44
|
puts e.inspect
|
|
47
45
|
raise e
|
|
48
46
|
end
|
|
@@ -64,7 +62,7 @@ describe SendGrid4r::REST::Stats::Subuser do
|
|
|
64
62
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
|
65
63
|
end
|
|
66
64
|
end
|
|
67
|
-
rescue => e
|
|
65
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
68
66
|
puts e.inspect
|
|
69
67
|
raise e
|
|
70
68
|
end
|
|
@@ -78,7 +76,7 @@ describe SendGrid4r::REST::Stats::Subuser do
|
|
|
78
76
|
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
|
79
77
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
|
80
78
|
end
|
|
81
|
-
rescue => e
|
|
79
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
82
80
|
puts e.inspect
|
|
83
81
|
raise e
|
|
84
82
|
end
|
|
@@ -99,52 +97,11 @@ describe SendGrid4r::REST::Stats::Subuser do
|
|
|
99
97
|
expect(stat).to be_a(SendGrid4r::REST::Stats::Stat)
|
|
100
98
|
expect(stat.metrics).to be_a(SendGrid4r::REST::Stats::Metric)
|
|
101
99
|
end
|
|
102
|
-
rescue => e
|
|
100
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
103
101
|
puts e.inspect
|
|
104
102
|
raise e
|
|
105
103
|
end
|
|
106
104
|
end
|
|
107
105
|
end
|
|
108
|
-
|
|
109
|
-
context 'with block call' do
|
|
110
|
-
it '#get_subusers_stats with all params' do
|
|
111
|
-
@client.get_subusers_stats(
|
|
112
|
-
start_date: '2015-01-01',
|
|
113
|
-
end_date: '2015-01-02',
|
|
114
|
-
aggregated_by: SendGrid4r::REST::Stats::AggregatedBy::WEEK,
|
|
115
|
-
subusers: @subuser
|
|
116
|
-
) do |resp, req, res|
|
|
117
|
-
resp =
|
|
118
|
-
SendGrid4r::REST::Stats.create_top_stats(
|
|
119
|
-
JSON.parse(resp)
|
|
120
|
-
)
|
|
121
|
-
expect(resp).to be_a(Array)
|
|
122
|
-
resp.each do |stat|
|
|
123
|
-
expect(stat).to be_a(SendGrid4r::REST::Stats::TopStat)
|
|
124
|
-
end
|
|
125
|
-
expect(req).to be_a(RestClient::Request)
|
|
126
|
-
expect(res).to be_a(Net::HTTPOK)
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it '#get_subusers_stats_sums with all params' do
|
|
131
|
-
@client.get_subusers_stats_sums(
|
|
132
|
-
start_date: '2015-01-01',
|
|
133
|
-
end_date: '2015-01-02',
|
|
134
|
-
sort_by_metric: 'opens',
|
|
135
|
-
sort_by_direction: 'desc',
|
|
136
|
-
limit: 5,
|
|
137
|
-
offset: 0
|
|
138
|
-
) do |resp, req, res|
|
|
139
|
-
resp =
|
|
140
|
-
SendGrid4r::REST::Stats.create_top_stat(
|
|
141
|
-
JSON.parse(resp)
|
|
142
|
-
)
|
|
143
|
-
expect(resp).to be_a(SendGrid4r::REST::Stats::TopStat)
|
|
144
|
-
expect(req).to be_a(RestClient::Request)
|
|
145
|
-
expect(res).to be_a(Net::HTTPOK)
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
106
|
end
|
|
150
107
|
end
|
|
@@ -6,18 +6,28 @@ describe SendGrid4r::REST::Subusers do
|
|
|
6
6
|
before do
|
|
7
7
|
begin
|
|
8
8
|
Dotenv.load
|
|
9
|
-
@client = SendGrid4r::Client.new(
|
|
10
|
-
username: ENV['SILVER_SENDGRID_USERNAME'],
|
|
11
|
-
password: ENV['SILVER_SENDGRID_PASSWORD'])
|
|
9
|
+
@client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
|
|
12
10
|
@username1 = ENV['SUBUSER1']
|
|
13
|
-
@username2 = ENV['
|
|
14
|
-
@username3 = ENV['
|
|
15
|
-
@email1 = ENV['
|
|
16
|
-
@password1 = ENV['
|
|
11
|
+
@username2 = ENV['SUBUSER2']
|
|
12
|
+
@username3 = ENV['SUBUSER3']
|
|
13
|
+
@email1 = ENV['MAIL']
|
|
14
|
+
@password1 = ENV['PASS']
|
|
17
15
|
|
|
18
16
|
@ip = @client.get_ips[0].ip
|
|
19
17
|
# celan up test env
|
|
20
|
-
|
|
18
|
+
begin
|
|
19
|
+
@client.delete_subuser(username: @username3)
|
|
20
|
+
rescue => e
|
|
21
|
+
puts e.inspect
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
@subuser3 = @client.post_subuser(
|
|
25
|
+
username: @username3,
|
|
26
|
+
email: @email1,
|
|
27
|
+
password: @password1,
|
|
28
|
+
ips: [@ip]
|
|
29
|
+
)
|
|
30
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
21
31
|
puts e.inspect
|
|
22
32
|
raise e
|
|
23
33
|
end
|
|
@@ -31,7 +41,7 @@ describe SendGrid4r::REST::Subusers do
|
|
|
31
41
|
subusers.each do |subuser|
|
|
32
42
|
expect(subuser).to be_a(SendGrid4r::REST::Subusers::Subuser)
|
|
33
43
|
end
|
|
34
|
-
rescue => e
|
|
44
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
35
45
|
puts e.inspect
|
|
36
46
|
raise e
|
|
37
47
|
end
|
|
@@ -39,104 +49,112 @@ describe SendGrid4r::REST::Subusers do
|
|
|
39
49
|
|
|
40
50
|
it '#post_subuser' do
|
|
41
51
|
begin
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
password: @password2,
|
|
47
|
-
ips: [@ip]
|
|
48
|
-
)
|
|
49
|
-
expect(subuser2).to be_a(SendGrid4r::REST::Subusers::Subuser)
|
|
50
|
-
expect(subuser2.username).to eq(@username2)
|
|
51
|
-
expect(subuser2.email).to eq(@email2)
|
|
52
|
-
expect(subuser2.password).to eq(@password2)
|
|
53
|
-
expect(subuser2.ips).to be_a(Array)
|
|
54
|
-
rescue => e
|
|
52
|
+
expect(@subuser3).to be_a(SendGrid4r::REST::Subusers::Subuser)
|
|
53
|
+
expect(@subuser3.username).to eq(@username3)
|
|
54
|
+
expect(@subuser3.email).to eq(@email1)
|
|
55
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
55
56
|
puts e.inspect
|
|
56
57
|
raise e
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
|
|
60
|
-
it '#
|
|
61
|
+
it '#patch_subuser' do
|
|
61
62
|
begin
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
params.push(@username3)
|
|
65
|
-
subusers = @client.get_subuser_reputation(usernames: params)
|
|
66
|
-
expect(subusers).to be_a(Array)
|
|
67
|
-
subusers.each do |subuser|
|
|
68
|
-
expect(subuser).to be_a(SendGrid4r::REST::Subusers::Subuser)
|
|
69
|
-
end
|
|
70
|
-
rescue => e
|
|
63
|
+
@client.patch_subuser(username: @username3, disabled: true)
|
|
64
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
71
65
|
puts e.inspect
|
|
72
66
|
raise e
|
|
73
67
|
end
|
|
74
68
|
end
|
|
75
69
|
|
|
76
|
-
it '#
|
|
70
|
+
it '#delete_subuser' do
|
|
77
71
|
begin
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
expect(subuser.ips).to be_a(Array)
|
|
81
|
-
subuser.ips.each do |ip|
|
|
82
|
-
expect(ip).to be_a(String)
|
|
83
|
-
end
|
|
84
|
-
rescue => e
|
|
72
|
+
@client.delete_subuser(username: @username3)
|
|
73
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
85
74
|
puts e.inspect
|
|
86
75
|
raise e
|
|
87
76
|
end
|
|
88
77
|
end
|
|
89
|
-
end
|
|
90
78
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
expect(
|
|
97
|
-
|
|
98
|
-
|
|
79
|
+
it '#get_subuser_monitor' do
|
|
80
|
+
begin
|
|
81
|
+
monitor = @client.get_subuser_monitor(
|
|
82
|
+
username: @username3, email: @email1, frequency: 10
|
|
83
|
+
)
|
|
84
|
+
expect(monitor).to be_a(SendGrid4r::REST::Subusers::Monitor)
|
|
85
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
86
|
+
puts e.inspect
|
|
87
|
+
raise e
|
|
99
88
|
end
|
|
100
89
|
end
|
|
101
90
|
|
|
102
|
-
it '#
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
91
|
+
it '#post_subuser_monitor' do
|
|
92
|
+
begin
|
|
93
|
+
monitor = @client.post_subuser_monitor(
|
|
94
|
+
username: @username3, email: @email1, frequency: 10
|
|
95
|
+
)
|
|
96
|
+
expect(monitor).to be_a(SendGrid4r::REST::Subusers::Monitor)
|
|
97
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
98
|
+
puts e.inspect
|
|
99
|
+
raise e
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it '#put_subuser_monitor' do
|
|
104
|
+
begin
|
|
105
|
+
@client.post_subuser_monitor(
|
|
106
|
+
username: @username3, email: @email1, frequency: 10
|
|
107
|
+
)
|
|
108
|
+
monitor = @client.put_subuser_monitor(
|
|
109
|
+
username: @username3, email: @email1, frequency: 10
|
|
110
|
+
)
|
|
111
|
+
expect(monitor).to be_a(SendGrid4r::REST::Subusers::Monitor)
|
|
112
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
113
|
+
puts e.inspect
|
|
114
|
+
raise e
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
it '#delete_subuser_monitor' do
|
|
119
|
+
begin
|
|
120
|
+
@client.post_subuser_monitor(
|
|
121
|
+
username: @username3, email: @email1, frequency: 10
|
|
122
|
+
)
|
|
123
|
+
@client.delete_subuser_monitor(username: @username3)
|
|
124
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
125
|
+
puts e.inspect
|
|
126
|
+
raise e
|
|
115
127
|
end
|
|
116
128
|
end
|
|
117
129
|
|
|
118
130
|
it '#get_subuser_reputation' do
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
expect(
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
begin
|
|
132
|
+
params = []
|
|
133
|
+
params.push(@username1)
|
|
134
|
+
params.push(@username2)
|
|
135
|
+
subusers = @client.get_subuser_reputation(usernames: params)
|
|
136
|
+
expect(subusers).to be_a(Array)
|
|
137
|
+
subusers.each do |subuser|
|
|
138
|
+
expect(subuser).to be_a(SendGrid4r::REST::Subusers::Subuser)
|
|
139
|
+
end
|
|
140
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
141
|
+
puts e.inspect
|
|
142
|
+
raise e
|
|
127
143
|
end
|
|
128
144
|
end
|
|
129
145
|
|
|
130
146
|
it '#put_subuser_assigned_ips' do
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
147
|
+
begin
|
|
148
|
+
subuser = @client.put_subuser_assigned_ips(
|
|
149
|
+
username: @username2, ips: [@ip]
|
|
150
|
+
)
|
|
151
|
+
expect(subuser.ips).to be_a(Array)
|
|
152
|
+
subuser.ips.each do |ip|
|
|
153
|
+
expect(ip).to be_a(String)
|
|
154
|
+
end
|
|
155
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
156
|
+
puts e.inspect
|
|
157
|
+
raise e
|
|
140
158
|
end
|
|
141
159
|
end
|
|
142
160
|
end
|
|
@@ -190,6 +208,15 @@ describe SendGrid4r::REST::Subusers do
|
|
|
190
208
|
)
|
|
191
209
|
end
|
|
192
210
|
|
|
211
|
+
let(:monitor) do
|
|
212
|
+
JSON.parse(
|
|
213
|
+
'{'\
|
|
214
|
+
'"email": "test@example.com",'\
|
|
215
|
+
'"frequency": 500'\
|
|
216
|
+
'}'
|
|
217
|
+
)
|
|
218
|
+
end
|
|
219
|
+
|
|
193
220
|
it '#get_subusers' do
|
|
194
221
|
allow(client).to receive(:execute).and_return(subusers)
|
|
195
222
|
actual = client.get_subusers(limit: 0, offset: 0, username: 'aaa')
|
|
@@ -207,6 +234,48 @@ describe SendGrid4r::REST::Subusers do
|
|
|
207
234
|
expect(actual).to be_a(SendGrid4r::REST::Subusers::Subuser)
|
|
208
235
|
end
|
|
209
236
|
|
|
237
|
+
it '#patch_subuser' do
|
|
238
|
+
allow(client).to receive(:execute).and_return(subuser)
|
|
239
|
+
actual = client.patch_subuser(username: '', disabled: true)
|
|
240
|
+
expect(actual).to be_a(SendGrid4r::REST::Subusers::Subuser)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
it '#delete_subuser' do
|
|
244
|
+
allow(client).to receive(:execute).and_return('')
|
|
245
|
+
actual = client.delete_subuser(username: '')
|
|
246
|
+
expect(actual).to eq('')
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
it '#get_subuser_monitor' do
|
|
250
|
+
allow(client).to receive(:execute).and_return(monitor)
|
|
251
|
+
actual = client.get_subuser_monitor(
|
|
252
|
+
username: '', email: '', frequency: 1
|
|
253
|
+
)
|
|
254
|
+
expect(actual).to be_a(SendGrid4r::REST::Subusers::Monitor)
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
it '#post_subuser_monitor' do
|
|
258
|
+
allow(client).to receive(:execute).and_return(monitor)
|
|
259
|
+
actual = client.post_subuser_monitor(
|
|
260
|
+
username: '', email: '', frequency: 1
|
|
261
|
+
)
|
|
262
|
+
expect(actual).to be_a(SendGrid4r::REST::Subusers::Monitor)
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
it '#put_subuser_monitor' do
|
|
266
|
+
allow(client).to receive(:execute).and_return(monitor)
|
|
267
|
+
actual = client.put_subuser_monitor(
|
|
268
|
+
username: '', email: '', frequency: 1
|
|
269
|
+
)
|
|
270
|
+
expect(actual).to be_a(SendGrid4r::REST::Subusers::Monitor)
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
it '#delete_subuser_monitor' do
|
|
274
|
+
allow(client).to receive(:execute).and_return('')
|
|
275
|
+
actual = client.delete_subuser_monitor(username: '')
|
|
276
|
+
expect(actual).to eq('')
|
|
277
|
+
end
|
|
278
|
+
|
|
210
279
|
it '#get_subuser_reputation' do
|
|
211
280
|
allow(client).to receive(:execute).and_return(subusers)
|
|
212
281
|
actual = client.get_subuser_reputation(usernames: [])
|
|
@@ -217,9 +286,8 @@ describe SendGrid4r::REST::Subusers do
|
|
|
217
286
|
end
|
|
218
287
|
|
|
219
288
|
it '#put_subuser_assigned_ips' do
|
|
220
|
-
pending 'waiting for sendgrid documentation update'
|
|
221
289
|
allow(client).to receive(:execute).and_return(subuser)
|
|
222
|
-
actual = client.put_subuser_assigned_ips('', [])
|
|
290
|
+
actual = client.put_subuser_assigned_ips(username: '', ips: [])
|
|
223
291
|
expect(actual).to be_a(SendGrid4r::REST::Subusers::Subuser)
|
|
224
292
|
end
|
|
225
293
|
|
|
@@ -242,5 +310,12 @@ describe SendGrid4r::REST::Subusers do
|
|
|
242
310
|
end
|
|
243
311
|
expect(actual.disabled).to eq(false)
|
|
244
312
|
end
|
|
313
|
+
|
|
314
|
+
it 'creates monitor instance' do
|
|
315
|
+
actual = SendGrid4r::REST::Subusers.create_monitor(monitor)
|
|
316
|
+
expect(actual).to be_a(SendGrid4r::REST::Subusers::Monitor)
|
|
317
|
+
expect(actual.email).to eq('test@example.com')
|
|
318
|
+
expect(actual.frequency).to eq(500)
|
|
319
|
+
end
|
|
245
320
|
end
|
|
246
321
|
end
|
|
@@ -6,36 +6,43 @@ describe SendGrid4r::REST::Templates do
|
|
|
6
6
|
before do
|
|
7
7
|
begin
|
|
8
8
|
Dotenv.load
|
|
9
|
-
@client = SendGrid4r::Client.new(
|
|
10
|
-
username: ENV['SENDGRID_USERNAME'],
|
|
11
|
-
password: ENV['SENDGRID_PASSWORD'])
|
|
9
|
+
@client = SendGrid4r::Client.new(api_key: ENV['SILVER_API_KEY'])
|
|
12
10
|
@template_name1 = 'template_test1'
|
|
13
11
|
@template_name2 = 'template_test2'
|
|
14
12
|
@template_edit1 = 'template_edit1'
|
|
13
|
+
@version_name1 = 'version_test1'
|
|
14
|
+
@factory = SendGrid4r::Factory::VersionFactory.new
|
|
15
15
|
|
|
16
16
|
# celan up test env
|
|
17
17
|
tmps = @client.get_templates
|
|
18
18
|
tmps.templates.each do |tmp|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
delete_template(tmp) if tmp.name == @template_name1
|
|
20
|
+
delete_template(tmp) if tmp.name == @template_name2
|
|
21
|
+
delete_template(tmp) if tmp.name == @template_edit1
|
|
22
22
|
end
|
|
23
23
|
# post a template
|
|
24
|
-
@template1 = @client.post_template(@template_name1)
|
|
25
|
-
rescue => e
|
|
24
|
+
@template1 = @client.post_template(name: @template_name1)
|
|
25
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
26
26
|
puts e.inspect
|
|
27
27
|
raise e
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
+
def delete_template(tmp)
|
|
32
|
+
tmp.versions.each do |ver|
|
|
33
|
+
@client.delete_version(template_id: tmp.id, version_id: ver.id)
|
|
34
|
+
end
|
|
35
|
+
@client.delete_template(template_id: tmp.id)
|
|
36
|
+
end
|
|
37
|
+
|
|
31
38
|
context 'without block call' do
|
|
32
39
|
it '#post_template' do
|
|
33
40
|
begin
|
|
34
|
-
new_template = @client.post_template(@template_name2)
|
|
41
|
+
new_template = @client.post_template(name: @template_name2)
|
|
35
42
|
expect(new_template.id).to be_a(String)
|
|
36
43
|
expect(new_template.name).to eq(@template_name2)
|
|
37
44
|
expect(new_template.versions).to be_a(Array)
|
|
38
|
-
rescue => e
|
|
45
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
39
46
|
puts e.inspect
|
|
40
47
|
raise e
|
|
41
48
|
end
|
|
@@ -56,7 +63,7 @@ describe SendGrid4r::REST::Templates do
|
|
|
56
63
|
expect(ver.updated_at).to be_a(String)
|
|
57
64
|
end
|
|
58
65
|
end
|
|
59
|
-
rescue => e
|
|
66
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
60
67
|
puts e.inspect
|
|
61
68
|
raise e
|
|
62
69
|
end
|
|
@@ -64,7 +71,11 @@ describe SendGrid4r::REST::Templates do
|
|
|
64
71
|
|
|
65
72
|
it '#patch_template' do
|
|
66
73
|
begin
|
|
67
|
-
|
|
74
|
+
version = @factory.create(name: @version_name1)
|
|
75
|
+
@client.post_version(template_id: @template1.id, version: version)
|
|
76
|
+
tmp = @client.patch_template(
|
|
77
|
+
template_id: @template1.id, name: @template_edit1
|
|
78
|
+
)
|
|
68
79
|
expect(tmp.id).to be_a(String)
|
|
69
80
|
expect(tmp.name).to be_a(String)
|
|
70
81
|
expect(tmp.versions).to be_a(Array)
|
|
@@ -75,7 +86,7 @@ describe SendGrid4r::REST::Templates do
|
|
|
75
86
|
expect(ver.name).to be_a(String)
|
|
76
87
|
expect(ver.updated_at).to be_a(String)
|
|
77
88
|
end
|
|
78
|
-
rescue => e
|
|
89
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
79
90
|
puts e.inspect
|
|
80
91
|
raise e
|
|
81
92
|
end
|
|
@@ -83,10 +94,10 @@ describe SendGrid4r::REST::Templates do
|
|
|
83
94
|
|
|
84
95
|
it '#get_template' do
|
|
85
96
|
begin
|
|
86
|
-
tmp = @client.get_template(@template1.id)
|
|
97
|
+
tmp = @client.get_template(template_id: @template1.id)
|
|
87
98
|
expect(tmp.id).to eq(@template1.id)
|
|
88
99
|
expect(tmp.versions).to eq(@template1.versions)
|
|
89
|
-
rescue => e
|
|
100
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
90
101
|
puts e.inspect
|
|
91
102
|
raise e
|
|
92
103
|
end
|
|
@@ -94,73 +105,13 @@ describe SendGrid4r::REST::Templates do
|
|
|
94
105
|
|
|
95
106
|
it '#delete_template' do
|
|
96
107
|
begin
|
|
97
|
-
@client.delete_template(@template1.id)
|
|
98
|
-
rescue => e
|
|
108
|
+
@client.delete_template(template_id: @template1.id)
|
|
109
|
+
rescue RestClient::ExceptionWithResponse => e
|
|
99
110
|
puts e.inspect
|
|
100
111
|
raise e
|
|
101
112
|
end
|
|
102
113
|
end
|
|
103
114
|
end
|
|
104
|
-
|
|
105
|
-
context 'with block call' do
|
|
106
|
-
it '#post_template' do
|
|
107
|
-
@client.post_template(@template_name2) do |resp, req, res|
|
|
108
|
-
resp =
|
|
109
|
-
SendGrid4r::REST::Templates.create_template(
|
|
110
|
-
JSON.parse(resp)
|
|
111
|
-
)
|
|
112
|
-
expect(resp).to be_a(SendGrid4r::REST::Templates::Template)
|
|
113
|
-
expect(req).to be_a(RestClient::Request)
|
|
114
|
-
expect(res).to be_a(Net::HTTPCreated)
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
it '#get_templates' do
|
|
119
|
-
@client.get_templates do |resp, req, res|
|
|
120
|
-
resp =
|
|
121
|
-
SendGrid4r::REST::Templates.create_templates(
|
|
122
|
-
JSON.parse(resp)
|
|
123
|
-
)
|
|
124
|
-
expect(resp).to be_a(SendGrid4r::REST::Templates::Templates)
|
|
125
|
-
expect(req).to be_a(RestClient::Request)
|
|
126
|
-
expect(res).to be_a(Net::HTTPOK)
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it '#get_template' do
|
|
131
|
-
@client.get_template(@template1.id) do |resp, req, res|
|
|
132
|
-
resp =
|
|
133
|
-
SendGrid4r::REST::Templates.create_template(
|
|
134
|
-
JSON.parse(resp)
|
|
135
|
-
)
|
|
136
|
-
expect(resp).to be_a(SendGrid4r::REST::Templates::Template)
|
|
137
|
-
expect(req).to be_a(RestClient::Request)
|
|
138
|
-
expect(res).to be_a(Net::HTTPOK)
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it '#patch_template' do
|
|
143
|
-
@client.patch_template(
|
|
144
|
-
@template1.id, @template_edit1
|
|
145
|
-
) do |resp, req, res|
|
|
146
|
-
resp =
|
|
147
|
-
SendGrid4r::REST::Templates.create_template(
|
|
148
|
-
JSON.parse(resp)
|
|
149
|
-
)
|
|
150
|
-
expect(resp).to be_a(SendGrid4r::REST::Templates::Template)
|
|
151
|
-
expect(req).to be_a(RestClient::Request)
|
|
152
|
-
expect(res).to be_a(Net::HTTPOK)
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
it '#delete_template' do
|
|
157
|
-
@client.delete_template(@template1.id) do |resp, req, res|
|
|
158
|
-
expect(resp).to eq('')
|
|
159
|
-
expect(req).to be_a(RestClient::Request)
|
|
160
|
-
expect(res).to be_a(Net::HTTPNoContent)
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
115
|
end
|
|
165
116
|
|
|
166
117
|
describe 'unit test', :ut do
|
|
@@ -206,7 +157,7 @@ describe SendGrid4r::REST::Templates do
|
|
|
206
157
|
|
|
207
158
|
it '#post_template' do
|
|
208
159
|
allow(client).to receive(:execute).and_return(template)
|
|
209
|
-
actual = client.post_template('')
|
|
160
|
+
actual = client.post_template(name: '')
|
|
210
161
|
expect(actual).to be_a(SendGrid4r::REST::Templates::Template)
|
|
211
162
|
end
|
|
212
163
|
|
|
@@ -218,19 +169,19 @@ describe SendGrid4r::REST::Templates do
|
|
|
218
169
|
|
|
219
170
|
it '#patch_template' do
|
|
220
171
|
allow(client).to receive(:execute).and_return(template)
|
|
221
|
-
actual = client.patch_template('', '')
|
|
172
|
+
actual = client.patch_template(template_id: '', name: '')
|
|
222
173
|
expect(actual).to be_a(SendGrid4r::REST::Templates::Template)
|
|
223
174
|
end
|
|
224
175
|
|
|
225
176
|
it '#get_template' do
|
|
226
177
|
allow(client).to receive(:execute).and_return(template)
|
|
227
|
-
actual = client.get_template('')
|
|
178
|
+
actual = client.get_template(template_id: '')
|
|
228
179
|
expect(actual).to be_a(SendGrid4r::REST::Templates::Template)
|
|
229
180
|
end
|
|
230
181
|
|
|
231
182
|
it '#delete_template' do
|
|
232
183
|
allow(client).to receive(:execute).and_return('')
|
|
233
|
-
actual = client.delete_template('')
|
|
184
|
+
actual = client.delete_template(template_id: '')
|
|
234
185
|
expect(actual).to eq('')
|
|
235
186
|
end
|
|
236
187
|
|