blob: d5b2947f529ae4a1cec0d0aa7533d317df38d7ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
<?php
// If you are using Composer
require 'vendor/autoload.php';
$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
////////////////////////////////////////////////////
// Create a new Alert #
// POST /alerts #
$request_body = json_decode('{
"email_to": "example@example.com",
"frequency": "daily",
"type": "stats_notification"
}');
$response = $sg->client->alerts()->post($request_body);
echo $response->statusCode();
echo $response->body();
echo $response->headers();
////////////////////////////////////////////////////
// Retrieve all alerts #
// GET /alerts #
$response = $sg->client->alerts()->get();
echo $response->statusCode();
echo $response->body();
echo $response->headers();
////////////////////////////////////////////////////
// Update an alert #
// PATCH /alerts/{alert_id} #
$request_body = json_decode('{
"email_to": "example@example.com"
}');
$alert_id = "test_url_param";
$response = $sg->client->alerts()->_($alert_id)->patch($request_body);
echo $response->statusCode();
echo $response->body();
echo $response->headers();
////////////////////////////////////////////////////
// Retrieve a specific alert #
// GET /alerts/{alert_id} #
$alert_id = "test_url_param";
$response = $sg->client->alerts()->_($alert_id)->get();
echo $response->statusCode();
echo $response->body();
echo $response->headers();
////////////////////////////////////////////////////
// Delete an alert #
// DELETE /alerts/{alert_id} #
$alert_id = "test_url_param";
$response = $sg->client->alerts()->_($alert_id)->delete();
echo $response->statusCode();
echo $response->body();
echo $response->headers();
|