[node js] SDK for messaging
# From npm server
$ npm install messaging
# From local machine
$ npm install local_path_of_package
• 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)
require('messaging')({client_id:'CLIENT_ID',client_secret:'CLIENT_SECRET'});
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"
}
}
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"
}
}
]
var messageEvent = await Messaging.dispatchEvent("task_status", "started", {key1: "tag1", key2: "tag2"}, false, "en");
Result:
success