sendgrid-ruby 1.1.6 → 3.0.0
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/.github/ISSUE_TEMPLATE +17 -0
- data/.travis.yml +1 -6
- data/CHANGELOG.md +6 -0
- data/CONTRIBUTING.md +202 -0
- data/Gemfile +3 -5
- data/LICENSE.txt +1 -1
- data/README.md +74 -248
- data/Rakefile +8 -6
- data/USAGE.md +4645 -0
- data/examples/accesssettings/accesssettings.rb +89 -0
- data/examples/apikeys/apikeys.rb +95 -0
- data/examples/asm/asm.rb +169 -0
- data/examples/browsers/browsers.rb +29 -0
- data/examples/campaigns/campaigns.rb +166 -0
- data/examples/categories/categories.rb +49 -0
- data/examples/clients/clients.rb +40 -0
- data/examples/contactdb/contactdb.rb +398 -0
- data/examples/devices/devices.rb +29 -0
- data/examples/geo/geo.rb +29 -0
- data/examples/helpers/mail/example.rb +130 -0
- data/examples/ips/ips.rb +167 -0
- data/examples/mail/mail.rb +191 -0
- data/examples/mailboxproviders/mailboxproviders.rb +29 -0
- data/examples/mailsettings/mailsettings.rb +232 -0
- data/examples/partnersettings/partnersettings.rb +52 -0
- data/examples/scopes/scopes.rb +28 -0
- data/examples/stats/stats.rb +29 -0
- data/examples/subusers/subusers.rb +182 -0
- data/examples/suppression/suppression.rb +186 -0
- data/examples/templates/templates.rb +142 -0
- data/examples/trackingsettings/trackingsettings.rb +123 -0
- data/examples/user/user.rb +256 -0
- data/examples/whitelabel/whitelabel.rb +323 -0
- data/lib/helpers/mail/README.md +14 -0
- data/lib/helpers/mail/mail.rb +999 -0
- data/lib/sendgrid-ruby.rb +33 -8
- data/sendgrid-ruby.gemspec +5 -17
- data/test/helpers/mail/test_mail.rb +122 -0
- data/test/test_sendgrid-ruby.rb +2016 -0
- metadata +42 -190
- data/.env_sample +0 -3
- data/.rspec +0 -2
- data/.rubocop.yml +0 -30
- data/FETCH_HEAD +0 -0
- data/Guardfile +0 -10
- data/example.rb +0 -41
- data/lib/sendgrid/client.rb +0 -62
- data/lib/sendgrid/exceptions.rb +0 -7
- data/lib/sendgrid/mail.rb +0 -182
- data/lib/sendgrid/recipient.rb +0 -29
- data/lib/sendgrid/response.rb +0 -14
- data/lib/sendgrid/template.rb +0 -26
- data/lib/sendgrid/template_mailer.rb +0 -59
- data/lib/sendgrid/version.rb +0 -3
- data/spec/lib/sendgrid/client_spec.rb +0 -87
- data/spec/lib/sendgrid/mail_spec.rb +0 -151
- data/spec/lib/sendgrid/recipient_spec.rb +0 -91
- data/spec/lib/sendgrid/template_mailer_spec.rb +0 -86
- data/spec/lib/sendgrid/template_spec.rb +0 -61
- data/spec/lib/sendgrid_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -1
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Retrieve email statistics by device type. #
|
22
|
+
# GET /devices/stats #
|
23
|
+
|
24
|
+
params = JSON.parse('{"aggregated_by": "day", "limit": 1, "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": 1}')
|
25
|
+
response = sg.client.devices.stats.get(query_params: params)
|
26
|
+
puts response.status_code
|
27
|
+
puts response.body
|
28
|
+
puts response.headers
|
29
|
+
|
data/examples/geo/geo.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Retrieve email statistics by country and state/province. #
|
22
|
+
# GET /geo/stats #
|
23
|
+
|
24
|
+
params = JSON.parse('{"end_date": "2016-04-01", "country": "US", "aggregated_by": "day", "limit": 1, "offset": 1, "start_date": "2016-01-01"}')
|
25
|
+
response = sg.client.geo.stats.get(query_params: params)
|
26
|
+
puts response.status_code
|
27
|
+
puts response.body
|
28
|
+
puts response.headers
|
29
|
+
|
@@ -0,0 +1,130 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
include SendGrid
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
def hello_world
|
6
|
+
from = Email.new(email: 'test@example.com')
|
7
|
+
subject = 'Hello World from the SendGrid Ruby Library'
|
8
|
+
to = Email.new(email: 'test@example.com')
|
9
|
+
content = Content.new(type: 'text/plain', value: 'some text here')
|
10
|
+
mail = Mail.new(from, subject, to, content)
|
11
|
+
# puts JSON.pretty_generate(mail.to_json)
|
12
|
+
puts mail.to_json
|
13
|
+
|
14
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'], host: 'https://api.sendgrid.com')
|
15
|
+
response = sg.client.mail._('send').post(request_body: mail.to_json)
|
16
|
+
puts response.status_code
|
17
|
+
puts response.response_body
|
18
|
+
puts response.response_headers
|
19
|
+
end
|
20
|
+
|
21
|
+
def kitchen_sink
|
22
|
+
mail = Mail.new
|
23
|
+
mail.from = Email.new(email: 'test@example.com')
|
24
|
+
mail.subject = 'Hello World from the SendGrid Ruby Library'
|
25
|
+
personalization = Personalization.new
|
26
|
+
personalization.to = Email.new(email: 'test1@example.com', name: 'Example User')
|
27
|
+
personalization.to = Email.new(email: 'test2@example.com', name: 'Example User')
|
28
|
+
personalization.cc = Email.new(email: 'test3@example.com', name: 'Example User')
|
29
|
+
personalization.cc = Email.new(email: 'test4@example.com', name: 'Example User')
|
30
|
+
personalization.bcc = Email.new(email: 'test5@example.com', name: 'Example User')
|
31
|
+
personalization.bcc = Email.new(email: 'test6@example.com', name: 'Example User')
|
32
|
+
personalization.subject = 'Hello World from the Personalized SendGrid Python Library'
|
33
|
+
personalization.headers = Header.new(key: 'X-Test', value: 'True')
|
34
|
+
personalization.headers = Header.new(key: 'X-Mock', value: 'False')
|
35
|
+
personalization.substitutions = Substitution.new(key: '%name%', value: 'Example User')
|
36
|
+
personalization.substitutions = Substitution.new(key: '%city%', value: 'Denver')
|
37
|
+
personalization.custom_args = CustomArg.new(key: 'user_id', value: '343')
|
38
|
+
personalization.custom_args = CustomArg.new(key: 'type', value: 'marketing')
|
39
|
+
personalization.send_at = 1443636843
|
40
|
+
mail.personalizations = personalization
|
41
|
+
|
42
|
+
personalization2 = Personalization.new
|
43
|
+
personalization2.to = Email.new(email: 'test1@example.com', name: 'Example User')
|
44
|
+
personalization2.to = Email.new(email: 'test2@example.com', name: 'Example User')
|
45
|
+
personalization2.cc = Email.new(email: 'test3@example.com', name: 'Example User')
|
46
|
+
personalization2.cc = Email.new(email: 'test4@example.com', name: 'Example User')
|
47
|
+
personalization2.bcc = Email.new(email: 'test5@example.com', name: 'Example User')
|
48
|
+
personalization2.bcc = Email.new(email: 'test6@example.com', name: 'Example User')
|
49
|
+
personalization2.subject = 'Hello World from the Personalized SendGrid Python Library'
|
50
|
+
personalization2.headers = Header.new(key: 'X-Test', value: 'True')
|
51
|
+
personalization2.headers = Header.new(key: 'X-Mock', value: 'False')
|
52
|
+
personalization2.substitutions = Substitution.new(key: '%name%', value: 'Example User')
|
53
|
+
personalization2.substitutions = Substitution.new(key: '%city%', value: 'Denver')
|
54
|
+
personalization2.custom_args = CustomArg.new(key: 'user_id', value: '343')
|
55
|
+
personalization2.custom_args = CustomArg.new(key: 'type', value: 'marketing')
|
56
|
+
personalization2.send_at = 1443636843
|
57
|
+
mail.personalizations = personalization2
|
58
|
+
|
59
|
+
mail.contents = Content.new(type: 'text/plain', value: 'some text here')
|
60
|
+
mail.contents = Content.new(type: 'text/html', value: '<html><body>some text here</body></html>')
|
61
|
+
|
62
|
+
attachment = Attachment.new
|
63
|
+
attachment.content = 'TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12'
|
64
|
+
attachment.type = 'application/pdf'
|
65
|
+
attachment.filename = 'balance_001.pdf'
|
66
|
+
attachment.disposition = 'attachment'
|
67
|
+
attachment.content_id = 'Balance Sheet'
|
68
|
+
|
69
|
+
mail.attachments = attachment
|
70
|
+
|
71
|
+
attachment2 = Attachment.new
|
72
|
+
attachment2.content = 'BwdW'
|
73
|
+
attachment2.type = 'image/png'
|
74
|
+
attachment2.filename = 'banner.png'
|
75
|
+
attachment2.disposition = 'inline'
|
76
|
+
attachment2.content_id = 'Banner'
|
77
|
+
mail.attachments = attachment2
|
78
|
+
|
79
|
+
mail.template_id = '13b8f94f-bcae-4ec6-b752-70d6cb59f932'
|
80
|
+
|
81
|
+
mail.sections = Section.new(key: '%section1%', value: 'Substitution Text for Section 1')
|
82
|
+
mail.sections = Section.new(key: '%section2%', value: 'Substitution Text for Section 2')
|
83
|
+
|
84
|
+
mail.headers = Header.new(key: 'X-Test3', value: 'test3')
|
85
|
+
mail.headers = Header.new(key: 'X-Test4', value: 'test4')
|
86
|
+
|
87
|
+
mail.categories = Category.new(name: 'May')
|
88
|
+
mail.categories = Category.new(name: '2016')
|
89
|
+
|
90
|
+
mail.custom_args = CustomArg.new(key: 'campaign', value: 'welcome')
|
91
|
+
mail.custom_args = CustomArg.new(key: 'weekday', value: 'morning')
|
92
|
+
|
93
|
+
mail.send_at = 1443636842
|
94
|
+
|
95
|
+
# This must be a valid [batch ID](https://sendgrid.com/docs/API_Reference/SMTP_API/scheduling_parameters.html) to work
|
96
|
+
# mail.batch_id = 'sendgrid_batch_id'
|
97
|
+
|
98
|
+
mail.asm = ASM.new(group_id: 99, groups_to_display: [4,5,6,7,8])
|
99
|
+
|
100
|
+
mail.ip_pool_name = '23'
|
101
|
+
|
102
|
+
mail_settings = MailSettings.new
|
103
|
+
mail_settings.bcc = BccSettings.new(enable: true, email: 'test@example.com')
|
104
|
+
mail_settings.bypass_list_management = BypassListManagement.new(enable: true)
|
105
|
+
mail_settings.footer = Footer.new(enable: true, text: 'Footer Text', html: '<html><body>Footer Text</body></html>')
|
106
|
+
mail_settings.sandbox_mode = SandBoxMode.new(enable: true)
|
107
|
+
mail_settings.spam_check = SpamCheck.new(enable: true, threshold: 1, post_to_url: 'https://spamcatcher.sendgrid.com')
|
108
|
+
mail.mail_settings = mail_settings
|
109
|
+
|
110
|
+
tracking_settings = TrackingSettings.new
|
111
|
+
tracking_settings.click_tracking = ClickTracking.new(enable: false, enable_text: false)
|
112
|
+
tracking_settings.open_tracking = OpenTracking.new(enable: true, substitution_tag: 'Optional tag to replace with the open image in the body of the message')
|
113
|
+
tracking_settings.subscription_tracking = SubscriptionTracking.new(enable: true, text: 'text to insert into the text/plain portion of the message', html: 'html to insert into the text/html portion of the message', substitution_tag: 'Optional tag to replace with the open image in the body of the message')
|
114
|
+
tracking_settings.ganalytics = Ganalytics.new(enable: true, utm_source: 'some source', utm_medium: 'some medium', utm_term: 'some term', utm_content: 'some content', utm_campaign: 'some campaign')
|
115
|
+
mail.tracking_settings = tracking_settings
|
116
|
+
|
117
|
+
mail.reply_to = Email.new(email: 'test@example.com')
|
118
|
+
|
119
|
+
# puts JSON.pretty_generate(mail.to_json)
|
120
|
+
puts mail.to_json
|
121
|
+
|
122
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'], host: 'https://api.sendgrid.com')
|
123
|
+
response = sg.client.mail._('send').post(request_body: mail.to_json)
|
124
|
+
puts response.status_code
|
125
|
+
puts response.response_body
|
126
|
+
puts response.response_headers
|
127
|
+
end
|
128
|
+
|
129
|
+
hello_world
|
130
|
+
kitchen_sink
|
data/examples/ips/ips.rb
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Retrieve all IP addresses #
|
22
|
+
# GET /ips #
|
23
|
+
|
24
|
+
params = JSON.parse('{"subuser": "test_string", "ip": "test_string", "limit": 1, "exclude_whitelabels": "true", "offset": 1}')
|
25
|
+
response = sg.client.ips.get(query_params: params)
|
26
|
+
puts response.status_code
|
27
|
+
puts response.body
|
28
|
+
puts response.headers
|
29
|
+
|
30
|
+
##################################################
|
31
|
+
# Retrieve all assigned IPs #
|
32
|
+
# GET /ips/assigned #
|
33
|
+
|
34
|
+
response = sg.client.ips.assigned.get()
|
35
|
+
puts response.status_code
|
36
|
+
puts response.body
|
37
|
+
puts response.headers
|
38
|
+
|
39
|
+
##################################################
|
40
|
+
# Create an IP pool. #
|
41
|
+
# POST /ips/pools #
|
42
|
+
|
43
|
+
data = JSON.parse('{
|
44
|
+
"name": "marketing"
|
45
|
+
}')
|
46
|
+
response = sg.client.ips.pools.post(request_body: data)
|
47
|
+
puts response.status_code
|
48
|
+
puts response.body
|
49
|
+
puts response.headers
|
50
|
+
|
51
|
+
##################################################
|
52
|
+
# Retrieve all IP pools. #
|
53
|
+
# GET /ips/pools #
|
54
|
+
|
55
|
+
response = sg.client.ips.pools.get()
|
56
|
+
puts response.status_code
|
57
|
+
puts response.body
|
58
|
+
puts response.headers
|
59
|
+
|
60
|
+
##################################################
|
61
|
+
# Update an IP pools name. #
|
62
|
+
# PUT /ips/pools/{pool_name} #
|
63
|
+
|
64
|
+
data = JSON.parse('{
|
65
|
+
"name": "new_pool_name"
|
66
|
+
}')
|
67
|
+
pool_name = "test_url_param"
|
68
|
+
response = sg.client.ips.pools._(pool_name).put(request_body: data)
|
69
|
+
puts response.status_code
|
70
|
+
puts response.body
|
71
|
+
puts response.headers
|
72
|
+
|
73
|
+
##################################################
|
74
|
+
# Retrieve all IPs in a specified pool. #
|
75
|
+
# GET /ips/pools/{pool_name} #
|
76
|
+
|
77
|
+
pool_name = "test_url_param"
|
78
|
+
response = sg.client.ips.pools._(pool_name).get()
|
79
|
+
puts response.status_code
|
80
|
+
puts response.body
|
81
|
+
puts response.headers
|
82
|
+
|
83
|
+
##################################################
|
84
|
+
# Delete an IP pool. #
|
85
|
+
# DELETE /ips/pools/{pool_name} #
|
86
|
+
|
87
|
+
pool_name = "test_url_param"
|
88
|
+
response = sg.client.ips.pools._(pool_name).delete()
|
89
|
+
puts response.status_code
|
90
|
+
puts response.body
|
91
|
+
puts response.headers
|
92
|
+
|
93
|
+
##################################################
|
94
|
+
# Add an IP address to a pool #
|
95
|
+
# POST /ips/pools/{pool_name}/ips #
|
96
|
+
|
97
|
+
data = JSON.parse('{
|
98
|
+
"ip": "0.0.0.0"
|
99
|
+
}')
|
100
|
+
pool_name = "test_url_param"
|
101
|
+
response = sg.client.ips.pools._(pool_name).ips.post(request_body: data)
|
102
|
+
puts response.status_code
|
103
|
+
puts response.body
|
104
|
+
puts response.headers
|
105
|
+
|
106
|
+
##################################################
|
107
|
+
# Remove an IP address from a pool. #
|
108
|
+
# DELETE /ips/pools/{pool_name}/ips/{ip} #
|
109
|
+
|
110
|
+
pool_name = "test_url_param"
|
111
|
+
ip = "test_url_param"
|
112
|
+
response = sg.client.ips.pools._(pool_name).ips._(ip).delete()
|
113
|
+
puts response.status_code
|
114
|
+
puts response.body
|
115
|
+
puts response.headers
|
116
|
+
|
117
|
+
##################################################
|
118
|
+
# Add an IP to warmup #
|
119
|
+
# POST /ips/warmup #
|
120
|
+
|
121
|
+
data = JSON.parse('{
|
122
|
+
"ip": "0.0.0.0"
|
123
|
+
}')
|
124
|
+
response = sg.client.ips.warmup.post(request_body: data)
|
125
|
+
puts response.status_code
|
126
|
+
puts response.body
|
127
|
+
puts response.headers
|
128
|
+
|
129
|
+
##################################################
|
130
|
+
# Retrieve all IPs currently in warmup #
|
131
|
+
# GET /ips/warmup #
|
132
|
+
|
133
|
+
response = sg.client.ips.warmup.get()
|
134
|
+
puts response.status_code
|
135
|
+
puts response.body
|
136
|
+
puts response.headers
|
137
|
+
|
138
|
+
##################################################
|
139
|
+
# Retrieve warmup status for a specific IP address #
|
140
|
+
# GET /ips/warmup/{ip_address} #
|
141
|
+
|
142
|
+
ip_address = "test_url_param"
|
143
|
+
response = sg.client.ips.warmup._(ip_address).get()
|
144
|
+
puts response.status_code
|
145
|
+
puts response.body
|
146
|
+
puts response.headers
|
147
|
+
|
148
|
+
##################################################
|
149
|
+
# Remove an IP from warmup #
|
150
|
+
# DELETE /ips/warmup/{ip_address} #
|
151
|
+
|
152
|
+
ip_address = "test_url_param"
|
153
|
+
response = sg.client.ips.warmup._(ip_address).delete()
|
154
|
+
puts response.status_code
|
155
|
+
puts response.body
|
156
|
+
puts response.headers
|
157
|
+
|
158
|
+
##################################################
|
159
|
+
# Retrieve all IP pools an IP address belongs to #
|
160
|
+
# GET /ips/{ip_address} #
|
161
|
+
|
162
|
+
ip_address = "test_url_param"
|
163
|
+
response = sg.client.ips._(ip_address).get()
|
164
|
+
puts response.status_code
|
165
|
+
puts response.body
|
166
|
+
puts response.headers
|
167
|
+
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'sendgrid-ruby'
|
2
|
+
|
3
|
+
|
4
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
5
|
+
|
6
|
+
|
7
|
+
import com.fasterxml.jackson.databind.JsonNode;
|
8
|
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
9
|
+
|
10
|
+
import com.sendgrid.Client;
|
11
|
+
import com.sendgrid.Method;
|
12
|
+
import com.sendgrid.Request;
|
13
|
+
import com.sendgrid.Response;
|
14
|
+
import com.sendgrid.SendGrid;
|
15
|
+
|
16
|
+
import java.io.IOException;
|
17
|
+
import java.util.HashMap;
|
18
|
+
import java.util.Map;
|
19
|
+
|
20
|
+
##################################################
|
21
|
+
# Create a batch ID #
|
22
|
+
# POST /mail/batch #
|
23
|
+
|
24
|
+
response = sg.client.mail.batch.post()
|
25
|
+
puts response.status_code
|
26
|
+
puts response.body
|
27
|
+
puts response.headers
|
28
|
+
|
29
|
+
##################################################
|
30
|
+
# Validate batch ID #
|
31
|
+
# GET /mail/batch/{batch_id} #
|
32
|
+
|
33
|
+
batch_id = "test_url_param"
|
34
|
+
response = sg.client.mail.batch._(batch_id).get()
|
35
|
+
puts response.status_code
|
36
|
+
puts response.body
|
37
|
+
puts response.headers
|
38
|
+
|
39
|
+
##################################################
|
40
|
+
# v3 Mail Send #
|
41
|
+
# POST /mail/send #
|
42
|
+
# This endpoint has a helper, check it out [here](https://github.com/sendgrid/sendgrid-ruby/blob/master/lib/helpers/mail/README.md).
|
43
|
+
|
44
|
+
data = JSON.parse('{
|
45
|
+
"asm": {
|
46
|
+
"group_id": 1,
|
47
|
+
"groups_to_display": [
|
48
|
+
1,
|
49
|
+
2,
|
50
|
+
3
|
51
|
+
]
|
52
|
+
},
|
53
|
+
"attachments": [
|
54
|
+
{
|
55
|
+
"content": "[BASE64 encoded content block here]",
|
56
|
+
"content_id": "ii_139db99fdb5c3704",
|
57
|
+
"disposition": "inline",
|
58
|
+
"filename": "file1.jpg",
|
59
|
+
"name": "file1",
|
60
|
+
"type": "jpg"
|
61
|
+
}
|
62
|
+
],
|
63
|
+
"batch_id": "[YOUR BATCH ID GOES HERE]",
|
64
|
+
"categories": [
|
65
|
+
"category1",
|
66
|
+
"category2"
|
67
|
+
],
|
68
|
+
"content": [
|
69
|
+
{
|
70
|
+
"type": "text/html",
|
71
|
+
"value": "<html><p>Hello, world!</p><img src=[CID GOES HERE]></img></html>"
|
72
|
+
}
|
73
|
+
],
|
74
|
+
"custom_args": {
|
75
|
+
"New Argument 1": "New Value 1",
|
76
|
+
"activationAttempt": "1",
|
77
|
+
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
|
78
|
+
},
|
79
|
+
"from": {
|
80
|
+
"email": "sam.smith@example.com",
|
81
|
+
"name": "Sam Smith"
|
82
|
+
},
|
83
|
+
"headers": {},
|
84
|
+
"ip_pool_name": "[YOUR POOL NAME GOES HERE]",
|
85
|
+
"mail_settings": {
|
86
|
+
"bcc": {
|
87
|
+
"email": "ben.doe@example.com",
|
88
|
+
"enable": true
|
89
|
+
},
|
90
|
+
"bypass_list_management": {
|
91
|
+
"enable": true
|
92
|
+
},
|
93
|
+
"footer": {
|
94
|
+
"enable": true,
|
95
|
+
"html": "<p>Thanks</br>The SendGrid Team</p>",
|
96
|
+
"text": "Thanks,/n The SendGrid Team"
|
97
|
+
},
|
98
|
+
"sandbox_mode": {
|
99
|
+
"enable": false
|
100
|
+
},
|
101
|
+
"spam_check": {
|
102
|
+
"enable": true,
|
103
|
+
"post_to_url": "http://example.com/compliance",
|
104
|
+
"threshold": 3
|
105
|
+
}
|
106
|
+
},
|
107
|
+
"personalizations": [
|
108
|
+
{
|
109
|
+
"bcc": [
|
110
|
+
{
|
111
|
+
"email": "sam.doe@example.com",
|
112
|
+
"name": "Sam Doe"
|
113
|
+
}
|
114
|
+
],
|
115
|
+
"cc": [
|
116
|
+
{
|
117
|
+
"email": "jane.doe@example.com",
|
118
|
+
"name": "Jane Doe"
|
119
|
+
}
|
120
|
+
],
|
121
|
+
"custom_args": {
|
122
|
+
"New Argument 1": "New Value 1",
|
123
|
+
"activationAttempt": "1",
|
124
|
+
"customerAccountNumber": "[CUSTOMER ACCOUNT NUMBER GOES HERE]"
|
125
|
+
},
|
126
|
+
"headers": {
|
127
|
+
"X-Accept-Language": "en",
|
128
|
+
"X-Mailer": "MyApp"
|
129
|
+
},
|
130
|
+
"send_at": 1409348513,
|
131
|
+
"subject": "Hello, World!",
|
132
|
+
"substitutions": {
|
133
|
+
"sub": {
|
134
|
+
"%name%": [
|
135
|
+
"John",
|
136
|
+
"Jane",
|
137
|
+
"Sam"
|
138
|
+
]
|
139
|
+
}
|
140
|
+
},
|
141
|
+
"to": [
|
142
|
+
{
|
143
|
+
"email": "john.doe@example.com",
|
144
|
+
"name": "John Doe"
|
145
|
+
}
|
146
|
+
]
|
147
|
+
}
|
148
|
+
],
|
149
|
+
"reply_to": {
|
150
|
+
"email": "sam.smith@example.com",
|
151
|
+
"name": "Sam Smith"
|
152
|
+
},
|
153
|
+
"sections": {
|
154
|
+
"section": {
|
155
|
+
":sectionName1": "section 1 text",
|
156
|
+
":sectionName2": "section 2 text"
|
157
|
+
}
|
158
|
+
},
|
159
|
+
"send_at": 1409348513,
|
160
|
+
"subject": "Hello, World!",
|
161
|
+
"template_id": "[YOUR TEMPLATE ID GOES HERE]",
|
162
|
+
"tracking_settings": {
|
163
|
+
"click_tracking": {
|
164
|
+
"enable": true,
|
165
|
+
"enable_text": true
|
166
|
+
},
|
167
|
+
"ganalytics": {
|
168
|
+
"enable": true,
|
169
|
+
"utm_campaign": "[NAME OF YOUR REFERRER SOURCE]",
|
170
|
+
"utm_content": "[USE THIS SPACE TO DIFFERENTIATE YOUR EMAIL FROM ADS]",
|
171
|
+
"utm_medium": "[NAME OF YOUR MARKETING MEDIUM e.g. email]",
|
172
|
+
"utm_name": "[NAME OF YOUR CAMPAIGN]",
|
173
|
+
"utm_term": "[IDENTIFY PAID KEYWORDS HERE]"
|
174
|
+
},
|
175
|
+
"open_tracking": {
|
176
|
+
"enable": true,
|
177
|
+
"substitution_tag": "%opentrack"
|
178
|
+
},
|
179
|
+
"subscription_tracking": {
|
180
|
+
"enable": true,
|
181
|
+
"html": "If you would like to unsubscribe and stop receiving these emails <% clickhere %>.",
|
182
|
+
"substitution_tag": "<%click here%>",
|
183
|
+
"text": "If you would like to unsubscribe and stop receiveing these emails <% click here %>."
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}')
|
187
|
+
response = sg.client.mail._("send").post(request_body: data)
|
188
|
+
puts response.status_code
|
189
|
+
puts response.body
|
190
|
+
puts response.headers
|
191
|
+
|