@ireceipt.pro/js
Version:
Create PDF files or images (JPG, PNG, WEBP) from your HTML template.
127 lines (126 loc) • 5.03 kB
JavaScript
import { createFile } from "./methods/index.js";
export class IReceiptPRO {
/**
*
* @param apiKey - IReceipt PRO API KEY, you can get it on <https://dashboard.ireceipt.pro>
*/
constructor(apiKey) {
this.apiKey = apiKey;
}
/**
*
* @param apiKey - IReceipt PRO API KEY, you can get it on <https://dashboard.ireceipt.pro>
* @returns
*/
static useApiKey(apiKey) {
return new IReceiptPRO(apiKey);
}
/**
* Create JPG Image from public template
*
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
* @param args - arguments for substitution in the template
* @param size - the size of the file being created
* @returns
*/
createJpgFromPublicTemplate(templateId, args, size) {
if (!this.apiKey)
throw new Error("Initialization is required before use");
return createFile(this.apiKey, "jpg", "public", templateId, args, size);
}
/**
* Create PDF File from public template
*
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
* @param args - arguments for substitution in the template
* @param size - the size of the file being created
* @returns
*/
createPdfFromPublicTemplate(templateId, args, size) {
if (!this.apiKey)
throw new Error("Initialization is required before use");
return createFile(this.apiKey, "pdf", "public", templateId, args, size);
}
/**
* Create PNG Image from public template
*
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
* @param args - arguments for substitution in the template
* @param size - the size of the file being created
* @returns
*/
createPngFromPublicTemplate(templateId, args, size) {
if (!this.apiKey)
throw new Error("Initialization is required before use");
return createFile(this.apiKey, "png", "public", templateId, args, size);
}
/**
* Create WEBP Image from public template
*
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
* @param args - arguments for substitution in the template
* @param size - the size of the file being created
* @returns
*/
createWebpFromPublicTemplate(templateId, args, size) {
if (!this.apiKey)
throw new Error("Initialization is required before use");
return createFile(this.apiKey, "webp", "public", templateId, args, size);
}
/**
* Create JPG Image from private template,
* you can manage it on <https://dashboard.ireceipt.pro>
*
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
* @param args - arguments for substitution in the template
* @param size - the size of the file being created
* @returns
*/
createJpgFromPrivateTemplate(templateId, args, size) {
if (!this.apiKey)
throw new Error("Initialization is required before use");
return createFile(this.apiKey, "jpg", "private", templateId, args, size);
}
/**
* Create PDF File from private template,
* you can manage it on <https://dashboard.ireceipt.pro>
*
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
* @param args - arguments for substitution in the template
* @param size - the size of the file being created
* @returns
*/
createPdfFromPrivateTemplate(templateId, args, size) {
if (!this.apiKey)
throw new Error("Initialization is required before use");
return createFile(this.apiKey, "pdf", "private", templateId, args, size);
}
/**
* Create PNG Image from private template,
* you can manage it on <https://dashboard.ireceipt.pro>
*
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
* @param args - arguments for substitution in the template
* @param size - the size of the file being created
* @returns
*/
createPngFromPrivateTemplate(templateId, args, size) {
if (!this.apiKey)
throw new Error("Initialization is required before use");
return createFile(this.apiKey, "png", "private", templateId, args, size);
}
/**
* Create WEBP Image from private template,
* you can manage it on <https://dashboard.ireceipt.pro>
*
* @param templateId - template id, you can find it on <https://dashboard.ireceipt.pro>
* @param args - arguments for substitution in the template
* @param size - the size of the file being created
* @returns
*/
createWebpFromPrivateTemplate(templateId, args, size) {
if (!this.apiKey)
throw new Error("Initialization is required before use");
return createFile(this.apiKey, "webp", "private", templateId, args, size);
}
}