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,186 @@
|
|
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 blocks #
|
22
|
+
# GET /suppression/blocks #
|
23
|
+
|
24
|
+
params = JSON.parse('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}')
|
25
|
+
response = sg.client.suppression.blocks.get(query_params: params)
|
26
|
+
puts response.status_code
|
27
|
+
puts response.body
|
28
|
+
puts response.headers
|
29
|
+
|
30
|
+
##################################################
|
31
|
+
# Delete blocks #
|
32
|
+
# DELETE /suppression/blocks #
|
33
|
+
|
34
|
+
response = sg.client.suppression.blocks.delete(request_body: data)
|
35
|
+
puts response.status_code
|
36
|
+
puts response.body
|
37
|
+
puts response.headers
|
38
|
+
|
39
|
+
##################################################
|
40
|
+
# Retrieve a specific block #
|
41
|
+
# GET /suppression/blocks/{email} #
|
42
|
+
|
43
|
+
email = "test_url_param"
|
44
|
+
response = sg.client.suppression.blocks._(email).get()
|
45
|
+
puts response.status_code
|
46
|
+
puts response.body
|
47
|
+
puts response.headers
|
48
|
+
|
49
|
+
##################################################
|
50
|
+
# Delete a specific block #
|
51
|
+
# DELETE /suppression/blocks/{email} #
|
52
|
+
|
53
|
+
email = "test_url_param"
|
54
|
+
response = sg.client.suppression.blocks._(email).delete()
|
55
|
+
puts response.status_code
|
56
|
+
puts response.body
|
57
|
+
puts response.headers
|
58
|
+
|
59
|
+
##################################################
|
60
|
+
# Retrieve all bounces #
|
61
|
+
# GET /suppression/bounces #
|
62
|
+
|
63
|
+
params = JSON.parse('{"start_time": 0, "end_time": 0}')
|
64
|
+
response = sg.client.suppression.bounces.get(query_params: params)
|
65
|
+
puts response.status_code
|
66
|
+
puts response.body
|
67
|
+
puts response.headers
|
68
|
+
|
69
|
+
##################################################
|
70
|
+
# Delete bounces #
|
71
|
+
# DELETE /suppression/bounces #
|
72
|
+
|
73
|
+
response = sg.client.suppression.bounces.delete(request_body: data)
|
74
|
+
puts response.status_code
|
75
|
+
puts response.body
|
76
|
+
puts response.headers
|
77
|
+
|
78
|
+
##################################################
|
79
|
+
# Retrieve a Bounce #
|
80
|
+
# GET /suppression/bounces/{email} #
|
81
|
+
|
82
|
+
email = "test_url_param"
|
83
|
+
response = sg.client.suppression.bounces._(email).get()
|
84
|
+
puts response.status_code
|
85
|
+
puts response.body
|
86
|
+
puts response.headers
|
87
|
+
|
88
|
+
##################################################
|
89
|
+
# Delete a bounce #
|
90
|
+
# DELETE /suppression/bounces/{email} #
|
91
|
+
|
92
|
+
params = JSON.parse('{"email_address": "example@example.com"}')
|
93
|
+
email = "test_url_param"
|
94
|
+
response = sg.client.suppression.bounces._(email).delete(query_params: params)
|
95
|
+
puts response.status_code
|
96
|
+
puts response.body
|
97
|
+
puts response.headers
|
98
|
+
|
99
|
+
##################################################
|
100
|
+
# Retrieve all invalid emails #
|
101
|
+
# GET /suppression/invalid_emails #
|
102
|
+
|
103
|
+
params = JSON.parse('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}')
|
104
|
+
response = sg.client.suppression.invalid_emails.get(query_params: params)
|
105
|
+
puts response.status_code
|
106
|
+
puts response.body
|
107
|
+
puts response.headers
|
108
|
+
|
109
|
+
##################################################
|
110
|
+
# Delete invalid emails #
|
111
|
+
# DELETE /suppression/invalid_emails #
|
112
|
+
|
113
|
+
response = sg.client.suppression.invalid_emails.delete(request_body: data)
|
114
|
+
puts response.status_code
|
115
|
+
puts response.body
|
116
|
+
puts response.headers
|
117
|
+
|
118
|
+
##################################################
|
119
|
+
# Retrieve a specific invalid email #
|
120
|
+
# GET /suppression/invalid_emails/{email} #
|
121
|
+
|
122
|
+
email = "test_url_param"
|
123
|
+
response = sg.client.suppression.invalid_emails._(email).get()
|
124
|
+
puts response.status_code
|
125
|
+
puts response.body
|
126
|
+
puts response.headers
|
127
|
+
|
128
|
+
##################################################
|
129
|
+
# Delete a specific invalid email #
|
130
|
+
# DELETE /suppression/invalid_emails/{email} #
|
131
|
+
|
132
|
+
email = "test_url_param"
|
133
|
+
response = sg.client.suppression.invalid_emails._(email).delete()
|
134
|
+
puts response.status_code
|
135
|
+
puts response.body
|
136
|
+
puts response.headers
|
137
|
+
|
138
|
+
##################################################
|
139
|
+
# Retrieve a specific spam report #
|
140
|
+
# GET /suppression/spam_report/{email} #
|
141
|
+
|
142
|
+
email = "test_url_param"
|
143
|
+
response = sg.client.suppression.spam_report._(email).get()
|
144
|
+
puts response.status_code
|
145
|
+
puts response.body
|
146
|
+
puts response.headers
|
147
|
+
|
148
|
+
##################################################
|
149
|
+
# Delete a specific spam report #
|
150
|
+
# DELETE /suppression/spam_report/{email} #
|
151
|
+
|
152
|
+
email = "test_url_param"
|
153
|
+
response = sg.client.suppression.spam_report._(email).delete()
|
154
|
+
puts response.status_code
|
155
|
+
puts response.body
|
156
|
+
puts response.headers
|
157
|
+
|
158
|
+
##################################################
|
159
|
+
# Retrieve all spam reports #
|
160
|
+
# GET /suppression/spam_reports #
|
161
|
+
|
162
|
+
params = JSON.parse('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}')
|
163
|
+
response = sg.client.suppression.spam_reports.get(query_params: params)
|
164
|
+
puts response.status_code
|
165
|
+
puts response.body
|
166
|
+
puts response.headers
|
167
|
+
|
168
|
+
##################################################
|
169
|
+
# Delete spam reports #
|
170
|
+
# DELETE /suppression/spam_reports #
|
171
|
+
|
172
|
+
response = sg.client.suppression.spam_reports.delete(request_body: data)
|
173
|
+
puts response.status_code
|
174
|
+
puts response.body
|
175
|
+
puts response.headers
|
176
|
+
|
177
|
+
##################################################
|
178
|
+
# Retrieve all global suppressions #
|
179
|
+
# GET /suppression/unsubscribes #
|
180
|
+
|
181
|
+
params = JSON.parse('{"start_time": 1, "limit": 1, "end_time": 1, "offset": 1}')
|
182
|
+
response = sg.client.suppression.unsubscribes.get(query_params: params)
|
183
|
+
puts response.status_code
|
184
|
+
puts response.body
|
185
|
+
puts response.headers
|
186
|
+
|
@@ -0,0 +1,142 @@
|
|
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 transactional template. #
|
22
|
+
# POST /templates #
|
23
|
+
|
24
|
+
data = JSON.parse('{
|
25
|
+
"name": "example_name"
|
26
|
+
}')
|
27
|
+
response = sg.client.templates.post(request_body: data)
|
28
|
+
puts response.status_code
|
29
|
+
puts response.body
|
30
|
+
puts response.headers
|
31
|
+
|
32
|
+
##################################################
|
33
|
+
# Retrieve all transactional templates. #
|
34
|
+
# GET /templates #
|
35
|
+
|
36
|
+
response = sg.client.templates.get()
|
37
|
+
puts response.status_code
|
38
|
+
puts response.body
|
39
|
+
puts response.headers
|
40
|
+
|
41
|
+
##################################################
|
42
|
+
# Edit a transactional template. #
|
43
|
+
# PATCH /templates/{template_id} #
|
44
|
+
|
45
|
+
data = JSON.parse('{
|
46
|
+
"name": "new_example_name"
|
47
|
+
}')
|
48
|
+
template_id = "test_url_param"
|
49
|
+
response = sg.client.templates._(template_id).patch(request_body: data)
|
50
|
+
puts response.status_code
|
51
|
+
puts response.body
|
52
|
+
puts response.headers
|
53
|
+
|
54
|
+
##################################################
|
55
|
+
# Retrieve a single transactional template. #
|
56
|
+
# GET /templates/{template_id} #
|
57
|
+
|
58
|
+
template_id = "test_url_param"
|
59
|
+
response = sg.client.templates._(template_id).get()
|
60
|
+
puts response.status_code
|
61
|
+
puts response.body
|
62
|
+
puts response.headers
|
63
|
+
|
64
|
+
##################################################
|
65
|
+
# Delete a template. #
|
66
|
+
# DELETE /templates/{template_id} #
|
67
|
+
|
68
|
+
template_id = "test_url_param"
|
69
|
+
response = sg.client.templates._(template_id).delete()
|
70
|
+
puts response.status_code
|
71
|
+
puts response.body
|
72
|
+
puts response.headers
|
73
|
+
|
74
|
+
##################################################
|
75
|
+
# Create a new transactional template version. #
|
76
|
+
# POST /templates/{template_id}/versions #
|
77
|
+
|
78
|
+
data = JSON.parse('{
|
79
|
+
"active": 1,
|
80
|
+
"html_content": "<%body%>",
|
81
|
+
"name": "example_version_name",
|
82
|
+
"plain_content": "<%body%>",
|
83
|
+
"subject": "<%subject%>",
|
84
|
+
"template_id": "ddb96bbc-9b92-425e-8979-99464621b543"
|
85
|
+
}')
|
86
|
+
template_id = "test_url_param"
|
87
|
+
response = sg.client.templates._(template_id).versions.post(request_body: data)
|
88
|
+
puts response.status_code
|
89
|
+
puts response.body
|
90
|
+
puts response.headers
|
91
|
+
|
92
|
+
##################################################
|
93
|
+
# Edit a transactional template version. #
|
94
|
+
# PATCH /templates/{template_id}/versions/{version_id} #
|
95
|
+
|
96
|
+
data = JSON.parse('{
|
97
|
+
"active": 1,
|
98
|
+
"html_content": "<%body%>",
|
99
|
+
"name": "updated_example_name",
|
100
|
+
"plain_content": "<%body%>",
|
101
|
+
"subject": "<%subject%>"
|
102
|
+
}')
|
103
|
+
template_id = "test_url_param"
|
104
|
+
version_id = "test_url_param"
|
105
|
+
response = sg.client.templates._(template_id).versions._(version_id).patch(request_body: data)
|
106
|
+
puts response.status_code
|
107
|
+
puts response.body
|
108
|
+
puts response.headers
|
109
|
+
|
110
|
+
##################################################
|
111
|
+
# Retrieve a specific transactional template version. #
|
112
|
+
# GET /templates/{template_id}/versions/{version_id} #
|
113
|
+
|
114
|
+
template_id = "test_url_param"
|
115
|
+
version_id = "test_url_param"
|
116
|
+
response = sg.client.templates._(template_id).versions._(version_id).get()
|
117
|
+
puts response.status_code
|
118
|
+
puts response.body
|
119
|
+
puts response.headers
|
120
|
+
|
121
|
+
##################################################
|
122
|
+
# Delete a transactional template version. #
|
123
|
+
# DELETE /templates/{template_id}/versions/{version_id} #
|
124
|
+
|
125
|
+
template_id = "test_url_param"
|
126
|
+
version_id = "test_url_param"
|
127
|
+
response = sg.client.templates._(template_id).versions._(version_id).delete()
|
128
|
+
puts response.status_code
|
129
|
+
puts response.body
|
130
|
+
puts response.headers
|
131
|
+
|
132
|
+
##################################################
|
133
|
+
# Activate a transactional template version. #
|
134
|
+
# POST /templates/{template_id}/versions/{version_id}/activate #
|
135
|
+
|
136
|
+
template_id = "test_url_param"
|
137
|
+
version_id = "test_url_param"
|
138
|
+
response = sg.client.templates._(template_id).versions._(version_id).activate.post()
|
139
|
+
puts response.status_code
|
140
|
+
puts response.body
|
141
|
+
puts response.headers
|
142
|
+
|
@@ -0,0 +1,123 @@
|
|
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 Tracking Settings #
|
22
|
+
# GET /tracking_settings #
|
23
|
+
|
24
|
+
params = JSON.parse('{"limit": 1, "offset": 1}')
|
25
|
+
response = sg.client.tracking_settings.get(query_params: params)
|
26
|
+
puts response.status_code
|
27
|
+
puts response.body
|
28
|
+
puts response.headers
|
29
|
+
|
30
|
+
##################################################
|
31
|
+
# Update Click Tracking Settings #
|
32
|
+
# PATCH /tracking_settings/click #
|
33
|
+
|
34
|
+
data = JSON.parse('{
|
35
|
+
"enabled": true
|
36
|
+
}')
|
37
|
+
response = sg.client.tracking_settings.click.patch(request_body: data)
|
38
|
+
puts response.status_code
|
39
|
+
puts response.body
|
40
|
+
puts response.headers
|
41
|
+
|
42
|
+
##################################################
|
43
|
+
# Retrieve Click Track Settings #
|
44
|
+
# GET /tracking_settings/click #
|
45
|
+
|
46
|
+
response = sg.client.tracking_settings.click.get()
|
47
|
+
puts response.status_code
|
48
|
+
puts response.body
|
49
|
+
puts response.headers
|
50
|
+
|
51
|
+
##################################################
|
52
|
+
# Update Google Analytics Settings #
|
53
|
+
# PATCH /tracking_settings/google_analytics #
|
54
|
+
|
55
|
+
data = JSON.parse('{
|
56
|
+
"enabled": true,
|
57
|
+
"utm_campaign": "website",
|
58
|
+
"utm_content": "",
|
59
|
+
"utm_medium": "email",
|
60
|
+
"utm_source": "sendgrid.com",
|
61
|
+
"utm_term": ""
|
62
|
+
}')
|
63
|
+
response = sg.client.tracking_settings.google_analytics.patch(request_body: data)
|
64
|
+
puts response.status_code
|
65
|
+
puts response.body
|
66
|
+
puts response.headers
|
67
|
+
|
68
|
+
##################################################
|
69
|
+
# Retrieve Google Analytics Settings #
|
70
|
+
# GET /tracking_settings/google_analytics #
|
71
|
+
|
72
|
+
response = sg.client.tracking_settings.google_analytics.get()
|
73
|
+
puts response.status_code
|
74
|
+
puts response.body
|
75
|
+
puts response.headers
|
76
|
+
|
77
|
+
##################################################
|
78
|
+
# Update Open Tracking Settings #
|
79
|
+
# PATCH /tracking_settings/open #
|
80
|
+
|
81
|
+
data = JSON.parse('{
|
82
|
+
"enabled": true
|
83
|
+
}')
|
84
|
+
response = sg.client.tracking_settings.open.patch(request_body: data)
|
85
|
+
puts response.status_code
|
86
|
+
puts response.body
|
87
|
+
puts response.headers
|
88
|
+
|
89
|
+
##################################################
|
90
|
+
# Get Open Tracking Settings #
|
91
|
+
# GET /tracking_settings/open #
|
92
|
+
|
93
|
+
response = sg.client.tracking_settings.open.get()
|
94
|
+
puts response.status_code
|
95
|
+
puts response.body
|
96
|
+
puts response.headers
|
97
|
+
|
98
|
+
##################################################
|
99
|
+
# Update Subscription Tracking Settings #
|
100
|
+
# PATCH /tracking_settings/subscription #
|
101
|
+
|
102
|
+
data = JSON.parse('{
|
103
|
+
"enabled": true,
|
104
|
+
"html_content": "html content",
|
105
|
+
"landing": "landing page html",
|
106
|
+
"plain_content": "text content",
|
107
|
+
"replace": "replacement tag",
|
108
|
+
"url": "url"
|
109
|
+
}')
|
110
|
+
response = sg.client.tracking_settings.subscription.patch(request_body: data)
|
111
|
+
puts response.status_code
|
112
|
+
puts response.body
|
113
|
+
puts response.headers
|
114
|
+
|
115
|
+
##################################################
|
116
|
+
# Retrieve Subscription Tracking Settings #
|
117
|
+
# GET /tracking_settings/subscription #
|
118
|
+
|
119
|
+
response = sg.client.tracking_settings.subscription.get()
|
120
|
+
puts response.status_code
|
121
|
+
puts response.body
|
122
|
+
puts response.headers
|
123
|
+
|