1- import { axios } from "@pipedream/platform" ;
1+ import {
2+ axios , ConfigurationError ,
3+ } from "@pipedream/platform" ;
24
35export default {
46 type : "app" ,
@@ -9,30 +11,63 @@ export default {
911 label : "Person ID" ,
1012 description : "Select a person to add to the cadence or provide a person ID" ,
1113 async options ( { page } ) {
12- const { data } = await this . listPeople ( {
14+ const people = await this . listPeople ( {
1315 params : {
1416 per_page : 100 ,
1517 page : page + 1 ,
1618 } ,
1719 } ) ;
18- return data ?. map ( ( person ) => ( {
20+ return people ?. map ( ( person ) => ( {
1921 label : person . full_email_address ?? person . email_address ?? person . display_name ,
2022 value : person . id ,
2123 } ) ) ;
2224 } ,
2325 } ,
26+ recordId : {
27+ type : "string" ,
28+ label : "Associated Record ID" ,
29+ description : "Select a record (a person or account) to associate this note with" ,
30+ async options ( {
31+ page, recordType,
32+ } ) {
33+ if ( recordType === "person" ) {
34+ const people = await this . listPeople ( {
35+ params : {
36+ per_page : 100 ,
37+ page : page + 1 ,
38+ } ,
39+ } ) ;
40+ return people ?. map ( ( person ) => ( {
41+ label : person . full_email_address ?? person . email_address ?? person . display_name ,
42+ value : person . id ,
43+ } ) ) ;
44+ } else if ( recordType === "account" ) {
45+ const accounts = await this . listAccounts ( {
46+ params : {
47+ per_page : 100 ,
48+ page : page + 1 ,
49+ } ,
50+ } ) ;
51+ return accounts ?. map ( ( account ) => ( {
52+ label : account . name ,
53+ value : account . id ,
54+ } ) ) ;
55+ } else throw new ConfigurationError ( "Invalid record type, select either `person` or `account`" ) ;
56+ } ,
57+ } ,
2458 cadenceId : {
2559 type : "string" ,
2660 label : "Cadence ID" ,
2761 description : "Select a cadence or provide a cadence ID" ,
2862 async options ( { page } ) {
29- const { data } = await this . listCadences ( {
63+ const cadences = await this . listCadences ( {
3064 params : {
3165 per_page : 100 ,
3266 page : page + 1 ,
3367 } ,
3468 } ) ;
35- return data ?. map ( ( cadence ) => ( {
69+ console . log ( cadences ) ;
70+ return cadences ?. map ( ( cadence ) => ( {
3671 label : cadence . name ,
3772 value : cadence . id ,
3873 } ) ) ;
@@ -44,13 +79,13 @@ export default {
4479 description : "Select a user who will own this cadence membership or provide a user ID. Defaults to the authenticated user if not provided." ,
4580 optional : true ,
4681 async options ( { page } ) {
47- const { data } = await this . listUsers ( {
82+ const users = await this . listUsers ( {
4883 params : {
4984 per_page : 100 ,
5085 page : page + 1 ,
5186 } ,
5287 } ) ;
53- return data ?. map ( ( user ) => ( {
88+ return users ?. map ( ( user ) => ( {
5489 label : user . name ?? user . email ,
5590 value : user . id ,
5691 } ) ) ;
@@ -127,5 +162,11 @@ export default {
127162 ...args ,
128163 } ) ;
129164 } ,
165+ async listAccounts ( args = { } ) {
166+ return this . _makeRequest ( {
167+ path : "/accounts" ,
168+ ...args ,
169+ } ) ;
170+ } ,
130171 } ,
131172} ;
0 commit comments