@fibonalabs/just-communicate
v0.6.1
Published
Using npm:
Downloads
3
Readme
Installing
Using npm:
$ npm install @fibonalabs/just-communicate
Using yarn:
$ yarn add @fibonalabs/just-communicate
Usage
You can create a new instance of just-communicate.
import { create } from '@fibonalabs/just-communicate'
const notificationInstance = create({
clientId: <CLIENT_ID>,
})
notificationInstance.sendEmail({
sender: string | string[],
body: string,
subject: string,
})
Push Notification
notificationInstance.sendPushNotification({
sender: string | string[],
title: string,
body: string,
target: 'token' | 'topic' | 'condition'
})
Send OTP
notificationInstance.sendOTP({
sender: string,
templateId: string,
})
Resend OTP
notificationInstance.resendOTP({
sender: string,
retryType: 'text' | 'voice',
})
Verify OTP
notificationInstance.verifyOTP({
sender: string,
otp: string,
})
SMS
notificationInstance.sendSMS({
sender: string,
templateId: string,
})
Configs
Just Communicate Config
| name | Type | Description | |
| -------- | -------- | -------------------------------- | -------- |
| clientId | string
| - | required |
| baseURL | string
| Use Client ID instead of baseURL | optional |
| name | Type | Description | |
| ----------- | ----------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -------- |
| sender | string \| string[]
| - | required |
| data | {string:string}
| - | optional |
| body | string
| - | required |
| subject | string
| The subject of the e-mail | required |
| subjectData | {string:string}
| - | optional |
| cc | string \| Address \| Array<string \| Address>
| Comma separated list or an array of recipients e-mail addresses that will appear on the Cc: field | optional |
| bcc | string \| Address \| Array<string \| Address>
| Comma separated list or an array of recipients e-mail addresses that will appear on the Bcc: field - | optional |
| attachments | AttachmentType[]
| An array of attachment objects- | optional |
Address
| name | Type | Description | |
| ------- | -------- | ----------- | -------- |
| name | string
| - | required |
| address | string
| - | required |
AttachmentType
| name | Type | Description | |
| ------------------ | -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| filename | string \| false
| filename to be reported as the name of the attached file, use of unicode is allowed. If you do not want to use a filename, set this value as false, otherwise a filename is generated automatically | optional |
| content | string
| String, Buffer or a Stream contents for the attachments | optional |
| href | string
| an URL to the file (data uris are allowed as well) | optional |
| httpHeaders | Headers
| optional HTTP headers to pass on with the href request, eg. {authorization: "bearer ..."}attachments | optional |
| contentType | string
| optional content type for the attachment, if not set will be derived from the filename property | optional |
| contentDisposition | 'attachment' \| 'inline'
| optional content disposition type for the attachment, defaults to ‘attachment’ | optional |
| cid | string
| optional content id for using inline images in HTML message source. Using cid sets the default contentDisposition to 'inline' and moves the attachment into a multipart/related mime node, so use it only if you actually want to use this attachment as an embedded image | optional |
| encoding | string
| If set and content is string, then encodes the content to a Buffer using the specified encoding. Example values: base64, hex, binary etc. Useful if you want to use binary attachments in a JSON formatted e-mail object | optional |
| headers | Headers
| custom headers for the attachment node. Same usage as with message headers | optional |
| raw | string
| an optional value that overrides entire node content in the mime message. If used then all other options set for this node are ignored. | optional |
| path | string
| path to a file or an URL (data uris are allowed as well) if you want to stream the file instead of including it (better for larger attachments) | optional |
Push Notification
| name | Type | Description | |
| ---------- | ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| sender | string \| string[]
| - | required |
| data | {string:string}
| - | optional |
| body | string
| The notification's body text. | required |
| title | string
| The notification's title. | required |
| target | 'token' \| 'topic' \| 'condition'
| Registration token to send a message to. | required |
| image | string
| Contains the URL of an image that is going to be downloaded on the device and displayed in a notification.JPEG, PNG, BMP have full support across platforms.Animated GIF and video only work on iOS. WebP and HEIF have varying levels of support across platforms and platform versions. Android has 1MB image size limit. | optional |
| android | AndroidConfig
| Input only. Android specific options for messages sent through FCM connection server. | optional |
| webpush | WebPushConfig
| Input only. Webpush protocol options. | optional |
| apns | ApnsConfig
| Input only. Apple Push Notification Service specific options. | optional |
| fcmOptions | FCMOptions
| Input only. Template for FCM SDK feature options to use across all platforms. | optional |
AndroidConfig
Refer https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#AndroidConfig
WebPushConfig
Refer https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#WebpushConfig
ApnsConfig
Refer https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages#ApnsConfig
Send SMS
| name | Type | Description | |
| ------------- | ----------------------------- | -------------------- | -------- |
| sender | string \| string[]
| - | required |
| data | {string:string}
| - | optional |
| recipientData | {[sender]: {string:string}}
| Sender Specific Data | optional |