0.0.4 • Published 2 years ago

@konso/messaging v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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: [ 'alex.lvovich@indevalbs.de'],
  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'
})
ParameterTypeRequired
apiKeystringtrue
apiURLstringtrue
bucketIdstringtrue
appNamestringfalse
envstringfalse
tagsArrayfalse

Methods


sendMessage

sendMessage(extraOptions: MessagingExtraOptions)

Parameters

ParameterTypeRequiredValue
extraOptionsObjecttrue{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

ParameterTypeRequiredValue
eventNamestringtrue'onSuccessful', 'onError' or keys of LogEvent object
callbackfunctiontrue(text: string) => void