sendgrid-ruby 1.1.6 → 6.0.4

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.
Files changed (136) hide show
  1. checksums.yaml +5 -5
  2. data/.codeclimate.yml +21 -0
  3. data/.env_sample +1 -3
  4. data/.gitignore +1 -0
  5. data/.travis.yml +28 -17
  6. data/CHANGELOG.md +231 -1
  7. data/CODE_OF_CONDUCT.md +73 -0
  8. data/CONTRIBUTING.md +214 -0
  9. data/Gemfile +5 -4
  10. data/ISSUE_TEMPLATE.md +26 -0
  11. data/LICENSE.md +21 -0
  12. data/Makefile +7 -0
  13. data/PULL_REQUEST_TEMPLATE.md +31 -0
  14. data/README.md +161 -225
  15. data/Rakefile +9 -2
  16. data/TROUBLESHOOTING.md +137 -0
  17. data/UPGRADE.md +5 -0
  18. data/USAGE.md +5037 -0
  19. data/USE_CASES.md +377 -0
  20. data/config.ru +4 -0
  21. data/docker/Dockerfile +12 -0
  22. data/docker/README.md +30 -0
  23. data/examples/accesssettings/accesssettings.rb +83 -0
  24. data/examples/alerts/alerts.rb +62 -0
  25. data/examples/apikeys/apikeys.rb +84 -0
  26. data/examples/asm/asm.rb +173 -0
  27. data/examples/browsers/browsers.rb +16 -0
  28. data/examples/campaigns/campaigns.rb +153 -0
  29. data/examples/categories/categories.rb +36 -0
  30. data/examples/clients/clients.rb +27 -0
  31. data/examples/contactdb/contactdb.rb +395 -0
  32. data/examples/devices/devices.rb +16 -0
  33. data/examples/geo/geo.rb +16 -0
  34. data/examples/helpers/mail/example.rb +147 -0
  35. data/examples/helpers/settings/example.rb +23 -0
  36. data/examples/helpers/stats/example.rb +42 -0
  37. data/examples/ips/ips.rb +167 -0
  38. data/examples/mail/mail.rb +173 -0
  39. data/examples/mailboxproviders/mailboxproviders.rb +16 -0
  40. data/examples/mailsettings/mailsettings.rb +219 -0
  41. data/examples/partnersettings/partnersettings.rb +39 -0
  42. data/examples/scopes/scopes.rb +61 -0
  43. data/examples/senderauthentication/senderauthentication.rb +310 -0
  44. data/examples/senders/senders.rb +98 -0
  45. data/examples/stats/stats.rb +16 -0
  46. data/examples/subusers/subusers.rb +169 -0
  47. data/examples/suppression/suppression.rb +201 -0
  48. data/examples/templates/templates.rb +129 -0
  49. data/examples/trackingsettings/trackingsettings.rb +110 -0
  50. data/examples/user/user.rb +293 -0
  51. data/gemfiles/Sinatra_1.gemfile +6 -0
  52. data/gemfiles/Sinatra_2.gemfile +6 -0
  53. data/lib/sendgrid/client.rb +33 -57
  54. data/lib/sendgrid/helpers/inbound/README.md +98 -0
  55. data/lib/sendgrid/helpers/inbound/app.rb +32 -0
  56. data/lib/sendgrid/helpers/inbound/config.yml +26 -0
  57. data/lib/sendgrid/helpers/inbound/public/index.html +10 -0
  58. data/lib/sendgrid/helpers/inbound/sample_data/default_data.txt +58 -0
  59. data/lib/sendgrid/helpers/inbound/sample_data/raw_data.txt +57 -0
  60. data/lib/sendgrid/helpers/inbound/sample_data/raw_data_with_attachments.txt +298 -0
  61. data/lib/sendgrid/helpers/inbound/send.rb +26 -0
  62. data/lib/sendgrid/helpers/ip_management/ip_management.rb +17 -0
  63. data/lib/sendgrid/helpers/mail/README.md +14 -0
  64. data/lib/sendgrid/helpers/mail/asm.rb +33 -0
  65. data/lib/sendgrid/helpers/mail/attachment.rb +86 -0
  66. data/lib/sendgrid/helpers/mail/bcc_settings.rb +33 -0
  67. data/lib/sendgrid/helpers/mail/bypass_list_management.rb +43 -0
  68. data/lib/sendgrid/helpers/mail/category.rb +20 -0
  69. data/lib/sendgrid/helpers/mail/click_tracking.rb +33 -0
  70. data/lib/sendgrid/helpers/mail/content.rb +20 -0
  71. data/lib/sendgrid/helpers/mail/custom_arg.rb +24 -0
  72. data/lib/sendgrid/helpers/mail/email.rb +29 -0
  73. data/lib/sendgrid/helpers/mail/footer.rb +43 -0
  74. data/lib/sendgrid/helpers/mail/ganalytics.rb +74 -0
  75. data/lib/sendgrid/helpers/mail/header.rb +24 -0
  76. data/lib/sendgrid/helpers/mail/mail.rb +140 -0
  77. data/lib/sendgrid/helpers/mail/mail_settings.rb +63 -0
  78. data/lib/sendgrid/helpers/mail/open_tracking.rb +33 -0
  79. data/lib/sendgrid/helpers/mail/personalization.rb +82 -0
  80. data/lib/sendgrid/helpers/mail/section.rb +24 -0
  81. data/lib/sendgrid/helpers/mail/spam_check.rb +43 -0
  82. data/lib/sendgrid/helpers/mail/subscription_tracking.rb +53 -0
  83. data/lib/sendgrid/helpers/mail/substitution.rb +24 -0
  84. data/lib/sendgrid/helpers/mail/tracking_settings.rb +53 -0
  85. data/lib/sendgrid/helpers/permissions/scope.rb +28 -0
  86. data/lib/sendgrid/helpers/permissions/scopes.yml +309 -0
  87. data/lib/sendgrid/helpers/settings/README.md +14 -0
  88. data/lib/sendgrid/helpers/settings/mail_settings_dto.rb +13 -0
  89. data/lib/sendgrid/helpers/settings/partner_settings_dto.rb +13 -0
  90. data/lib/sendgrid/helpers/settings/settings.rb +28 -0
  91. data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +24 -0
  92. data/lib/sendgrid/helpers/settings/user_settings_dto.rb +13 -0
  93. data/lib/sendgrid/helpers/stats/email_stats.rb +46 -0
  94. data/lib/sendgrid/helpers/stats/metrics.rb +35 -0
  95. data/lib/sendgrid/helpers/stats/stats_response.rb +31 -0
  96. data/lib/sendgrid/version.rb +1 -1
  97. data/lib/sendgrid-ruby.rb +27 -6
  98. data/mail_helper_v3.md +390 -0
  99. data/sendgrid-ruby.gemspec +13 -17
  100. data/spec/sendgrid/helpers/ip_management/ip_management_spec.rb +12 -0
  101. data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +32 -0
  102. data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +24 -0
  103. data/spec/sendgrid/helpers/settings/settings_spec.rb +25 -0
  104. data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +27 -0
  105. data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +24 -0
  106. data/spec/sendgrid/helpers/stats/email_stats_spec.rb +112 -0
  107. data/spec/sendgrid/helpers/stats/metrics_spec.rb +46 -0
  108. data/spec/sendgrid/helpers/stats/stats_response_spec.rb +76 -0
  109. data/spec/spec_helper.rb +10 -1
  110. data/test/prism.sh +42 -0
  111. data/test/sendgrid/helpers/mail/test_attachment.rb +35 -0
  112. data/test/sendgrid/helpers/mail/test_category.rb +27 -0
  113. data/test/sendgrid/helpers/mail/test_email.rb +34 -0
  114. data/test/sendgrid/helpers/mail/test_mail.rb +261 -0
  115. data/test/sendgrid/helpers/mail/test_personalizations.rb +161 -0
  116. data/test/sendgrid/permissions/test_scopes.rb +38 -0
  117. data/test/sendgrid/test_sendgrid-ruby.rb +2751 -0
  118. metadata +149 -115
  119. data/.rspec +0 -2
  120. data/.rubocop.yml +0 -30
  121. data/FETCH_HEAD +0 -0
  122. data/Guardfile +0 -10
  123. data/LICENSE.txt +0 -22
  124. data/example.rb +0 -41
  125. data/lib/sendgrid/exceptions.rb +0 -7
  126. data/lib/sendgrid/mail.rb +0 -182
  127. data/lib/sendgrid/recipient.rb +0 -29
  128. data/lib/sendgrid/response.rb +0 -14
  129. data/lib/sendgrid/template.rb +0 -26
  130. data/lib/sendgrid/template_mailer.rb +0 -59
  131. data/spec/lib/sendgrid/client_spec.rb +0 -87
  132. data/spec/lib/sendgrid/mail_spec.rb +0 -151
  133. data/spec/lib/sendgrid/recipient_spec.rb +0 -91
  134. data/spec/lib/sendgrid/template_mailer_spec.rb +0 -86
  135. data/spec/lib/sendgrid/template_spec.rb +0 -61
  136. data/spec/lib/sendgrid_spec.rb +0 -7
