@pipedream/pandadoc 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,7 @@ export default defineComponent({
|
|
|
5
5
|
name: "Send Document",
|
|
6
6
|
description: "Move a document to sent status and send an optional email. [See the documentation](https://developers.pandadoc.com/reference/send-document)",
|
|
7
7
|
type: "action",
|
|
8
|
-
version: "0.0.
|
|
8
|
+
version: "0.0.4",
|
|
9
9
|
props: {
|
|
10
10
|
app,
|
|
11
11
|
documentId: {
|
|
@@ -60,25 +60,35 @@ export default defineComponent({
|
|
|
60
60
|
},
|
|
61
61
|
async run({ $ }) {
|
|
62
62
|
const documentId = this.documentId;
|
|
63
|
-
|
|
64
63
|
let documentStatus = "";
|
|
64
|
+
let retryCount = 0;
|
|
65
|
+
const maxRetries = 5; // Maximum number of retries
|
|
65
66
|
|
|
66
|
-
while (documentStatus !== "document.draft") {
|
|
67
|
+
while (documentStatus !== "document.draft" && retryCount < maxRetries) {
|
|
67
68
|
try {
|
|
68
69
|
const response = await this.app.getDocument({
|
|
69
70
|
id: documentId,
|
|
70
71
|
});
|
|
71
|
-
|
|
72
|
-
|
|
72
|
+
console.log(response);
|
|
73
|
+
documentStatus = response.status;
|
|
74
|
+
if (documentStatus === "document.draft") {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
73
77
|
console.log(
|
|
74
78
|
`Document status is '${documentStatus}' and not 'document.draft'. Waiting 1s and trying again...`
|
|
75
79
|
);
|
|
76
80
|
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
|
|
81
|
+
retryCount++;
|
|
77
82
|
} catch (error) {
|
|
78
83
|
console.error("Error fetching document details:", error);
|
|
84
|
+
retryCount++; // Increment the retry count on error
|
|
79
85
|
}
|
|
80
86
|
}
|
|
81
87
|
|
|
88
|
+
if (documentStatus !== "document.draft") {
|
|
89
|
+
console.error(`Maximum retry limit (${maxRetries}) reached. Exiting.`);
|
|
90
|
+
}
|
|
91
|
+
|
|
82
92
|
const data = {
|
|
83
93
|
subject: this.subject,
|
|
84
94
|
message: this.message,
|
|
@@ -102,7 +112,10 @@ export default defineComponent({
|
|
|
102
112
|
data,
|
|
103
113
|
});
|
|
104
114
|
|
|
105
|
-
$.export(
|
|
115
|
+
$.export(
|
|
116
|
+
"$summary",
|
|
117
|
+
`Successfully sent "${response.name}" document with ID: ${response.id} to ${response.recipients.length} recipient(s)`
|
|
118
|
+
);
|
|
106
119
|
return response;
|
|
107
120
|
},
|
|
108
121
|
});
|