@konso/messaging
v0.0.4
Published
@konso client for messaging
Downloads
7
Keywords
Readme
Messaging
Installation
npm i @konso/messaging
Example
import { createMessagingClient } from "@konso/messaging";
let client = createMessagingClient({
apiURL: 'https://devapis.konso.io',
bucketId: '1fc41560',
apiKey: 'REa9xeOvk6fRxAcNEyebk+5nC5LnbeCr+bJTBpoLm5E=',
appName: 'test'
})
client.on(LogEvents.onSuccessful, (text) => { console.log(text) })
.on(LogEvents.onError, (text) => console.error(text));
client.sendMessage({
recepients: [ '[email protected]'],
messageType: 1
})
createMessagingClient
createMessagingClient - the function takes a parameters object and returns an instance of the Messaging class
const client = createMessagingClient({
apiKey: 'REa9xeOvk6fRxAcNEyebk+5nC5LnbeCr+bJTBpoLm5E=',
apiURL: 'https://devapis.konso.io',
bucketId: '1fc41560',
appName: 'test'
})
| Parameter | Type | Required | |:----------|---------------|:---------| | apiKey | string | true | | apiURL | string | true | | bucketId | string | true | | appName | string | false | | env | string | false | | tags | Array | false |
Methods
sendMessage
sendMessage(extraOptions: MessagingExtraOptions)
Parameters
| Parameter | Type | Required | Value | |--------------|--------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | extraOptions | Object | true | {recepients: Array<string>,messageType: number (1 = Email, 2 = SMS, 3 = Push),subject?: string,plainBase64Body?: string,htmlBase64Body?: string,delay?: number,tags?: Array<string>,correlationId?: string} |
on
on(eventName: LogEvents, callback: (text: string) => void);
Parameters
| Parameter | Type | Required | Value | |-----------|----------|----------|------------------------------------------------------| | eventName | string | true | 'onSuccessful', 'onError' or keys of LogEvent object | | callback | function | true | (text: string) => void |