-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* krispcall init * [Components] KrispCall #12729 Sources - New Contact (Instant) - New SMS or MMS (Instant) - New Voicemail (Instant) Actions - Add Contact - Delete Contact - New SMS - New MMS * pnpm update * Update components/krispcall/sources/common/base.mjs Co-authored-by: Jorge Cortes <[email protected]> * fix doc links --------- Co-authored-by: Jorge Cortes <[email protected]>
- Loading branch information
1 parent
0acdb8b
commit 97af485
Showing
15 changed files
with
539 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import krispcall from "../../krispcall.app.mjs"; | ||
|
||
export default { | ||
key: "krispcall-add-contact", | ||
name: "Add Contact", | ||
description: "Creates a new contact. [See the documentation](https://documenter.getpostman.com/view/32476792/2sA3dxFCaL)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
krispcall, | ||
number: { | ||
propDefinition: [ | ||
krispcall, | ||
"number", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
krispcall, | ||
"name", | ||
], | ||
optional: true, | ||
}, | ||
email: { | ||
propDefinition: [ | ||
krispcall, | ||
"email", | ||
], | ||
optional: true, | ||
}, | ||
company: { | ||
propDefinition: [ | ||
krispcall, | ||
"company", | ||
], | ||
optional: true, | ||
}, | ||
address: { | ||
propDefinition: [ | ||
krispcall, | ||
"address", | ||
], | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.krispcall.createContact({ | ||
$, | ||
data: { | ||
number: this.number, | ||
name: this.name, | ||
email: this.email, | ||
company: this.company, | ||
address: this.address, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully created contact with ID ${response.id}`); | ||
return response; | ||
}, | ||
}; |
30 changes: 30 additions & 0 deletions
30
components/krispcall/actions/delete-contact/delete-contact.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { parseObject } from "../../common/utils.mjs"; | ||
import krispcall from "../../krispcall.app.mjs"; | ||
|
||
export default { | ||
key: "krispcall-delete-contact", | ||
name: "Delete Contact", | ||
description: "Deletes a list of contacts. [See the documentation](https://documenter.getpostman.com/view/32476792/2sA3dxFCaL)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
krispcall, | ||
contactIds: { | ||
propDefinition: [ | ||
krispcall, | ||
"contactIds", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const parsedContacts = parseObject(this.contactIds); | ||
const response = await this.krispcall.deleteContacts({ | ||
$, | ||
data: { | ||
contacts: parsedContacts, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully deleted ${parsedContacts.length} contact(s)`); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import krispcall from "../../krispcall.app.mjs"; | ||
|
||
export default { | ||
key: "krispcall-new-mms", | ||
name: "Send New MMS", | ||
description: "Send a new MMS to a contact. [See the documentation](https://documenter.getpostman.com/view/32476792/2sA3dxFCaL)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
krispcall, | ||
fromNumber: { | ||
propDefinition: [ | ||
krispcall, | ||
"fromNumber", | ||
], | ||
}, | ||
toNumber: { | ||
propDefinition: [ | ||
krispcall, | ||
"toNumber", | ||
], | ||
}, | ||
content: { | ||
propDefinition: [ | ||
krispcall, | ||
"content", | ||
], | ||
optional: true, | ||
}, | ||
medias: { | ||
propDefinition: [ | ||
krispcall, | ||
"medias", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.krispcall.sendMMS({ | ||
$, | ||
data: { | ||
from_number: this.fromNumber, | ||
to_number: this.toNumber, | ||
content: this.content, | ||
medias: this.medias, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully sent MMS from ${this.fromNumber} to ${this.toNumber}`); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import krispcall from "../../krispcall.app.mjs"; | ||
|
||
export default { | ||
key: "krispcall-new-sms", | ||
name: "Send New SMS", | ||
description: "Send a new SMS to a number. [See the documentation](https://documenter.getpostman.com/view/32476792/2sA3dxFCaL)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
krispcall, | ||
fromNumber: { | ||
propDefinition: [ | ||
krispcall, | ||
"fromNumber", | ||
], | ||
}, | ||
toNumber: { | ||
propDefinition: [ | ||
krispcall, | ||
"toNumber", | ||
], | ||
}, | ||
content: { | ||
propDefinition: [ | ||
krispcall, | ||
"content", | ||
], | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.krispcall.sendSMS({ | ||
$, | ||
data: { | ||
from_number: this.fromNumber, | ||
to_number: this.toNumber, | ||
content: this.content, | ||
}, | ||
}); | ||
$.export("$summary", `Successfully sent SMS to ${this.toNumber}`); | ||
return response; | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export const parseObject = (obj) => { | ||
if (!obj) return undefined; | ||
|
||
if (Array.isArray(obj)) { | ||
return obj.map((item) => { | ||
if (typeof item === "string") { | ||
try { | ||
return JSON.parse(item); | ||
} catch (e) { | ||
return item; | ||
} | ||
} | ||
return item; | ||
}); | ||
} | ||
if (typeof obj === "string") { | ||
try { | ||
return JSON.parse(obj); | ||
} catch (e) { | ||
return obj; | ||
} | ||
} | ||
return obj; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,146 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "krispcall", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
number: { | ||
type: "string", | ||
label: "Number", | ||
description: "The phone number of the contact", | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "The name of the contact", | ||
optional: true, | ||
}, | ||
email: { | ||
type: "string", | ||
label: "Email", | ||
description: "The email of the contact", | ||
optional: true, | ||
}, | ||
company: { | ||
type: "string", | ||
label: "Company", | ||
description: "The company of the contact", | ||
optional: true, | ||
}, | ||
address: { | ||
type: "string", | ||
label: "Address", | ||
description: "The address of the contact", | ||
optional: true, | ||
}, | ||
fromNumber: { | ||
type: "string", | ||
label: "From Number", | ||
description: "The number from which the SMS/MMS is sent", | ||
async options() { | ||
const numbers = await this.listNumbers(); | ||
return numbers.map(({ number }) => number); | ||
}, | ||
}, | ||
toNumber: { | ||
type: "string", | ||
label: "To Number", | ||
description: "The recipient's phone number", | ||
}, | ||
content: { | ||
type: "string", | ||
label: "Content", | ||
description: "The content of the SMS/MMS", | ||
}, | ||
medias: { | ||
type: "string[]", | ||
label: "Medias", | ||
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.", | ||
}, | ||
contactIds: { | ||
type: "string[]", | ||
label: "Contact Numbers", | ||
description: "The phone numbers of the contacts to delete", | ||
async options() { | ||
const contacts = await this.listContacts(); | ||
return contacts.map(({ | ||
name, contact_number: number, | ||
}) => ({ | ||
label: `${name} ${number}`, | ||
value: number, | ||
})); | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return `${this.$auth.url}/api/v1/platform/pipedream`; | ||
}, | ||
_headers() { | ||
return { | ||
"X-API-Key": `${this.$auth.api_key}`, | ||
}; | ||
}, | ||
_makeRequest({ | ||
$ = this, path, ...opts | ||
}) { | ||
return axios($, { | ||
url: this._baseUrl() + path, | ||
headers: this._headers(), | ||
...opts, | ||
}); | ||
}, | ||
listNumbers() { | ||
return this._makeRequest({ | ||
path: "/get-numbers", | ||
}); | ||
}, | ||
listContacts() { | ||
return this._makeRequest({ | ||
path: "/get-contacts", | ||
}); | ||
}, | ||
createContact(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/add-contact", | ||
...opts, | ||
}); | ||
}, | ||
sendSMS(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/send-sms", | ||
...opts, | ||
}); | ||
}, | ||
sendMMS(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/send-mms", | ||
...opts, | ||
}); | ||
}, | ||
deleteContacts(opts = {}) { | ||
return this._makeRequest({ | ||
method: "DELETE", | ||
path: "/delete-contacts", | ||
...opts, | ||
}); | ||
}, | ||
createWebhook(opts = {}) { | ||
return this._makeRequest({ | ||
method: "POST", | ||
path: "/subscribe", | ||
...opts, | ||
}); | ||
}, | ||
deleteWebhook(opts = {}) { | ||
return this._makeRequest({ | ||
method: "DELETE", | ||
path: "/unsubscribe", | ||
...opts, | ||
}); | ||
}, | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@pipedream/krispcall", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream KrispCall Components", | ||
"main": "krispcall.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.1" | ||
} | ||
} | ||
} |
Oops, something went wrong.