1+ import  {  axios  }  from  "@pipedream/platform" ; 
2+ 
13export  default  { 
24  type : "app" , 
35  app : "rinkel" , 
4-   propDefinitions : { } , 
6+   propDefinitions : { 
7+     callId : { 
8+       type : "string" , 
9+       label : "Call ID" , 
10+       description : "The ID of the call to get the call detail records for" , 
11+       async  options ( {  page } )  { 
12+         const  response  =  await  this . listCallDetailRecords ( { 
13+           params : { 
14+             page : page  +  1 , 
15+             sort : "date" , 
16+             sortOrder : "DESC" , 
17+           } , 
18+         } ) ; 
19+         return  response . data . map ( ( call )  =>  call . id ) ; 
20+       } , 
21+     } , 
22+     recordingId : { 
23+       type : "string" , 
24+       label : "Recording ID" , 
25+       description : "The ID of the recording to get the details for" , 
26+       async  options ( {  page } )  { 
27+         const  response  =  await  this . listCallRecordings ( { 
28+           params : { 
29+             page : page  +  1 , 
30+             sort : "date" , 
31+             sortOrder : "DESC" , 
32+           } , 
33+         } ) ; 
34+         return  response . data . map ( ( recording )  =>  recording . id ) ; 
35+       } , 
36+     } , 
37+     voicemailId : { 
38+       type : "string" , 
39+       label : "Voicemail ID" , 
40+       description : "The ID of the voicemail to get the details for" , 
41+       async  options ( {  page } )  { 
42+         const  response  =  await  this . listVoicemails ( { 
43+           params : { 
44+             page : page  +  1 , 
45+             sort : "date" , 
46+             sortOrder : "DESC" , 
47+           } , 
48+         } ) ; 
49+         return  response . data . map ( ( voicemail )  =>  voicemail . id ) ; 
50+       } , 
51+     } , 
52+     noteId : { 
53+       type : "string" , 
54+       label : "Note ID" , 
55+       description : "The ID of the note to update" , 
56+       async  options ( {  callId } )  { 
57+         const  response  =  await  this . getCallDetailRecord ( { 
58+           id : callId , 
59+         } ) ; 
60+         const  notes  =  response . data . notes ; 
61+         return  notes . map ( ( note )  =>  ( { 
62+           label : note . content , 
63+           value : note . id , 
64+         } ) ) ; 
65+       } , 
66+     } , 
67+   } , 
568  methods : { 
6-     // this.$auth contains connected account data 
7-     authKeys ( )  { 
8-       console . log ( Object . keys ( this . $auth ) ) ; 
69+     _baseUrl ( )  { 
70+       return  "https://api.rinkel.com/v1" ; 
71+     } , 
72+     _makeRequest ( { 
73+       $ =  this ,  path,  ...opts 
74+     } )  { 
75+       return  axios ( $ ,  { 
76+         url : `${ this . _baseUrl ( ) } ${ path }  , 
77+         headers : { 
78+           "x-rinkel-api-key" : this . $auth . api_key , 
79+         } , 
80+         ...opts , 
81+       } ) ; 
82+     } , 
83+     createWebhook ( { 
84+       event,  ...opts 
85+     } )  { 
86+       return  this . _makeRequest ( { 
87+         path : `/webhooks/${ event }  , 
88+         method : "POST" , 
89+         ...opts , 
90+       } ) ; 
91+     } , 
92+     deleteWebhook ( { 
93+       event,  ...opts 
94+     } )  { 
95+       return  this . _makeRequest ( { 
96+         path : `/webhooks/${ event }  , 
97+         method : "DELETE" , 
98+         ...opts , 
99+       } ) ; 
100+     } , 
101+     getCallDetailRecord ( { 
102+       id,  ...opts 
103+     } )  { 
104+       return  this . _makeRequest ( { 
105+         path : `/call-detail-records/${ id }  , 
106+         ...opts , 
107+       } ) ; 
108+     } , 
109+     getCallRecording ( { 
110+       id,  ...opts 
111+     } )  { 
112+       return  this . _makeRequest ( { 
113+         path : `/recordings/${ id }  , 
114+         ...opts , 
115+       } ) ; 
116+     } , 
117+     getVoicemail ( { 
118+       id,  ...opts 
119+     } )  { 
120+       return  this . _makeRequest ( { 
121+         path : `/voicemails/${ id }  , 
122+         ...opts , 
123+       } ) ; 
124+     } , 
125+     listCallDetailRecords ( opts  =  { } )  { 
126+       return  this . _makeRequest ( { 
127+         path : "/call-detail-records" , 
128+         ...opts , 
129+       } ) ; 
130+     } , 
131+     listCallRecordings ( opts  =  { } )  { 
132+       return  this . _makeRequest ( { 
133+         path : "/recordings" , 
134+         ...opts , 
135+       } ) ; 
136+     } , 
137+     listVoicemails ( opts  =  { } )  { 
138+       return  this . _makeRequest ( { 
139+         path : "/voicemails" , 
140+         ...opts , 
141+       } ) ; 
142+     } , 
143+     addNote ( { 
144+       id,  ...opts 
145+     } )  { 
146+       return  this . _makeRequest ( { 
147+         path : `/call-detail-records/${ id }  , 
148+         method : "PUT" , 
149+         ...opts , 
150+       } ) ; 
151+     } , 
152+     updateNote ( { 
153+       callId,  noteId,  ...opts 
154+     } )  { 
155+       return  this . _makeRequest ( { 
156+         path : `/call-detail-records/${ callId } ${ noteId }  , 
157+         method : "PATCH" , 
158+         ...opts , 
159+       } ) ; 
9160    } , 
10161  } , 
11- } ; 
162+ } ; 
0 commit comments