sendgrid-ruby 6.3.1 → 6.3.6
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -8,9 +8,9 @@ def is_valid_signature(request)
|
|
8
8
|
ec_public_key = event_webhook.convert_public_key_to_ecdsa(public_key)
|
9
9
|
|
10
10
|
event_webhook.verify_signature(
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
ec_public_key,
|
12
|
+
request.body.read,
|
13
|
+
request.env[SendGrid::EventWebhookHeader::SIGNATURE],
|
14
|
+
request.env[SendGrid::EventWebhookHeader::TIMESTAMP]
|
15
15
|
)
|
16
16
|
end
|
@@ -11,7 +11,7 @@ def hello_world
|
|
11
11
|
# puts JSON.pretty_generate(mail.to_json)
|
12
12
|
puts mail.to_json
|
13
13
|
|
14
|
-
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']
|
14
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
15
15
|
response = sg.client.mail._('send').post(request_body: mail.to_json)
|
16
16
|
puts response.status_code
|
17
17
|
puts response.body
|
@@ -36,7 +36,7 @@ def kitchen_sink
|
|
36
36
|
personalization.add_substitution(Substitution.new(key: '%city%', value: 'Denver'))
|
37
37
|
personalization.add_custom_arg(CustomArg.new(key: 'user_id', value: '343'))
|
38
38
|
personalization.add_custom_arg(CustomArg.new(key: 'type', value: 'marketing'))
|
39
|
-
personalization.send_at =
|
39
|
+
personalization.send_at = 1_443_636_843
|
40
40
|
mail.add_personalization(personalization)
|
41
41
|
|
42
42
|
personalization2 = Personalization.new
|
@@ -53,7 +53,7 @@ def kitchen_sink
|
|
53
53
|
personalization2.add_substitution(Substitution.new(key: '%city%', value: 'Denver'))
|
54
54
|
personalization2.add_custom_arg(CustomArg.new(key: 'user_id', value: '343'))
|
55
55
|
personalization2.add_custom_arg(CustomArg.new(key: 'type', value: 'marketing'))
|
56
|
-
personalization2.send_at =
|
56
|
+
personalization2.send_at = 1_443_636_843
|
57
57
|
mail.add_personalization(personalization2)
|
58
58
|
|
59
59
|
mail.add_content(Content.new(type: 'text/plain', value: 'some text here'))
|
@@ -89,12 +89,12 @@ def kitchen_sink
|
|
89
89
|
mail.add_custom_arg(CustomArg.new(key: 'campaign', value: 'welcome'))
|
90
90
|
mail.add_custom_arg(CustomArg.new(key: 'weekday', value: 'morning'))
|
91
91
|
|
92
|
-
mail.send_at =
|
92
|
+
mail.send_at = 1_443_636_842
|
93
93
|
|
94
94
|
# This must be a valid [batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html) to work
|
95
95
|
# mail.batch_id = 'sendgrid_batch_id'
|
96
96
|
|
97
|
-
mail.asm = ASM.new(group_id: 99, groups_to_display: [4,5,6,7,8])
|
97
|
+
mail.asm = ASM.new(group_id: 99, groups_to_display: [4, 5, 6, 7, 8])
|
98
98
|
|
99
99
|
mail.ip_pool_name = '23'
|
100
100
|
|
@@ -118,7 +118,7 @@ def kitchen_sink
|
|
118
118
|
# puts JSON.pretty_generate(mail.to_json)
|
119
119
|
puts mail.to_json
|
120
120
|
|
121
|
-
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']
|
121
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
122
122
|
response = sg.client.mail._('send').post(request_body: mail.to_json)
|
123
123
|
puts response.status_code
|
124
124
|
puts response.body
|
@@ -129,19 +129,25 @@ def dynamic_template_data_hello_world
|
|
129
129
|
mail = Mail.new
|
130
130
|
mail.template_id = '' # a non-legacy template id
|
131
131
|
mail.from = Email.new(email: 'test@example.com')
|
132
|
-
subject = 'Dynamic Template Data Hello World from the Twilio SendGrid Ruby Library'
|
133
|
-
mail.subject = subject
|
134
132
|
personalization = Personalization.new
|
135
133
|
personalization.add_to(Email.new(email: 'test1@example.com', name: 'Example User'))
|
136
|
-
personalization.add_dynamic_template_data(
|
137
|
-
|
138
|
-
{
|
134
|
+
personalization.add_dynamic_template_data(
|
135
|
+
'variable' => [
|
136
|
+
{ 'foo' => 'bar' }, { 'foo' => 'baz' }
|
139
137
|
]
|
140
|
-
|
138
|
+
)
|
141
139
|
mail.add_personalization(personalization)
|
140
|
+
|
141
|
+
# puts JSON.pretty_generate(mail.to_json)
|
142
|
+
puts mail.to_json
|
143
|
+
|
144
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
145
|
+
response = sg.client.mail._('send').post(request_body: mail.to_json)
|
146
|
+
puts response.status_code
|
147
|
+
puts response.body
|
148
|
+
puts response.headers
|
142
149
|
end
|
143
150
|
|
144
151
|
hello_world
|
145
152
|
kitchen_sink
|
146
153
|
dynamic_template_data_hello_world
|
147
|
-
|
@@ -11,7 +11,7 @@ puts response.body
|
|
11
11
|
puts response.headers
|
12
12
|
|
13
13
|
# Turn on bcc settings
|
14
|
-
response = settings.update_bcc(enabled: true, email:
|
14
|
+
response = settings.update_bcc(enabled: true, email: 'email@example.com')
|
15
15
|
puts response.status_code
|
16
16
|
puts response.body
|
17
17
|
puts response.headers
|
@@ -7,14 +7,14 @@ sg_client = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']).client
|
|
7
7
|
stats = SendGrid::EmailStats.new(sendgrid_client: sg_client)
|
8
8
|
|
9
9
|
# Fetch stats by day, between 2 dates
|
10
|
-
from = Date.new(2017, 10,
|
10
|
+
from = Date.new(2017, 10, 1)
|
11
11
|
to = Date.new(2017, 10, 12)
|
12
12
|
|
13
13
|
email_stats = stats.by_day(from, to)
|
14
14
|
|
15
15
|
email_stats.metrics
|
16
16
|
|
17
|
-
|
17
|
+
unless email_stats.error?
|
18
18
|
email_stats.metrics.each do |metric|
|
19
19
|
puts "Date - #{metric.date}"
|
20
20
|
puts "Number of Requests - #{metric.requests}"
|
@@ -25,13 +25,13 @@ if !email_stats.error?
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# Fetch stats by week, between 2 dates for a category
|
28
|
-
from = Date.new(2017, 10,
|
28
|
+
from = Date.new(2017, 10, 1)
|
29
29
|
to = Date.new(2017, 10, 12)
|
30
30
|
category = 'abcd'
|
31
31
|
|
32
32
|
email_stats = stats.by_week(from, to, category)
|
33
33
|
|
34
|
-
|
34
|
+
unless email_stats.error?
|
35
35
|
email_stats.metrics.each do |metric|
|
36
36
|
puts "Date - #{metric.date}"
|
37
37
|
puts "Number of Requests - #{metric.requests}"
|
data/examples/ips/ips.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 all IP addresses #
|
9
7
|
# GET /ips #
|
@@ -18,7 +16,7 @@ puts response.headers
|
|
18
16
|
# Retrieve all assigned IPs #
|
19
17
|
# GET /ips/assigned #
|
20
18
|
|
21
|
-
response = sg.client.ips.assigned.get
|
19
|
+
response = sg.client.ips.assigned.get
|
22
20
|
puts response.status_code
|
23
21
|
puts response.body
|
24
22
|
puts response.headers
|
@@ -30,7 +28,7 @@ puts response.headers
|
|
30
28
|
params = {}
|
31
29
|
response = sg.client.ips.get(query_params: params)
|
32
30
|
all_ips = JSON.parse(response.body)
|
33
|
-
unassigned_ips = all_ips.select {|ip| ip.subusers.empty?}
|
31
|
+
unassigned_ips = all_ips.select { |ip| ip.subusers.empty? }
|
34
32
|
puts response.status_code
|
35
33
|
puts response.body
|
36
34
|
puts unassigned_ips
|
@@ -52,7 +50,7 @@ puts response.headers
|
|
52
50
|
# Retrieve all IP pools. #
|
53
51
|
# GET /ips/pools #
|
54
52
|
|
55
|
-
response = sg.client.ips.pools.get
|
53
|
+
response = sg.client.ips.pools.get
|
56
54
|
puts response.status_code
|
57
55
|
puts response.body
|
58
56
|
puts response.headers
|
@@ -64,7 +62,7 @@ puts response.headers
|
|
64
62
|
data = JSON.parse('{
|
65
63
|
"name": "new_pool_name"
|
66
64
|
}')
|
67
|
-
pool_name =
|
65
|
+
pool_name = 'test_url_param'
|
68
66
|
response = sg.client.ips.pools._(pool_name).put(request_body: data)
|
69
67
|
puts response.status_code
|
70
68
|
puts response.body
|
@@ -74,8 +72,8 @@ puts response.headers
|
|
74
72
|
# Retrieve all IPs in a specified pool. #
|
75
73
|
# GET /ips/pools/{pool_name} #
|
76
74
|
|
77
|
-
pool_name =
|
78
|
-
response = sg.client.ips.pools._(pool_name).get
|
75
|
+
pool_name = 'test_url_param'
|
76
|
+
response = sg.client.ips.pools._(pool_name).get
|
79
77
|
puts response.status_code
|
80
78
|
puts response.body
|
81
79
|
puts response.headers
|
@@ -84,8 +82,8 @@ puts response.headers
|
|
84
82
|
# Delete an IP pool. #
|
85
83
|
# DELETE /ips/pools/{pool_name} #
|
86
84
|
|
87
|
-
pool_name =
|
88
|
-
response = sg.client.ips.pools._(pool_name).delete
|
85
|
+
pool_name = 'test_url_param'
|
86
|
+
response = sg.client.ips.pools._(pool_name).delete
|
89
87
|
puts response.status_code
|
90
88
|
puts response.body
|
91
89
|
puts response.headers
|
@@ -97,7 +95,7 @@ puts response.headers
|
|
97
95
|
data = JSON.parse('{
|
98
96
|
"ip": "0.0.0.0"
|
99
97
|
}')
|
100
|
-
pool_name =
|
98
|
+
pool_name = 'test_url_param'
|
101
99
|
response = sg.client.ips.pools._(pool_name).ips.post(request_body: data)
|
102
100
|
puts response.status_code
|
103
101
|
puts response.body
|
@@ -107,9 +105,9 @@ puts response.headers
|
|
107
105
|
# Remove an IP address from a pool. #
|
108
106
|
# DELETE /ips/pools/{pool_name}/ips/{ip} #
|
109
107
|
|
110
|
-
pool_name =
|
111
|
-
ip =
|
112
|
-
response = sg.client.ips.pools._(pool_name).ips._(ip).delete
|
108
|
+
pool_name = 'test_url_param'
|
109
|
+
ip = 'test_url_param'
|
110
|
+
response = sg.client.ips.pools._(pool_name).ips._(ip).delete
|
113
111
|
puts response.status_code
|
114
112
|
puts response.body
|
115
113
|
puts response.headers
|
@@ -130,7 +128,7 @@ puts response.headers
|
|
130
128
|
# Retrieve all IPs currently in warmup #
|
131
129
|
# GET /ips/warmup #
|
132
130
|
|
133
|
-
response = sg.client.ips.warmup.get
|
131
|
+
response = sg.client.ips.warmup.get
|
134
132
|
puts response.status_code
|
135
133
|
puts response.body
|
136
134
|
puts response.headers
|
@@ -139,8 +137,8 @@ puts response.headers
|
|
139
137
|
# Retrieve warmup status for a specific IP address #
|
140
138
|
# GET /ips/warmup/{ip_address} #
|
141
139
|
|
142
|
-
ip_address =
|
143
|
-
response = sg.client.ips.warmup._(ip_address).get
|
140
|
+
ip_address = 'test_url_param'
|
141
|
+
response = sg.client.ips.warmup._(ip_address).get
|
144
142
|
puts response.status_code
|
145
143
|
puts response.body
|
146
144
|
puts response.headers
|
@@ -149,8 +147,8 @@ puts response.headers
|
|
149
147
|
# Remove an IP from warmup #
|
150
148
|
# DELETE /ips/warmup/{ip_address} #
|
151
149
|
|
152
|
-
ip_address =
|
153
|
-
response = sg.client.ips.warmup._(ip_address).delete
|
150
|
+
ip_address = 'test_url_param'
|
151
|
+
response = sg.client.ips.warmup._(ip_address).delete
|
154
152
|
puts response.status_code
|
155
153
|
puts response.body
|
156
154
|
puts response.headers
|
@@ -159,9 +157,8 @@ puts response.headers
|
|
159
157
|
# Retrieve all IP pools an IP address belongs to #
|
160
158
|
# GET /ips/{ip_address} #
|
161
159
|
|
162
|
-
ip_address =
|
163
|
-
response = sg.client.ips._(ip_address).get
|
160
|
+
ip_address = 'test_url_param'
|
161
|
+
response = sg.client.ips._(ip_address).get
|
164
162
|
puts response.status_code
|
165
163
|
puts response.body
|
166
164
|
puts response.headers
|
167
|
-
|
data/examples/mail/mail.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
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 batch ID #
|
9
7
|
# POST /mail/batch #
|
10
8
|
|
11
|
-
response = sg.client.mail.batch.post
|
9
|
+
response = sg.client.mail.batch.post
|
12
10
|
puts response.status_code
|
13
11
|
puts response.body
|
14
12
|
puts response.headers
|
@@ -17,8 +15,8 @@ puts response.headers
|
|
17
15
|
# Validate batch ID #
|
18
16
|
# GET /mail/batch/{batch_id} #
|
19
17
|
|
20
|
-
batch_id =
|
21
|
-
response = sg.client.mail.batch._(batch_id).get
|
18
|
+
batch_id = 'test_url_param'
|
19
|
+
response = sg.client.mail.batch._(batch_id).get
|
22
20
|
puts response.status_code
|
23
21
|
puts response.body
|
24
22
|
puts response.headers
|
@@ -26,148 +24,147 @@ puts response.headers
|
|
26
24
|
##################################################
|
27
25
|
# v3 Mail Send #
|
28
26
|
# POST /mail/send #
|
29
|
-
# This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-ruby/blob/
|
27
|
+
# This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-ruby/blob/HEAD/lib/sendgrid/helpers/mail/README.md).
|
30
28
|
|
31
29
|
data = JSON.parse('{
|
32
30
|
"asm": {
|
33
|
-
"group_id": 1,
|
31
|
+
"group_id": 1,
|
34
32
|
"groups_to_display": [
|
35
|
-
1,
|
36
|
-
2,
|
33
|
+
1,
|
34
|
+
2,
|
37
35
|
3
|
38
36
|
]
|
39
|
-
},
|
37
|
+
},
|
40
38
|
"attachments": [
|
41
39
|
{
|
42
|
-
"content": "[BASE64 encoded content block here]",
|
43
|
-
"content_id": "ii_139db99fdb5c3704",
|
44
|
-
"disposition": "inline",
|
45
|
-
"filename": "file1.jpg",
|
46
|
-
"name": "file1",
|
40
|
+
"content": "[BASE64 encoded content block here]",
|
41
|
+
"content_id": "ii_139db99fdb5c3704",
|
42
|
+
"disposition": "inline",
|
43
|
+
"filename": "file1.jpg",
|
44
|
+
"name": "file1",
|
47
45
|
"type": "jpg"
|
48
46
|
}
|
49
|
-
],
|
50
|
-
"batch_id": "[YOUR BATCH ID GOES HERE]",
|
47
|
+
],
|
48
|
+
"batch_id": "[YOUR BATCH ID GOES HERE]",
|
51
49
|
"categories": [
|
52
|
-
"category1",
|
50
|
+
"category1",
|
53
51
|
"category2"
|
54
|
-
],
|
52
|
+
],
|
55
53
|
"content": [
|
56
54
|
{
|
57
|
-
"type": "text/html",
|
55
|
+
"type": "text/html",
|
58
56
|
"value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>"
|
59
57
|
}
|
60
|
-
],
|
58
|
+
],
|
61
59
|
"custom_args": {
|
62
|
-
"New Argument 1": "New Value 1",
|
63
|
-
"activationAttempt": "1",
|
60
|
+
"New Argument 1": "New Value 1",
|
61
|
+
"activationAttempt": "1",
|
64
62
|
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
|
65
|
-
},
|
63
|
+
},
|
66
64
|
"from": {
|
67
|
-
"email": "sam.smith@example.com",
|
65
|
+
"email": "sam.smith@example.com",
|
68
66
|
"name": "Sam Smith"
|
69
|
-
},
|
70
|
-
"headers": {},
|
71
|
-
"ip_pool_name": "[YOUR POOL NAME GOES HERE]",
|
67
|
+
},
|
68
|
+
"headers": {},
|
69
|
+
"ip_pool_name": "[YOUR POOL NAME GOES HERE]",
|
72
70
|
"mail_settings": {
|
73
71
|
"bcc": {
|
74
|
-
"email": "ben.doe@example.com",
|
72
|
+
"email": "ben.doe@example.com",
|
75
73
|
"enable": true
|
76
|
-
},
|
74
|
+
},
|
77
75
|
"bypass_list_management": {
|
78
76
|
"enable": true
|
79
|
-
},
|
77
|
+
},
|
80
78
|
"footer": {
|
81
|
-
"enable": true,
|
82
|
-
"html": "<p>Thanks</br>The Twilio SendGrid Team</p>",
|
79
|
+
"enable": true,
|
80
|
+
"html": "<p>Thanks</br>The Twilio SendGrid Team</p>",
|
83
81
|
"text": "Thanks,/n The Twilio SendGrid Team"
|
84
|
-
},
|
82
|
+
},
|
85
83
|
"sandbox_mode": {
|
86
84
|
"enable": false
|
87
|
-
},
|
85
|
+
},
|
88
86
|
"spam_check": {
|
89
|
-
"enable": true,
|
90
|
-
"post_to_url": "http://example.com/compliance",
|
87
|
+
"enable": true,
|
88
|
+
"post_to_url": "http://example.com/compliance",
|
91
89
|
"threshold": 3
|
92
90
|
}
|
93
|
-
},
|
91
|
+
},
|
94
92
|
"personalizations": [
|
95
93
|
{
|
96
94
|
"bcc": [
|
97
95
|
{
|
98
|
-
"email": "sam.doe@example.com",
|
96
|
+
"email": "sam.doe@example.com",
|
99
97
|
"name": "Sam Doe"
|
100
98
|
}
|
101
|
-
],
|
99
|
+
],
|
102
100
|
"cc": [
|
103
101
|
{
|
104
|
-
"email": "jane.doe@example.com",
|
102
|
+
"email": "jane.doe@example.com",
|
105
103
|
"name": "Jane Doe"
|
106
104
|
}
|
107
|
-
],
|
105
|
+
],
|
108
106
|
"custom_args": {
|
109
|
-
"New Argument 1": "New Value 1",
|
110
|
-
"activationAttempt": "1",
|
107
|
+
"New Argument 1": "New Value 1",
|
108
|
+
"activationAttempt": "1",
|
111
109
|
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
|
112
|
-
},
|
110
|
+
},
|
113
111
|
"headers": {
|
114
|
-
"X-Accept-Language": "en",
|
112
|
+
"X-Accept-Language": "en",
|
115
113
|
"X-Mailer": "MyApp"
|
116
|
-
},
|
117
|
-
"send_at": 1409348513,
|
118
|
-
"subject": "Hello, World!",
|
114
|
+
},
|
115
|
+
"send_at": 1409348513,
|
116
|
+
"subject": "Hello, World!",
|
119
117
|
"substitutions": {
|
120
|
-
"id": "substitutions",
|
118
|
+
"id": "substitutions",
|
121
119
|
"type": "object"
|
122
|
-
},
|
120
|
+
},
|
123
121
|
"to": [
|
124
122
|
{
|
125
|
-
"email": "john.doe@example.com",
|
123
|
+
"email": "john.doe@example.com",
|
126
124
|
"name": "John Doe"
|
127
125
|
}
|
128
126
|
]
|
129
127
|
}
|
130
|
-
],
|
128
|
+
],
|
131
129
|
"reply_to": {
|
132
|
-
"email": "sam.smith@example.com",
|
130
|
+
"email": "sam.smith@example.com",
|
133
131
|
"name": "Sam Smith"
|
134
|
-
},
|
132
|
+
},
|
135
133
|
"sections": {
|
136
134
|
"section": {
|
137
|
-
":sectionName1": "section 1 text",
|
135
|
+
":sectionName1": "section 1 text",
|
138
136
|
":sectionName2": "section 2 text"
|
139
137
|
}
|
140
|
-
},
|
141
|
-
"send_at": 1409348513,
|
142
|
-
"subject": "Hello, World!",
|
143
|
-
"template_id": "[YOUR TEMPLATE ID GOES HERE]",
|
138
|
+
},
|
139
|
+
"send_at": 1409348513,
|
140
|
+
"subject": "Hello, World!",
|
141
|
+
"template_id": "[YOUR TEMPLATE ID GOES HERE]",
|
144
142
|
"tracking_settings": {
|
145
143
|
"click_tracking": {
|
146
|
-
"enable": true,
|
144
|
+
"enable": true,
|
147
145
|
"enable_text": true
|
148
|
-
},
|
146
|
+
},
|
149
147
|
"ganalytics": {
|
150
|
-
"enable": true,
|
151
|
-
"utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
|
152
|
-
"utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
|
153
|
-
"utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
|
154
|
-
"utm_name": "[NAME OF YOUR CAMPAIGN]",
|
148
|
+
"enable": true,
|
149
|
+
"utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
|
150
|
+
"utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
|
151
|
+
"utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
|
152
|
+
"utm_name": "[NAME OF YOUR CAMPAIGN]",
|
155
153
|
"utm_term": "[IDENTIFY PAID KEYWORDS HERE]"
|
156
|
-
},
|
154
|
+
},
|
157
155
|
"open_tracking": {
|
158
|
-
"enable": true,
|
156
|
+
"enable": true,
|
159
157
|
"substitution_tag": "%opentrack"
|
160
|
-
},
|
158
|
+
},
|
161
159
|
"subscription_tracking": {
|
162
|
-
"enable": true,
|
163
|
-
"html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
|
164
|
-
"substitution_tag": "<%click here%>",
|
160
|
+
"enable": true,
|
161
|
+
"html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
|
162
|
+
"substitution_tag": "<%click here%>",
|
165
163
|
"text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>."
|
166
164
|
}
|
167
165
|
}
|
168
166
|
}')
|
169
|
-
response = sg.client.mail._(
|
167
|
+
response = sg.client.mail._('send').post(request_body: data)
|
170
168
|
puts response.status_code
|
171
169
|
puts response.body
|
172
170
|
puts response.headers
|
173
|
-
|