Skip to content

Commit

Permalink
[Components] gainsight_px #14359 (#14467)
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
lcaresia and vunguyenhung authored Nov 7, 2024
1 parent 70c3710 commit 9230bf1
Show file tree
Hide file tree
Showing 7 changed files with 309 additions and 8 deletions.
68 changes: 68 additions & 0 deletions components/gainsight_px/actions/create-account/create-account.mjs
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 components/gainsight_px/actions/create-user/create-user.mjs
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 components/gainsight_px/actions/delete-user/delete-user.mjs
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;
},
};
8 changes: 8 additions & 0 deletions components/gainsight_px/common/contants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export default {
USER_TYPES: [
"LEAD",
"USER",
"VISITOR",
"EMPTY_USER_TYPE",
],
};
128 changes: 124 additions & 4 deletions components/gainsight_px/gainsight_px.app.mjs
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,
});
},
},
};
7 changes: 5 additions & 2 deletions components/gainsight_px/package.json
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": [
Expand All @@ -11,5 +11,8 @@
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.3"
}
}
}
7 changes: 5 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9230bf1

Please sign in to comment.