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,256 @@
|
|
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
|
+
# Get a user's account information. #
|
22
|
+
# GET /user/account #
|
23
|
+
|
24
|
+
response = sg.client.user.account.get()
|
25
|
+
puts response.status_code
|
26
|
+
puts response.body
|
27
|
+
puts response.headers
|
28
|
+
|
29
|
+
##################################################
|
30
|
+
# Retrieve your credit balance #
|
31
|
+
# GET /user/credits #
|
32
|
+
|
33
|
+
response = sg.client.user.credits.get()
|
34
|
+
puts response.status_code
|
35
|
+
puts response.body
|
36
|
+
puts response.headers
|
37
|
+
|
38
|
+
##################################################
|
39
|
+
# Update your account email address #
|
40
|
+
# PUT /user/email #
|
41
|
+
|
42
|
+
data = JSON.parse('{
|
43
|
+
"email": "example@example.com"
|
44
|
+
}')
|
45
|
+
response = sg.client.user.email.put(request_body: data)
|
46
|
+
puts response.status_code
|
47
|
+
puts response.body
|
48
|
+
puts response.headers
|
49
|
+
|
50
|
+
##################################################
|
51
|
+
# Retrieve your account email address #
|
52
|
+
# GET /user/email #
|
53
|
+
|
54
|
+
response = sg.client.user.email.get()
|
55
|
+
puts response.status_code
|
56
|
+
puts response.body
|
57
|
+
puts response.headers
|
58
|
+
|
59
|
+
##################################################
|
60
|
+
# Update your password #
|
61
|
+
# PUT /user/password #
|
62
|
+
|
63
|
+
data = JSON.parse('{
|
64
|
+
"new_password": "new_password",
|
65
|
+
"old_password": "old_password"
|
66
|
+
}')
|
67
|
+
response = sg.client.user.password.put(request_body: data)
|
68
|
+
puts response.status_code
|
69
|
+
puts response.body
|
70
|
+
puts response.headers
|
71
|
+
|
72
|
+
##################################################
|
73
|
+
# Update a user's profile #
|
74
|
+
# PATCH /user/profile #
|
75
|
+
|
76
|
+
data = JSON.parse('{
|
77
|
+
"city": "Orange",
|
78
|
+
"first_name": "Example",
|
79
|
+
"last_name": "User"
|
80
|
+
}')
|
81
|
+
response = sg.client.user.profile.patch(request_body: data)
|
82
|
+
puts response.status_code
|
83
|
+
puts response.body
|
84
|
+
puts response.headers
|
85
|
+
|
86
|
+
##################################################
|
87
|
+
# Get a user's profile #
|
88
|
+
# GET /user/profile #
|
89
|
+
|
90
|
+
response = sg.client.user.profile.get()
|
91
|
+
puts response.status_code
|
92
|
+
puts response.body
|
93
|
+
puts response.headers
|
94
|
+
|
95
|
+
##################################################
|
96
|
+
# Cancel or pause a scheduled send #
|
97
|
+
# POST /user/scheduled_sends #
|
98
|
+
|
99
|
+
data = JSON.parse('{
|
100
|
+
"batch_id": "YOUR_BATCH_ID",
|
101
|
+
"status": "pause"
|
102
|
+
}')
|
103
|
+
response = sg.client.user.scheduled_sends.post(request_body: data)
|
104
|
+
puts response.status_code
|
105
|
+
puts response.body
|
106
|
+
puts response.headers
|
107
|
+
|
108
|
+
##################################################
|
109
|
+
# Retrieve all scheduled sends #
|
110
|
+
# GET /user/scheduled_sends #
|
111
|
+
|
112
|
+
response = sg.client.user.scheduled_sends.get()
|
113
|
+
puts response.status_code
|
114
|
+
puts response.body
|
115
|
+
puts response.headers
|
116
|
+
|
117
|
+
##################################################
|
118
|
+
# Update user scheduled send information #
|
119
|
+
# PATCH /user/scheduled_sends/{batch_id} #
|
120
|
+
|
121
|
+
data = JSON.parse('{
|
122
|
+
"status": "pause"
|
123
|
+
}')
|
124
|
+
batch_id = "test_url_param"
|
125
|
+
response = sg.client.user.scheduled_sends._(batch_id).patch(request_body: data)
|
126
|
+
puts response.status_code
|
127
|
+
puts response.body
|
128
|
+
puts response.headers
|
129
|
+
|
130
|
+
##################################################
|
131
|
+
# Retrieve scheduled send #
|
132
|
+
# GET /user/scheduled_sends/{batch_id} #
|
133
|
+
|
134
|
+
batch_id = "test_url_param"
|
135
|
+
response = sg.client.user.scheduled_sends._(batch_id).get()
|
136
|
+
puts response.status_code
|
137
|
+
puts response.body
|
138
|
+
puts response.headers
|
139
|
+
|
140
|
+
##################################################
|
141
|
+
# Delete a cancellation or pause of a scheduled send #
|
142
|
+
# DELETE /user/scheduled_sends/{batch_id} #
|
143
|
+
|
144
|
+
batch_id = "test_url_param"
|
145
|
+
response = sg.client.user.scheduled_sends._(batch_id).delete()
|
146
|
+
puts response.status_code
|
147
|
+
puts response.body
|
148
|
+
puts response.headers
|
149
|
+
|
150
|
+
##################################################
|
151
|
+
# Update Enforced TLS settings #
|
152
|
+
# PATCH /user/settings/enforced_tls #
|
153
|
+
|
154
|
+
data = JSON.parse('{
|
155
|
+
"require_tls": true,
|
156
|
+
"require_valid_cert": false
|
157
|
+
}')
|
158
|
+
response = sg.client.user.settings.enforced_tls.patch(request_body: data)
|
159
|
+
puts response.status_code
|
160
|
+
puts response.body
|
161
|
+
puts response.headers
|
162
|
+
|
163
|
+
##################################################
|
164
|
+
# Retrieve current Enforced TLS settings. #
|
165
|
+
# GET /user/settings/enforced_tls #
|
166
|
+
|
167
|
+
response = sg.client.user.settings.enforced_tls.get()
|
168
|
+
puts response.status_code
|
169
|
+
puts response.body
|
170
|
+
puts response.headers
|
171
|
+
|
172
|
+
##################################################
|
173
|
+
# Update your username #
|
174
|
+
# PUT /user/username #
|
175
|
+
|
176
|
+
data = JSON.parse('{
|
177
|
+
"username": "test_username"
|
178
|
+
}')
|
179
|
+
response = sg.client.user.username.put(request_body: data)
|
180
|
+
puts response.status_code
|
181
|
+
puts response.body
|
182
|
+
puts response.headers
|
183
|
+
|
184
|
+
##################################################
|
185
|
+
# Retrieve your username #
|
186
|
+
# GET /user/username #
|
187
|
+
|
188
|
+
response = sg.client.user.username.get()
|
189
|
+
puts response.status_code
|
190
|
+
puts response.body
|
191
|
+
puts response.headers
|
192
|
+
|
193
|
+
##################################################
|
194
|
+
# Update Event Notification Settings #
|
195
|
+
# PATCH /user/webhooks/event/settings #
|
196
|
+
|
197
|
+
data = JSON.parse('{
|
198
|
+
"bounce": true,
|
199
|
+
"click": true,
|
200
|
+
"deferred": true,
|
201
|
+
"delivered": true,
|
202
|
+
"dropped": true,
|
203
|
+
"enabled": true,
|
204
|
+
"group_resubscribe": true,
|
205
|
+
"group_unsubscribe": true,
|
206
|
+
"open": true,
|
207
|
+
"processed": true,
|
208
|
+
"spam_report": true,
|
209
|
+
"unsubscribe": true,
|
210
|
+
"url": "url"
|
211
|
+
}')
|
212
|
+
response = sg.client.user.webhooks.event.settings.patch(request_body: data)
|
213
|
+
puts response.status_code
|
214
|
+
puts response.body
|
215
|
+
puts response.headers
|
216
|
+
|
217
|
+
##################################################
|
218
|
+
# Retrieve Event Webhook settings #
|
219
|
+
# GET /user/webhooks/event/settings #
|
220
|
+
|
221
|
+
response = sg.client.user.webhooks.event.settings.get()
|
222
|
+
puts response.status_code
|
223
|
+
puts response.body
|
224
|
+
puts response.headers
|
225
|
+
|
226
|
+
##################################################
|
227
|
+
# Test Event Notification Settings #
|
228
|
+
# POST /user/webhooks/event/test #
|
229
|
+
|
230
|
+
data = JSON.parse('{
|
231
|
+
"url": "url"
|
232
|
+
}')
|
233
|
+
response = sg.client.user.webhooks.event.test.post(request_body: data)
|
234
|
+
puts response.status_code
|
235
|
+
puts response.body
|
236
|
+
puts response.headers
|
237
|
+
|
238
|
+
##################################################
|
239
|
+
# Retrieve Parse Webhook settings #
|
240
|
+
# GET /user/webhooks/parse/settings #
|
241
|
+
|
242
|
+
response = sg.client.user.webhooks.parse.settings.get()
|
243
|
+
puts response.status_code
|
244
|
+
puts response.body
|
245
|
+
puts response.headers
|
246
|
+
|
247
|
+
##################################################
|
248
|
+
# Retrieves Inbound Parse Webhook statistics. #
|
249
|
+
# GET /user/webhooks/parse/stats #
|
250
|
+
|
251
|
+
params = JSON.parse('{"aggregated_by": "day", "limit": "test_string", "start_date": "2016-01-01", "end_date": "2016-04-01", "offset": "test_string"}')
|
252
|
+
response = sg.client.user.webhooks.parse.stats.get(query_params: params)
|
253
|
+
puts response.status_code
|
254
|
+
puts response.body
|
255
|
+
puts response.headers
|
256
|
+
|
@@ -0,0 +1,323 @@
|
|
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 domain whitelabel. #
|
22
|
+
# POST /whitelabel/domains #
|
23
|
+
|
24
|
+
data = JSON.parse('{
|
25
|
+
"automatic_security": false,
|
26
|
+
"custom_spf": true,
|
27
|
+
"default": true,
|
28
|
+
"domain": "example.com",
|
29
|
+
"ips": [
|
30
|
+
"192.168.1.1",
|
31
|
+
"192.168.1.2"
|
32
|
+
],
|
33
|
+
"subdomain": "news",
|
34
|
+
"username": "john@example.com"
|
35
|
+
}')
|
36
|
+
response = sg.client.whitelabel.domains.post(request_body: data)
|
37
|
+
puts response.status_code
|
38
|
+
puts response.body
|
39
|
+
puts response.headers
|
40
|
+
|
41
|
+
##################################################
|
42
|
+
# List all domain whitelabels. #
|
43
|
+
# GET /whitelabel/domains #
|
44
|
+
|
45
|
+
params = JSON.parse('{"username": "test_string", "domain": "test_string", "exclude_subusers": "true", "limit": 1, "offset": 1}')
|
46
|
+
response = sg.client.whitelabel.domains.get(query_params: params)
|
47
|
+
puts response.status_code
|
48
|
+
puts response.body
|
49
|
+
puts response.headers
|
50
|
+
|
51
|
+
##################################################
|
52
|
+
# Get the default domain whitelabel. #
|
53
|
+
# GET /whitelabel/domains/default #
|
54
|
+
|
55
|
+
response = sg.client.whitelabel.domains.default.get()
|
56
|
+
puts response.status_code
|
57
|
+
puts response.body
|
58
|
+
puts response.headers
|
59
|
+
|
60
|
+
##################################################
|
61
|
+
# List the domain whitelabel associated with the given user. #
|
62
|
+
# GET /whitelabel/domains/subuser #
|
63
|
+
|
64
|
+
response = sg.client.whitelabel.domains.subuser.get()
|
65
|
+
puts response.status_code
|
66
|
+
puts response.body
|
67
|
+
puts response.headers
|
68
|
+
|
69
|
+
##################################################
|
70
|
+
# Disassociate a domain whitelabel from a given user. #
|
71
|
+
# DELETE /whitelabel/domains/subuser #
|
72
|
+
|
73
|
+
response = sg.client.whitelabel.domains.subuser.delete()
|
74
|
+
puts response.status_code
|
75
|
+
puts response.body
|
76
|
+
puts response.headers
|
77
|
+
|
78
|
+
##################################################
|
79
|
+
# Update a domain whitelabel. #
|
80
|
+
# PATCH /whitelabel/domains/{domain_id} #
|
81
|
+
|
82
|
+
data = JSON.parse('{
|
83
|
+
"custom_spf": true,
|
84
|
+
"default": false
|
85
|
+
}')
|
86
|
+
domain_id = "test_url_param"
|
87
|
+
response = sg.client.whitelabel.domains._(domain_id).patch(request_body: data)
|
88
|
+
puts response.status_code
|
89
|
+
puts response.body
|
90
|
+
puts response.headers
|
91
|
+
|
92
|
+
##################################################
|
93
|
+
# Retrieve a domain whitelabel. #
|
94
|
+
# GET /whitelabel/domains/{domain_id} #
|
95
|
+
|
96
|
+
domain_id = "test_url_param"
|
97
|
+
response = sg.client.whitelabel.domains._(domain_id).get()
|
98
|
+
puts response.status_code
|
99
|
+
puts response.body
|
100
|
+
puts response.headers
|
101
|
+
|
102
|
+
##################################################
|
103
|
+
# Delete a domain whitelabel. #
|
104
|
+
# DELETE /whitelabel/domains/{domain_id} #
|
105
|
+
|
106
|
+
domain_id = "test_url_param"
|
107
|
+
response = sg.client.whitelabel.domains._(domain_id).delete()
|
108
|
+
puts response.status_code
|
109
|
+
puts response.body
|
110
|
+
puts response.headers
|
111
|
+
|
112
|
+
##################################################
|
113
|
+
# Associate a domain whitelabel with a given user. #
|
114
|
+
# POST /whitelabel/domains/{domain_id}/subuser #
|
115
|
+
|
116
|
+
data = JSON.parse('{
|
117
|
+
"username": "jane@example.com"
|
118
|
+
}')
|
119
|
+
domain_id = "test_url_param"
|
120
|
+
response = sg.client.whitelabel.domains._(domain_id).subuser.post(request_body: data)
|
121
|
+
puts response.status_code
|
122
|
+
puts response.body
|
123
|
+
puts response.headers
|
124
|
+
|
125
|
+
##################################################
|
126
|
+
# Add an IP to a domain whitelabel. #
|
127
|
+
# POST /whitelabel/domains/{id}/ips #
|
128
|
+
|
129
|
+
data = JSON.parse('{
|
130
|
+
"ip": "192.168.0.1"
|
131
|
+
}')
|
132
|
+
id = "test_url_param"
|
133
|
+
response = sg.client.whitelabel.domains._(id).ips.post(request_body: data)
|
134
|
+
puts response.status_code
|
135
|
+
puts response.body
|
136
|
+
puts response.headers
|
137
|
+
|
138
|
+
##################################################
|
139
|
+
# Remove an IP from a domain whitelabel. #
|
140
|
+
# DELETE /whitelabel/domains/{id}/ips/{ip} #
|
141
|
+
|
142
|
+
id = "test_url_param"
|
143
|
+
ip = "test_url_param"
|
144
|
+
response = sg.client.whitelabel.domains._(id).ips._(ip).delete()
|
145
|
+
puts response.status_code
|
146
|
+
puts response.body
|
147
|
+
puts response.headers
|
148
|
+
|
149
|
+
##################################################
|
150
|
+
# Validate a domain whitelabel. #
|
151
|
+
# POST /whitelabel/domains/{id}/validate #
|
152
|
+
|
153
|
+
id = "test_url_param"
|
154
|
+
response = sg.client.whitelabel.domains._(id).validate.post()
|
155
|
+
puts response.status_code
|
156
|
+
puts response.body
|
157
|
+
puts response.headers
|
158
|
+
|
159
|
+
##################################################
|
160
|
+
# Create an IP whitelabel #
|
161
|
+
# POST /whitelabel/ips #
|
162
|
+
|
163
|
+
data = JSON.parse('{
|
164
|
+
"domain": "example.com",
|
165
|
+
"ip": "192.168.1.1",
|
166
|
+
"subdomain": "email"
|
167
|
+
}')
|
168
|
+
response = sg.client.whitelabel.ips.post(request_body: data)
|
169
|
+
puts response.status_code
|
170
|
+
puts response.body
|
171
|
+
puts response.headers
|
172
|
+
|
173
|
+
##################################################
|
174
|
+
# Retrieve all IP whitelabels #
|
175
|
+
# GET /whitelabel/ips #
|
176
|
+
|
177
|
+
params = JSON.parse('{"ip": "test_string", "limit": 1, "offset": 1}')
|
178
|
+
response = sg.client.whitelabel.ips.get(query_params: params)
|
179
|
+
puts response.status_code
|
180
|
+
puts response.body
|
181
|
+
puts response.headers
|
182
|
+
|
183
|
+
##################################################
|
184
|
+
# Retrieve an IP whitelabel #
|
185
|
+
# GET /whitelabel/ips/{id} #
|
186
|
+
|
187
|
+
id = "test_url_param"
|
188
|
+
response = sg.client.whitelabel.ips._(id).get()
|
189
|
+
puts response.status_code
|
190
|
+
puts response.body
|
191
|
+
puts response.headers
|
192
|
+
|
193
|
+
##################################################
|
194
|
+
# Delete an IP whitelabel #
|
195
|
+
# DELETE /whitelabel/ips/{id} #
|
196
|
+
|
197
|
+
id = "test_url_param"
|
198
|
+
response = sg.client.whitelabel.ips._(id).delete()
|
199
|
+
puts response.status_code
|
200
|
+
puts response.body
|
201
|
+
puts response.headers
|
202
|
+
|
203
|
+
##################################################
|
204
|
+
# Validate an IP whitelabel #
|
205
|
+
# POST /whitelabel/ips/{id}/validate #
|
206
|
+
|
207
|
+
id = "test_url_param"
|
208
|
+
response = sg.client.whitelabel.ips._(id).validate.post()
|
209
|
+
puts response.status_code
|
210
|
+
puts response.body
|
211
|
+
puts response.headers
|
212
|
+
|
213
|
+
##################################################
|
214
|
+
# Create a Link Whitelabel #
|
215
|
+
# POST /whitelabel/links #
|
216
|
+
|
217
|
+
data = JSON.parse('{
|
218
|
+
"default": true,
|
219
|
+
"domain": "example.com",
|
220
|
+
"subdomain": "mail"
|
221
|
+
}')
|
222
|
+
params = JSON.parse('{"limit": 1, "offset": 1}')
|
223
|
+
response = sg.client.whitelabel.links.post(request_body: data, query_params: params)
|
224
|
+
puts response.status_code
|
225
|
+
puts response.body
|
226
|
+
puts response.headers
|
227
|
+
|
228
|
+
##################################################
|
229
|
+
# Retrieve all link whitelabels #
|
230
|
+
# GET /whitelabel/links #
|
231
|
+
|
232
|
+
params = JSON.parse('{"limit": 1}')
|
233
|
+
response = sg.client.whitelabel.links.get(query_params: params)
|
234
|
+
puts response.status_code
|
235
|
+
puts response.body
|
236
|
+
puts response.headers
|
237
|
+
|
238
|
+
##################################################
|
239
|
+
# Retrieve a Default Link Whitelabel #
|
240
|
+
# GET /whitelabel/links/default #
|
241
|
+
|
242
|
+
params = JSON.parse('{"domain": "test_string"}')
|
243
|
+
response = sg.client.whitelabel.links.default.get(query_params: params)
|
244
|
+
puts response.status_code
|
245
|
+
puts response.body
|
246
|
+
puts response.headers
|
247
|
+
|
248
|
+
##################################################
|
249
|
+
# Retrieve Associated Link Whitelabel #
|
250
|
+
# GET /whitelabel/links/subuser #
|
251
|
+
|
252
|
+
params = JSON.parse('{"username": "test_string"}')
|
253
|
+
response = sg.client.whitelabel.links.subuser.get(query_params: params)
|
254
|
+
puts response.status_code
|
255
|
+
puts response.body
|
256
|
+
puts response.headers
|
257
|
+
|
258
|
+
##################################################
|
259
|
+
# Disassociate a Link Whitelabel #
|
260
|
+
# DELETE /whitelabel/links/subuser #
|
261
|
+
|
262
|
+
params = JSON.parse('{"username": "test_string"}')
|
263
|
+
response = sg.client.whitelabel.links.subuser.delete(query_params: params)
|
264
|
+
puts response.status_code
|
265
|
+
puts response.body
|
266
|
+
puts response.headers
|
267
|
+
|
268
|
+
##################################################
|
269
|
+
# Update a Link Whitelabel #
|
270
|
+
# PATCH /whitelabel/links/{id} #
|
271
|
+
|
272
|
+
data = JSON.parse('{
|
273
|
+
"default": true
|
274
|
+
}')
|
275
|
+
id = "test_url_param"
|
276
|
+
response = sg.client.whitelabel.links._(id).patch(request_body: data)
|
277
|
+
puts response.status_code
|
278
|
+
puts response.body
|
279
|
+
puts response.headers
|
280
|
+
|
281
|
+
##################################################
|
282
|
+
# Retrieve a Link Whitelabel #
|
283
|
+
# GET /whitelabel/links/{id} #
|
284
|
+
|
285
|
+
id = "test_url_param"
|
286
|
+
response = sg.client.whitelabel.links._(id).get()
|
287
|
+
puts response.status_code
|
288
|
+
puts response.body
|
289
|
+
puts response.headers
|
290
|
+
|
291
|
+
##################################################
|
292
|
+
# Delete a Link Whitelabel #
|
293
|
+
# DELETE /whitelabel/links/{id} #
|
294
|
+
|
295
|
+
id = "test_url_param"
|
296
|
+
response = sg.client.whitelabel.links._(id).delete()
|
297
|
+
puts response.status_code
|
298
|
+
puts response.body
|
299
|
+
puts response.headers
|
300
|
+
|
301
|
+
##################################################
|
302
|
+
# Validate a Link Whitelabel #
|
303
|
+
# POST /whitelabel/links/{id}/validate #
|
304
|
+
|
305
|
+
id = "test_url_param"
|
306
|
+
response = sg.client.whitelabel.links._(id).validate.post()
|
307
|
+
puts response.status_code
|
308
|
+
puts response.body
|
309
|
+
puts response.headers
|
310
|
+
|
311
|
+
##################################################
|
312
|
+
# Associate a Link Whitelabel #
|
313
|
+
# POST /whitelabel/links/{link_id}/subuser #
|
314
|
+
|
315
|
+
data = JSON.parse('{
|
316
|
+
"username": "jane@example.com"
|
317
|
+
}')
|
318
|
+
link_id = "test_url_param"
|
319
|
+
response = sg.client.whitelabel.links._(link_id).subuser.post(request_body: data)
|
320
|
+
puts response.status_code
|
321
|
+
puts response.body
|
322
|
+
puts response.headers
|
323
|
+
|