xinvoice/ts/formats/base/base.decoder.ts
2025-04-03 15:53:08 +00:00

38 lines
876 B
TypeScript

import type { TInvoice } from '../../interfaces/common.js';
import { ValidationLevel } from '../../interfaces/common.js';
import type { ValidationResult } from '../../interfaces/common.js';
/**
* Base decoder class that defines common decoding functionality
* for all invoice format decoders
*/
export abstract class BaseDecoder {
protected xml: string;
constructor(xml: string) {
this.xml = xml;
}
/**
* Decodes XML into a TInvoice object
* @returns Promise resolving to a TInvoice object
*/
abstract decode(): Promise<TInvoice>;
/**
* Gets letter data in the standard format
* @returns Promise resolving to a TInvoice object
*/
public async getLetterData(): Promise<TInvoice> {
return this.decode();
}
/**
* Gets the raw XML content
* @returns XML string
*/
public getXml(): string {
return this.xml;
}
}