Skip to content

Commit 05b0338

Browse files
committed
validate fileId
1 parent 8a7445c commit 05b0338

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

components/zerobounce/actions/get-validation-results-file/get-validation-results-file.mjs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import zerobounce from "../../zerobounce.app.mjs";
22
import fs from "fs";
3+
import { ConfigurationError } from "@pipedream/platform";
34

45
export default {
56
key: "zerobounce-get-validation-results-file",
@@ -12,20 +13,46 @@ export default {
1213
fileId: {
1314
type: "string",
1415
label: "File ID",
15-
description: "The file_id returned when sending the file for validation",
16+
description: "The file_id returned when sending the file for validation. Can be found on your Zerobounce \"Validate\" tab under Results next to each filename. Click on the ID circle.",
1617
},
1718
fileName: {
1819
type: "string",
1920
label: "File Name",
2021
description: "The filename to save the file as in the \"/tmp\" directory",
2122
},
2223
},
24+
methods: {
25+
getResultsFile({
26+
$, ...opts
27+
}) {
28+
return this.zerobounce.getResultsFile({
29+
$,
30+
params: {
31+
file_id: this.fileId,
32+
},
33+
...opts,
34+
});
35+
},
36+
async validateFileId({ $ }) {
37+
try {
38+
const x = await this.getResultsFile({
39+
$,
40+
});
41+
console.log(x);
42+
return true;
43+
} catch {
44+
throw new ConfigurationError("File not found. Make sure the File ID is correct");
45+
}
46+
},
47+
},
2348
async run({ $ }) {
24-
const response = await this.zerobounce.getResultsFile({
49+
if (!(await this.validateFileId({
50+
$,
51+
}))) {
52+
return;
53+
}
54+
const response = await this.getResultsFile({
2555
$,
26-
params: {
27-
file_id: this.fileId,
28-
},
2956
responseType: "arraybuffer",
3057
});
3158

0 commit comments

Comments
 (0)