Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gupshup-whatsapp-sdk

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gupshup-whatsapp-sdk - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

66

dist/client.js

@@ -15,3 +15,3 @@ "use strict";

defaultHeaders: {
// "apikey": config.APP_KEY,
"apikey": config.APP_KEY,
"Content-Type": "application/x-www-form-urlencoded",

@@ -86,3 +86,24 @@ "Accept": "application/json",

sendReplyButtons(source, destination, sourceName, payload, button) {
let type = Object.assign(Object.assign({ "type": "quick_reply" }, payload), button);
let resultContent = '';
let resultOptions = '';
let entriesContent = Object.entries(payload.content);
entriesContent.map(([key, val], i, arr) => {
let message = resultContent;
if (arr.length - 1 === i) {
resultContent = message.concat(`"${key}": "${val}" `);
}
else {
resultContent = message.concat(`"${key}": "${val}", `);
}
});
let entriesOptions = button.options;
entriesOptions.map((e, i, arr) => {
let message = resultOptions;
if (arr.length - 1 === i) {
resultOptions = message.concat(`{"type": "${e.type}", "title": "${e.title}"} `);
}
else {
resultOptions = message.concat(`{"type": "${e.type}", "title": "${e.title}"}, `);
}
});
return this.http.post("/msg", new url_1.URLSearchParams({

@@ -93,6 +114,41 @@ channel: "whatsapp",

"src.name": sourceName,
message: `${type}`
message: `{ "type": "quick_reply", "content": { ${resultContent} }, "options": [ ${resultOptions} ] }`
}));
}
sendListMessage(source, destination, sourceName, payload) {
let resultItems = '';
let resultButtons = '';
let entriesItem = payload.items;
entriesItem.map((e, i, arr) => {
let message = resultItems;
let resultOptions = '';
let entriesOption = e.options;
entriesOption.map((option, j, array) => {
let messageOption = resultOptions;
if (array.length - 1 === j) {
resultOptions = messageOption.concat(`{"type": "${option.type}", "title": "${option.title}", "description": "${option.description}"} `);
}
else {
resultOptions = messageOption.concat(`{"type": "${option.type}", "title": "${option.title}", "description": "${option.description}"}, `);
}
});
if (arr.length - 1 === i) {
resultItems = message.concat(`{"title": "${e.title}", "subtitle": "${e.subtitle}", "options": [ ${resultOptions}] }`);
}
else {
resultItems = message.concat(`{"title": "${e.title}", "subtitle": "${e.subtitle}", "options": [ ${resultOptions}]}, `);
}
});
let entriesButton = payload.globalButtons;
entriesButton.map((e, i, arr) => {
let message = resultButtons;
if (arr.length - 1 === i) {
resultButtons = message.concat(`{"type": "${e.type}", "title": "${e.title}"} `);
}
else {
resultButtons = message.concat(`{"type": "${e.type}", "title": "${e.title}"}, `);
}
});
let test = `{ "type": "list", "body": "${payload.body}" , "title": "${payload.title}", "globalButtons" : [ ${resultButtons}], "items" : [ ${resultItems}] }`;
console.log(test);
return this.http.post("/msg", new url_1.URLSearchParams({

@@ -103,5 +159,3 @@ channel: "whatsapp",

"src.name": sourceName,
message: `{
${payload}
}`
message: `{ "type": "list", "title": "${payload.title}", "body": "${payload.body}", "globalButtons" : [ ${resultButtons}], "items" : [ ${resultItems}] }`
}));

@@ -108,0 +162,0 @@ }

2

package.json
{
"name": "gupshup-whatsapp-sdk",
"version": "0.1.1",
"version": "0.1.2",
"description": "NodeJS sdk for communicating with gupshup whatsapp api",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc