-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New Components - krispcall #13867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
New Components - krispcall #13867
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e9ee165
krispcall init
luancazarine f3356fc
[Components] KrispCall #12729
luancazarine 11d6354
pnpm update
luancazarine 23cf812
Merge branch 'master' into issue-12729
luancazarine af8d508
Update components/krispcall/sources/common/base.mjs
luancazarine 832eb60
fix doc links
luancazarine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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; | ||
| }, | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.