trycourier / courier
PHP implementation of Courier's API as an SDK. With additional support for Laravel 5.8+
Installs: 495 439
Dependents: 0
Suggesters: 0
Security: 0
Stars: 11
Watchers: 17
Forks: 4
Open Issues: 4
Requires
- php: >=7.4
- ext-json: *
- php-http/discovery: ^1.0
- php-http/httplug: ^2.0
- php-http/message-factory: ^1.0
- psr/http-client-implementation: ^1.0
- psr/http-message: ^1.0
Requires (Dev)
- guzzlehttp/psr7: ^2.1
- illuminate/support: >=6.0
- php-coveralls/php-coveralls: ^2.1
- php-http/message: ^1.0
- php-http/mock-client: ^1.0
- phpunit/phpunit: ^8.1
- symfony/var-dumper: ^4.2
- vimeo/psalm: ^3.3
- dev-main
- v2.0.0
- v1.12.0
- v1.10.0
- v1.9.0
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.0
- v1.0.0
- dev-C-10109/php-sdk-accounts-tenants
- dev-user-account-api
- dev-chris/c-9805-update-php-sdk
- dev-i18n1.1
- dev-C-6481
- dev-drew/c-6187-add-support-for-token-management-to-php
- dev-v2-support
- dev-C-4964
- dev-drew/c-3969-php-sdk-automations-api
- dev-more-endpoints
- dev-C-3747-notifications-api
- dev-add-template
This package is auto-updated.
Last update: 2024-11-09 21:32:34 UTC
README
Courier PHP SDK supporting:
- Send API
- Messages API
- Profiles API
- Preferences API
- Events API
- Brands API
- Lists API
- Notifications API
- Automations API
- Bulk API
- Audiences API
- Token Management API
- Audit Events API
- Tenants API
- Users 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-json
Installation
This library uses HTTPlug as HTTP client. HTTPlug is an abstraction that allows this library to support different HTTP Clients. Therefore, you need to provide it with an client and/or adapter for the HTTP library you prefer. You can find all the available adapters in Packagist. This documentation assumes you use the Guzzle Client, but you can replace it with any client that you prefer.
The recommended way to install courier-php is through Composer:
composer require trycourier/courier guzzlehttp/guzzle
Configuration
Instantiate the Courier client class with your authorization token OR username and password. Providing just an authorization token will generate a "Bearer" authorization header, while providing a username and password will generate a "Basic" (base64-encoded) authorization header
$client = new CourierClient("base-url", "authorization-token", "username", "password");
Options
Many methods allow the passing of optional data to the Courier endpoints. 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" => "courier.pigeon@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, string $brand = NULL, object $profile = NULL, object $data = NULL, object $preferences = NULL, object $override = NULL, string $idempotency_key = NULL): object
(Send API)sendEnhancedNotification(object $message, string $idempotency_key = NULL): object
(Send API)sendNotificationToList(string $event, string $list = NULL, string $pattern = NULL, string $brand = NULL, object $data = NULL, object $override = NULL, string $idempotency_key = NULL): object
(Send list API)
Messages API
cancelMessage(string $message_id): object
[?]getMessages(string $cursor = NULL, string $event = NULL, string $list = NULL, string $message_id = NULL, string $notification = NULL, string $recipient = NULL): object
[?]getMessage(string $message_id): object
[?]getMessageHistory(string $message_id, string $type = NULL): object
[?]
Lists API
getLists(string $cursor = NULL, string $pattern = NULL): object
[?]getList(string $list_id): object
[?]putList(string $list_id, string $name): object
[?]deleteList(string $list_id): object
[?]restoreList(string $list_id): object
[?]getListSubscriptions(string $list_id, string $cursor = NULL): object
[?]subscribeMultipleRecipientsToList(string $list_id, array $recipients): object
[?]subscribeRecipientToList(string $list_id, string $recipient_id): object
[?]deleteListSubscription(string $list_id, string $recipient_id): object
[?]
Brands API
getBrands(string $cursor = NULL): object
[?]createBrand(string $id = NULL, string $name, object $settings, object $snippets = NULL, string $idempotency_key = NULL): object
[?]getBrand(string $brand_id): object
[?]replaceBrand(string $brand_id, string $name, object $settings, object $snippets = NULL): object
[?]deleteBrand(string $brand_id): object
[?]
Events API
getEvents(): object
[?]getEvent(string $event_id): object
[?]putEvent(string $event_id, string $id, string $type): object
[?]
Profiles API
getProfile(string $recipient_id): object
[?]upsertProfile(string $recipient_id, object $profile): object
[?]patchProfile(string $recipient_id, array $patch): object
[?]replaceProfile(string $recipient_id, object $profile): object
[?]getProfileLists(string $recipient_id, string $cursor = NULL): object
[?]
Preferences API
getPreferences(string $recipient_id, string $preferred_channel): object
[?]updatePreferences(string $recipient_id, string $preferred_channel): object
[?]
Notifications API
listNotifications(string $cursor = NULL): object
getNotificationContent(string $id): object
getNotificationDraftContent(string $id): object
postNotificationVariations(string $id, array $blocks, array $channels = NULL): object
postNotificationDraftVariations(string $id, array $blocks, array $channels = NULL): object
getNotificationSubmissionChecks(string $id, string $submissionId): object
putNotificationSubmissionChecks(string $id, string $submissionId, array $checks): object
deleteNotificationSubmission(string $id, string $submissionId): object
Automations API
invokeAutomation(object $automation, string $brand = NULL, string $template = NULL, string $recipient = NULL, object $data = NULL, object $profile = NULL): object
[?]invokeAutomationFromTemplate(string $templateId, string $brand = NULL, object $data = NULL, object $profile = NULL, string $recipient = NULL, string $template = NULL): object
[?]getAutomationRun(string $runId): object
Bulk API
createBulkJob(object $message): object
(Create Bulk Job)ingestBulkJob(string $jobId, array $users): object
(Ingest Bulk Job Users)runBulkJob(string $jobId): object
(Run Bulk Job)getBulkJob(string $jobId): object
(Get Bulk Job)getBulkJobUsers(string $jobId): object
(Get Bulk Job Users)
Audiences API
putAudience(object $audience): object
(Create Audience)getAudience(string $audienceId): object
(Get Audience)getAudienceMembers(string $audienceId): object
(List audience members)getAudiences(): object
(List audiences)
Token Management API
putUserTokens(string $user_id, array $tokens): object
(Put User Tokens)putUserToken(string $user_id, array $token): object
(Put User Token)patchUserToken(string $user_id, string $token, array $patch): object
(Patch User Token)getUserToken(string $user_id, string $token): object
(Get User Token)getUserTokens(string $user_id): object
(Get User Tokens)
Audit Events API
getAuditEvent(string $audit_event_id): object
(Get Audit Event)listAuditEvents(string $cursor = NULL): object
(List Audit Events)
Accounts API (only on v1.12.0)
getAccount(): object
(Get Account)listAccounts(string $cursor = NULL): object
(List Accounts)putAccount(string $account_id, object $account): object
(Put Account)deleteAccount(string $account_id): object
(Delete Account)
Tenants API (v2.0.0+)
getTenant(): object
(Get Tenant)listTenants(string $cursor = NULL): object
(List Tenants)putTenant(string $tenant_id, object $tenant): object
(Put Tenant)deleteTenant(string $tenant_id): object
(Delete Tenant)
Users API
putUser(): object
(Put User)putUserTenants(): object
(Put User Tenants)
Errors
All unsuccessful (non 2xx) responses will throw a CourierRequestException
. The full response object is available via the getResponse()
method.