digs / courier-sdk-php
PHP implementation of Courier's API as an SDK. With additional support for Laravel 5.8+
Installs: 1 449 726
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 3
Open Issues: 1
Requires
- php: >=7.2
- ext-curl: *
- ext-json: *
- nimbly/shuttle: ^0.3
Requires (Dev)
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^8.1
- symfony/var-dumper: ^4.2
- vimeo/psalm: ^3.3
This package is auto-updated.
Last update: 2025-01-09 13:10:08 UTC
README
Courier PHP SDK supporting:
- Send API
- Messages API
- Profiles API
- Preferences API
Official Courier API docs
For a full description of request and response payloads and properties, please see the official Courier API docs.
Requirements
- PHP 7.2+
- ext-curl
- ext-json
Installation
composer require digs/courier-sdk-php
Configuration
Instantiate the Courier client class with your authorization and (optional) username. Providing just a authorization token will generate a "Bearer" authorization header, while providing a username will generate a "Basic" (base64-encoded) authorization header
$client = new Courier("authorization-token", "username");
Options
Many methods allow the passing of optional data to the Courier endoint. This data should be an associative array of key/value pairs. The exact options supported are dependent on the endpoint being called. Please refer to the official Courier documentation for more information.
$profile = [ "firstname" => "Johnny", "lastname" => "Appleseed", "email" => "johnny.appleseed@mail.com" ];
Methods
For a full description of request and response payloads and properties, please see the official Courier API docs.
Send API
sendNotification(string $event, string $recipient, array $profile = [], array $data = [], array $preferences = [], array $overrides = []): object
[?]
Messages API
getMessage(string $message_id): object
[?]
Profiles API
getProfile(string $recipient_id): object
[?]upsertProfile(string $recipient_id, array $profile_attributes): object
[?]replaceProfile(string $recipient_id, array $profile_attributes): object
[?]patchProfile(string $recipient_id, array $patch): object
[?]
Preferences API
getPreferences(string $recipient_id, string $preferred_channel): object
[?]updatePreferences(string $recipient_id, string $preferred_channel): object
[?]
Errors
All unsuccessfull (non 2xx) responses will throw a CourierRequestException
. The full response object is available via the getResponse()
method.