Skip to content

Commit e5de48e

Browse files
committed
Example fix
1 parent 7d49213 commit e5de48e

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

examples/example.php

+24-25
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
11
<?php
2+
23
// If running this outside of this context, use the following include and
34
// comment out the two includes below
45
// require __DIR__ . '/vendor/autoload.php';
56
include(dirname(__DIR__) . '/lib/Client.php');
67
// This gets the parent directory, for your current directory use getcwd()
78
$path_to_config = dirname(__DIR__);
8-
$api_key = getenv('SENDGRID_API_KEY');
9-
$headers = array('Authorization: Bearer '.$api_key);
10-
$client = new SendGrid\Client('https://api.sendgrid.com', $headers, '/v3', null);
9+
$apiKey = getenv('SENDGRID_API_KEY');
10+
$headers = ['Authorization: Bearer ' . $apiKey];
11+
$client = new SendGrid\Client('https://api.sendgrid.com', $headers, '/v3');
1112

1213
// GET Collection
13-
$query_params = array('limit' => 100, 'offset' => 0);
14-
$request_headers = array('X-Mock: 200');
14+
$query_params = ['limit' => 100, 'offset' => 0];
15+
$request_headers = ['X-Mock: 200'];
1516
$response = $client->api_keys()->get(null, $query_params, $request_headers);
1617
echo $response->statusCode();
1718
echo $response->body();
1819
echo $response->headers();
1920

2021
// POST
21-
$request_body = array(
22-
'name' => 'My PHP API Key',
23-
'scopes' => array(
24-
'mail.send',
25-
'alerts.create',
26-
'alerts.read'
27-
)
28-
);
22+
$request_body = [
23+
'name' => 'My PHP API Key',
24+
'scopes' => [
25+
'mail.send',
26+
'alerts.create',
27+
'alerts.read'
28+
]
29+
];
2930
$response = $client->api_keys()->post($request_body);
3031
echo $response->statusCode();
3132
echo $response->body();
@@ -40,22 +41,22 @@
4041
echo $response->headers();
4142

4243
// PATCH
43-
$request_body = array(
44-
'name' => 'A New Hope'
45-
);
44+
$request_body = [
45+
'name' => 'A New Hope'
46+
];
4647
$response = $client->api_keys()->_($api_key_id)->patch($request_body);
4748
echo $response->statusCode();
4849
echo $response->body();
4950
echo $response->headers();
5051

5152
// PUT
52-
$request_body = array(
53-
'name' => 'A New Hope',
54-
'scopes' => array(
55-
'user.profile.read',
56-
'user.profile.update'
57-
)
58-
);
53+
$request_body = [
54+
'name' => 'A New Hope',
55+
'scopes' => [
56+
'user.profile.read',
57+
'user.profile.update'
58+
]
59+
];
5960
$response = $client->api_keys()->_($api_key_id)->put($request_body);
6061
echo $response->statusCode();
6162
echo $response->body();
@@ -66,5 +67,3 @@
6667
echo $response->statusCode();
6768
echo $response->body();
6869
echo $response->headers();
69-
70-
?>

0 commit comments

Comments
 (0)