sendgrid-ruby 1.1.6 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE +17 -0
- data/.travis.yml +1 -6
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +202 -0
- data/Gemfile +3 -5
- data/LICENSE.txt +1 -1
- data/README.md +74 -248
- data/Rakefile +8 -6
- data/USAGE.md +4645 -0
- data/examples/accesssettings/accesssettings.rb +89 -0
- data/examples/apikeys/apikeys.rb +95 -0
- data/examples/asm/asm.rb +169 -0
- data/examples/browsers/browsers.rb +29 -0
- data/examples/campaigns/campaigns.rb +166 -0
- data/examples/categories/categories.rb +49 -0
- data/examples/clients/clients.rb +40 -0
- data/examples/contactdb/contactdb.rb +398 -0
- data/examples/devices/devices.rb +29 -0
- data/examples/geo/geo.rb +29 -0
- data/examples/helpers/mail/example.rb +130 -0
- data/examples/ips/ips.rb +167 -0
- data/examples/mail/mail.rb +191 -0
- data/examples/mailboxproviders/mailboxproviders.rb +29 -0
- data/examples/mailsettings/mailsettings.rb +232 -0
- data/examples/partnersettings/partnersettings.rb +52 -0
- data/examples/scopes/scopes.rb +28 -0
- data/examples/stats/stats.rb +29 -0
- data/examples/subusers/subusers.rb +182 -0
- data/examples/suppression/suppression.rb +186 -0
- data/examples/templates/templates.rb +142 -0
- data/examples/trackingsettings/trackingsettings.rb +123 -0
- data/examples/user/user.rb +256 -0
- data/examples/whitelabel/whitelabel.rb +323 -0
- data/lib/helpers/mail/README.md +14 -0
- data/lib/helpers/mail/mail.rb +999 -0
- data/lib/sendgrid-ruby.rb +33 -8
- data/sendgrid-ruby.gemspec +5 -17
- data/test/helpers/mail/test_mail.rb +122 -0
- data/test/test_sendgrid-ruby.rb +2016 -0
- metadata +42 -190
- data/.env_sample +0 -3
- data/.rspec +0 -2
- data/.rubocop.yml +0 -30
- data/FETCH_HEAD +0 -0
- data/Guardfile +0 -10
- data/example.rb +0 -41
- data/lib/sendgrid/client.rb +0 -62
- data/lib/sendgrid/exceptions.rb +0 -7
- data/lib/sendgrid/mail.rb +0 -182
- data/lib/sendgrid/recipient.rb +0 -29
- data/lib/sendgrid/response.rb +0 -14
- data/lib/sendgrid/template.rb +0 -26
- data/lib/sendgrid/template_mailer.rb +0 -59
- data/lib/sendgrid/version.rb +0 -3
- data/spec/lib/sendgrid/client_spec.rb +0 -87
- data/spec/lib/sendgrid/mail_spec.rb +0 -151
- data/spec/lib/sendgrid/recipient_spec.rb +0 -91
- data/spec/lib/sendgrid/template_mailer_spec.rb +0 -86
- data/spec/lib/sendgrid/template_spec.rb +0 -61
- data/spec/lib/sendgrid_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -1
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Retrieve email statistics by mailbox provider. #
|
22
|
+
# GET /mailbox_providers/stats #
|
23
|
+
|
24
|
+
params = JSON.parse('{"end_date": "2016-04-01", "mailbox_providers": "test_string", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}')
|
25
|
+
response = sg.client.mailbox_providers.stats.get(query_params: params)
|
26
|
+
puts response.status_code
|
27
|
+
puts response.body
|
28
|
+
puts response.headers
|
29
|
+
|
@@ -0,0 +1,232 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Retrieve all mail settings #
|
22
|
+
# GET /mail_settings #
|
23
|
+
|
24
|
+
params = JSON.parse('{"limit": 1, "offset": 1}')
|
25
|
+
response = sg.client.mail_settings.get(query_params: params)
|
26
|
+
puts response.status_code
|
27
|
+
puts response.body
|
28
|
+
puts response.headers
|
29
|
+
|
30
|
+
##################################################
|
31
|
+
# Update address whitelist mail settings #
|
32
|
+
# PATCH /mail_settings/address_whitelist #
|
33
|
+
|
34
|
+
data = JSON.parse('{
|
35
|
+
"enabled": true,
|
36
|
+
"list": [
|
37
|
+
"email1@example.com",
|
38
|
+
"example.com"
|
39
|
+
]
|
40
|
+
}')
|
41
|
+
response = sg.client.mail_settings.address_whitelist.patch(request_body: data)
|
42
|
+
puts response.status_code
|
43
|
+
puts response.body
|
44
|
+
puts response.headers
|
45
|
+
|
46
|
+
##################################################
|
47
|
+
# Retrieve address whitelist mail settings #
|
48
|
+
# GET /mail_settings/address_whitelist #
|
49
|
+
|
50
|
+
response = sg.client.mail_settings.address_whitelist.get()
|
51
|
+
puts response.status_code
|
52
|
+
puts response.body
|
53
|
+
puts response.headers
|
54
|
+
|
55
|
+
##################################################
|
56
|
+
# Update BCC mail settings #
|
57
|
+
# PATCH /mail_settings/bcc #
|
58
|
+
|
59
|
+
data = JSON.parse('{
|
60
|
+
"email": "email@example.com",
|
61
|
+
"enabled": false
|
62
|
+
}')
|
63
|
+
response = sg.client.mail_settings.bcc.patch(request_body: data)
|
64
|
+
puts response.status_code
|
65
|
+
puts response.body
|
66
|
+
puts response.headers
|
67
|
+
|
68
|
+
##################################################
|
69
|
+
# Retrieve all BCC mail settings #
|
70
|
+
# GET /mail_settings/bcc #
|
71
|
+
|
72
|
+
response = sg.client.mail_settings.bcc.get()
|
73
|
+
puts response.status_code
|
74
|
+
puts response.body
|
75
|
+
puts response.headers
|
76
|
+
|
77
|
+
##################################################
|
78
|
+
# Update bounce purge mail settings #
|
79
|
+
# PATCH /mail_settings/bounce_purge #
|
80
|
+
|
81
|
+
data = JSON.parse('{
|
82
|
+
"enabled": true,
|
83
|
+
"hard_bounces": 5,
|
84
|
+
"soft_bounces": 5
|
85
|
+
}')
|
86
|
+
response = sg.client.mail_settings.bounce_purge.patch(request_body: data)
|
87
|
+
puts response.status_code
|
88
|
+
puts response.body
|
89
|
+
puts response.headers
|
90
|
+
|
91
|
+
##################################################
|
92
|
+
# Retrieve bounce purge mail settings #
|
93
|
+
# GET /mail_settings/bounce_purge #
|
94
|
+
|
95
|
+
response = sg.client.mail_settings.bounce_purge.get()
|
96
|
+
puts response.status_code
|
97
|
+
puts response.body
|
98
|
+
puts response.headers
|
99
|
+
|
100
|
+
##################################################
|
101
|
+
# Update footer mail settings #
|
102
|
+
# PATCH /mail_settings/footer #
|
103
|
+
|
104
|
+
data = JSON.parse('{
|
105
|
+
"enabled": true,
|
106
|
+
"html_content": "...",
|
107
|
+
"plain_content": "..."
|
108
|
+
}')
|
109
|
+
response = sg.client.mail_settings.footer.patch(request_body: data)
|
110
|
+
puts response.status_code
|
111
|
+
puts response.body
|
112
|
+
puts response.headers
|
113
|
+
|
114
|
+
##################################################
|
115
|
+
# Retrieve footer mail settings #
|
116
|
+
# GET /mail_settings/footer #
|
117
|
+
|
118
|
+
response = sg.client.mail_settings.footer.get()
|
119
|
+
puts response.status_code
|
120
|
+
puts response.body
|
121
|
+
puts response.headers
|
122
|
+
|
123
|
+
##################################################
|
124
|
+
# Update forward bounce mail settings #
|
125
|
+
# PATCH /mail_settings/forward_bounce #
|
126
|
+
|
127
|
+
data = JSON.parse('{
|
128
|
+
"email": "example@example.com",
|
129
|
+
"enabled": true
|
130
|
+
}')
|
131
|
+
response = sg.client.mail_settings.forward_bounce.patch(request_body: data)
|
132
|
+
puts response.status_code
|
133
|
+
puts response.body
|
134
|
+
puts response.headers
|
135
|
+
|
136
|
+
##################################################
|
137
|
+
# Retrieve forward bounce mail settings #
|
138
|
+
# GET /mail_settings/forward_bounce #
|
139
|
+
|
140
|
+
response = sg.client.mail_settings.forward_bounce.get()
|
141
|
+
puts response.status_code
|
142
|
+
puts response.body
|
143
|
+
puts response.headers
|
144
|
+
|
145
|
+
##################################################
|
146
|
+
# Update forward spam mail settings #
|
147
|
+
# PATCH /mail_settings/forward_spam #
|
148
|
+
|
149
|
+
data = JSON.parse('{
|
150
|
+
"email": "",
|
151
|
+
"enabled": false
|
152
|
+
}')
|
153
|
+
response = sg.client.mail_settings.forward_spam.patch(request_body: data)
|
154
|
+
puts response.status_code
|
155
|
+
puts response.body
|
156
|
+
puts response.headers
|
157
|
+
|
158
|
+
##################################################
|
159
|
+
# Retrieve forward spam mail settings #
|
160
|
+
# GET /mail_settings/forward_spam #
|
161
|
+
|
162
|
+
response = sg.client.mail_settings.forward_spam.get()
|
163
|
+
puts response.status_code
|
164
|
+
puts response.body
|
165
|
+
puts response.headers
|
166
|
+
|
167
|
+
##################################################
|
168
|
+
# Update plain content mail settings #
|
169
|
+
# PATCH /mail_settings/plain_content #
|
170
|
+
|
171
|
+
data = JSON.parse('{
|
172
|
+
"enabled": false
|
173
|
+
}')
|
174
|
+
response = sg.client.mail_settings.plain_content.patch(request_body: data)
|
175
|
+
puts response.status_code
|
176
|
+
puts response.body
|
177
|
+
puts response.headers
|
178
|
+
|
179
|
+
##################################################
|
180
|
+
# Retrieve plain content mail settings #
|
181
|
+
# GET /mail_settings/plain_content #
|
182
|
+
|
183
|
+
response = sg.client.mail_settings.plain_content.get()
|
184
|
+
puts response.status_code
|
185
|
+
puts response.body
|
186
|
+
puts response.headers
|
187
|
+
|
188
|
+
##################################################
|
189
|
+
# Update spam check mail settings #
|
190
|
+
# PATCH /mail_settings/spam_check #
|
191
|
+
|
192
|
+
data = JSON.parse('{
|
193
|
+
"enabled": true,
|
194
|
+
"max_score": 5,
|
195
|
+
"url": "url"
|
196
|
+
}')
|
197
|
+
response = sg.client.mail_settings.spam_check.patch(request_body: data)
|
198
|
+
puts response.status_code
|
199
|
+
puts response.body
|
200
|
+
puts response.headers
|
201
|
+
|
202
|
+
##################################################
|
203
|
+
# Retrieve spam check mail settings #
|
204
|
+
# GET /mail_settings/spam_check #
|
205
|
+
|
206
|
+
response = sg.client.mail_settings.spam_check.get()
|
207
|
+
puts response.status_code
|
208
|
+
puts response.body
|
209
|
+
puts response.headers
|
210
|
+
|
211
|
+
##################################################
|
212
|
+
# Update template mail settings #
|
213
|
+
# PATCH /mail_settings/template #
|
214
|
+
|
215
|
+
data = JSON.parse('{
|
216
|
+
"enabled": true,
|
217
|
+
"html_content": "<% body %>"
|
218
|
+
}')
|
219
|
+
response = sg.client.mail_settings.template.patch(request_body: data)
|
220
|
+
puts response.status_code
|
221
|
+
puts response.body
|
222
|
+
puts response.headers
|
223
|
+
|
224
|
+
##################################################
|
225
|
+
# Retrieve legacy template mail settings #
|
226
|
+
# GET /mail_settings/template #
|
227
|
+
|
228
|
+
response = sg.client.mail_settings.template.get()
|
229
|
+
puts response.status_code
|
230
|
+
puts response.body
|
231
|
+
puts response.headers
|
232
|
+
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Returns a list of all partner settings. #
|
22
|
+
# GET /partner_settings #
|
23
|
+
|
24
|
+
params = JSON.parse('{"limit": 1, "offset": 1}')
|
25
|
+
response = sg.client.partner_settings.get(query_params: params)
|
26
|
+
puts response.status_code
|
27
|
+
puts response.body
|
28
|
+
puts response.headers
|
29
|
+
|
30
|
+
##################################################
|
31
|
+
# Updates New Relic partner settings. #
|
32
|
+
# PATCH /partner_settings/new_relic #
|
33
|
+
|
34
|
+
data = JSON.parse('{
|
35
|
+
"enable_subuser_statistics": true,
|
36
|
+
"enabled": true,
|
37
|
+
"license_key": ""
|
38
|
+
}')
|
39
|
+
response = sg.client.partner_settings.new_relic.patch(request_body: data)
|
40
|
+
puts response.status_code
|
41
|
+
puts response.body
|
42
|
+
puts response.headers
|
43
|
+
|
44
|
+
##################################################
|
45
|
+
# Returns all New Relic partner settings. #
|
46
|
+
# GET /partner_settings/new_relic #
|
47
|
+
|
48
|
+
response = sg.client.partner_settings.new_relic.get()
|
49
|
+
puts response.status_code
|
50
|
+
puts response.body
|
51
|
+
puts response.headers
|
52
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Retrieve a list of scopes for which this user has access. #
|
22
|
+
# GET /scopes #
|
23
|
+
|
24
|
+
response = sg.client.scopes.get()
|
25
|
+
puts response.status_code
|
26
|
+
puts response.body
|
27
|
+
puts response.headers
|
28
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Retrieve global email statistics #
|
22
|
+
# GET /stats #
|
23
|
+
|
24
|
+
params = JSON.parse('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}')
|
25
|
+
response = sg.client.stats.get(query_params: params)
|
26
|
+
puts response.status_code
|
27
|
+
puts response.body
|
28
|
+
puts response.headers
|
29
|
+
|
@@ -0,0 +1,182 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Create Subuser #
|
22
|
+
# POST /subusers #
|
23
|
+
|
24
|
+
data = JSON.parse('{
|
25
|
+
"email": "John@example.com",
|
26
|
+
"ips": [
|
27
|
+
"1.1.1.1",
|
28
|
+
"2.2.2.2"
|
29
|
+
],
|
30
|
+
"password": "johns_password",
|
31
|
+
"username": "John@example.com"
|
32
|
+
}')
|
33
|
+
response = sg.client.subusers.post(request_body: data)
|
34
|
+
puts response.status_code
|
35
|
+
puts response.body
|
36
|
+
puts response.headers
|
37
|
+
|
38
|
+
##################################################
|
39
|
+
# List all Subusers #
|
40
|
+
# GET /subusers #
|
41
|
+
|
42
|
+
params = JSON.parse('{"username": "test_string", "limit": 0, "offset": 0}')
|
43
|
+
response = sg.client.subusers.get(query_params: params)
|
44
|
+
puts response.status_code
|
45
|
+
puts response.body
|
46
|
+
puts response.headers
|
47
|
+
|
48
|
+
##################################################
|
49
|
+
# Retrieve Subuser Reputations #
|
50
|
+
# GET /subusers/reputations #
|
51
|
+
|
52
|
+
params = JSON.parse('{"usernames": "test_string"}')
|
53
|
+
response = sg.client.subusers.reputations.get(query_params: params)
|
54
|
+
puts response.status_code
|
55
|
+
puts response.body
|
56
|
+
puts response.headers
|
57
|
+
|
58
|
+
##################################################
|
59
|
+
# Retrieve email statistics for your subusers. #
|
60
|
+
# GET /subusers/stats #
|
61
|
+
|
62
|
+
params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "subusers": "test_string"}')
|
63
|
+
response = sg.client.subusers.stats.get(query_params: params)
|
64
|
+
puts response.status_code
|
65
|
+
puts response.body
|
66
|
+
puts response.headers
|
67
|
+
|
68
|
+
##################################################
|
69
|
+
# Retrieve monthly stats for all subusers #
|
70
|
+
# GET /subusers/stats/monthly #
|
71
|
+
|
72
|
+
params = JSON.parse('{"subuser": "test_string", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "date": "test_string", "sort_by_direction": "asc"}')
|
73
|
+
response = sg.client.subusers.stats.monthly.get(query_params: params)
|
74
|
+
puts response.status_code
|
75
|
+
puts response.body
|
76
|
+
puts response.headers
|
77
|
+
|
78
|
+
##################################################
|
79
|
+
# Retrieve the totals for each email statistic metric for all subusers. #
|
80
|
+
# GET /subusers/stats/sums #
|
81
|
+
|
82
|
+
params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "start_date": "2016-01-01", "sort_by_direction": "asc"}')
|
83
|
+
response = sg.client.subusers.stats.sums.get(query_params: params)
|
84
|
+
puts response.status_code
|
85
|
+
puts response.body
|
86
|
+
puts response.headers
|
87
|
+
|
88
|
+
##################################################
|
89
|
+
# Enable/disable a subuser #
|
90
|
+
# PATCH /subusers/{subuser_name} #
|
91
|
+
|
92
|
+
data = JSON.parse('{
|
93
|
+
"disabled": false
|
94
|
+
}')
|
95
|
+
subuser_name = "test_url_param"
|
96
|
+
response = sg.client.subusers._(subuser_name).patch(request_body: data)
|
97
|
+
puts response.status_code
|
98
|
+
puts response.body
|
99
|
+
puts response.headers
|
100
|
+
|
101
|
+
##################################################
|
102
|
+
# Delete a subuser #
|
103
|
+
# DELETE /subusers/{subuser_name} #
|
104
|
+
|
105
|
+
subuser_name = "test_url_param"
|
106
|
+
response = sg.client.subusers._(subuser_name).delete()
|
107
|
+
puts response.status_code
|
108
|
+
puts response.body
|
109
|
+
puts response.headers
|
110
|
+
|
111
|
+
##################################################
|
112
|
+
# Update IPs assigned to a subuser #
|
113
|
+
# PUT /subusers/{subuser_name}/ips #
|
114
|
+
|
115
|
+
data = JSON.parse('[
|
116
|
+
"127.0.0.1"
|
117
|
+
]')
|
118
|
+
subuser_name = "test_url_param"
|
119
|
+
response = sg.client.subusers._(subuser_name).ips.put(request_body: data)
|
120
|
+
puts response.status_code
|
121
|
+
puts response.body
|
122
|
+
puts response.headers
|
123
|
+
|
124
|
+
##################################################
|
125
|
+
# Update Monitor Settings for a subuser #
|
126
|
+
# PUT /subusers/{subuser_name}/monitor #
|
127
|
+
|
128
|
+
data = JSON.parse('{
|
129
|
+
"email": "example@example.com",
|
130
|
+
"frequency": 500
|
131
|
+
}')
|
132
|
+
subuser_name = "test_url_param"
|
133
|
+
response = sg.client.subusers._(subuser_name).monitor.put(request_body: data)
|
134
|
+
puts response.status_code
|
135
|
+
puts response.body
|
136
|
+
puts response.headers
|
137
|
+
|
138
|
+
##################################################
|
139
|
+
# Create monitor settings #
|
140
|
+
# POST /subusers/{subuser_name}/monitor #
|
141
|
+
|
142
|
+
data = JSON.parse('{
|
143
|
+
"email": "example@example.com",
|
144
|
+
"frequency": 50000
|
145
|
+
}')
|
146
|
+
subuser_name = "test_url_param"
|
147
|
+
response = sg.client.subusers._(subuser_name).monitor.post(request_body: data)
|
148
|
+
puts response.status_code
|
149
|
+
puts response.body
|
150
|
+
puts response.headers
|
151
|
+
|
152
|
+
##################################################
|
153
|
+
# Retrieve monitor settings for a subuser #
|
154
|
+
# GET /subusers/{subuser_name}/monitor #
|
155
|
+
|
156
|
+
subuser_name = "test_url_param"
|
157
|
+
response = sg.client.subusers._(subuser_name).monitor.get()
|
158
|
+
puts response.status_code
|
159
|
+
puts response.body
|
160
|
+
puts response.headers
|
161
|
+
|
162
|
+
##################################################
|
163
|
+
# Delete monitor settings #
|
164
|
+
# DELETE /subusers/{subuser_name}/monitor #
|
165
|
+
|
166
|
+
subuser_name = "test_url_param"
|
167
|
+
response = sg.client.subusers._(subuser_name).monitor.delete()
|
168
|
+
puts response.status_code
|
169
|
+
puts response.body
|
170
|
+
puts response.headers
|
171
|
+
|
172
|
+
##################################################
|
173
|
+
# Retrieve the monthly email statistics for a single subuser #
|
174
|
+
# GET /subusers/{subuser_name}/stats/monthly #
|
175
|
+
|
176
|
+
params = JSON.parse('{"date": "test_string", "sort_by_direction": "asc", "limit": 0, "sort_by_metric": "test_string", "offset": 1}')
|
177
|
+
subuser_name = "test_url_param"
|
178
|
+
response = sg.client.subusers._(subuser_name).stats.monthly.get(query_params: params)
|
179
|
+
puts response.status_code
|
180
|
+
puts response.body
|
181
|
+
puts response.headers
|
182
|
+
|