Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding method chaining into the Mail helpers' setters #287

Closed
wants to merge 18 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/).

## [6.0.0] - 2017-05-23 ##
### BREAKING CHANGE
- Pull #287: Adding method chaining into the Mail helpers' setters
- Updated to the [PSR-4 autoloader](http://www.php-fig.org/psr/psr-4/)
- To use the various classes, you will need to update your function calls (e.g. /SendGrid becomes SendGrid with the appropriate `use` statement), please see the [README](https://github.com/sendgrid/sendgrid-php/blob/master/README.md) or [USAGE](https://github.com/sendgrid/sendgrid-php/blob/master/USAGE.md) or [examples](https://github.com/sendgrid/sendgrid-php/tree/master/examples) for details
- The [Mail Helper](https://github.com/sendgrid/sendgrid-php/tree/master/lib/helpers/mail) is broken up in separate files and it's namespace is updated to be `SendGrid\Helper\Mail`
- Method chaining is added to the Mail Helper
- Thanks to [vitya1](https://github.com/vitya1) for the PR!

## [5.5.1] - 2017-05-18 ##
### Fixed
- Pull #396: Use `print_r` instead of `echo` on Arrays
Expand Down
47 changes: 29 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Please see our announcement regarding [breaking changes](https://github.com/send

**This library allows you to quickly and easily use the SendGrid Web API v3 via PHP.**

Version 5.X.X of this library provides full support for all SendGrid [Web API v3](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) endpoints, including the new [v3 /mail/send](https://sendgrid.com/blog/introducing-v3mailsend-sendgrids-new-mail-endpoint).
Version 6.X.X of this library provides full support for all SendGrid [Web API v3](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) endpoints, including the new [v3 /mail/send](https://sendgrid.com/blog/introducing-v3mailsend-sendgrids-new-mail-endpoint).

This library represents the beginning of a new path for SendGrid. We want this library to be community driven and SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/sendgrid/sendgrid-php/issues) and [pull requests](https://github.com/sendgrid/sendgrid-php/blob/master/CONTRIBUTING.md) or simply upvote or comment on existing issues or pull requests.

Expand Down Expand Up @@ -49,7 +49,7 @@ Add SendGrid to your `composer.json` file. If you are not using [Composer](http:
```json
{
"require": {
"sendgrid/sendgrid": "~5.5"
"sendgrid/sendgrid": "~6.0"
}
}
```
Expand Down Expand Up @@ -79,17 +79,22 @@ The following is the minimum needed code to send an email with the [/mail/send H
// If you are using Composer (recommended)
require 'vendor/autoload.php';

// If you are not using Composer
// If you are not using Composer (recommended)
// require("path/to/sendgrid-php/sendgrid-php.php");

$from = new SendGrid\Email("Example User", "test@example.com");
use SendGrid\SendGrid;
use SendGrid\Helper\Mail\Email;
use SendGrid\Helper\Mail\Content;
use SendGrid\Helper\Mail\Mail;

$from = new Email("Example User", "test@example.com");
$subject = "Sending with SendGrid is Fun";
$to = new SendGrid\Email("Example User", "test@example.com");
$content = new SendGrid\Content("text/plain", "and easy to do anywhere, even with PHP");
$mail = new SendGrid\Mail($from, $subject, $to, $content);
$to = new Email("Example User", "test@example.com");
$content = new Content("text/plain", "and easy to do anywhere, even with PHP");
$mail = new Mail($from, $subject, $to, $content);

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
$sg = new SendGrid($apiKey);

$response = $sg->client->mail()->send()->post($mail);
echo $response->statusCode();
Expand All @@ -108,9 +113,11 @@ The following is the minimum needed code to send an email without the /mail/send
// If you are using Composer (recommended)
require 'vendor/autoload.php';

// If you are not using Composer
// If you are not using Composer (recommended)
// require("path/to/sendgrid-php/sendgrid-php.php");

use SendGrid\SendGrid;

$request_body = json_decode('{
"personalizations": [
{
Expand All @@ -134,7 +141,7 @@ $request_body = json_decode('{
}');

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
$sg = new SendGrid($apiKey);

$response = $sg->client->mail()->send()->post($request_body);
echo $response->statusCode();
Expand All @@ -149,17 +156,19 @@ print_r($response->headers());
// If you are using Composer (recommended)
require 'vendor/autoload.php';

use SendGrid\SendGrid;

// If you are not using Composer
// require("path/to/sendgrid-php/sendgrid-php.php");

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
$sg = new SendGrid($apiKey);

$response = $sg->client->suppression()->bounces()->get();

print $response->statusCode();
print $response->headers();
print $response->body();
echo $response->statusCode();
print_r($response->headers());
echo $response->body();
```

## General v3 Web API Usage (Without Fluent Interface)
Expand All @@ -169,17 +178,19 @@ print $response->body();
// If you are using Composer (recommended)
require 'vendor/autoload.php';

use SendGrid\SendGrid;

// If you are not using Composer
// require("path/to/sendgrid-php/sendgrid-php.php");

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
$sg = new SendGrid($apiKey);

$response = $sg->client->_("suppression/bounces")->get();

print $response->statusCode();
print $response->headers();
print $response->body();
echo $response->statusCode();
print_r($response->headers());
echo $response->body();
```

<a name="usage"></a>
Expand Down
Loading