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

Add PushNotificationsInterface #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/PushNotifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Used to publish notifications to the Pusher Push Notifications API
* http://www.pusher.com/push-notifications
*/
class PushNotifications {
class PushNotifications implements PushNotificationsInterface {
const SDK_VERSION = "2.0.0";
const MAX_INTERESTS = 100;
const MAX_INTEREST_LENGTH = 164;
Expand Down
63 changes: 63 additions & 0 deletions src/PushNotificationsInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace Pusher\PushNotifications;

/**
* Used to publish notifications to the Pusher Push Notifications API
*
* @see http://www.pusher.com/push-notifications
*/
interface PushNotificationsInterface
{
/**
* Sends broadcast notifications to groups of subscribed devices using Device Interests.
*
* @param array $interests
* Array of interests to send the push notification to, ranging from 1 to 100 per publish request.
* @param array<string> $publishRequest
* An array of parameters to add to the request body
*
* @return mixed
* An array containing the publish response body.
*
* @throws \Exception
* @see https://pusher.com/docs/beams/concepts/device-interests
*/
public function publishToInterests(array $interests, array $publishRequest): mixed;

/**
* Securely send notifications to individual users of your application using Authenticated Users.
*
* @param array $userIds
* Array of ids of users to send the push notification to, ranging from 1 to 1000 per publish request.
* @param array<string> $publishRequest
* An array of parameters to add to the request body
*
* @return mixed
* An array containing the publish response body.
*
* @throws \Exception
*/
public function publishToUsers(array $userIds, array $publishRequest): mixed;

/**
* Remove the given user (and all of their devices) from Beams. This user will no longer receive any notifications and all state stored about their devices will be deleted.
*
* @param string $userId
* The id of the user you would like to remove from Beams.
*
* @throws \Exception
*/
public function deleteUser(string $userId): void;

/**
* Generate a Beams auth token to allow a user to associate their device with their user id. The token is valid for 24 hours.
*
* @param string $userId
* The id of the user you would like to generate a Beams auth token for.
*
* @return array
* An array containing the token key.
*/
public function generateToken(string $userId): array;
}