@greenapsis/greenetwork-notification-system-sdk
v1.3.0
Published
Javascript SDK for Greenetwork Notification System
Downloads
14
Readme
Greenetwork Notification Service SDK
The Greenetwork Notification Service SDK allows developers to easily integrate and utilize the API of the Greenetwork notification system. This SDK provides a convenient way to send notifications, manage subscriptions, and handle various notification-related tasks.
Getting Started
To get started with the Greenetwork Notification Service SDK, follow the installation instructions below:
Install the SDK using your preferred package manager:
$ npm install @greenapsis/greenetwork-notification-system-sdk
Import the SDK into your project:
import GreenetworkNotification from '@greenapsis/greenetwork-notification-system-sdk';
Configure the SDK with your API credentials:
await GreenetworkNotification.config({ ApiAccessId: 'YOUR_API_KEY', ApiSecretKey: 'YOUR_API_SECRET', });
Start using the SDK to send notifications:
// Send a notification GreenetworkNotification.sendNotification('Hello, world!', 'projectId');
Usage
The SDK allows subscribing endpoints
(which can be different protocols) to receive notifications. The endpoints
subscribe to projects, and will only receive notifications from the projects to which they are subscribed.
Subscription
Currently, two types of endpoints
can be subscribed:
sms
(must include the country code)email
To achieve this, you just need to add the endpoint
, the project id, and specify the type of protocol:
GreenetworkNotification.subscribeProjectNotification(
'project',
'+529999999999',
'sms'
);
[!NOTE] It's important to consider that the SDK does not yet validate if the endpoint has the correct format according to its protocol.
[!NOTE] The SDK does not validate if the referenced project is existing and valid.
Remove subscription
To prevent an endpoint
from continuing to receive notifications from a project, it is only necessary to remove the subscription.
To do this, you need to use this method specifying only the endpoint
and the project you want to unsubscribe from.
GreenetworkNotification.removeProjectSubscription('project', '+529999999999');
Send Notification
At the time of sending a notification, all endpoints that are subscribed to the project will receive this notification.
GreenetworkNotification.sendNotification('Hello World!', 'projectId');
Happy coding! 👨💻