Skip to content

Commit 050194d

Browse files
authored
Merge branch 'master' into issue-13863
2 parents a61dd11 + 8d0cefa commit 050194d

File tree

28 files changed

+716
-126
lines changed

28 files changed

+716
-126
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export default {
2+
type: "app",
3+
app: "algodocs",
4+
propDefinitions: {},
5+
methods: {
6+
// this.$auth contains connected account data
7+
authKeys() {
8+
console.log(Object.keys(this.$auth));
9+
},
10+
},
11+
};

components/algodocs/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@pipedream/algodocs",
3+
"version": "0.0.1",
4+
"description": "Pipedream AlgoDocs Components",
5+
"main": "algodocs.app.mjs",
6+
"keywords": [
7+
"pipedream",
8+
"algodocs"
9+
],
10+
"homepage": "https://pipedream.com/apps/algodocs",
11+
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
12+
"publishConfig": {
13+
"access": "public"
14+
}
15+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import krispcall from "../../krispcall.app.mjs";
2+
3+
export default {
4+
key: "krispcall-add-contact",
5+
name: "Add Contact",
6+
description: "Creates a new contact. [See the documentation](https://documenter.getpostman.com/view/32476792/2sA3dxFCaL)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
krispcall,
11+
number: {
12+
propDefinition: [
13+
krispcall,
14+
"number",
15+
],
16+
},
17+
name: {
18+
propDefinition: [
19+
krispcall,
20+
"name",
21+
],
22+
optional: true,
23+
},
24+
email: {
25+
propDefinition: [
26+
krispcall,
27+
"email",
28+
],
29+
optional: true,
30+
},
31+
company: {
32+
propDefinition: [
33+
krispcall,
34+
"company",
35+
],
36+
optional: true,
37+
},
38+
address: {
39+
propDefinition: [
40+
krispcall,
41+
"address",
42+
],
43+
optional: true,
44+
},
45+
},
46+
async run({ $ }) {
47+
const response = await this.krispcall.createContact({
48+
$,
49+
data: {
50+
number: this.number,
51+
name: this.name,
52+
email: this.email,
53+
company: this.company,
54+
address: this.address,
55+
},
56+
});
57+
$.export("$summary", `Successfully created contact with ID ${response.id}`);
58+
return response;
59+
},
60+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { parseObject } from "../../common/utils.mjs";
2+
import krispcall from "../../krispcall.app.mjs";
3+
4+
export default {
5+
key: "krispcall-delete-contact",
6+
name: "Delete Contact",
7+
description: "Deletes a list of contacts. [See the documentation](https://documenter.getpostman.com/view/32476792/2sA3dxFCaL)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
krispcall,
12+
contactIds: {
13+
propDefinition: [
14+
krispcall,
15+
"contactIds",
16+
],
17+
},
18+
},
19+
async run({ $ }) {
20+
const parsedContacts = parseObject(this.contactIds);
21+
const response = await this.krispcall.deleteContacts({
22+
$,
23+
data: {
24+
contacts: parsedContacts,
25+
},
26+
});
27+
$.export("$summary", `Successfully deleted ${parsedContacts.length} contact(s)`);
28+
return response;
29+
},
30+
};
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import krispcall from "../../krispcall.app.mjs";
2+
3+
export default {
4+
key: "krispcall-new-mms",
5+
name: "Send New MMS",
6+
description: "Send a new MMS to a contact. [See the documentation](https://documenter.getpostman.com/view/32476792/2sA3dxFCaL)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
krispcall,
11+
fromNumber: {
12+
propDefinition: [
13+
krispcall,
14+
"fromNumber",
15+
],
16+
},
17+
toNumber: {
18+
propDefinition: [
19+
krispcall,
20+
"toNumber",
21+
],
22+
},
23+
content: {
24+
propDefinition: [
25+
krispcall,
26+
"content",
27+
],
28+
optional: true,
29+
},
30+
medias: {
31+
propDefinition: [
32+
krispcall,
33+
"medias",
34+
],
35+
},
36+
},
37+
async run({ $ }) {
38+
const response = await this.krispcall.sendMMS({
39+
$,
40+
data: {
41+
from_number: this.fromNumber,
42+
to_number: this.toNumber,
43+
content: this.content,
44+
medias: this.medias,
45+
},
46+
});
47+
$.export("$summary", `Successfully sent MMS from ${this.fromNumber} to ${this.toNumber}`);
48+
return response;
49+
},
50+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import krispcall from "../../krispcall.app.mjs";
2+
3+
export default {
4+
key: "krispcall-new-sms",
5+
name: "Send New SMS",
6+
description: "Send a new SMS to a number. [See the documentation](https://documenter.getpostman.com/view/32476792/2sA3dxFCaL)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
krispcall,
11+
fromNumber: {
12+
propDefinition: [
13+
krispcall,
14+
"fromNumber",
15+
],
16+
},
17+
toNumber: {
18+
propDefinition: [
19+
krispcall,
20+
"toNumber",
21+
],
22+
},
23+
content: {
24+
propDefinition: [
25+
krispcall,
26+
"content",
27+
],
28+
},
29+
},
30+
async run({ $ }) {
31+
const response = await this.krispcall.sendSMS({
32+
$,
33+
data: {
34+
from_number: this.fromNumber,
35+
to_number: this.toNumber,
36+
content: this.content,
37+
},
38+
});
39+
$.export("$summary", `Successfully sent SMS to ${this.toNumber}`);
40+
return response;
41+
},
42+
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export const parseObject = (obj) => {
2+
if (!obj) return undefined;
3+
4+
if (Array.isArray(obj)) {
5+
return obj.map((item) => {
6+
if (typeof item === "string") {
7+
try {
8+
return JSON.parse(item);
9+
} catch (e) {
10+
return item;
11+
}
12+
}
13+
return item;
14+
});
15+
}
16+
if (typeof obj === "string") {
17+
try {
18+
return JSON.parse(obj);
19+
} catch (e) {
20+
return obj;
21+
}
22+
}
23+
return obj;
24+
};
Lines changed: 140 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,146 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "krispcall",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
number: {
8+
type: "string",
9+
label: "Number",
10+
description: "The phone number of the contact",
11+
},
12+
name: {
13+
type: "string",
14+
label: "Name",
15+
description: "The name of the contact",
16+
optional: true,
17+
},
18+
email: {
19+
type: "string",
20+
label: "Email",
21+
description: "The email of the contact",
22+
optional: true,
23+
},
24+
company: {
25+
type: "string",
26+
label: "Company",
27+
description: "The company of the contact",
28+
optional: true,
29+
},
30+
address: {
31+
type: "string",
32+
label: "Address",
33+
description: "The address of the contact",
34+
optional: true,
35+
},
36+
fromNumber: {
37+
type: "string",
38+
label: "From Number",
39+
description: "The number from which the SMS/MMS is sent",
40+
async options() {
41+
const numbers = await this.listNumbers();
42+
return numbers.map(({ number }) => number);
43+
},
44+
},
45+
toNumber: {
46+
type: "string",
47+
label: "To Number",
48+
description: "The recipient's phone number",
49+
},
50+
content: {
51+
type: "string",
52+
label: "Content",
53+
description: "The content of the SMS/MMS",
54+
},
55+
medias: {
56+
type: "string[]",
57+
label: "Medias",
58+
description: "The media files for MMS. It should be a valid url field and size should not be greater than 5mb. Upto 5 media lists are supported. Media url should be starting from https. Media url should be public accessible and content-type should be supported by KrispCall app.",
59+
},
60+
contactIds: {
61+
type: "string[]",
62+
label: "Contact Numbers",
63+
description: "The phone numbers of the contacts to delete",
64+
async options() {
65+
const contacts = await this.listContacts();
66+
return contacts.map(({
67+
name, contact_number: number,
68+
}) => ({
69+
label: `${name} ${number}`,
70+
value: number,
71+
}));
72+
},
73+
},
74+
},
575
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
76+
_baseUrl() {
77+
return `${this.$auth.url}/api/v1/platform/pipedream`;
78+
},
79+
_headers() {
80+
return {
81+
"X-API-Key": `${this.$auth.api_key}`,
82+
};
83+
},
84+
_makeRequest({
85+
$ = this, path, ...opts
86+
}) {
87+
return axios($, {
88+
url: this._baseUrl() + path,
89+
headers: this._headers(),
90+
...opts,
91+
});
92+
},
93+
listNumbers() {
94+
return this._makeRequest({
95+
path: "/get-numbers",
96+
});
97+
},
98+
listContacts() {
99+
return this._makeRequest({
100+
path: "/get-contacts",
101+
});
102+
},
103+
createContact(opts = {}) {
104+
return this._makeRequest({
105+
method: "POST",
106+
path: "/add-contact",
107+
...opts,
108+
});
109+
},
110+
sendSMS(opts = {}) {
111+
return this._makeRequest({
112+
method: "POST",
113+
path: "/send-sms",
114+
...opts,
115+
});
116+
},
117+
sendMMS(opts = {}) {
118+
return this._makeRequest({
119+
method: "POST",
120+
path: "/send-mms",
121+
...opts,
122+
});
123+
},
124+
deleteContacts(opts = {}) {
125+
return this._makeRequest({
126+
method: "DELETE",
127+
path: "/delete-contacts",
128+
...opts,
129+
});
130+
},
131+
createWebhook(opts = {}) {
132+
return this._makeRequest({
133+
method: "POST",
134+
path: "/subscribe",
135+
...opts,
136+
});
137+
},
138+
deleteWebhook(opts = {}) {
139+
return this._makeRequest({
140+
method: "DELETE",
141+
path: "/unsubscribe",
142+
...opts,
143+
});
9144
},
10145
},
11-
};
146+
};

0 commit comments

Comments
 (0)