-
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.
Browse files
Browse the repository at this point in the history
* Added actions * Update components/gainsight_px/gainsight_px.app.mjs * Update components/gainsight_px/actions/create-account/create-account.mjs * pnpm-lock * pnpm-lock * Fixing action name --------- Co-authored-by: Leo Vu <[email protected]>
- Loading branch information
1 parent
70c3710
commit 9230bf1
Showing
7 changed files
with
309 additions
and
8 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
components/gainsight_px/actions/create-account/create-account.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,68 @@ | ||
import app from "../../gainsight_px.app.mjs"; | ||
|
||
export default { | ||
key: "gainsight_px-create-account", | ||
name: "Create Account", | ||
description: "Create a new account with the given data. [See the documentation](https://gainsightpx.docs.apiary.io/#reference/accounts/v1accounts/create-account)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
id: { | ||
propDefinition: [ | ||
app, | ||
"id", | ||
], | ||
}, | ||
name: { | ||
propDefinition: [ | ||
app, | ||
"name", | ||
], | ||
}, | ||
propertyKeys: { | ||
propDefinition: [ | ||
app, | ||
"propertyKeys", | ||
], | ||
}, | ||
countryName: { | ||
propDefinition: [ | ||
app, | ||
"countryName", | ||
], | ||
}, | ||
stateName: { | ||
propDefinition: [ | ||
app, | ||
"stateName", | ||
], | ||
}, | ||
city: { | ||
propDefinition: [ | ||
app, | ||
"city", | ||
], | ||
}, | ||
}, | ||
|
||
async run({ $ }) { | ||
const response = await this.app.createAccount({ | ||
$, | ||
data: { | ||
id: this.id, | ||
name: this.name, | ||
propertyKeys: this.propertyKeys, | ||
location: { | ||
countryName: this.countryName, | ||
stateName: this.stateName, | ||
city: this.city, | ||
}, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created account with the name '${this.name}'`); | ||
|
||
return response; | ||
}, | ||
}; |
68 changes: 68 additions & 0 deletions
68
components/gainsight_px/actions/create-user/create-user.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,68 @@ | ||
import app from "../../gainsight_px.app.mjs"; | ||
|
||
export default { | ||
key: "gainsight_px-create-user", | ||
name: "Create User", | ||
description: "Creates a new user with the given data. [See the documentation](https://gainsightpx.docs.apiary.io/#reference/users/v1users/create-user)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
id: { | ||
propDefinition: [ | ||
app, | ||
"id", | ||
], | ||
label: "Identify ID", | ||
description: "Identifier of the user", | ||
}, | ||
propertyKeys: { | ||
propDefinition: [ | ||
app, | ||
"propertyKeys", | ||
], | ||
}, | ||
type: { | ||
propDefinition: [ | ||
app, | ||
"type", | ||
], | ||
}, | ||
email: { | ||
propDefinition: [ | ||
app, | ||
"email", | ||
], | ||
}, | ||
firstName: { | ||
propDefinition: [ | ||
app, | ||
"firstName", | ||
], | ||
}, | ||
lastName: { | ||
propDefinition: [ | ||
app, | ||
"lastName", | ||
], | ||
}, | ||
}, | ||
|
||
async run({ $ }) { | ||
const response = await this.app.createUser({ | ||
$, | ||
data: { | ||
identifyId: this.id, | ||
propertyKeys: this.propertyKeys, | ||
type: this.type, | ||
email: this.email, | ||
firstName: this.firstName, | ||
lastName: this.lastName, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully created user with ID '${this.id}'`); | ||
|
||
return response; | ||
}, | ||
}; |
31 changes: 31 additions & 0 deletions
31
components/gainsight_px/actions/delete-user/delete-user.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,31 @@ | ||
import app from "../../gainsight_px.app.mjs"; | ||
|
||
export default { | ||
key: "gainsight_px-delete-user", | ||
name: "Delete User", | ||
description: "Deletes a user with he specified identifyId. [See the documentation](https://gainsightpx.docs.apiary.io/#reference/users/v1usersdelete/delete-user)", | ||
version: "0.0.1", | ||
type: "action", | ||
props: { | ||
app, | ||
identifyId: { | ||
propDefinition: [ | ||
app, | ||
"identifyId", | ||
], | ||
}, | ||
}, | ||
|
||
async run({ $ }) { | ||
const response = await this.app.deleteUser({ | ||
$, | ||
data: { | ||
identifyId: this.identifyId, | ||
}, | ||
}); | ||
|
||
$.export("$summary", `Successfully deleted user with ID ${this.identifyId}`); | ||
|
||
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,8 @@ | ||
export default { | ||
USER_TYPES: [ | ||
"LEAD", | ||
"USER", | ||
"VISITOR", | ||
"EMPTY_USER_TYPE", | ||
], | ||
}; |
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,131 @@ | ||
import { axios } from "@pipedream/platform"; | ||
import contants from "./common/contants.mjs"; | ||
|
||
export default { | ||
type: "app", | ||
app: "gainsight_px", | ||
propDefinitions: {}, | ||
propDefinitions: { | ||
id: { | ||
type: "string", | ||
label: "ID", | ||
description: "Unique identifier for the account", | ||
}, | ||
name: { | ||
type: "string", | ||
label: "Name", | ||
description: "Name associated with the account", | ||
}, | ||
propertyKeys: { | ||
type: "string[]", | ||
label: "Property Keys", | ||
description: "At least one tag key. The key can be found by clicking on `Administration` >`Set Up` > `Products` > Tag Key. For example: AP-xxx-1", | ||
}, | ||
countryName: { | ||
type: "string", | ||
label: "County Name", | ||
description: "Name of the country associated with the account", | ||
optional: true, | ||
}, | ||
stateName: { | ||
type: "string", | ||
label: "State Name", | ||
description: "Name of the State associated with the account", | ||
optional: true, | ||
}, | ||
city: { | ||
type: "string", | ||
label: "City", | ||
description: "City associated with the account", | ||
optional: true, | ||
}, | ||
identifyId: { | ||
type: "string", | ||
label: "Identify ID", | ||
description: "Identifier of the user", | ||
async options() { | ||
const response = await this.listUsers(); | ||
const userIds = response.users; | ||
return userIds.map(({ | ||
identifyId, email, | ||
}) => ({ | ||
label: email, | ||
value: identifyId, | ||
})); | ||
}, | ||
}, | ||
type: { | ||
type: "string", | ||
label: "User Type", | ||
description: "Type of the user", | ||
options: contants.USER_TYPES, | ||
optional: true, | ||
}, | ||
email: { | ||
type: "string", | ||
label: "Email", | ||
description: "Email of the user", | ||
optional: true, | ||
}, | ||
firstName: { | ||
type: "string", | ||
label: "First Name", | ||
description: "First Name of the user", | ||
optional: true, | ||
}, | ||
lastName: { | ||
type: "string", | ||
label: "Last Name", | ||
description: "Last Name of the user", | ||
optional: true, | ||
}, | ||
}, | ||
methods: { | ||
// this.$auth contains connected account data | ||
authKeys() { | ||
console.log(Object.keys(this.$auth)); | ||
_baseUrl() { | ||
return this.$auth.base_endpoint; | ||
}, | ||
async _makeRequest(opts = {}) { | ||
const { | ||
$ = this, | ||
path, | ||
headers, | ||
...otherOpts | ||
} = opts; | ||
return axios($, { | ||
...otherOpts, | ||
url: this._baseUrl() + path, | ||
headers: { | ||
...headers, | ||
"X-APTRINSIC-API-KEY": `${this.$auth.api_key}`, | ||
"Accept": "application/json", | ||
}, | ||
}); | ||
}, | ||
async createAccount(args = {}) { | ||
return this._makeRequest({ | ||
path: "/accounts", | ||
method: "post", | ||
...args, | ||
}); | ||
}, | ||
async deleteUser(args = {}) { | ||
return this._makeRequest({ | ||
path: "/users/delete", | ||
method: "delete", | ||
...args, | ||
}); | ||
}, | ||
async createUser(args = {}) { | ||
return this._makeRequest({ | ||
path: "/users", | ||
method: "post", | ||
...args, | ||
}); | ||
}, | ||
async listUsers(args = {}) { | ||
return this._makeRequest({ | ||
path: "/users", | ||
...args, | ||
}); | ||
}, | ||
}, | ||
}; |
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/gainsight_px", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "Pipedream Gainsight PX Components", | ||
"main": "gainsight_px.app.mjs", | ||
"keywords": [ | ||
|
@@ -11,5 +11,8 @@ | |
"author": "Pipedream <[email protected]> (https://pipedream.com/)", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"@pipedream/platform": "^3.0.3" | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.