e-invoice-api
Version:
The official TypeScript library for the e-invoice API
68 lines • 2.92 kB
JavaScript
;
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Documents = void 0;
const tslib_1 = require("../../internal/tslib.js");
const resource_1 = require("../../core/resource.js");
const AttachmentsAPI = tslib_1.__importStar(require("./attachments.js"));
const attachments_1 = require("./attachments.js");
const UblAPI = tslib_1.__importStar(require("./ubl.js"));
const ubl_1 = require("./ubl.js");
const uploads_1 = require("../../internal/uploads.js");
const path_1 = require("../../internal/utils/path.js");
class Documents extends resource_1.APIResource {
constructor() {
super(...arguments);
this.attachments = new AttachmentsAPI.Attachments(this._client);
this.ubl = new UblAPI.Ubl(this._client);
}
/**
* Create a new invoice or credit note
*/
create(body, options) {
return this._client.post('/api/documents/', { body, ...options });
}
/**
* Get an invoice or credit note by ID
*/
retrieve(documentID, options) {
return this._client.get((0, path_1.path) `/api/documents/${documentID}`, options);
}
/**
* Delete an invoice or credit note
*/
delete(documentID, options) {
return this._client.delete((0, path_1.path) `/api/documents/${documentID}`, options);
}
/**
* Create a new invoice or credit note from a PDF file. If the 'ubl_document' field
* is set in the response, it indicates that sufficient details were extracted from
* the PDF to automatically generate a valid UBL document ready for sending. If
* 'ubl_document' is not set, human intervention may be required to ensure
* compliance.
*/
createFromPdf(params, options) {
const { customer_tax_id, vendor_tax_id, ...body } = params;
return this._client.post('/api/documents/pdf', (0, uploads_1.multipartFormRequestOptions)({ query: { customer_tax_id, vendor_tax_id }, body, ...options }, this._client));
}
/**
* Send an invoice or credit note via Peppol
*/
send(documentID, params = {}, options) {
const { email, receiver_peppol_id, receiver_peppol_scheme, sender_peppol_id, sender_peppol_scheme } = params ?? {};
return this._client.post((0, path_1.path) `/api/documents/${documentID}/send`, {
query: { email, receiver_peppol_id, receiver_peppol_scheme, sender_peppol_id, sender_peppol_scheme },
...options,
});
}
/**
* Validate a UBL document according to Peppol BIS Billing 3.0
*/
validate(documentID, options) {
return this._client.post((0, path_1.path) `/api/documents/${documentID}/validate`, options);
}
}
exports.Documents = Documents;
Documents.Attachments = attachments_1.Attachments;
Documents.Ubl = ubl_1.Ubl;
//# sourceMappingURL=documents.js.map