diff --git a/components/momentum_ams/actions/get-client/get-client.mjs b/components/momentum_ams/actions/get-client/get-client.mjs new file mode 100644 index 0000000000000..0440eae8a20c5 --- /dev/null +++ b/components/momentum_ams/actions/get-client/get-client.mjs @@ -0,0 +1,26 @@ +import app from "../../momentum_ams.app.mjs"; + +export default { + key: "momentum_ams-get-client", + name: "Get Client", + description: "Get data for the client with the specified ID. [See the documentation](https://support.momentumamp.com/nowcerts-rest-api-search-insureds)", + version: "0.0.1", + type: "action", + props: { + app, + id: { + propDefinition: [ + app, + "id", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getClient({ + $, + id: this.id, + }); + $.export("$summary", "Successfully retrieved the client with ID: " + this.id); + return response; + }, +}; diff --git a/components/momentum_ams/actions/insert-note/insert-note.mjs b/components/momentum_ams/actions/insert-note/insert-note.mjs new file mode 100644 index 0000000000000..e6a85ce21d598 --- /dev/null +++ b/components/momentum_ams/actions/insert-note/insert-note.mjs @@ -0,0 +1,63 @@ +import app from "../../momentum_ams.app.mjs"; + +export default { + key: "momentum_ams-insert-note", + name: "Insert Note", + description: "Insert note . [See the documentation](https://docs.google.com/document/d/11Xk7TviRujq806pLK8pQTcdzDF2ClmPvkfnVmdh1bGc/edit?tab=t.0)", + version: "0.0.1", + type: "action", + props: { + app, + id: { + propDefinition: [ + app, + "id", + ], + }, + subject: { + propDefinition: [ + app, + "subject", + ], + }, + creatorName: { + propDefinition: [ + app, + "creatorName", + ], + }, + type: { + propDefinition: [ + app, + "type", + ], + }, + isStickyNote: { + propDefinition: [ + app, + "isStickyNote", + ], + }, + hide: { + propDefinition: [ + app, + "hide", + ], + }, + }, + async run({ $ }) { + const response = await this.app.insertNote({ + $, + data: { + insured_database_id: this.id, + subject: this.subject, + creator_name: this.creatorName, + type: this.type, + is_sticky_note: this.isStickyNote, + hide: this.hide, + }, + }); + $.export("$summary", "Successfully inserted note with subject: " + this.subject); + return response; + }, +}; diff --git a/components/momentum_ams/momentum_ams.app.mjs b/components/momentum_ams/momentum_ams.app.mjs index a9a13189e1115..b507cd44cc013 100644 --- a/components/momentum_ams/momentum_ams.app.mjs +++ b/components/momentum_ams/momentum_ams.app.mjs @@ -1,11 +1,102 @@ +import { axios } from "@pipedream/platform"; + export default { type: "app", app: "momentum_ams", - propDefinitions: {}, + propDefinitions: { + subject: { + type: "string", + label: "Subject", + description: "The subject or title for the note", + }, + creatorName: { + type: "string", + label: "Creator Name", + description: "The name of the user creating the note", + optional: true, + }, + type: { + type: "string", + label: "Type", + description: "A category to classify the note", + optional: true, + }, + isStickyNote: { + type: "boolean", + label: "Is Sticky Note", + description: "Set to true to make this note a sticky note for higher visibility", + optional: true, + }, + hide: { + type: "boolean", + label: "Hide", + description: "Set to true to archive or hide the note from the default view", + optional: true, + }, + id: { + type: "string", + label: "Client ID", + description: "The ID of the client", + async options({ page }) { + const response = await this.getClients({ + params: { + "$top": 10, + "$skip": page * 10, + "$orderby": "id", + }, + }); + return response.value.map(({ + id, commercialName, + }) => ({ + value: id, + label: commercialName, + })); + }, + }, + }, methods: { - // this.$auth contains connected account data - authKeys() { - console.log(Object.keys(this.$auth)); + _baseUrl() { + return "https://api.nowcerts.com/api"; + }, + async _makeRequest(opts = {}) { + const { + $ = this, + path, + headers, + ...otherOpts + } = opts; + return axios($, { + ...otherOpts, + url: this._baseUrl() + path, + headers: { + Authorization: `Bearer ${this.$auth.oauth_access_token}`, + ...headers, + }, + }); + }, + + async insertNote(args = {}) { + return this._makeRequest({ + path: "/Zapier/InsertNote", + method: "post", + ...args, + }); + }, + + async getClient({ + id, ...args + }) { + return this._makeRequest({ + path: `/InsuredList(${id})`, + ...args, + }); + }, + + async getClients(args = {}) { + return this._makeRequest({ + path: "/InsuredDetailList", + ...args, + }); }, }, }; diff --git a/components/momentum_ams/package.json b/components/momentum_ams/package.json index 5a68fe61fd9ad..e647c48637a19 100644 --- a/components/momentum_ams/package.json +++ b/components/momentum_ams/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/momentum_ams", - "version": "0.0.1", + "version": "0.1.0", "description": "Pipedream Momentum AMS Components", "main": "momentum_ams.app.mjs", "keywords": [ @@ -11,5 +11,8 @@ "author": "Pipedream (https://pipedream.com/)", "publishConfig": { "access": "public" + }, + "dependencies": { + "@pipedream/platform": "^3.1.0" } -} \ No newline at end of file +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5097d77eb36e3..ac86f49759fa4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1872,8 +1872,7 @@ importers: specifier: ^3.0.0 version: 3.0.3 - components/bright_data: - specifiers: {} + components/bright_data: {} components/brilliant_directories: dependencies: @@ -2646,14 +2645,11 @@ importers: specifier: ^1.0.1 version: 1.0.1 - components/clio_australia: - specifiers: {} + components/clio_australia: {} - components/clio_canada: - specifiers: {} + components/clio_canada: {} - components/clio_eu: - specifiers: {} + components/clio_eu: {} components/clockify: dependencies: @@ -8594,7 +8590,11 @@ importers: components/mollie: {} - components/momentum_ams: {} + components/momentum_ams: + dependencies: + '@pipedream/platform': + specifier: ^3.1.0 + version: 3.1.0 components/monday: dependencies: @@ -11470,8 +11470,7 @@ importers: specifier: ^1.5.1 version: 1.6.6 - components/rhombus: - specifiers: {} + components/rhombus: {} components/richpanel: dependencies: