1
+ import { axios } from "@pipedream/platform" ;
2
+
1
3
export default {
2
4
type : "app" ,
3
5
app : "documerge" ,
4
- propDefinitions : { } ,
6
+ propDefinitions : {
7
+ documentId : {
8
+ type : "string" ,
9
+ label : "Document ID" ,
10
+ description : "Identifier of a document" ,
11
+ async options ( ) {
12
+ const { data } = await this . listDocuments ( ) ;
13
+ return data ?. map ( ( {
14
+ id : value , name : label ,
15
+ } ) => ( {
16
+ value,
17
+ label,
18
+ } ) ) || [ ] ;
19
+ } ,
20
+ } ,
21
+ routeId : {
22
+ type : "string" ,
23
+ label : "Routet ID" ,
24
+ description : "Identifier of a route" ,
25
+ async options ( ) {
26
+ const { data } = await this . listRoutes ( ) ;
27
+ return data ?. map ( ( {
28
+ id : value , name : label ,
29
+ } ) => ( {
30
+ value,
31
+ label,
32
+ } ) ) || [ ] ;
33
+ } ,
34
+ } ,
35
+ } ,
5
36
methods : {
6
- // this.$auth contains connected account data
7
- authKeys ( ) {
8
- console . log ( Object . keys ( this . $auth ) ) ;
37
+ _baseUrl ( ) {
38
+ return "https://app.documerge.ai/api" ;
39
+ } ,
40
+ _makeRequest ( opts = { } ) {
41
+ const {
42
+ $ = this ,
43
+ path,
44
+ ...otherOpts
45
+ } = opts ;
46
+ return axios ( $ , {
47
+ ...otherOpts ,
48
+ url : `${ this . _baseUrl ( ) } ${ path } ` ,
49
+ headers : {
50
+ "Authorization" : `Bearer ${ this . $auth . api_token } ` ,
51
+ "Content-Type" : "application/json" ,
52
+ "Accept" : "application/json" ,
53
+ } ,
54
+ } ) ;
55
+ } ,
56
+ listDocuments ( opts = { } ) {
57
+ return this . _makeRequest ( {
58
+ path : "/documents" ,
59
+ ...opts ,
60
+ } ) ;
61
+ } ,
62
+ listRoutes ( opts = { } ) {
63
+ return this . _makeRequest ( {
64
+ path : "/routes" ,
65
+ ...opts ,
66
+ } ) ;
67
+ } ,
68
+ getDocumentFields ( {
69
+ documentId, ...opts
70
+ } ) {
71
+ return this . _makeRequest ( {
72
+ path : `/documents/fields/${ documentId } ` ,
73
+ ...opts ,
74
+ } ) ;
75
+ } ,
76
+ combineFiles ( opts = { } ) {
77
+ return this . _makeRequest ( {
78
+ method : "POST" ,
79
+ path : "/tools/combine" ,
80
+ responseType : "arraybuffer" ,
81
+ ...opts ,
82
+ } ) ;
83
+ } ,
84
+ convertToPdf ( opts = { } ) {
85
+ return this . _makeRequest ( {
86
+ method : "POST" ,
87
+ path : "/tools/pdf/convert" ,
88
+ responseType : "arraybuffer" ,
89
+ ...opts ,
90
+ } ) ;
91
+ } ,
92
+ createDocumentDeliveryMethod ( {
93
+ documentId, ...opts
94
+ } ) {
95
+ return this . _makeRequest ( {
96
+ method : "POST" ,
97
+ path : `/documents/delivery-methods/${ documentId } ` ,
98
+ ...opts ,
99
+ } ) ;
100
+ } ,
101
+ deleteDocumentDeliveryMethod ( {
102
+ documentId, deliveryMethodId, ...opts
103
+ } ) {
104
+ return this . _makeRequest ( {
105
+ method : "DELETE" ,
106
+ path : `/documents/delivery-methods/${ documentId } /${ deliveryMethodId } ` ,
107
+ ...opts ,
108
+ } ) ;
109
+ } ,
110
+ createRouteDeliveryMethod ( {
111
+ routeId, ...opts
112
+ } ) {
113
+ return this . _makeRequest ( {
114
+ method : "POST" ,
115
+ path : `/routes/delivery-methods/${ routeId } ` ,
116
+ ...opts ,
117
+ } ) ;
118
+ } ,
119
+ deleteRouteDeliveryMethod ( {
120
+ routeId, deliveryMethodId, ...opts
121
+ } ) {
122
+ return this . _makeRequest ( {
123
+ method : "DELETE" ,
124
+ path : `/routes/delivery-methods/${ routeId } /${ deliveryMethodId } ` ,
125
+ ...opts ,
126
+ } ) ;
9
127
} ,
10
128
} ,
11
- } ;
129
+ } ;
0 commit comments