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';
56include (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 );
1617echo $ response ->statusCode ();
1718echo $ response ->body ();
1819echo $ 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 );
3031echo $ response ->statusCode ();
3132echo $ response ->body ();
4041echo $ 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 );
4748echo $ response ->statusCode ();
4849echo $ response ->body ();
4950echo $ 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 );
6061echo $ response ->statusCode ();
6162echo $ response ->body ();
6667echo $ response ->statusCode ();
6768echo $ response ->body ();
6869echo $ response ->headers ();
69-
70- ?>
0 commit comments