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