stephanecoinon/sendgrid-activity

PHP Client for SendGrid e-Mail Activity API

dev-master 2019-08-05 21:50 UTC

This package is auto-updated.

Last update: 2024-11-06 09:54:18 UTC


README

Latest Version on Packagist Build Status Quality Score Total Downloads

Based on SendGrid API v3.

Installation

You can install the package via composer:

composer require stephanecoinon/sendgrid-activity

This package is agnostic but also can integrate with Laravel (tested on 5.8 but should work >=5.5).

Just add your SendGrid API key in .env:

SENDGRID_API_KEY=your_API_key_here

Then update config/services.php and you're good to go:

return [

    // ...

    'sendgrid' => [
        'key' => env('SENDGRID_API_KEY'),
    ],

];

Usage

use StephaneCoinon\SendGridActivity\Requests\MessagesRequest;
use StephaneCoinon\SendGridActivity\SendGrid;

// First, get SendGrid API client instance
// In vanilla PHP
$api = new SendGrid('your API key here');
// Or in Laravel
$api = app(SendGrid::class);

// Fetch the message activity
$messages = $api->request(
    (new MessagesRequest)
        ->limit(50)
        ->query('status="delivered"')
);
// Note: $messages will be a \Illuminate\Support\Collection when in a Laravel app

// Find a message by id
$message = $api->request(MessagesRequest::find('message-id'));

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email me@stephanecoinon.co.uk instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

PHP Package Boilerplate

This package was generated using the PHP Package Boilerplate.