@weweb/backend-pdfmonkey
v0.2.3
Published
Pdfmonkey integration for WeWeb backend services
Readme
@weweb/backend-pdfmonkey
Pdfmonkey integration for WeWeb backend services. This package provides access to the PDFMonkey API within WeWeb backend workflows.
Installation
npm install @weweb/backend-pdfmonkey
# or
yarn add @weweb/backend-pdfmonkey
# or
pnpm add @weweb/backend-pdfmonkeyConfiguration
The integration can be configured using environment variables or by passing options to the createPdfmonkeyIntegration function:
import { createPdfmonkeyIntegration } from '@weweb/backend-pdfmonkey';
// Using environment variables
const pdfmonkey = createPdfmonkeyIntegration();
// Or with custom options
const customPdfmonkey = createPdfmonkeyIntegration({
apiKey: 'your-api-key'
});Environment Variables
PDFMONKEY_API_KEY: Your PDFMonkey API key
Usage
List Documents
const documents = await pdfmonkey.listDocuments({
page: 1,
status: 'success',
documentTemplateId: 'template-id',
workspaceId: 'workspace-id',
updatedSince: '2023-01-01T00:00:00Z'
});Get Document
const document = await pdfmonkey.getDocument({
id: 'document-id'
});Get Document Card
const documentCard = await pdfmonkey.getDocumentCard({
id: 'document-id'
});Create Document
const newDocument = await pdfmonkey.createDocument({
document_template_id: 'template-id',
status: 'pending', // or "draft"
payload: {
clientName: 'John Doe',
orderDate: '2023-01-01',
products: [
{ name: 'Product 1', quantity: 2, unitPrice: 10.99 },
{ name: 'Product 2', quantity: 1, unitPrice: 24.99 }
]
},
meta: {
_filename: '2023-01-01 John Doe.pdf',
clientRef: 'client-123'
}
});Update Document
const updatedDocument = await pdfmonkey.updateDocument({
id: 'document-id',
status: 'pending',
payload: {
clientName: 'Jane Doe'
}
});Delete Document
await pdfmonkey.deleteDocument({
id: 'document-id'
});List Templates
const templates = await pdfmonkey.listTemplates({
page: 1,
workspaceId: 'workspace-id',
folders: 'folder-id-1,folder-id-2',
sort: 'identifier'
});Get Template
const template = await pdfmonkey.getTemplate({
id: 'template-id'
});Create Template
const newTemplate = await pdfmonkey.createTemplate({
identifier: 'Invoice Template',
edition_mode: 'code',
body: '<h1>Invoice for {{clientName}}</h1>',
scss_style: 'h1 { color: blue; }',
sample_data: JSON.stringify({ clientName: 'John Doe' }),
settings: {
orientation: 'portrait',
paper_format: 'a4',
margin: {
top: 10,
right: 10,
bottom: 10,
left: 10
}
},
pdf_engine_id: 'engine-id',
ttl: 86400 // 1 day
});Update Template
const updatedTemplate = await pdfmonkey.updateTemplate({
id: 'template-id',
body: '<h1>Updated Invoice for {{clientName}}</h1>'
});Delete Template
await pdfmonkey.deleteTemplate({
id: 'template-id'
});List Engines
const engines = await pdfmonkey.listEngines();License
MIT
