forked from PipedreamHQ/pipedream
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GoDial PipedreamHQ#3639 (PipedreamHQ#5996)
* Go Dial * Added actions and sources * Package.json new line * Fixed * Fixed bug on select teams * Fixed bug on select teams
- Loading branch information
Showing
8 changed files
with
281 additions
and
21 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,52 @@ | ||
import godial from "../../app/godial.app.mjs"; | ||
|
||
export default { | ||
name: "Add Contact", | ||
version: "0.0.1", | ||
key: "godial-add-contact", | ||
description: "Adds a contact. [See docs here](https://godial.stoplight.io/docs/godial/b3A6MzAzMTY2Mg-contact-add)", | ||
type: "action", | ||
props: { | ||
godial, | ||
listId: { | ||
propDefinition: [ | ||
godial, | ||
"listId", | ||
], | ||
}, | ||
phone: { | ||
type: "string", | ||
label: "Phone", | ||
description: "The phone of the contact to add", | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "The name of the contact to add", | ||
optional: true, | ||
}, | ||
email: { | ||
type: "string", | ||
label: "Email", | ||
description: "The email of the contact to add", | ||
optional: true, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
const response = await this.godial.addContact({ | ||
$, | ||
data: { | ||
listId: this.listId, | ||
name: this.name, | ||
email: this.email, | ||
phone: this.phone, | ||
}, | ||
}); | ||
|
||
if (response) { | ||
$.export("$summary", `Successfully added contact with ID ${response.id}`); | ||
} | ||
|
||
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,78 @@ | ||
import { ConfigurationError } from "@pipedream/platform"; | ||
import godial from "../../app/godial.app.mjs"; | ||
import constants from "../common/constants.mjs"; | ||
|
||
export default { | ||
name: "Add Member", | ||
version: "0.0.1", | ||
key: "godial-add-member", | ||
description: "Adds a member. [See docs here](https://godial.stoplight.io/docs/godial/b3A6MzAzMTY1Ng-accounts-add)", | ||
type: "action", | ||
props: { | ||
godial, | ||
teamsId: { | ||
label: "Teams ID", | ||
type: "string[]", | ||
propDefinition: [ | ||
godial, | ||
"teamId", | ||
], | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "The name of the member to add", | ||
}, | ||
email: { | ||
type: "string", | ||
label: "Email", | ||
description: "The email of the member to add", | ||
optional: true, | ||
}, | ||
username: { | ||
type: "string", | ||
label: "Username", | ||
description: "The username of the member to add", | ||
}, | ||
password: { | ||
type: "string", | ||
label: "Password", | ||
description: "The password of the member to add", | ||
secret: true, | ||
}, | ||
role: { | ||
type: "string", | ||
label: "Role", | ||
description: "The role of the member to add", | ||
options: constants.ROLES, | ||
}, | ||
}, | ||
async run({ $ }) { | ||
console.log(this.teamsId); | ||
this.teamsId = typeof this.teamsId === "string" | ||
? JSON.parse(this.teamsId) | ||
: this.teamsId; | ||
|
||
if (!this.teamsId || !this.teamsId?.length) { | ||
throw new ConfigurationError("TeamsId is required"); | ||
} | ||
|
||
const response = await this.godial.addMember({ | ||
$, | ||
data: { | ||
teamsId: this.teamsId, | ||
name: this.name, | ||
email: this.email, | ||
username: this.username, | ||
password: this.password, | ||
role: this.role, | ||
}, | ||
}); | ||
|
||
if (response) { | ||
$.export("$summary", `Successfully added member with ID ${response.id}`); | ||
} | ||
|
||
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,7 @@ | ||
export default { | ||
ROLES: [ | ||
"Manager", | ||
"SubManager", | ||
"Agent", | ||
], | ||
}; |
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,95 @@ | ||
import { axios } from "@pipedream/platform"; | ||
|
||
export default { | ||
type: "app", | ||
app: "godial", | ||
propDefinitions: { | ||
teamId: { | ||
label: "Team ID", | ||
description: "The team ID", | ||
type: "string", | ||
async options() { | ||
const teams = await this.getTeams(); | ||
|
||
return teams.map((team) => ({ | ||
value: team.id, | ||
label: team.name, | ||
})); | ||
}, | ||
}, | ||
listId: { | ||
label: "List ID", | ||
description: "The list ID", | ||
type: "string", | ||
async options() { | ||
const lists = await this.getLists(); | ||
|
||
return lists.map((list) => ({ | ||
value: list.id, | ||
label: list.name, | ||
})); | ||
}, | ||
}, | ||
}, | ||
methods: { | ||
_apiToken() { | ||
return this.$auth.api_token; | ||
}, | ||
_apiUrl() { | ||
return "https://enterprise.godial.cc/meta/api"; | ||
}, | ||
async _makeRequest({ | ||
$ = this, path, ...args | ||
}) { | ||
return axios($, { | ||
url: `${this._apiUrl()}${path}`, | ||
...args, | ||
params: { | ||
...args.params, | ||
access_token: this._apiToken(), | ||
}, | ||
}); | ||
}, | ||
async addList(args = {}) { | ||
return this._makeRequest({ | ||
path: "/externals/lists/add", | ||
method: "post", | ||
...args, | ||
}); | ||
}, | ||
async addContact(args = {}) { | ||
return this._makeRequest({ | ||
path: "/externals/contact/add", | ||
method: "post", | ||
...args, | ||
}); | ||
}, | ||
async addMember(args = {}) { | ||
return this._makeRequest({ | ||
path: "/externals/accounts/add", | ||
method: "post", | ||
...args, | ||
}); | ||
}, | ||
async getTeams(args = {}) { | ||
return this._makeRequest({ | ||
path: "/externals/team/list", | ||
...args, | ||
}); | ||
}, | ||
async getLists(args = {}) { | ||
return this._makeRequest({ | ||
path: "/externals/lists/list", | ||
...args, | ||
}); | ||
}, | ||
async getContacts({ | ||
listId, ...args | ||
}) { | ||
return this._makeRequest({ | ||
path: `/externals/contact/list/${listId}`, | ||
...args, | ||
}); | ||
}, | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
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,15 +1,12 @@ | ||
{ | ||
"name": "@pipedream/godial", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Pipedream GoDial Components", | ||
"main": "dist/app/godial.app.mjs", | ||
"main": "app/godial.app.mjs", | ||
"keywords": [ | ||
"pipedream", | ||
"godial" | ||
], | ||
"files": [ | ||
"dist" | ||
], | ||
"homepage": "https://pipedream.com/apps/godial", | ||
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
|
47 changes: 47 additions & 0 deletions
47
components/godial/sources/new-updated-contact/new-updated-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,47 @@ | ||
import godial from "../../app/godial.app.mjs"; | ||
import { DEFAULT_POLLING_SOURCE_TIMER_INTERVAL } from "@pipedream/platform"; | ||
|
||
export default { | ||
name: "New Updated Contact", | ||
version: "0.0.3", | ||
key: "godial-new-updated-contact", | ||
description: "Emit new event on a contact is updated.", | ||
type: "source", | ||
dedupe: "unique", | ||
props: { | ||
godial, | ||
db: "$.service.db", | ||
timer: { | ||
type: "$.interface.timer", | ||
static: { | ||
intervalSeconds: DEFAULT_POLLING_SOURCE_TIMER_INTERVAL, | ||
}, | ||
}, | ||
listId: { | ||
propDefinition: [ | ||
godial, | ||
"listId", | ||
], | ||
}, | ||
}, | ||
methods: { | ||
emitEvent(data) { | ||
if (!data.modifiedOn) { | ||
return; | ||
} | ||
|
||
this.$emit(data, { | ||
id: `${data.id} - ${data.modifiedOn}`, | ||
summary: `New contact updated with ID ${data.id}`, | ||
ts: Date.parse(data.modifiedOn), | ||
}); | ||
}, | ||
}, | ||
async run() { | ||
const contacts = await this.godial.getContacts({ | ||
listId: this.listId, | ||
}); | ||
|
||
contacts.reverse().forEach(this.emitEvent); | ||
}, | ||
}; |