diff --git a/components/gong/actions/get-extensive-data/get-extensive-data.mjs b/components/gong/actions/get-extensive-data/get-extensive-data.mjs new file mode 100644 index 0000000000000..fc7d6a642c4b1 --- /dev/null +++ b/components/gong/actions/get-extensive-data/get-extensive-data.mjs @@ -0,0 +1,105 @@ +import app from "../../gong.app.mjs"; +import constants from "../../common/constants.mjs"; +import { ConfigurationError } from "@pipedream/platform"; + +export default { + key: "gong-get-extensive-data", + name: "Get Extensive Data", + description: "Lists detailed call data. [See the documentation](https://us-66463.app.gong.io/settings/api/documentation#post-/v2/calls/extensive)", + version: "0.0.1", + type: "action", + props: { + app, + fromDateTime: { + propDefinition: [ + app, + "fromDateTime", + ], + optional: true, + }, + toDateTime: { + propDefinition: [ + app, + "toDateTime", + ], + optional: true, + }, + workspaceId: { + optional: true, + propDefinition: [ + app, + "workspaceId", + ], + }, + callIds: { + propDefinition: [ + app, + "callIds", + ], + }, + primaryUserIds: { + type: "string[]", + label: "Primary User IDs", + description: "An optional list of user identifiers, if supplied the API will return only the calls hosted by the specified users. The identifiers in this field match the primaryUserId field of the calls.", + propDefinition: [ + app, + "userId", + ], + optional: true, + }, + maxResults: { + type: "integer", + label: "Max Results", + description: "The maximum number or results to return", + default: constants.DEFAULT_MAX, + optional: true, + }, + }, + methods: { + getExtensiveData(args = {}) { + return this.app.post({ + path: "/calls/extensive", + ...args, + }); + }, + }, + async run({ $ }) { + const { + app, + getExtensiveData, + maxResults, + ...filter + } = this; + + if (filter?.workspaceId && filter?.callIds) { + throw new ConfigurationError("Must not provide both `callIds` and `workspaceId`"); + } + + try { + const calls = await app.paginate({ + resourceFn: getExtensiveData, + resourceFnArgs: { + step: $, + data: { + filter, + }, + }, + resourceName: "calls", + max: maxResults, + }); + + if (calls?.length) { + $.export("$summary", `Successfully retrieved data for ${calls.length} calls`); + } + return calls; + } + catch (error) { + const noCallsMessage = "No calls found corresponding to the provided filters"; + if (error?.message.includes(noCallsMessage)) { + $.export("$summary", noCallsMessage); + } else { + throw new ConfigurationError(`${error?.message}`); + } + } + }, +}; diff --git a/components/gong/package.json b/components/gong/package.json index 1d792f2301947..f7a09cd82f3b3 100644 --- a/components/gong/package.json +++ b/components/gong/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/gong", - "version": "0.1.2", + "version": "0.2.0", "description": "Pipedream Gong Components", "main": "gong.app.mjs", "keywords": [ diff --git a/components/notiff_io/notiff_io.app.mjs b/components/notiff_io/notiff_io.app.mjs index 4c406fa1dccc1..fe906e2282bc2 100644 --- a/components/notiff_io/notiff_io.app.mjs +++ b/components/notiff_io/notiff_io.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +}; diff --git a/components/smartlead/smartlead.app.mjs b/components/smartlead/smartlead.app.mjs index 634afd01fd9ae..a838a01a49cff 100644 --- a/components/smartlead/smartlead.app.mjs +++ b/components/smartlead/smartlead.app.mjs @@ -8,4 +8,4 @@ export default { console.log(Object.keys(this.$auth)); }, }, -}; \ No newline at end of file +};