Skip to content

Commit 7404196

Browse files
committed
Added actions
1 parent 65d964b commit 7404196

File tree

5 files changed

+283
-17
lines changed

5 files changed

+283
-17
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import app from "../../momentum_ams.app.mjs";
2+
3+
export default {
4+
key: "momentum_ams-get-clients",
5+
name: "Get Clients",
6+
description: "Get a list of the clients. [See the documentation](https://docs.google.com/document/d/11Xk7TviRujq806pLK8pQTcdzDF2ClmPvkfnVmdh1bGc/edit?tab=t.0)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
count: {
12+
propDefinition: [
13+
app,
14+
"count",
15+
],
16+
},
17+
orderby: {
18+
propDefinition: [
19+
app,
20+
"orderby",
21+
],
22+
},
23+
skip: {
24+
propDefinition: [
25+
app,
26+
"skip",
27+
],
28+
},
29+
top: {
30+
propDefinition: [
31+
app,
32+
"top",
33+
],
34+
},
35+
id: {
36+
propDefinition: [
37+
app,
38+
"id",
39+
(c) => ({
40+
count: c.count,
41+
orderby: c.orderby,
42+
skip: c.skip,
43+
top: c.top,
44+
}),
45+
],
46+
},
47+
},
48+
async run({ $ }) {
49+
const response = await this.app.getClient({
50+
$,
51+
id: this.id,
52+
});
53+
$.export("$summary", "Successfully retrieved the client with ID: " + this.id);
54+
return response;
55+
},
56+
};
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import app from "../../momentum_ams.app.mjs";
2+
3+
export default {
4+
key: "momentum_ams-insert-note",
5+
name: "Insert Note",
6+
description: "Description for insert-note. [See the documentation](https://docs.google.com/document/d/11Xk7TviRujq806pLK8pQTcdzDF2ClmPvkfnVmdh1bGc/edit?tab=t.0)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
count: {
12+
propDefinition: [
13+
app,
14+
"count",
15+
],
16+
},
17+
orderby: {
18+
propDefinition: [
19+
app,
20+
"orderby",
21+
],
22+
},
23+
skip: {
24+
propDefinition: [
25+
app,
26+
"skip",
27+
],
28+
},
29+
top: {
30+
propDefinition: [
31+
app,
32+
"top",
33+
],
34+
},
35+
id: {
36+
propDefinition: [
37+
app,
38+
"id",
39+
(c) => ({
40+
count: c.count,
41+
orderby: c.orderby,
42+
skip: c.skip,
43+
top: c.top,
44+
}),
45+
],
46+
},
47+
subject: {
48+
propDefinition: [
49+
app,
50+
"subject",
51+
],
52+
},
53+
creatorName: {
54+
propDefinition: [
55+
app,
56+
"creatorName",
57+
],
58+
},
59+
type: {
60+
propDefinition: [
61+
app,
62+
"type",
63+
],
64+
},
65+
isStickyNote: {
66+
propDefinition: [
67+
app,
68+
"isStickyNote",
69+
],
70+
},
71+
hide: {
72+
propDefinition: [
73+
app,
74+
"hide",
75+
],
76+
},
77+
},
78+
async run({ $ }) {
79+
const response = await this.app.insertNote({
80+
$,
81+
data: {
82+
insured_database_id: this.insuredDatabaseId,
83+
subject: this.subject,
84+
creator_name: this.creatorName,
85+
type: this.type,
86+
is_sticky_note: this.isStickyNote,
87+
hide: this.hide,
88+
},
89+
});
90+
$.export("$summary", "Successfully inserted note with subject: " + this.subject);
91+
return response;
92+
},
93+
};
Lines changed: 122 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,129 @@
1+
import { axios } from "@pipedream/platform";
2+
13
export default {
24
type: "app",
35
app: "momentum_ams",
4-
propDefinitions: {},
6+
propDefinitions: {
7+
subject: {
8+
type: "string",
9+
label: "Subject",
10+
description: "The subject or title for the note",
11+
},
12+
creatorName: {
13+
type: "string",
14+
label: "Creator Name",
15+
description: "The name of the user creating the note",
16+
optional: true,
17+
},
18+
type: {
19+
type: "string",
20+
label: "Type",
21+
description: "A category to classify the note",
22+
optional: true,
23+
},
24+
isStickyNote: {
25+
type: "boolean",
26+
label: "Is Sticky Note",
27+
description: "Set to true to make this note a sticky note for higher visibility",
28+
optional: true,
29+
},
30+
hide: {
31+
type: "boolean",
32+
label: "Hide",
33+
description: "Set to true to archive or hide the note from the default view",
34+
optional: true,
35+
},
36+
id: {
37+
type: "string",
38+
label: "Client ID",
39+
description: "The ID of the client",
40+
async options({
41+
count, orderby, skip, top,
42+
}) {
43+
const response = await this.getClients({
44+
count,
45+
orderby,
46+
skip,
47+
top,
48+
});
49+
const ids = response.value;
50+
return ids.map(({
51+
id, commercialName,
52+
}) => ({
53+
value: id,
54+
label: commercialName,
55+
}));
56+
},
57+
},
58+
count: {
59+
type: "boolean",
60+
label: "Count",
61+
description: "Returns the total number of records that exist in nowcerts database",
62+
},
63+
orderby: {
64+
type: "string",
65+
label: "Order By",
66+
description: "The parameter used to sort the results, e.g.: `firstName`, `changeDate`)",
67+
},
68+
skip: {
69+
type: "integer",
70+
label: "Skip",
71+
description: "The number of records to skip for pagination purposes",
72+
},
73+
top: {
74+
type: "integer",
75+
label: "Top",
76+
description: "The maximum number of records to retrieve for pagination purposes",
77+
},
78+
},
579
methods: {
6-
// this.$auth contains connected account data
7-
authKeys() {
8-
console.log(Object.keys(this.$auth));
80+
_baseUrl() {
81+
return "https://api.nowcerts.com/api";
82+
},
83+
async _makeRequest(opts = {}) {
84+
const {
85+
$ = this,
86+
path,
87+
headers,
88+
...otherOpts
89+
} = opts;
90+
return axios($, {
91+
...otherOpts,
92+
url: this._baseUrl() + path,
93+
headers: {
94+
Authorization: `Bearer ${this.$auth.oauth_access_token}`,
95+
...headers,
96+
},
97+
});
98+
},
99+
100+
async insertNote(args = {}) {
101+
return this._makeRequest({
102+
path: "/InsertNote",
103+
...args,
104+
});
105+
},
106+
async getClient({
107+
id, ...args
108+
}) {
109+
return this._makeRequest({
110+
path: `/InsuredList(${id})`,
111+
...args,
112+
});
113+
},
114+
async getClients({
115+
count, orderby, skip, top, ...args
116+
}) {
117+
return this._makeRequest({
118+
path: "/InsuredDetailList",
119+
params: {
120+
"$count": count,
121+
"$orderby": orderby,
122+
"$skip": skip,
123+
"$top": top,
124+
},
125+
...args,
126+
});
9127
},
10128
},
11129
};

components/momentum_ams/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/momentum_ams",
3-
"version": "0.0.1",
3+
"version": "0.1.0",
44
"description": "Pipedream Momentum AMS Components",
55
"main": "momentum_ams.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.1.0"
1417
}
15-
}
18+
}

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)