sendgrid-ruby 6.3.1 → 6.3.6
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/.codeclimate.yml +1 -1
- data/.rubocop.yml +8 -0
- data/.rubocop_todo.yml +109 -0
- data/.travis.yml +2 -3
- data/CHANGELOG.md +61 -9
- data/CONTRIBUTING.md +10 -20
- data/FIRST_TIMERS.md +79 -0
- data/ISSUE_TEMPLATE.md +5 -1
- data/Makefile +3 -2
- data/PULL_REQUEST_TEMPLATE.md +1 -1
- data/README.md +22 -27
- data/Rakefile +2 -3
- data/TROUBLESHOOTING.md +5 -5
- data/USAGE.md +145 -38
- data/examples/accesssettings/accesssettings.rb +9 -12
- data/examples/alerts/alerts.rb +8 -11
- data/examples/apikeys/apikeys.rb +12 -15
- data/examples/asm/asm.rb +27 -30
- data/examples/browsers/browsers.rb +0 -3
- data/examples/campaigns/campaigns.rb +29 -32
- data/examples/categories/categories.rb +0 -3
- data/examples/clients/clients.rb +1 -4
- data/examples/contactdb/contactdb.rb +63 -66
- data/examples/devices/devices.rb +0 -3
- data/examples/emailactivity/emailactivity.rb +52 -0
- data/examples/geo/geo.rb +0 -3
- data/examples/helpers/eventwebhook/example.rb +4 -4
- data/examples/helpers/mail/example.rb +19 -13
- data/examples/helpers/settings/example.rb +1 -1
- data/examples/helpers/stats/example.rb +4 -4
- data/examples/ips/ips.rb +19 -22
- data/examples/mail/mail.rb +72 -75
- data/examples/mailboxproviders/mailboxproviders.rb +0 -3
- data/examples/mailsettings/mailsettings.rb +21 -24
- data/examples/partnersettings/partnersettings.rb +3 -6
- data/examples/scopes/scopes.rb +7 -9
- data/examples/senderauthentication/senderauthentication.rb +41 -44
- data/examples/senders/senders.rb +28 -31
- data/examples/stats/stats.rb +0 -3
- data/examples/subusers/subusers.rb +17 -20
- data/examples/suppression/suppression.rb +15 -18
- data/examples/templates/templates.rb +29 -31
- data/examples/trackingsettings/trackingsettings.rb +14 -17
- data/examples/user/user.rb +41 -44
- data/lib/rack/sendgrid_webhook_verification.rb +5 -2
- data/lib/sendgrid/base_interface.rb +1 -1
- data/lib/sendgrid/helpers/eventwebhook/eventwebhook.rb +4 -6
- data/lib/sendgrid/helpers/inbound/README.md +5 -5
- data/lib/sendgrid/helpers/inbound/app.rb +1 -1
- data/lib/sendgrid/helpers/inbound/public/index.html +1 -1
- data/lib/sendgrid/helpers/inbound/send.rb +2 -2
- data/lib/sendgrid/helpers/ip_management/ip_management.rb +1 -1
- data/lib/sendgrid/helpers/mail/README.md +3 -3
- data/lib/sendgrid/helpers/mail/asm.rb +6 -18
- data/lib/sendgrid/helpers/mail/attachment.rb +12 -42
- data/lib/sendgrid/helpers/mail/bcc_settings.rb +6 -18
- data/lib/sendgrid/helpers/mail/bypass_list_management.rb +8 -18
- data/lib/sendgrid/helpers/mail/category.rb +2 -2
- data/lib/sendgrid/helpers/mail/click_tracking.rb +6 -18
- data/lib/sendgrid/helpers/mail/content.rb +4 -3
- data/lib/sendgrid/helpers/mail/custom_arg.rb +6 -10
- data/lib/sendgrid/helpers/mail/email.rb +5 -4
- data/lib/sendgrid/helpers/mail/footer.rb +7 -27
- data/lib/sendgrid/helpers/mail/ganalytics.rb +10 -54
- data/lib/sendgrid/helpers/mail/header.rb +6 -10
- data/lib/sendgrid/helpers/mail/mail.rb +30 -48
- data/lib/sendgrid/helpers/mail/mail_settings.rb +9 -25
- data/lib/sendgrid/helpers/mail/open_tracking.rb +6 -18
- data/lib/sendgrid/helpers/mail/personalization.rb +34 -27
- data/lib/sendgrid/helpers/mail/section.rb +6 -10
- data/lib/sendgrid/helpers/mail/spam_check.rb +7 -27
- data/lib/sendgrid/helpers/mail/subscription_tracking.rb +8 -36
- data/lib/sendgrid/helpers/mail/substitution.rb +6 -10
- data/lib/sendgrid/helpers/mail/tracking_settings.rb +7 -20
- data/lib/sendgrid/helpers/permissions/scope.rb +1 -1
- data/lib/sendgrid/helpers/settings/README.md +2 -2
- data/lib/sendgrid/helpers/settings/settings.rb +1 -1
- data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +3 -5
- data/lib/sendgrid/helpers/stats/metrics.rb +5 -5
- data/lib/sendgrid/sendgrid.rb +1 -1
- data/lib/sendgrid/twilio_email.rb +1 -1
- data/lib/sendgrid/version.rb +1 -1
- data/mail_helper_v3.md +12 -12
- data/sendgrid-ruby.gemspec +8 -8
- data/spec/fixtures/event_webhook.rb +17 -11
- data/spec/rack/sendgrid_webhook_verification_spec.rb +30 -4
- data/spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb +38 -36
- data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +1 -1
- data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +1 -1
- data/spec/sendgrid/helpers/settings/settings_spec.rb +2 -2
- data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +1 -1
- data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +1 -1
- data/spec/sendgrid/helpers/stats/email_stats_spec.rb +22 -23
- data/spec/sendgrid/helpers/stats/metrics_spec.rb +19 -20
- data/spec/sendgrid/helpers/stats/stats_response_spec.rb +22 -23
- data/spec/spec_helper.rb +3 -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 +4 -6
- data/test/sendgrid/helpers/mail/test_category.rb +0 -2
- data/test/sendgrid/helpers/mail/test_email.rb +9 -11
- data/test/sendgrid/helpers/mail/test_mail.rb +101 -102
- data/test/sendgrid/helpers/mail/test_personalizations.rb +106 -93
- data/test/sendgrid/permissions/test_scopes.rb +0 -2
- data/test/sendgrid/test_sendgrid-ruby.rb +1948 -1958
- data/twilio_sendgrid_logo.png +0 -0
- data/use-cases/README.md +16 -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/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 +53 -28
- data/USE_CASES.md +0 -405
- data/docker/Dockerfile +0 -12
- data/docker/README.md +0 -30
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
require 'sendgrid-ruby'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
|
5
4
|
|
|
6
|
-
|
|
7
5
|
##################################################
|
|
8
6
|
# Retrieve all categories #
|
|
9
7
|
# GET /categories #
|
|
@@ -33,4 +31,3 @@ response = sg.client.categories.stats.sums.get(query_params: params)
|
|
|
33
31
|
puts response.status_code
|
|
34
32
|
puts response.body
|
|
35
33
|
puts response.headers
|
|
36
|
-
|
data/examples/clients/clients.rb
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
require 'sendgrid-ruby'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
|
5
4
|
|
|
6
|
-
|
|
7
5
|
##################################################
|
|
8
6
|
# Retrieve email statistics by client type. #
|
|
9
7
|
# GET /clients/stats #
|
|
@@ -19,9 +17,8 @@ puts response.headers
|
|
|
19
17
|
# GET /clients/{client_type}/stats #
|
|
20
18
|
|
|
21
19
|
params = JSON.parse('{"aggregated_by": "day", "start_date": "2016-01-01", "end_date": "2016-04-01"}')
|
|
22
|
-
client_type =
|
|
20
|
+
client_type = 'test_url_param'
|
|
23
21
|
response = sg.client.clients._(client_type).stats.get(query_params: params)
|
|
24
22
|
puts response.status_code
|
|
25
23
|
puts response.body
|
|
26
24
|
puts response.headers
|
|
27
|
-
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
require 'sendgrid-ruby'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
|
5
4
|
|
|
6
|
-
|
|
7
5
|
##################################################
|
|
8
6
|
# Create a Custom Field #
|
|
9
7
|
# POST /contactdb/custom_fields #
|
|
10
8
|
|
|
11
9
|
data = JSON.parse('{
|
|
12
|
-
"name": "pet",
|
|
10
|
+
"name": "pet",
|
|
13
11
|
"type": "text"
|
|
14
12
|
}')
|
|
15
13
|
response = sg.client.contactdb.custom_fields.post(request_body: data)
|
|
@@ -21,7 +19,7 @@ puts response.headers
|
|
|
21
19
|
# Retrieve all custom fields #
|
|
22
20
|
# GET /contactdb/custom_fields #
|
|
23
21
|
|
|
24
|
-
response = sg.client.contactdb.custom_fields.get
|
|
22
|
+
response = sg.client.contactdb.custom_fields.get
|
|
25
23
|
puts response.status_code
|
|
26
24
|
puts response.body
|
|
27
25
|
puts response.headers
|
|
@@ -30,8 +28,8 @@ puts response.headers
|
|
|
30
28
|
# Retrieve a Custom Field #
|
|
31
29
|
# GET /contactdb/custom_fields/{custom_field_id} #
|
|
32
30
|
|
|
33
|
-
custom_field_id =
|
|
34
|
-
response = sg.client.contactdb.custom_fields._(custom_field_id).get
|
|
31
|
+
custom_field_id = 'test_url_param'
|
|
32
|
+
response = sg.client.contactdb.custom_fields._(custom_field_id).get
|
|
35
33
|
puts response.status_code
|
|
36
34
|
puts response.body
|
|
37
35
|
puts response.headers
|
|
@@ -40,8 +38,8 @@ puts response.headers
|
|
|
40
38
|
# Delete a Custom Field #
|
|
41
39
|
# DELETE /contactdb/custom_fields/{custom_field_id} #
|
|
42
40
|
|
|
43
|
-
custom_field_id =
|
|
44
|
-
response = sg.client.contactdb.custom_fields._(custom_field_id).delete
|
|
41
|
+
custom_field_id = 'test_url_param'
|
|
42
|
+
response = sg.client.contactdb.custom_fields._(custom_field_id).delete
|
|
45
43
|
puts response.status_code
|
|
46
44
|
puts response.body
|
|
47
45
|
puts response.headers
|
|
@@ -62,7 +60,7 @@ puts response.headers
|
|
|
62
60
|
# Retrieve all lists #
|
|
63
61
|
# GET /contactdb/lists #
|
|
64
62
|
|
|
65
|
-
response = sg.client.contactdb.lists.get
|
|
63
|
+
response = sg.client.contactdb.lists.get
|
|
66
64
|
puts response.status_code
|
|
67
65
|
puts response.body
|
|
68
66
|
puts response.headers
|
|
@@ -72,9 +70,9 @@ puts response.headers
|
|
|
72
70
|
# DELETE /contactdb/lists #
|
|
73
71
|
|
|
74
72
|
data = JSON.parse('[
|
|
75
|
-
1,
|
|
76
|
-
2,
|
|
77
|
-
3,
|
|
73
|
+
1,
|
|
74
|
+
2,
|
|
75
|
+
3,
|
|
78
76
|
4
|
|
79
77
|
]')
|
|
80
78
|
response = sg.client.contactdb.lists.delete(request_body: data)
|
|
@@ -90,7 +88,7 @@ data = JSON.parse('{
|
|
|
90
88
|
"name": "newlistname"
|
|
91
89
|
}')
|
|
92
90
|
params = JSON.parse('{"list_id": 1}')
|
|
93
|
-
list_id =
|
|
91
|
+
list_id = 'test_url_param'
|
|
94
92
|
response = sg.client.contactdb.lists._(list_id).patch(request_body: data, query_params: params)
|
|
95
93
|
puts response.status_code
|
|
96
94
|
puts response.body
|
|
@@ -101,7 +99,7 @@ puts response.headers
|
|
|
101
99
|
# GET /contactdb/lists/{list_id} #
|
|
102
100
|
|
|
103
101
|
params = JSON.parse('{"list_id": 1}')
|
|
104
|
-
list_id =
|
|
102
|
+
list_id = 'test_url_param'
|
|
105
103
|
response = sg.client.contactdb.lists._(list_id).get(query_params: params)
|
|
106
104
|
puts response.status_code
|
|
107
105
|
puts response.body
|
|
@@ -112,7 +110,7 @@ puts response.headers
|
|
|
112
110
|
# DELETE /contactdb/lists/{list_id} #
|
|
113
111
|
|
|
114
112
|
params = JSON.parse('{"delete_contacts": "true"}')
|
|
115
|
-
list_id =
|
|
113
|
+
list_id = 'test_url_param'
|
|
116
114
|
response = sg.client.contactdb.lists._(list_id).delete(query_params: params)
|
|
117
115
|
puts response.status_code
|
|
118
116
|
puts response.body
|
|
@@ -123,10 +121,10 @@ puts response.headers
|
|
|
123
121
|
# POST /contactdb/lists/{list_id}/recipients #
|
|
124
122
|
|
|
125
123
|
data = JSON.parse('[
|
|
126
|
-
"recipient_id1",
|
|
124
|
+
"recipient_id1",
|
|
127
125
|
"recipient_id2"
|
|
128
126
|
]')
|
|
129
|
-
list_id =
|
|
127
|
+
list_id = 'test_url_param'
|
|
130
128
|
response = sg.client.contactdb.lists._(list_id).recipients.post(request_body: data)
|
|
131
129
|
puts response.status_code
|
|
132
130
|
puts response.body
|
|
@@ -137,7 +135,7 @@ puts response.headers
|
|
|
137
135
|
# GET /contactdb/lists/{list_id}/recipients #
|
|
138
136
|
|
|
139
137
|
params = JSON.parse('{"page": 1, "page_size": 1, "list_id": 1}')
|
|
140
|
-
list_id =
|
|
138
|
+
list_id = 'test_url_param'
|
|
141
139
|
response = sg.client.contactdb.lists._(list_id).recipients.get(query_params: params)
|
|
142
140
|
puts response.status_code
|
|
143
141
|
puts response.body
|
|
@@ -147,9 +145,9 @@ puts response.headers
|
|
|
147
145
|
# Add a Single Recipient to a List #
|
|
148
146
|
# POST /contactdb/lists/{list_id}/recipients/{recipient_id} #
|
|
149
147
|
|
|
150
|
-
list_id =
|
|
151
|
-
recipient_id =
|
|
152
|
-
response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).post
|
|
148
|
+
list_id = 'test_url_param'
|
|
149
|
+
recipient_id = 'test_url_param'
|
|
150
|
+
response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).post
|
|
153
151
|
puts response.status_code
|
|
154
152
|
puts response.body
|
|
155
153
|
puts response.headers
|
|
@@ -159,8 +157,8 @@ puts response.headers
|
|
|
159
157
|
# DELETE /contactdb/lists/{list_id}/recipients/{recipient_id} #
|
|
160
158
|
|
|
161
159
|
params = JSON.parse('{"recipient_id": 1, "list_id": 1}')
|
|
162
|
-
list_id =
|
|
163
|
-
recipient_id =
|
|
160
|
+
list_id = 'test_url_param'
|
|
161
|
+
recipient_id = 'test_url_param'
|
|
164
162
|
response = sg.client.contactdb.lists._(list_id).recipients._(recipient_id).delete(query_params: params)
|
|
165
163
|
puts response.status_code
|
|
166
164
|
puts response.body
|
|
@@ -172,8 +170,8 @@ puts response.headers
|
|
|
172
170
|
|
|
173
171
|
data = JSON.parse('[
|
|
174
172
|
{
|
|
175
|
-
"email": "jones@example.com",
|
|
176
|
-
"first_name": "Guy",
|
|
173
|
+
"email": "jones@example.com",
|
|
174
|
+
"first_name": "Guy",
|
|
177
175
|
"last_name": "Jones"
|
|
178
176
|
}
|
|
179
177
|
]')
|
|
@@ -188,15 +186,15 @@ puts response.headers
|
|
|
188
186
|
|
|
189
187
|
data = JSON.parse('[
|
|
190
188
|
{
|
|
191
|
-
"age": 25,
|
|
192
|
-
"email": "example@example.com",
|
|
193
|
-
"first_name": "",
|
|
189
|
+
"age": 25,
|
|
190
|
+
"email": "example@example.com",
|
|
191
|
+
"first_name": "",
|
|
194
192
|
"last_name": "User"
|
|
195
|
-
},
|
|
193
|
+
},
|
|
196
194
|
{
|
|
197
|
-
"age": 25,
|
|
198
|
-
"email": "example2@example.com",
|
|
199
|
-
"first_name": "Example",
|
|
195
|
+
"age": 25,
|
|
196
|
+
"email": "example2@example.com",
|
|
197
|
+
"first_name": "Example",
|
|
200
198
|
"last_name": "User"
|
|
201
199
|
}
|
|
202
200
|
]')
|
|
@@ -220,7 +218,7 @@ puts response.headers
|
|
|
220
218
|
# DELETE /contactdb/recipients #
|
|
221
219
|
|
|
222
220
|
data = JSON.parse('[
|
|
223
|
-
"recipient_id1",
|
|
221
|
+
"recipient_id1",
|
|
224
222
|
"recipient_id2"
|
|
225
223
|
]')
|
|
226
224
|
response = sg.client.contactdb.recipients.delete(request_body: data)
|
|
@@ -232,7 +230,7 @@ puts response.headers
|
|
|
232
230
|
# Retrieve the count of billable recipients #
|
|
233
231
|
# GET /contactdb/recipients/billable_count #
|
|
234
232
|
|
|
235
|
-
response = sg.client.contactdb.recipients.billable_count.get
|
|
233
|
+
response = sg.client.contactdb.recipients.billable_count.get
|
|
236
234
|
puts response.status_code
|
|
237
235
|
puts response.body
|
|
238
236
|
puts response.headers
|
|
@@ -241,7 +239,7 @@ puts response.headers
|
|
|
241
239
|
# Retrieve a Count of Recipients #
|
|
242
240
|
# GET /contactdb/recipients/count #
|
|
243
241
|
|
|
244
|
-
response = sg.client.contactdb.recipients.count.get
|
|
242
|
+
response = sg.client.contactdb.recipients.count.get
|
|
245
243
|
puts response.status_code
|
|
246
244
|
puts response.body
|
|
247
245
|
puts response.headers
|
|
@@ -260,8 +258,8 @@ puts response.headers
|
|
|
260
258
|
# Retrieve a single recipient #
|
|
261
259
|
# GET /contactdb/recipients/{recipient_id} #
|
|
262
260
|
|
|
263
|
-
recipient_id =
|
|
264
|
-
response = sg.client.contactdb.recipients._(recipient_id).get
|
|
261
|
+
recipient_id = 'test_url_param'
|
|
262
|
+
response = sg.client.contactdb.recipients._(recipient_id).get
|
|
265
263
|
puts response.status_code
|
|
266
264
|
puts response.body
|
|
267
265
|
puts response.headers
|
|
@@ -270,8 +268,8 @@ puts response.headers
|
|
|
270
268
|
# Delete a Recipient #
|
|
271
269
|
# DELETE /contactdb/recipients/{recipient_id} #
|
|
272
270
|
|
|
273
|
-
recipient_id =
|
|
274
|
-
response = sg.client.contactdb.recipients._(recipient_id).delete
|
|
271
|
+
recipient_id = 'test_url_param'
|
|
272
|
+
response = sg.client.contactdb.recipients._(recipient_id).delete
|
|
275
273
|
puts response.status_code
|
|
276
274
|
puts response.body
|
|
277
275
|
puts response.headers
|
|
@@ -280,8 +278,8 @@ puts response.headers
|
|
|
280
278
|
# Retrieve the lists that a recipient is on #
|
|
281
279
|
# GET /contactdb/recipients/{recipient_id}/lists #
|
|
282
280
|
|
|
283
|
-
recipient_id =
|
|
284
|
-
response = sg.client.contactdb.recipients._(recipient_id).lists.get
|
|
281
|
+
recipient_id = 'test_url_param'
|
|
282
|
+
response = sg.client.contactdb.recipients._(recipient_id).lists.get
|
|
285
283
|
puts response.status_code
|
|
286
284
|
puts response.body
|
|
287
285
|
puts response.headers
|
|
@@ -290,7 +288,7 @@ puts response.headers
|
|
|
290
288
|
# Retrieve reserved fields #
|
|
291
289
|
# GET /contactdb/reserved_fields #
|
|
292
290
|
|
|
293
|
-
response = sg.client.contactdb.reserved_fields.get
|
|
291
|
+
response = sg.client.contactdb.reserved_fields.get
|
|
294
292
|
puts response.status_code
|
|
295
293
|
puts response.body
|
|
296
294
|
puts response.headers
|
|
@@ -302,25 +300,25 @@ puts response.headers
|
|
|
302
300
|
data = JSON.parse('{
|
|
303
301
|
"conditions": [
|
|
304
302
|
{
|
|
305
|
-
"and_or": "",
|
|
306
|
-
"field": "last_name",
|
|
307
|
-
"operator": "eq",
|
|
303
|
+
"and_or": "",
|
|
304
|
+
"field": "last_name",
|
|
305
|
+
"operator": "eq",
|
|
308
306
|
"value": "Miller"
|
|
309
|
-
},
|
|
307
|
+
},
|
|
310
308
|
{
|
|
311
|
-
"and_or": "and",
|
|
312
|
-
"field": "last_clicked",
|
|
313
|
-
"operator": "gt",
|
|
309
|
+
"and_or": "and",
|
|
310
|
+
"field": "last_clicked",
|
|
311
|
+
"operator": "gt",
|
|
314
312
|
"value": "01/02/2015"
|
|
315
|
-
},
|
|
313
|
+
},
|
|
316
314
|
{
|
|
317
|
-
"and_or": "or",
|
|
318
|
-
"field": "clicks.campaign_identifier",
|
|
319
|
-
"operator": "eq",
|
|
315
|
+
"and_or": "or",
|
|
316
|
+
"field": "clicks.campaign_identifier",
|
|
317
|
+
"operator": "eq",
|
|
320
318
|
"value": "513"
|
|
321
319
|
}
|
|
322
|
-
],
|
|
323
|
-
"list_id": 4,
|
|
320
|
+
],
|
|
321
|
+
"list_id": 4,
|
|
324
322
|
"name": "Last Name Miller"
|
|
325
323
|
}')
|
|
326
324
|
response = sg.client.contactdb.segments.post(request_body: data)
|
|
@@ -332,7 +330,7 @@ puts response.headers
|
|
|
332
330
|
# Retrieve all segments #
|
|
333
331
|
# GET /contactdb/segments #
|
|
334
332
|
|
|
335
|
-
response = sg.client.contactdb.segments.get
|
|
333
|
+
response = sg.client.contactdb.segments.get
|
|
336
334
|
puts response.status_code
|
|
337
335
|
puts response.body
|
|
338
336
|
puts response.headers
|
|
@@ -344,17 +342,17 @@ puts response.headers
|
|
|
344
342
|
data = JSON.parse('{
|
|
345
343
|
"conditions": [
|
|
346
344
|
{
|
|
347
|
-
"and_or": "",
|
|
348
|
-
"field": "last_name",
|
|
349
|
-
"operator": "eq",
|
|
345
|
+
"and_or": "",
|
|
346
|
+
"field": "last_name",
|
|
347
|
+
"operator": "eq",
|
|
350
348
|
"value": "Miller"
|
|
351
349
|
}
|
|
352
|
-
],
|
|
353
|
-
"list_id": 5,
|
|
350
|
+
],
|
|
351
|
+
"list_id": 5,
|
|
354
352
|
"name": "The Millers"
|
|
355
353
|
}')
|
|
356
354
|
params = JSON.parse('{"segment_id": "test_string"}')
|
|
357
|
-
segment_id =
|
|
355
|
+
segment_id = 'test_url_param'
|
|
358
356
|
response = sg.client.contactdb.segments._(segment_id).patch(request_body: data, query_params: params)
|
|
359
357
|
puts response.status_code
|
|
360
358
|
puts response.body
|
|
@@ -365,7 +363,7 @@ puts response.headers
|
|
|
365
363
|
# GET /contactdb/segments/{segment_id} #
|
|
366
364
|
|
|
367
365
|
params = JSON.parse('{"segment_id": 1}')
|
|
368
|
-
segment_id =
|
|
366
|
+
segment_id = 'test_url_param'
|
|
369
367
|
response = sg.client.contactdb.segments._(segment_id).get(query_params: params)
|
|
370
368
|
puts response.status_code
|
|
371
369
|
puts response.body
|
|
@@ -376,7 +374,7 @@ puts response.headers
|
|
|
376
374
|
# DELETE /contactdb/segments/{segment_id} #
|
|
377
375
|
|
|
378
376
|
params = JSON.parse('{"delete_contacts": "true"}')
|
|
379
|
-
segment_id =
|
|
377
|
+
segment_id = 'test_url_param'
|
|
380
378
|
response = sg.client.contactdb.segments._(segment_id).delete(query_params: params)
|
|
381
379
|
puts response.status_code
|
|
382
380
|
puts response.body
|
|
@@ -387,9 +385,8 @@ puts response.headers
|
|
|
387
385
|
# GET /contactdb/segments/{segment_id}/recipients #
|
|
388
386
|
|
|
389
387
|
params = JSON.parse('{"page": 1, "page_size": 1}')
|
|
390
|
-
segment_id =
|
|
388
|
+
segment_id = 'test_url_param'
|
|
391
389
|
response = sg.client.contactdb.segments._(segment_id).recipients.get(query_params: params)
|
|
392
390
|
puts response.status_code
|
|
393
391
|
puts response.body
|
|
394
392
|
puts response.headers
|
|
395
|
-
|
data/examples/devices/devices.rb
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
require 'sendgrid-ruby'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
|
5
4
|
|
|
6
|
-
|
|
7
5
|
##################################################
|
|
8
6
|
# Retrieve email statistics by device type. #
|
|
9
7
|
# GET /devices/stats #
|
|
@@ -13,4 +11,3 @@ response = sg.client.devices.stats.get(query_params: params)
|
|
|
13
11
|
puts response.status_code
|
|
14
12
|
puts response.body
|
|
15
13
|
puts response.headers
|
|
16
|
-
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require 'sendgrid-ruby'
|
|
2
|
+
|
|
3
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
|
4
|
+
|
|
5
|
+
##################################################
|
|
6
|
+
# Filter all messages #
|
|
7
|
+
# GET /messages #
|
|
8
|
+
|
|
9
|
+
require 'erb'
|
|
10
|
+
|
|
11
|
+
filter_key = 'to_email'
|
|
12
|
+
filter_operator = ERB::Util.url_encode('=')
|
|
13
|
+
filter_value = 'testing@sendgrid.net'
|
|
14
|
+
filter_value = ERB::Util.url_encode(format('"%s"', filter_value))
|
|
15
|
+
query_params = {}
|
|
16
|
+
query_params['query'] = format("%s%s%s", filter_key, filter_operator, filter_value)
|
|
17
|
+
query_params['limit'] = '1'
|
|
18
|
+
|
|
19
|
+
params = query_params
|
|
20
|
+
response = sg.client.messages.get(query_params: params)
|
|
21
|
+
puts response.status_code
|
|
22
|
+
puts response.body
|
|
23
|
+
puts response.headers
|
|
24
|
+
|
|
25
|
+
##################################################
|
|
26
|
+
# Filter messages by message ID #
|
|
27
|
+
# GET /messages/{msg_id} #
|
|
28
|
+
|
|
29
|
+
msg_id = "test_url_param"
|
|
30
|
+
response = sg.client.messages._(msg_id).get
|
|
31
|
+
puts response.status_code
|
|
32
|
+
puts response.body
|
|
33
|
+
puts response.headers
|
|
34
|
+
|
|
35
|
+
##################################################
|
|
36
|
+
# Request a CSV #
|
|
37
|
+
# POST /messages/download #
|
|
38
|
+
|
|
39
|
+
response = sg.client.messages.download.post
|
|
40
|
+
puts response.status_code
|
|
41
|
+
puts response.body
|
|
42
|
+
puts response.headers
|
|
43
|
+
|
|
44
|
+
##################################################
|
|
45
|
+
# Download CSV #
|
|
46
|
+
# GET /messages/download/{download_uuid} #
|
|
47
|
+
|
|
48
|
+
download_uuid = "test_url_param"
|
|
49
|
+
response = sg.client.messages.download._(download_uuid).get
|
|
50
|
+
puts response.status_code
|
|
51
|
+
puts response.body
|
|
52
|
+
puts response.headers
|
data/examples/geo/geo.rb
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
require 'sendgrid-ruby'
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
|
5
4
|
|
|
6
|
-
|
|
7
5
|
##################################################
|
|
8
6
|
# Retrieve email statistics by country and state/province. #
|
|
9
7
|
# GET /geo/stats #
|
|
@@ -13,4 +11,3 @@ response = sg.client.geo.stats.get(query_params: params)
|
|
|
13
11
|
puts response.status_code
|
|
14
12
|
puts response.body
|
|
15
13
|
puts response.headers
|
|
16
|
-
|