0.6.1 • Published 2 years ago

@fibonalabs/just-communicate v0.6.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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>,
})

Email

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

nameTypeDescription
clientIdstring-required
baseURLstringUse Client ID instead of baseURLoptional

Email

nameTypeDescription
senderstring \| string[]-required
data{string:string}-optional
bodystring-required
subjectstringThe subject of the e-mailrequired
subjectData{string:string}-optional
ccstring \| Address \| Array<string \| Address>Comma separated list or an array of recipients e-mail addresses that will appear on the Cc: fieldoptional
bccstring \| Address \| Array<string \| Address>Comma separated list or an array of recipients e-mail addresses that will appear on the Bcc: field -optional
attachmentsAttachmentType[]An array of attachment objects-optional

Address

nameTypeDescription
namestring-required
addressstring-required

AttachmentType

nameTypeDescription
filenamestring \| falsefilename 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 automaticallyoptional
contentstringString, Buffer or a Stream contents for the attachmentsoptional
hrefstringan URL to the file (data uris are allowed as well)optional
httpHeadersHeadersoptional HTTP headers to pass on with the href request, eg. {authorization: "bearer ..."}attachmentsoptional
contentTypestringoptional content type for the attachment, if not set will be derived from the filename propertyoptional
contentDisposition'attachment' \| 'inline'optional content disposition type for the attachment, defaults to ‘attachment’optional
cidstringoptional 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 imageoptional
encodingstringIf 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 objectoptional
headersHeaderscustom headers for the attachment node. Same usage as with message headersoptional
rawstringan optional value that overrides entire node content in the mime message. If used then all other options set for this node are ignored.optional
pathstringpath 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

nameTypeDescription
senderstring \| string[]-required
data{string:string}-optional
bodystringThe notification's body text.required
titlestringThe notification's title.required
target'token' \| 'topic' \| 'condition'Registration token to send a message to.required
imagestringContains 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
androidAndroidConfigInput only. Android specific options for messages sent through FCM connection server.optional
webpushWebPushConfigInput only. Webpush protocol options.optional
apnsApnsConfigInput only. Apple Push Notification Service specific options.optional
fcmOptionsFCMOptionsInput 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

nameTypeDescription
senderstring \| string[]-required
data{string:string}-optional
recipientData{[sender]: {string:string}}Sender Specific Dataoptional
0.6.1

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.1

3 years ago

0.4.0

3 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.2.2

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago