103 |
- |
1 |
<?php
|
|
|
2 |
// If you are using Composer
|
|
|
3 |
require 'vendor/autoload.php';
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
$apiKey = getenv('SENDGRID_API_KEY');
|
|
|
7 |
$sg = new \SendGrid($apiKey);
|
|
|
8 |
|
|
|
9 |
////////////////////////////////////////////////////
|
|
|
10 |
// Create a domain whitelabel. #
|
|
|
11 |
// POST /whitelabel/domains #
|
|
|
12 |
|
|
|
13 |
$request_body = json_decode('{
|
|
|
14 |
"automatic_security": false,
|
|
|
15 |
"custom_spf": true,
|
|
|
16 |
"default": true,
|
|
|
17 |
"domain": "example.com",
|
|
|
18 |
"ips": [
|
|
|
19 |
"192.168.1.1",
|
|
|
20 |
"192.168.1.2"
|
|
|
21 |
],
|
|
|
22 |
"subdomain": "news",
|
|
|
23 |
"username": "john@example.com"
|
|
|
24 |
}');
|
|
|
25 |
$response = $sg->client->whitelabel()->domains()->post($request_body);
|
|
|
26 |
echo $response->statusCode();
|
|
|
27 |
echo $response->body();
|
|
|
28 |
echo $response->headers();
|
|
|
29 |
|
|
|
30 |
////////////////////////////////////////////////////
|
|
|
31 |
// List all domain whitelabels. #
|
|
|
32 |
// GET /whitelabel/domains #
|
|
|
33 |
|
|
|
34 |
$query_params = json_decode('{"username": "test_string", "domain": "test_string", "exclude_subusers": "true", "limit": 1, "offset": 1}');
|
|
|
35 |
$response = $sg->client->whitelabel()->domains()->get(null, $query_params);
|
|
|
36 |
echo $response->statusCode();
|
|
|
37 |
echo $response->body();
|
|
|
38 |
echo $response->headers();
|
|
|
39 |
|
|
|
40 |
////////////////////////////////////////////////////
|
|
|
41 |
// Get the default domain whitelabel. #
|
|
|
42 |
// GET /whitelabel/domains/default #
|
|
|
43 |
|
|
|
44 |
$response = $sg->client->whitelabel()->domains()->default()->get();
|
|
|
45 |
echo $response->statusCode();
|
|
|
46 |
echo $response->body();
|
|
|
47 |
echo $response->headers();
|
|
|
48 |
|
|
|
49 |
////////////////////////////////////////////////////
|
|
|
50 |
// List the domain whitelabel associated with the given user. #
|
|
|
51 |
// GET /whitelabel/domains/subuser #
|
|
|
52 |
|
|
|
53 |
$response = $sg->client->whitelabel()->domains()->subuser()->get();
|
|
|
54 |
echo $response->statusCode();
|
|
|
55 |
echo $response->body();
|
|
|
56 |
echo $response->headers();
|
|
|
57 |
|
|
|
58 |
////////////////////////////////////////////////////
|
|
|
59 |
// Disassociate a domain whitelabel from a given user. #
|
|
|
60 |
// DELETE /whitelabel/domains/subuser #
|
|
|
61 |
|
|
|
62 |
$response = $sg->client->whitelabel()->domains()->subuser()->delete();
|
|
|
63 |
echo $response->statusCode();
|
|
|
64 |
echo $response->body();
|
|
|
65 |
echo $response->headers();
|
|
|
66 |
|
|
|
67 |
////////////////////////////////////////////////////
|
|
|
68 |
// Update a domain whitelabel. #
|
|
|
69 |
// PATCH /whitelabel/domains/{domain_id} #
|
|
|
70 |
|
|
|
71 |
$request_body = json_decode('{
|
|
|
72 |
"custom_spf": true,
|
|
|
73 |
"default": false
|
|
|
74 |
}');
|
|
|
75 |
$domain_id = "test_url_param";
|
|
|
76 |
$response = $sg->client->whitelabel()->domains()->_($domain_id)->patch($request_body);
|
|
|
77 |
echo $response->statusCode();
|
|
|
78 |
echo $response->body();
|
|
|
79 |
echo $response->headers();
|
|
|
80 |
|
|
|
81 |
////////////////////////////////////////////////////
|
|
|
82 |
// Retrieve a domain whitelabel. #
|
|
|
83 |
// GET /whitelabel/domains/{domain_id} #
|
|
|
84 |
|
|
|
85 |
$domain_id = "test_url_param";
|
|
|
86 |
$response = $sg->client->whitelabel()->domains()->_($domain_id)->get();
|
|
|
87 |
echo $response->statusCode();
|
|
|
88 |
echo $response->body();
|
|
|
89 |
echo $response->headers();
|
|
|
90 |
|
|
|
91 |
////////////////////////////////////////////////////
|
|
|
92 |
// Delete a domain whitelabel. #
|
|
|
93 |
// DELETE /whitelabel/domains/{domain_id} #
|
|
|
94 |
|
|
|
95 |
$domain_id = "test_url_param";
|
|
|
96 |
$response = $sg->client->whitelabel()->domains()->_($domain_id)->delete();
|
|
|
97 |
echo $response->statusCode();
|
|
|
98 |
echo $response->body();
|
|
|
99 |
echo $response->headers();
|
|
|
100 |
|
|
|
101 |
////////////////////////////////////////////////////
|
|
|
102 |
// Associate a domain whitelabel with a given user. #
|
|
|
103 |
// POST /whitelabel/domains/{domain_id}/subuser #
|
|
|
104 |
|
|
|
105 |
$request_body = json_decode('{
|
|
|
106 |
"username": "jane@example.com"
|
|
|
107 |
}');
|
|
|
108 |
$domain_id = "test_url_param";
|
|
|
109 |
$response = $sg->client->whitelabel()->domains()->_($domain_id)->subuser()->post($request_body);
|
|
|
110 |
echo $response->statusCode();
|
|
|
111 |
echo $response->body();
|
|
|
112 |
echo $response->headers();
|
|
|
113 |
|
|
|
114 |
////////////////////////////////////////////////////
|
|
|
115 |
// Add an IP to a domain whitelabel. #
|
|
|
116 |
// POST /whitelabel/domains/{id}/ips #
|
|
|
117 |
|
|
|
118 |
$request_body = json_decode('{
|
|
|
119 |
"ip": "192.168.0.1"
|
|
|
120 |
}');
|
|
|
121 |
$id = "test_url_param";
|
|
|
122 |
$response = $sg->client->whitelabel()->domains()->_($id)->ips()->post($request_body);
|
|
|
123 |
echo $response->statusCode();
|
|
|
124 |
echo $response->body();
|
|
|
125 |
echo $response->headers();
|
|
|
126 |
|
|
|
127 |
////////////////////////////////////////////////////
|
|
|
128 |
// Remove an IP from a domain whitelabel. #
|
|
|
129 |
// DELETE /whitelabel/domains/{id}/ips/{ip} #
|
|
|
130 |
|
|
|
131 |
$id = "test_url_param";
|
|
|
132 |
$ip = "test_url_param";
|
|
|
133 |
$response = $sg->client->whitelabel()->domains()->_($id)->ips()->_($ip)->delete();
|
|
|
134 |
echo $response->statusCode();
|
|
|
135 |
echo $response->body();
|
|
|
136 |
echo $response->headers();
|
|
|
137 |
|
|
|
138 |
////////////////////////////////////////////////////
|
|
|
139 |
// Validate a domain whitelabel. #
|
|
|
140 |
// POST /whitelabel/domains/{id}/validate #
|
|
|
141 |
|
|
|
142 |
$id = "test_url_param";
|
|
|
143 |
$response = $sg->client->whitelabel()->domains()->_($id)->validate()->post();
|
|
|
144 |
echo $response->statusCode();
|
|
|
145 |
echo $response->body();
|
|
|
146 |
echo $response->headers();
|
|
|
147 |
|
|
|
148 |
////////////////////////////////////////////////////
|
|
|
149 |
// Create an IP whitelabel #
|
|
|
150 |
// POST /whitelabel/ips #
|
|
|
151 |
|
|
|
152 |
$request_body = json_decode('{
|
|
|
153 |
"domain": "example.com",
|
|
|
154 |
"ip": "192.168.1.1",
|
|
|
155 |
"subdomain": "email"
|
|
|
156 |
}');
|
|
|
157 |
$response = $sg->client->whitelabel()->ips()->post($request_body);
|
|
|
158 |
echo $response->statusCode();
|
|
|
159 |
echo $response->body();
|
|
|
160 |
echo $response->headers();
|
|
|
161 |
|
|
|
162 |
////////////////////////////////////////////////////
|
|
|
163 |
// Retrieve all IP whitelabels #
|
|
|
164 |
// GET /whitelabel/ips #
|
|
|
165 |
|
|
|
166 |
$query_params = json_decode('{"ip": "test_string", "limit": 1, "offset": 1}');
|
|
|
167 |
$response = $sg->client->whitelabel()->ips()->get(null, $query_params);
|
|
|
168 |
echo $response->statusCode();
|
|
|
169 |
echo $response->body();
|
|
|
170 |
echo $response->headers();
|
|
|
171 |
|
|
|
172 |
////////////////////////////////////////////////////
|
|
|
173 |
// Retrieve an IP whitelabel #
|
|
|
174 |
// GET /whitelabel/ips/{id} #
|
|
|
175 |
|
|
|
176 |
$id = "test_url_param";
|
|
|
177 |
$response = $sg->client->whitelabel()->ips()->_($id)->get();
|
|
|
178 |
echo $response->statusCode();
|
|
|
179 |
echo $response->body();
|
|
|
180 |
echo $response->headers();
|
|
|
181 |
|
|
|
182 |
////////////////////////////////////////////////////
|
|
|
183 |
// Delete an IP whitelabel #
|
|
|
184 |
// DELETE /whitelabel/ips/{id} #
|
|
|
185 |
|
|
|
186 |
$id = "test_url_param";
|
|
|
187 |
$response = $sg->client->whitelabel()->ips()->_($id)->delete();
|
|
|
188 |
echo $response->statusCode();
|
|
|
189 |
echo $response->body();
|
|
|
190 |
echo $response->headers();
|
|
|
191 |
|
|
|
192 |
////////////////////////////////////////////////////
|
|
|
193 |
// Validate an IP whitelabel #
|
|
|
194 |
// POST /whitelabel/ips/{id}/validate #
|
|
|
195 |
|
|
|
196 |
$id = "test_url_param";
|
|
|
197 |
$response = $sg->client->whitelabel()->ips()->_($id)->validate()->post();
|
|
|
198 |
echo $response->statusCode();
|
|
|
199 |
echo $response->body();
|
|
|
200 |
echo $response->headers();
|
|
|
201 |
|
|
|
202 |
////////////////////////////////////////////////////
|
|
|
203 |
// Create a Link Whitelabel #
|
|
|
204 |
// POST /whitelabel/links #
|
|
|
205 |
|
|
|
206 |
$request_body = json_decode('{
|
|
|
207 |
"default": true,
|
|
|
208 |
"domain": "example.com",
|
|
|
209 |
"subdomain": "mail"
|
|
|
210 |
}');
|
|
|
211 |
$query_params = json_decode('{"limit": 1, "offset": 1}');
|
|
|
212 |
$response = $sg->client->whitelabel()->links()->post($request_body, $query_params);
|
|
|
213 |
echo $response->statusCode();
|
|
|
214 |
echo $response->body();
|
|
|
215 |
echo $response->headers();
|
|
|
216 |
|
|
|
217 |
////////////////////////////////////////////////////
|
|
|
218 |
// Retrieve all link whitelabels #
|
|
|
219 |
// GET /whitelabel/links #
|
|
|
220 |
|
|
|
221 |
$query_params = json_decode('{"limit": 1}');
|
|
|
222 |
$response = $sg->client->whitelabel()->links()->get(null, $query_params);
|
|
|
223 |
echo $response->statusCode();
|
|
|
224 |
echo $response->body();
|
|
|
225 |
echo $response->headers();
|
|
|
226 |
|
|
|
227 |
////////////////////////////////////////////////////
|
|
|
228 |
// Retrieve a Default Link Whitelabel #
|
|
|
229 |
// GET /whitelabel/links/default #
|
|
|
230 |
|
|
|
231 |
$query_params = json_decode('{"domain": "test_string"}');
|
|
|
232 |
$response = $sg->client->whitelabel()->links()->default()->get(null, $query_params);
|
|
|
233 |
echo $response->statusCode();
|
|
|
234 |
echo $response->body();
|
|
|
235 |
echo $response->headers();
|
|
|
236 |
|
|
|
237 |
////////////////////////////////////////////////////
|
|
|
238 |
// Retrieve Associated Link Whitelabel #
|
|
|
239 |
// GET /whitelabel/links/subuser #
|
|
|
240 |
|
|
|
241 |
$query_params = json_decode('{"username": "test_string"}');
|
|
|
242 |
$response = $sg->client->whitelabel()->links()->subuser()->get(null, $query_params);
|
|
|
243 |
echo $response->statusCode();
|
|
|
244 |
echo $response->body();
|
|
|
245 |
echo $response->headers();
|
|
|
246 |
|
|
|
247 |
////////////////////////////////////////////////////
|
|
|
248 |
// Disassociate a Link Whitelabel #
|
|
|
249 |
// DELETE /whitelabel/links/subuser #
|
|
|
250 |
|
|
|
251 |
$query_params = json_decode('{"username": "test_string"}');
|
|
|
252 |
$response = $sg->client->whitelabel()->links()->subuser()->delete(null, $query_params);
|
|
|
253 |
echo $response->statusCode();
|
|
|
254 |
echo $response->body();
|
|
|
255 |
echo $response->headers();
|
|
|
256 |
|
|
|
257 |
////////////////////////////////////////////////////
|
|
|
258 |
// Update a Link Whitelabel #
|
|
|
259 |
// PATCH /whitelabel/links/{id} #
|
|
|
260 |
|
|
|
261 |
$request_body = json_decode('{
|
|
|
262 |
"default": true
|
|
|
263 |
}');
|
|
|
264 |
$id = "test_url_param";
|
|
|
265 |
$response = $sg->client->whitelabel()->links()->_($id)->patch($request_body);
|
|
|
266 |
echo $response->statusCode();
|
|
|
267 |
echo $response->body();
|
|
|
268 |
echo $response->headers();
|
|
|
269 |
|
|
|
270 |
////////////////////////////////////////////////////
|
|
|
271 |
// Retrieve a Link Whitelabel #
|
|
|
272 |
// GET /whitelabel/links/{id} #
|
|
|
273 |
|
|
|
274 |
$id = "test_url_param";
|
|
|
275 |
$response = $sg->client->whitelabel()->links()->_($id)->get();
|
|
|
276 |
echo $response->statusCode();
|
|
|
277 |
echo $response->body();
|
|
|
278 |
echo $response->headers();
|
|
|
279 |
|
|
|
280 |
////////////////////////////////////////////////////
|
|
|
281 |
// Delete a Link Whitelabel #
|
|
|
282 |
// DELETE /whitelabel/links/{id} #
|
|
|
283 |
|
|
|
284 |
$id = "test_url_param";
|
|
|
285 |
$response = $sg->client->whitelabel()->links()->_($id)->delete();
|
|
|
286 |
echo $response->statusCode();
|
|
|
287 |
echo $response->body();
|
|
|
288 |
echo $response->headers();
|
|
|
289 |
|
|
|
290 |
////////////////////////////////////////////////////
|
|
|
291 |
// Validate a Link Whitelabel #
|
|
|
292 |
// POST /whitelabel/links/{id}/validate #
|
|
|
293 |
|
|
|
294 |
$id = "test_url_param";
|
|
|
295 |
$response = $sg->client->whitelabel()->links()->_($id)->validate()->post();
|
|
|
296 |
echo $response->statusCode();
|
|
|
297 |
echo $response->body();
|
|
|
298 |
echo $response->headers();
|
|
|
299 |
|
|
|
300 |
////////////////////////////////////////////////////
|
|
|
301 |
// Associate a Link Whitelabel #
|
|
|
302 |
// POST /whitelabel/links/{link_id}/subuser #
|
|
|
303 |
|
|
|
304 |
$request_body = json_decode('{
|
|
|
305 |
"username": "jane@example.com"
|
|
|
306 |
}');
|
|
|
307 |
$link_id = "test_url_param";
|
|
|
308 |
$response = $sg->client->whitelabel()->links()->_($link_id)->subuser()->post($request_body);
|
|
|
309 |
echo $response->statusCode();
|
|
|
310 |
echo $response->body();
|
|
|
311 |
echo $response->headers();
|