@@ -0,0 +1,310 @@
1
+ require 'sendgrid-ruby'
2
+
3
+
4
+ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
+
6
+
7
+ ##################################################
8
+ # Create a domain authentication. #
9
+ # POST /whitelabel/domains #
10
+
11
+ data = JSON.parse('{
12
+ "automatic_security": false,
13
+ "custom_spf": true,
14
+ "default": true,
15
+ "domain": "example.com",
16
+ "ips": [
17
+ "192.168.1.1",
18
+ "192.168.1.2"
19
+ ],
20
+ "subdomain": "news",
21
+ "username": "john@example.com"
22
+ }')
23
+ response = sg.client.whitelabel.domains.post(request_body: data)
24
+ puts response.status_code
25
+ puts response.body
26
+ puts response.headers
27
+
28
+ ##################################################
29
+ # List all domain authentications. #
30
+ # GET /whitelabel/domains #
31
+
32
+ params = JSON.parse('{"username": "test_string", "domain": "test_string", "exclude_subusers": "true", "limit": 1, "offset": 1}')
33
+ response = sg.client.whitelabel.domains.get(query_params: params)
34
+ puts response.status_code
35
+ puts response.body
36
+ puts response.headers
37
+
38
+ ##################################################
39
+ # Get the default domain authentication. #
40
+ # GET /whitelabel/domains/default #
41
+
42
+ response = sg.client.whitelabel.domains.default.get()
43
+ puts response.status_code
44
+ puts response.body
45
+ puts response.headers
46
+
47
+ ##################################################
48
+ # List the domain authentication associated with the given user. #
49
+ # GET /whitelabel/domains/subuser #
50
+
51
+ response = sg.client.whitelabel.domains.subuser.get()
52
+ puts response.status_code
53
+ puts response.body
54
+ puts response.headers
55
+
56
+ ##################################################
57
+ # Disassociate a domain authentication from a given user. #
58
+ # DELETE /whitelabel/domains/subuser #
59
+
60
+ response = sg.client.whitelabel.domains.subuser.delete()
61
+ puts response.status_code
62
+ puts response.body
63
+ puts response.headers
64
+
65
+ ##################################################
66
+ # Update a domain authentication. #
67
+ # PATCH /whitelabel/domains/{domain_id} #
68
+
69
+ data = JSON.parse('{
70
+ "custom_spf": true,
71
+ "default": false
72
+ }')
73
+ domain_id = "test_url_param"
74
+ response = sg.client.whitelabel.domains._(domain_id).patch(request_body: data)
75
+ puts response.status_code
76
+ puts response.body
77
+ puts response.headers
78
+
79
+ ##################################################
80
+ # Retrieve a domain authentication. #
81
+ # GET /whitelabel/domains/{domain_id} #
82
+
83
+ domain_id = "test_url_param"
84
+ response = sg.client.whitelabel.domains._(domain_id).get()
85
+ puts response.status_code
86
+ puts response.body
87
+ puts response.headers
88
+
89
+ ##################################################
90
+ # Delete a domain authentication. #
91
+ # DELETE /whitelabel/domains/{domain_id} #
92
+
93
+ domain_id = "test_url_param"
94
+ response = sg.client.whitelabel.domains._(domain_id).delete()
95
+ puts response.status_code
96
+ puts response.body
97
+ puts response.headers
98
+
99
+ ##################################################
100
+ # Associate a domain authentication with a given user. #
101
+ # POST /whitelabel/domains/{domain_id}/subuser #
102
+
103
+ data = JSON.parse('{
104
+ "username": "jane@example.com"
105
+ }')
106
+ domain_id = "test_url_param"
107
+ response = sg.client.whitelabel.domains._(domain_id).subuser.post(request_body: data)
108
+ puts response.status_code
109
+ puts response.body
110
+ puts response.headers
111
+
112
+ ##################################################
113
+ # Add an IP to a domain authentication. #
114
+ # POST /whitelabel/domains/{id}/ips #
115
+
116
+ data = JSON.parse('{
117
+ "ip": "192.168.0.1"
118
+ }')
119
+ id = "test_url_param"
120
+ response = sg.client.whitelabel.domains._(id).ips.post(request_body: data)
121
+ puts response.status_code
122
+ puts response.body
123
+ puts response.headers
124
+
125
+ ##################################################
126
+ # Remove an IP from a domain authentication. #
127
+ # DELETE /whitelabel/domains/{id}/ips/{ip} #
128
+
129
+ id = "test_url_param"
130
+ ip = "test_url_param"
131
+ response = sg.client.whitelabel.domains._(id).ips._(ip).delete()
132
+ puts response.status_code
133
+ puts response.body
134
+ puts response.headers
135
+
136
+ ##################################################
137
+ # Validate a domain authentication. #
138
+ # POST /whitelabel/domains/{id}/validate #
139
+
140
+ id = "test_url_param"
141
+ response = sg.client.whitelabel.domains._(id).validate.post()
142
+ puts response.status_code
143
+ puts response.body
144
+ puts response.headers
145
+
146
+ ##################################################
147
+ # Create a reverse DNS record #
148
+ # POST /whitelabel/ips #
149
+
150
+ data = JSON.parse('{
151
+ "domain": "example.com",
152
+ "ip": "192.168.1.1",
153
+ "subdomain": "email"
154
+ }')
155
+ response = sg.client.whitelabel.ips.post(request_body: data)
156
+ puts response.status_code
157
+ puts response.body
158
+ puts response.headers
159
+
160
+ ##################################################
161
+ # Retrieve a reverse DNS record #
162
+ # GET /whitelabel/ips #
163
+
164
+ params = JSON.parse('{"ip": "test_string", "limit": 1, "offset": 1}')
165
+ response = sg.client.whitelabel.ips.get(query_params: params)
166
+ puts response.status_code
167
+ puts response.body
168
+ puts response.headers
169
+
170
+ ##################################################
171
+ # Retrieve a reverse DNS record #
172
+ # GET /whitelabel/ips/{id} #
173
+
174
+ id = "test_url_param"
175
+ response = sg.client.whitelabel.ips._(id).get()
176
+ puts response.status_code
177
+ puts response.body
178
+ puts response.headers
179
+
180
+ ##################################################
181
+ # Delete a reverse DNS record #
182
+ # DELETE /whitelabel/ips/{id} #
183
+
184
+ id = "test_url_param"
185
+ response = sg.client.whitelabel.ips._(id).delete()
186
+ puts response.status_code
187
+ puts response.body
188
+ puts response.headers
189
+
190
+ ##################################################
191
+ # Validate a reverse DNS record #
192
+ # POST /whitelabel/ips/{id}/validate #
193
+
194
+ id = "test_url_param"
195
+ response = sg.client.whitelabel.ips._(id).validate.post()
196
+ puts response.status_code
197
+ puts response.body
198
+ puts response.headers
199
+
200
+ ##################################################
201
+ # Create a Branded Link #
202
+ # POST /whitelabel/links #
203
+
204
+ data = JSON.parse('{
205
+ "default": true,
206
+ "domain": "example.com",
207
+ "subdomain": "mail"
208
+ }')
209
+ params = JSON.parse('{"limit": 1, "offset": 1}')
210
+ response = sg.client.whitelabel.links.post(request_body: data, query_params: params)
211
+ puts response.status_code
212
+ puts response.body
213
+ puts response.headers
214
+
215
+ ##################################################
216
+ # Retrieve all link brandings #
217
+ # GET /whitelabel/links #
218
+
219
+ params = JSON.parse('{"limit": 1}')
220
+ response = sg.client.whitelabel.links.get(query_params: params)
221
+ puts response.status_code
222
+ puts response.body
223
+ puts response.headers
224
+
225
+ ##################################################
226
+ # Retrieve a Default Link Branding #
227
+ # GET /whitelabel/links/default #
228
+
229
+ params = JSON.parse('{"domain": "test_string"}')
230
+ response = sg.client.whitelabel.links.default.get(query_params: params)
231
+ puts response.status_code
232
+ puts response.body
233
+ puts response.headers
234
+
235
+ ##################################################
236
+ # Retrieve Associated Link Branding #
237
+ # GET /whitelabel/links/subuser #
238
+
239
+ params = JSON.parse('{"username": "test_string"}')
240
+ response = sg.client.whitelabel.links.subuser.get(query_params: params)
241
+ puts response.status_code
242
+ puts response.body
243
+ puts response.headers
244
+
245
+ ##################################################
246
+ # Disassociate a Link Branding #
247
+ # DELETE /whitelabel/links/subuser #
248
+
249
+ params = JSON.parse('{"username": "test_string"}')
250
+ response = sg.client.whitelabel.links.subuser.delete(query_params: params)
251
+ puts response.status_code
252
+ puts response.body
253
+ puts response.headers
254
+
255
+ ##################################################
256
+ # Update a Link Branding #
257
+ # PATCH /whitelabel/links/{id} #
258
+
259
+ data = JSON.parse('{
260
+ "default": true
261
+ }')
262
+ id = "test_url_param"
263
+ response = sg.client.whitelabel.links._(id).patch(request_body: data)
264
+ puts response.status_code
265
+ puts response.body
266
+ puts response.headers
267
+
268
+ ##################################################
269
+ # Retrieve a Link Branding #
270
+ # GET /whitelabel/links/{id} #
271
+
272
+ id = "test_url_param"
273
+ response = sg.client.whitelabel.links._(id).get()
274
+ puts response.status_code
275
+ puts response.body
276
+ puts response.headers
277
+
278
+ ##################################################
279
+ # Delete a Link Branding #
280
+ # DELETE /whitelabel/links/{id} #
281
+
282
+ id = "test_url_param"
283
+ response = sg.client.whitelabel.links._(id).delete()
284
+ puts response.status_code
285
+ puts response.body
286
+ puts response.headers
287
+
288
+ ##################################################
289
+ # Validate a Link Branding #
290
+ # POST /whitelabel/links/{id}/validate #
291
+
292
+ id = "test_url_param"
293
+ response = sg.client.whitelabel.links._(id).validate.post()
294
+ puts response.status_code
295
+ puts response.body
296
+ puts response.headers
297
+
298
+ ##################################################
299
+ # Associate a Link Branding #
300
+ # POST /whitelabel/links/{link_id}/subuser #
301
+
302
+ data = JSON.parse('{
303
+ "username": "jane@example.com"
304
+ }')
305
+ link_id = "test_url_param"
306
+ response = sg.client.whitelabel.links._(link_id).subuser.post(request_body: data)
307
+ puts response.status_code
308
+ puts response.body
309
+ puts response.headers
310
+
@@ -0,0 +1,98 @@
1
+ require 'sendgrid-ruby'
2
+
3
+
4
+ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
+
6
+
7
+ ##################################################
8
+ # Create a Sender Identity #
9
+ # POST /senders #
10
+
11
+ data = JSON.parse('{
12
+ "address": "123 Elm St.",
13
+ "address_2": "Apt. 456",
14
+ "city": "Denver",
15
+ "country": "United States",
16
+ "from": {
17
+ "email": "from@example.com",
18
+ "name": "Example INC"
19
+ },
20
+ "nickname": "My Sender ID",
21
+ "reply_to": {
22
+ "email": "replyto@example.com",
23
+ "name": "Example INC"
24
+ },
25
+ "state": "Colorado",
26
+ "zip": "80202"
27
+ }')
28
+ response = sg.client.senders.post(request_body: data)
29
+ puts response.status_code
30
+ puts response.body
31
+ puts response.headers
32
+
33
+ ##################################################
34
+ # Get all Sender Identities #
35
+ # GET /senders #
36
+
37
+ response = sg.client.senders.get()
38
+ puts response.status_code
39
+ puts response.body
40
+ puts response.headers
41
+
42
+ ##################################################
43
+ # Update a Sender Identity #
44
+ # PATCH /senders/{sender_id} #
45
+
46
+ data = JSON.parse('{
47
+ "address": "123 Elm St.",
48
+ "address_2": "Apt. 456",
49
+ "city": "Denver",
50
+ "country": "United States",
51
+ "from": {
52
+ "email": "from@example.com",
53
+ "name": "Example INC"
54
+ },
55
+ "nickname": "My Sender ID",
56
+ "reply_to": {
57
+ "email": "replyto@example.com",
58
+ "name": "Example INC"
59
+ },
60
+ "state": "Colorado",
61
+ "zip": "80202"
62
+ }')
63
+ sender_id = "test_url_param"
64
+ response = sg.client.senders._(sender_id).patch(request_body: data)
65
+ puts response.status_code
66
+ puts response.body
67
+ puts response.headers
68
+
69
+ ##################################################
70
+ # View a Sender Identity #
71
+ # GET /senders/{sender_id} #
72
+
73
+ sender_id = "test_url_param"
74
+ response = sg.client.senders._(sender_id).get()
75
+ puts response.status_code
76
+ puts response.body
77
+ puts response.headers
78
+
79
+ ##################################################
80
+ # Delete a Sender Identity #
81
+ # DELETE /senders/{sender_id} #
82
+
83
+ sender_id = "test_url_param"
84
+ response = sg.client.senders._(sender_id).delete()
85
+ puts response.status_code
86
+ puts response.body
87
+ puts response.headers
88
+
89
+ ##################################################
90
+ # Resend Sender Identity Verification #
91
+ # POST /senders/{sender_id}/resend_verification #
92
+
93
+ sender_id = "test_url_param"
94
+ response = sg.client.senders._(sender_id).resend_verification.post()
95
+ puts response.status_code
96
+ puts response.body
97
+ puts response.headers
98
+
@@ -0,0 +1,16 @@
1
+ require 'sendgrid-ruby'
2
+
3
+
4
+ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
+
6
+
7
+ ##################################################
8
+ # Retrieve global email statistics #
9
+ # GET /stats #
10
+
11
+ params = JSON.parse('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}')
12
+ response = sg.client.stats.get(query_params: params)
13
+ puts response.status_code
14
+ puts response.body
15
+ puts response.headers
16
+
@@ -0,0 +1,169 @@
1
+ require 'sendgrid-ruby'
2
+
3
+
4
+ sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
5
+
6
+
7
+ ##################################################
8
+ # Create Subuser #
9
+ # POST /subusers #
10
+
11
+ data = JSON.parse('{
12
+ "email": "John@example.com",
13
+ "ips": [
14
+ "1.1.1.1",
15
+ "2.2.2.2"
16
+ ],
17
+ "password": "johns_password",
18
+ "username": "John@example.com"
19
+ }')
20
+ response = sg.client.subusers.post(request_body: data)
21
+ puts response.status_code
22
+ puts response.body
23
+ puts response.headers
24
+
25
+ ##################################################
26
+ # List all Subusers #
27
+ # GET /subusers #
28
+
29
+ params = JSON.parse('{"username": "test_string", "limit": 1, "offset": 1}')
30
+ response = sg.client.subusers.get(query_params: params)
31
+ puts response.status_code
32
+ puts response.body
33
+ puts response.headers
34
+
35
+ ##################################################
36
+ # Retrieve Subuser Reputations #
37
+ # GET /subusers/reputations #
38
+
39
+ params = JSON.parse('{"usernames": "test_string"}')
40
+ response = sg.client.subusers.reputations.get(query_params: params)
41
+ puts response.status_code
42
+ puts response.body
43
+ puts response.headers
44
+
45
+ ##################################################
46
+ # Retrieve email statistics for your subusers. #
47
+ # GET /subusers/stats #
48
+
49
+ params = JSON.parse('{"end_date": "2016-04-01", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01", "subusers": "test_string"}')
50
+ response = sg.client.subusers.stats.get(query_params: params)
51
+ puts response.status_code
52
+ puts response.body
53
+ puts response.headers
54
+
55
+ ##################################################
56
+ # Retrieve monthly stats for all subusers #
57
+ # GET /subusers/stats/monthly #
58
+
59
+ params = JSON.parse('{"subuser": "test_string", "limit": 1, "sort_by_metric": "test_string", "offset": 1, "date": "test_string", "sort_by_direction": "asc"}')
60
+ response = sg.client.subusers.stats.monthly.get(query_params: params)
61
+ puts response.status_code
62
+ puts response.body
63
+ puts response.headers
64
+
65
+ ##################################################
66
+ # Retrieve the totals for each email statistic metric for all subusers. #
67
+ # GET /subusers/stats/sums #
68
+
69
+ 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"}')
70
+ response = sg.client.subusers.stats.sums.get(query_params: params)
71
+ puts response.status_code
72
+ puts response.body
73
+ puts response.headers
74
+
75
+ ##################################################
76
+ # Enable/disable a subuser #
77
+ # PATCH /subusers/{subuser_name} #
78
+
79
+ data = JSON.parse('{
80
+ "disabled": false
81
+ }')
82
+ subuser_name = "test_url_param"
83
+ response = sg.client.subusers._(subuser_name).patch(request_body: data)
84
+ puts response.status_code
85
+ puts response.body
86
+ puts response.headers
87
+
88
+ ##################################################
89
+ # Delete a subuser #
90
+ # DELETE /subusers/{subuser_name} #
91
+
92
+ subuser_name = "test_url_param"
93
+ response = sg.client.subusers._(subuser_name).delete()
94
+ puts response.status_code
95
+ puts response.body
96
+ puts response.headers
97
+
98
+ ##################################################
99
+ # Update IPs assigned to a subuser #
100
+ # PUT /subusers/{subuser_name}/ips #
101
+
102
+ data = JSON.parse('[
103
+ "127.0.0.1"
104
+ ]')
105
+ subuser_name = "test_url_param"
106
+ response = sg.client.subusers._(subuser_name).ips.put(request_body: data)
107
+ puts response.status_code
108
+ puts response.body
109
+ puts response.headers
110
+
111
+ ##################################################
112
+ # Update Monitor Settings for a subuser #
113
+ # PUT /subusers/{subuser_name}/monitor #
114
+
115
+ data = JSON.parse('{
116
+ "email": "example@example.com",
117
+ "frequency": 500
118
+ }')
119
+ subuser_name = "test_url_param"
120
+ response = sg.client.subusers._(subuser_name).monitor.put(request_body: data)
121
+ puts response.status_code
122
+ puts response.body
123
+ puts response.headers
124
+
125
+ ##################################################
126
+ # Create monitor settings #
127
+ # POST /subusers/{subuser_name}/monitor #
128
+
129
+ data = JSON.parse('{
130
+ "email": "example@example.com",
131
+ "frequency": 50000
132
+ }')
133
+ subuser_name = "test_url_param"
134
+ response = sg.client.subusers._(subuser_name).monitor.post(request_body: data)
135
+ puts response.status_code
136
+ puts response.body
137
+ puts response.headers
138
+
139
+ ##################################################
140
+ # Retrieve monitor settings for a subuser #
141
+ # GET /subusers/{subuser_name}/monitor #
142
+
143
+ subuser_name = "test_url_param"
144
+ response = sg.client.subusers._(subuser_name).monitor.get()
145
+ puts response.status_code
146
+ puts response.body
147
+ puts response.headers
148
+
149
+ ##################################################
150
+ # Delete monitor settings #
151
+ # DELETE /subusers/{subuser_name}/monitor #
152
+
153
+ subuser_name = "test_url_param"
154
+ response = sg.client.subusers._(subuser_name).monitor.delete()
155
+ puts response.status_code
156
+ puts response.body
157
+ puts response.headers
158
+
159
+ ##################################################
160
+ # Retrieve the monthly email statistics for a single subuser #
161
+ # GET /subusers/{subuser_name}/stats/monthly #
162
+
163
+ params = JSON.parse('{"date": "test_string", "sort_by_direction": "asc", "limit": 1, "sort_by_metric": "test_string", "offset": 1}')
164
+ subuser_name = "test_url_param"
165
+ response = sg.client.subusers._(subuser_name).stats.monthly.get(query_params: params)
166
+ puts response.status_code
167
+ puts response.body
168
+ puts response.headers
169
+