Skip to content

Commit

Permalink
Version Bump 4.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkingserious committed Dec 15, 2015
1 parent 6f46520 commit ebf68af
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [v4.0.2] - (2015-12-15) ##
### Added
- Tests for API Keys endpoint [POST, PATCH, DELETE]

## [v4.0.1] - (2015-12-03) ##
### Fixed
- HTTP 406 Not Acceptable Errors [#177](https://github.com/sendgrid/sendgrid-php/issues/177)
Expand Down
36 changes: 35 additions & 1 deletion README.md
Expand Up @@ -317,7 +317,7 @@ Permission denied, wrong credentials

[APIKeys](https://sendgrid.com/docs/API_Reference/Web_API_v3/API_Keys/index.html)

List all API Keys belonging to the authenticated user.
List all API Keys belonging to the authenticated user. [GET]

```php
require 'vendor/autoload.php';
Expand All @@ -329,6 +329,40 @@ print("Status Code: " . $response->getStatusCode() . "\n");
print("Body: " . $response->getBody() . "\n");
```

Generate a new API Key for the authenticated user. [POST]

```php
require 'vendor/autoload.php';
Dotenv::load(__DIR__);
$sendgrid_apikey = getenv('SG_KEY');
$sendgrid = new Client($sendgrid_apikey);
$response = $sendgrid->api_keys->post("Key Name");
print("Status Code: " . $response->getStatusCode() . "\n");
print("Body: " . $response->getBody() . "\n");
```

Update the name of an existing API Key

```php
require 'vendor/autoload.php';
Dotenv::load(__DIR__);
$sendgrid_apikey = getenv('SG_KEY');
$sendgrid = new Client($sendgrid_apikey);
$response = $sendgrid->api_keys->patch("<API Key ID>", "Updated API Key Name");
print("Status Code: " . $response->getStatusCode() . "\n");
print("Body: " . $response->getBody() . "\n");
```
Revoke an existing API Key [DELETE]

```php
require 'vendor/autoload.php';
Dotenv::load(__DIR__);
$sendgrid_apikey = getenv('SG_KEY');
$sendgrid = new Client($sendgrid_apikey);
$response = $sendgrid->api_keys->delete("<API Key ID>");
print("Status Code: " . $response->getStatusCode() . "\n");
print("Body: " . $response->getBody() . "\n");

[ASMGroups](https://sendgrid.com/docs/API_Reference/Web_API_v3/Suppression_Management/groups.html)

Retrieve all suppression groups associated with the user.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
@@ -1,7 +1,7 @@
{
"name": "sendgrid/sendgrid",
"description": "This library allows you to quickly and easily send emails through SendGrid using PHP.",
"version": "4.0.1",
"version": "4.0.2",
"homepage": "http://github.com/sendgrid/sendgrid-php",
"license": "MIT",
"keywords": ["SendGrid", "sendgrid", "email", "send", "grid"],
Expand Down
2 changes: 1 addition & 1 deletion example_v3.php
Expand Up @@ -39,7 +39,7 @@
print("Status Code: " . $response->getStatusCode() . "\n");
print("Body: " . $response->getBody() . "\n");
$response = $sendgrid->api_keys->delete("<API Key ID>);
$response = $sendgrid->api_keys->delete("<API Key ID>");
print("Status Code: " . $response->getStatusCode() . "\n");
print("Body: " . $response->getBody() . "\n");
Expand Down
2 changes: 1 addition & 1 deletion lib/Client.php
Expand Up @@ -6,7 +6,7 @@

class Client
{
const VERSION = '4.0.1';
const VERSION = '4.0.2';

protected
$namespace = 'SendGrid',
Expand Down
2 changes: 1 addition & 1 deletion lib/SendGrid.php
Expand Up @@ -2,7 +2,7 @@

class SendGrid
{
const VERSION = '4.0.1';
const VERSION = '4.0.2';

protected
$namespace = 'SendGrid',
Expand Down
2 changes: 1 addition & 1 deletion test/unit/SendGridTest.php
Expand Up @@ -12,7 +12,7 @@ public function tearDown()

public function testVersion()
{
$this->assertEquals(SendGrid::VERSION, '4.0.1');
$this->assertEquals(SendGrid::VERSION, '4.0.2');
$this->assertEquals(json_decode(file_get_contents(__DIR__ . '/../../composer.json'))->version, SendGrid::VERSION);
}

Expand Down
46 changes: 46 additions & 0 deletions test/unit/resources/api_keysTest.php
Expand Up @@ -13,4 +13,50 @@ public function testGET()
$this->assertEquals($code, $response->getStatusCode());
$this->assertEquals($body, $response->getBody());
}

public function testPOST()
{
$code = 200;
$headers = array('Content-Type' => 'application/json');
$body = '{
"api_key": "SG.xxxxxxxx.yyyyyyyy",
"api_key_id": "xxxxxxxx",
"name": "My API Key",
"scopes": [
"mail.send",
"alerts.create",
"alerts.read"
]
}';
$sendgrid = $this->buildClient($code, $headers, $body);
$response = $sendgrid->api_keys->post("My API Key");
$this->assertEquals($code, $response->getStatusCode());
$this->assertEquals($body, $response->getBody());
}

public function testPATCH()
{
$code = 200;
$headers = array('Content-Type' => 'application/json');
$body = '{
"api_key_id": "qfTQ6KG0QBiwWdJ0-pCLCA",
"name": "A New Hope"
}';
$sendgrid = $this->buildClient($code, $headers, $body);
$response = $sendgrid->api_keys->patch("qfTQ6KG0QBiwWdJ0-pCLCA", "Magic Key Updated");
$this->assertEquals($code, $response->getStatusCode());
$this->assertEquals($body, $response->getBody());
}

public function testDELETE()
{
$code = 204;
$headers = '';
$body = '';
$sendgrid = $this->buildClient($code, $headers, $body);
$response = $sendgrid->api_keys->delete("qfTQ6KG0QBiwWdJ0-pCLCA");
$this->assertEquals($code, $response->getStatusCode());
$this->assertEquals($body, $response->getBody());
}

}

0 comments on commit ebf68af

Please sign in to comment.