Here’s a Pipedream component that downloads a document from PandaDoc and saves it to the /tmp
directory: import { axios } from "@pipedream/platform"; import fs from "fs"; import stream from "stream"; import { promisify } from "util"; export default defineComponent({ props: { pandadoc: { type: "app", app: "pandadoc", }, documentId: { type: "string", label: "Document ID", }, watermarkText: { type: "string", label: "Watermark Text", optional: true, }, watermarkColor: { type: "string", label: "Watermark Color", optional: true, }, watermarkFontSize: { type: "integer", label: "Watermark Font Size", optional: true, }, watermarkOpacity: { type: "number", label: "Watermark Opacity", optional: true, }, separateFiles: { type: "boolean", label: "Separate Files", optional: true, }, }, async run({ steps, $ }) { const pipeline = promisify(stream.pipeline); const url = `https://api.pandadoc.com/public/v1/documents/${this.documentId}/download`; const params = { watermark_text: this.watermarkText, watermark_color: this.watermarkColor, watermark_font_size: this.watermarkFontSize, watermark_opacity: this.watermarkOpacity, separate_files: this.separateFiles, }; const response = await axios($, { method: "GET", url, params, responseType: "stream", headers: { Authorization: `Bearer ${this.pandadoc.$auth.oauth_access_token}`, }, }); const filePath = `/tmp/${this.documentId}.pdf`; await pipeline(response.data, fs.createWriteStream(filePath)); return filePath; }, });
This component has one required prop for the Document ID and five optional props: watermark_text, watermark_color, watermark_font_size, watermark_opacity, and separate_files. It downloads the document from PandaDoc and saves it to the /tmp
directory, then returns the full path to the file.