viettel-s-invoice
Version:
Viettel S Invoice
65 lines (64 loc) • 3.53 kB
TypeScript
import { IViettelSInvoiceDraftInvoicePreviewResponse, IViettelSInvoice, IViettelSInvoiceConfiguration, IViettelSInvoiceDetailResponse, IViettelSInvoiceDetailsResponse, IViettelSInvoiceGetFileResponse, IViettelSInvoiceResponse, IViettelSInvoiceGetTemplatesResponse } from './interfaces/viettel-s-invoice';
import { GetInvoiceFileParams } from './types';
declare class ViettelSInvoice {
private readonly username;
private readonly password;
private readonly apiEndPoint;
constructor({ apiEndPoint, username, password }: IViettelSInvoiceConfiguration);
private isValidUrl;
private validateDate;
private getApiUrl;
private login;
/**
* Previews a draft invoice by sending the invoice data to the server.
*
* @param invoice - The invoice data to be previewed.
* @returns A promise that resolves to the draft invoice response.
* @throws ReviewDraftInvoiceException if the server response is not successful.
*/
previewDraftInvoice(invoice: IViettelSInvoice): Promise<IViettelSInvoiceDraftInvoicePreviewResponse>;
/**
* Creates an invoice by sending the provided invoice data to the server.
*
* @param invoice - The invoice data to be created.
* @returns A promise that resolves to the invoice response.
* @throws ViettelSInvoiceCreateInvoiceException if the server response is not successful.
*/
createInvoice(invoice: IViettelSInvoice): Promise<IViettelSInvoiceResponse>;
/**
* Retrieves an invoice by its transaction UUID.
*
* @param transactionUuid - The unique identifier for the transaction.
* @returns A promise that resolves to the invoice detail response.
* @throws ViettelSInvoiceGetInvoiceException if the server response is not successful.
*/
getInvoiceByTransactionUuid(transactionUuid: string): Promise<IViettelSInvoiceDetailResponse>;
/**
* Retrieves a list of invoices within a specified date range.
*
* @param fromDate - The start date of the range in 'dd/MM/yyyy' format.
* @param toDate - The end date of the range in 'dd/MM/yyyy' format.
* @returns A promise that resolves to the invoice detail response.
* @throws ViettelSInvoiceGetInvoicesException if the date format is invalid or the server response is not successful.
*/
getInvoicesByDateRange(fromDate: string, toDate: string): Promise<IViettelSInvoiceDetailsResponse>;
/**
* Retrieves the file representation of an invoice based on the provided parameters.
*
* @param invoiceNo - The invoice number to identify the invoice.
* @param templateCode - The template code associated with the invoice.
* @param fileType - The type of file to retrieve (PDF, ZIP).
* @returns A promise that resolves to the invoice file response.
* @throws ViettelSInvoiceGetInvoiceFileException if the server response is not successful.
*/
getInvoiceFile({ invoiceNo, templateCode, fileType }: GetInvoiceFileParams): Promise<IViettelSInvoiceGetFileResponse>;
/**
* Retrieves available invoice templates for a specified invoice type.
*
* @param invoiceType - The type of invoice for which templates are requested.
* @returns A promise that resolves to the response containing invoice templates.
* @throws ViettelSInvoiceGetTemplatesException if the server response is not successful.
*/
getInvoiceTemplates(invoiceType: string): Promise<IViettelSInvoiceGetTemplatesResponse>;
}
export default ViettelSInvoice;