Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import gupshup from "../../gupshup.app.mjs";

export default {
key: "gupshup-send-template-message",
name: "Send Template Message",
description: "Send a template message. Requires a paid Gupshup account. [See the documentation](https://docs.gupshup.io/reference/sending-text-template)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: false,
openWorldHint: true,
readOnlyHint: false,
},
props: {
gupshup,
info: {

Check warning on line 16 in components/gupshup/actions/send-template-message/send-template-message.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop info must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 16 in components/gupshup/actions/send-template-message/send-template-message.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop info must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "Note: This action requires a paid Gupshup account.",
},
source: {
type: "string",
label: "Source",
description: "Sender Whatsapp Number",
},
destination: {
type: "string",
label: "Destination",
description: "Receiver Whatsapp Number",
},
templateId: {
propDefinition: [
gupshup,
"templateId",
],
},
params: {
type: "string[]",
label: "Parameters",
description: "List of template parameters",
},
},
async run({ $ }) {
const response = await this.gupshup.sendTemplateMessage({
$,
data: {
source: this.source,
destination: this.destination,
template: {
id: this.templateId,
params: this.params,
},
},
});
if (response.status === "success") {
$.export("$summary", `Successfully sent template message to ${this.destination}`);
}
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import gupshup from "../../gupshup.app.mjs";

export default {
key: "gupshup-update-subscription",
name: "Update Subscription",
description: "Update a subscription. Requires a paid Gupshup account. [See the documentation](https://docs.gupshup.io/reference/updateanexisitngsubscription)",
version: "0.0.1",
type: "action",
annotations: {
destructiveHint: true,
openWorldHint: true,
readOnlyHint: false,
},
props: {
gupshup,
info: {

Check warning on line 16 in components/gupshup/actions/update-subscription/update-subscription.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop info must have a description. See https://pipedream.com/docs/components/guidelines/#props

Check warning on line 16 in components/gupshup/actions/update-subscription/update-subscription.mjs

View workflow job for this annotation

GitHub Actions / Lint Code Base

Component prop info must have a label. See https://pipedream.com/docs/components/guidelines/#props
type: "alert",
alertType: "info",
content: "Note: This action requires a paid Gupshup account.",
},
subscriptionId: {
type: "string",
label: "Subscription ID",
description: "The ID of the subscription to update",
},
modes: {
type: "string",
label: "Modes",
description: "The modes of the subscription",
},
url: {
type: "string",
label: "URL",
description: "The subscription URL",
},
version: {
type: "integer",
label: "Version",
description: "The version of the subscription",
},
active: {
type: "boolean",
label: "Active",
description: "Whether the subscription is active",
},
},
async run({ $ }) {
const response = await this.gupshup.updateSubscription({
$,
subscriptionId: this.subscriptionId,
data: {
modes: this.modes,
url: this.url,
version: this.version,
active: this.active,
},
});
if (response.status === "success") {
$.export("$summary", `Successfully updated subscription ${this.subscriptionId}`);
}
return response;
},
};
66 changes: 62 additions & 4 deletions components/gupshup/gupshup.app.mjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,69 @@
import { axios } from "@pipedream/platform";

export default {
type: "app",
app: "gupshup",
propDefinitions: {},
propDefinitions: {
templateId: {
type: "string",
label: "Template ID",
description: "The ID of the template to use",
async options({ page }) {
const { templates } = await this.listTemplates({
params: {
pageNo: page,
},
});
return templates?.map(({ id }) => id) || [];
},
},
},
methods: {
// this.$auth contains connected account data
authKeys() {
console.log(Object.keys(this.$auth));
_baseUrl() {
return "https://api.gupshup.io";
},
_appName() {
return this.$auth.appname;
},
_makeRequest({
$ = this, path, headers, ...opts
}) {
return axios($, {
url: `${this._baseUrl()}${path}`,
headers: {
...headers,
"apikey": `${this.$auth.apikey}`,
},
...opts,
});
},
listTemplates(opts = {}) {
return this._makeRequest({
path: `/wa/app/${this._appName()}/template`,
...opts,
});
},
sendTemplateMessage(opts = {}) {
return this._makeRequest({
method: "POST",
path: "/wa/api/v1/template/msg",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
...opts,
});
},
updateSubscription({
subscriptionId, ...opts
}) {
return this._makeRequest({
method: "PUT",
path: `/wa/app/${this._appName()}/subscription/${subscriptionId}`,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
...opts,
});
},
},
};
5 changes: 4 additions & 1 deletion components/gupshup/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/gupshup",
"version": "0.0.3",
"version": "0.1.0",
"description": "Pipedream Gupshup Components",
"main": "gupshup.app.mjs",
"keywords": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <support@pipedream.com> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.1.1"
}
}
42 changes: 17 additions & 25 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading