myinvois-sdk
Version:
TypeScript SDK for interacting with the Malaysia e-invoicing system (MyInvois) API
79 lines (78 loc) • 2.67 kB
TypeScript
import { InvoiceService } from './services/invoice-service';
import { DocumentService } from './services/document-service';
import { MyInvoisConfig } from './config';
import { CodeService } from './services/code-service';
import { CertificateChainInfo } from './models/certificate-info';
/**
* Main client for interacting with the MyInvois API
*/
export declare class MyInvoisClient {
private config;
private httpClient;
private authService;
private invoiceService;
private documentService;
private certificateHandler;
private codeService;
/**
* Creates a new MyInvois client
* @param config Configuration for the MyInvois client
*/
constructor(config: MyInvoisConfig);
/**
* Authenticate with the MyInvois system
* @returns A promise resolving to the authentication token
*/
authenticate(): Promise<string>;
/**
* Authenticate on behalf of a taxpayer
* @param taxpayerTIN The taxpayer's TIN
* @returns A promise resolving to the authentication token
*/
authenticateAsIntermediary(taxpayerTIN: string): Promise<string>;
/**
* Get a valid token for authentication
* @param authTIN The TIN to use for authentication (optional)
* @returns A promise resolving to the authentication token
*/
getToken(authTIN?: string): Promise<string>;
/**
* Get all TINs that have valid authentication tokens
* @returns An array of TINs
*/
getAllAuthenticatedTINs(): string[];
/**
* Get details about the certificate chain
* @returns A promise resolving to the certificate details
*/
getCertificateDetails(): Promise<CertificateChainInfo>;
/**
* Validate a taxpayer's TIN
* @param taxpayerTIN The taxpayer's TIN
* @param idType The type of ID
* @param idValue The value of the ID
* @param authTIN The TIN to use for authentication (optional)
* @returns A promise resolving to the validation result with consistent format
*/
validateTaxpayerTIN(taxpayerTIN: string, idType: string, idValue: string, authTIN?: string): Promise<{
isValid: boolean;
statusCode: number;
message: string;
data?: any;
}>;
/**
* Get the invoice service for creating and managing invoices
* @returns The invoice service
*/
get invoices(): InvoiceService;
/**
* Get the document service for managing documents
* @returns The document service
*/
get documents(): DocumentService;
/**
* Get the code service for retrieving code tables
* @returns The code service
*/
get codes(): CodeService;
}