ato-machine-messaging

1.0.0 • Public • Published

Messaging SDK

[node js] SDK for messaging

Installation

# From npm server
$ npm install messaging

# From local machine
$ npm install local_path_of_package

Methods


• Get message: 
getMessage(event, action, {key1: "param1", key2: "param2",...}, is_regex_match, language)

• List of messages: 
getMessages([{event: 'event_1", action: 'action_1', {key1: "param1", key2: "param2",...}},{event: 'event_2", action: 'action_2', {key1: "param1", key2: "param2",...}},...], is_regex_match, language)

• Dispatch event: 
dispatchEvent(event, action, {key1: "param1", key2: "param2",...}, is_regex_match, language)

Example

Import sdk
require('messaging')({client_id:'CLIENT_ID',client_secret:'CLIENT_SECRET'});
Get Message
await Messaging.getMessageList("task_status", "started", {key1: "tag1", key2: "tag2"}, false, "en");

Result:
{
    "id": 7,
    "event": "task_status",
    "action": "started",
    "param": "param1,param2",
    "note": null,
    "redirection": null,
    "created": "1635424248326",
    "additional_data": null,
    "messageLocale": {
        "id": 11,
        "message_id": 7,
        "locale": "en",
        "message": "Your project task has been updated to status started"
    }
}
Get Messages
await Messaging.getMessages([{event:"task_status",action:"started",param:{key1: "tag1", key2: "tag2"}},{event:"task_status",action:"completed",param:{key1: "tag1", key2: "tag2"}}], false, "en"));

Result:
[
    {
        "id": 8,
        "event": "task_status",
        "action": "completed",
        "param": "param1,param2",
        "note": null,
        "redirection": null,
        "created": "1635483229763",
        "additional_data": null,
        "messageLocale": {
            "id": 15,
            "message_id": 8,
            "locale": "en",
            "message": "Your project task has been updated to status completed"
        }
    },
    {
        "id": 7,
        "event": "task_status",
        "action": "started",
        "param": "param1,param2",
        "note": null,
        "redirection": null,
        "created": "1635424248326",
        "additional_data": null,
        "messageLocale": {
            "id": 11,
            "message_id": 7,
            "locale": "en",
            "message": "Your project task has been updated to status started"
        }
    }
]
Dispatch Event
var messageEvent = await Messaging.dispatchEvent("task_status", "started", {key1: "tag1", key2: "tag2"}, false, "en");

Result:
success

Readme

Keywords

none

Package Sidebar

Install

npm i ato-machine-messaging

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

14.3 kB

Total Files

13

Last publish

Collaborators

  • atologist.dhruv2