Skip to content

Commit 2200fc5

Browse files
[Components] gainsight_px #14359 (#14467)
* 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]>
1 parent b4f0e5b commit 2200fc5

File tree

7 files changed

+309
-8
lines changed

7 files changed

+309
-8
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import app from "../../gainsight_px.app.mjs";
2+
3+
export default {
4+
key: "gainsight_px-create-account",
5+
name: "Create Account",
6+
description: "Create a new account with the given data. [See the documentation](https://gainsightpx.docs.apiary.io/#reference/accounts/v1accounts/create-account)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
id: {
12+
propDefinition: [
13+
app,
14+
"id",
15+
],
16+
},
17+
name: {
18+
propDefinition: [
19+
app,
20+
"name",
21+
],
22+
},
23+
propertyKeys: {
24+
propDefinition: [
25+
app,
26+
"propertyKeys",
27+
],
28+
},
29+
countryName: {
30+
propDefinition: [
31+
app,
32+
"countryName",
33+
],
34+
},
35+
stateName: {
36+
propDefinition: [
37+
app,
38+
"stateName",
39+
],
40+
},
41+
city: {
42+
propDefinition: [
43+
app,
44+
"city",
45+
],
46+
},
47+
},
48+
49+
async run({ $ }) {
50+
const response = await this.app.createAccount({
51+
$,
52+
data: {
53+
id: this.id,
54+
name: this.name,
55+
propertyKeys: this.propertyKeys,
56+
location: {
57+
countryName: this.countryName,
58+
stateName: this.stateName,
59+
city: this.city,
60+
},
61+
},
62+
});
63+
64+
$.export("$summary", `Successfully created account with the name '${this.name}'`);
65+
66+
return response;
67+
},
68+
};
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import app from "../../gainsight_px.app.mjs";
2+
3+
export default {
4+
key: "gainsight_px-create-user",
5+
name: "Create User",
6+
description: "Creates a new user with the given data. [See the documentation](https://gainsightpx.docs.apiary.io/#reference/users/v1users/create-user)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
id: {
12+
propDefinition: [
13+
app,
14+
"id",
15+
],
16+
label: "Identify ID",
17+
description: "Identifier of the user",
18+
},
19+
propertyKeys: {
20+
propDefinition: [
21+
app,
22+
"propertyKeys",
23+
],
24+
},
25+
type: {
26+
propDefinition: [
27+
app,
28+
"type",
29+
],
30+
},
31+
email: {
32+
propDefinition: [
33+
app,
34+
"email",
35+
],
36+
},
37+
firstName: {
38+
propDefinition: [
39+
app,
40+
"firstName",
41+
],
42+
},
43+
lastName: {
44+
propDefinition: [
45+
app,
46+
"lastName",
47+
],
48+
},
49+
},
50+
51+
async run({ $ }) {
52+
const response = await this.app.createUser({
53+
$,
54+
data: {
55+
identifyId: this.id,
56+
propertyKeys: this.propertyKeys,
57+
type: this.type,
58+
email: this.email,
59+
firstName: this.firstName,
60+
lastName: this.lastName,
61+
},
62+
});
63+
64+
$.export("$summary", `Successfully created user with ID '${this.id}'`);
65+
66+
return response;
67+
},
68+
};
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../gainsight_px.app.mjs";
2+
3+
export default {
4+
key: "gainsight_px-delete-user",
5+
name: "Delete User",
6+
description: "Deletes a user with he specified identifyId. [See the documentation](https://gainsightpx.docs.apiary.io/#reference/users/v1usersdelete/delete-user)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
identifyId: {
12+
propDefinition: [
13+
app,
14+
"identifyId",
15+
],
16+
},
17+
},
18+
19+
async run({ $ }) {
20+
const response = await this.app.deleteUser({
21+
$,
22+
data: {
23+
identifyId: this.identifyId,
24+
},
25+
});
26+
27+
$.export("$summary", `Successfully deleted user with ID ${this.identifyId}`);
28+
29+
return response;
30+
},
31+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default {
2+
USER_TYPES: [
3+
"LEAD",
4+
"USER",
5+
"VISITOR",
6+
"EMPTY_USER_TYPE",
7+
],
8+
};
Lines changed: 124 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,131 @@
1+
import { axios } from "@pipedream/platform";
2+
import contants from "./common/contants.mjs";
3+
14
export default {
25
type: "app",
36
app: "gainsight_px",
4-
propDefinitions: {},
7+
propDefinitions: {
8+
id: {
9+
type: "string",
10+
label: "ID",
11+
description: "Unique identifier for the account",
12+
},
13+
name: {
14+
type: "string",
15+
label: "Name",
16+
description: "Name associated with the account",
17+
},
18+
propertyKeys: {
19+
type: "string[]",
20+
label: "Property Keys",
21+
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",
22+
},
23+
countryName: {
24+
type: "string",
25+
label: "County Name",
26+
description: "Name of the country associated with the account",
27+
optional: true,
28+
},
29+
stateName: {
30+
type: "string",
31+
label: "State Name",
32+
description: "Name of the State associated with the account",
33+
optional: true,
34+
},
35+
city: {
36+
type: "string",
37+
label: "City",
38+
description: "City associated with the account",
39+
optional: true,
40+
},
41+
identifyId: {
42+
type: "string",
43+
label: "Identify ID",
44+
description: "Identifier of the user",
45+
async options() {
46+
const response = await this.listUsers();
47+
const userIds = response.users;
48+
return userIds.map(({
49+
identifyId, email,
50+
}) => ({
51+
label: email,
52+
value: identifyId,
53+
}));
54+
},
55+
},
56+
type: {
57+
type: "string",
58+
label: "User Type",
59+
description: "Type of the user",
60+
options: contants.USER_TYPES,
61+
optional: true,
62+
},
63+
email: {
64+
type: "string",
65+
label: "Email",
66+
description: "Email of the user",
67+
optional: true,
68+
},
69+
firstName: {
70+
type: "string",
71+
label: "First Name",
72+
description: "First Name of the user",
73+
optional: true,
74+
},
75+
lastName: {
76+
type: "string",
77+
label: "Last Name",
78+
description: "Last Name of the user",
79+
optional: true,
80+
},
81+
},
582
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
83+
_baseUrl() {
84+
return this.$auth.base_endpoint;
85+
},
86+
async _makeRequest(opts = {}) {
87+
const {
88+
$ = this,
89+
path,
90+
headers,
91+
...otherOpts
92+
} = opts;
93+
return axios($, {
94+
...otherOpts,
95+
url: this._baseUrl() + path,
96+
headers: {
97+
...headers,
98+
"X-APTRINSIC-API-KEY": `${this.$auth.api_key}`,
99+
"Accept": "application/json",
100+
},
101+
});
102+
},
103+
async createAccount(args = {}) {
104+
return this._makeRequest({
105+
path: "/accounts",
106+
method: "post",
107+
...args,
108+
});
109+
},
110+
async deleteUser(args = {}) {
111+
return this._makeRequest({
112+
path: "/users/delete",
113+
method: "delete",
114+
...args,
115+
});
116+
},
117+
async createUser(args = {}) {
118+
return this._makeRequest({
119+
path: "/users",
120+
method: "post",
121+
...args,
122+
});
123+
},
124+
async listUsers(args = {}) {
125+
return this._makeRequest({
126+
path: "/users",
127+
...args,
128+
});
9129
},
10130
},
11131
};

components/gainsight_px/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/gainsight_px",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Gainsight PX Components",
55
"main": "gainsight_px.app.mjs",
66
"keywords": [
@@ -11,5 +11,8 @@
1111
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
1212
"publishConfig": {
1313
"access": "public"
14+
},
15+
"dependencies": {
16+
"@pipedream/platform": "^3.0.3"
1417
}
15-
}
18+
}

pnpm-lock.yaml

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)