UNPKG

@print-one/moneybird-js

Version:
69 lines 2.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SalesInvoice = void 0; const httpHandler_1 = require("./httpHandler"); class SalesInvoice { constructor(moneybird, administration, data) { this.moneybird = moneybird; this.administration = administration; this.id = data.id; this.data = data; this.HTTP = new httpHandler_1.HttpHandler(this.administration.HTTP, `sales_invoices/${this.id}`); } async send(data = {}) { return new SalesInvoice(this.moneybird, this.administration, await this.HTTP.PATCH("send_invoice", { sales_invoice_sending: data, })); } async downloadPDF() { return this.HTTP.GET("download_pdf", { responseType: "arraybuffer", }); } async downloadUBL() { return this.HTTP.GET("download_ubl", { responseType: "arraybuffer", }); } async downloadPackingSlip() { return this.HTTP.GET("download_packing_slip_pdf", { responseType: "arraybuffer", }); } async addPayment(payment) { return this.HTTP.POST("payments", { payment: payment, }); } async deletePayment(payment) { const id = typeof payment === "string" ? payment : payment.id; await this.HTTP.DELETE(`payments/${id}`); } async addAttachment(content, file_name) { const formData = new FormData(); formData.append("file", new Blob([content]), file_name); return this.HTTP.POST("attachments", formData, { headers: { "Content-Type": "multipart/form-data", }, }); } async deleteAttachment(attachment) { const attachmentId = typeof attachment === "string" ? attachment : attachment.id; return this.HTTP.DELETE(`attachments/${attachmentId}`); } async downloadAttachment(attachment) { const attachmentId = typeof attachment === "string" ? attachment : attachment.id; return this.HTTP.GET(`attachments/${attachmentId}/download`, { responseType: "arraybuffer", }); } async update(data) { return new SalesInvoice(this.moneybird, this.administration, await this.HTTP.PATCH("", { sales_invoice: data })); } async delete() { return this.HTTP.DELETE(""); } } exports.SalesInvoice = SalesInvoice; //# sourceMappingURL=salesInvoice.js.map