UNPKG

e-invoice-api

Version:

The official TypeScript library for the e-invoice API

63 lines 2.62 kB
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from "../../core/resource.mjs"; import * as AttachmentsAPI from "./attachments.mjs"; import { Attachments, } from "./attachments.mjs"; import * as UblAPI from "./ubl.mjs"; import { Ubl } from "./ubl.mjs"; import { multipartFormRequestOptions } from "../../internal/uploads.mjs"; import { path } from "../../internal/utils/path.mjs"; export class Documents extends 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(path `/api/documents/${documentID}`, options); } /** * Delete an invoice or credit note */ delete(documentID, options) { return this._client.delete(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', 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(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(path `/api/documents/${documentID}/validate`, options); } } Documents.Attachments = Attachments; Documents.Ubl = Ubl; //# sourceMappingURL=documents.mjs.map