@montarist/nilvera-api
Version:
An unofficial SDK for integrating with Nilvera e-Invoice, e-Archive services
77 lines (76 loc) • 2.69 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NilveraApiClient = void 0;
const services_1 = require("./services");
/**
* @class NilveraApiClient
* @description Main client class for interacting with the Nilvera API services.
* Provides access to various services including payments, firms, e-invoices, products, and master data.
*/
class NilveraApiClient {
/**
* @constructor
* @param {string} baseUrl - Base URL of the Nilvera API
* @param {string} apiKey - The API key for authentication
*/
constructor(baseUrl, apiKey, mode) {
this.apiClient = new services_1.ApiClient(baseUrl, apiKey, mode);
}
/**
* @getter
* @description Access master data operations
* @returns {EInvoiceService} Instance of EInvoiceService
* @throws {Error} If API client is not initialized
*/
get eInvoice() {
if (!this.eInvoiceService) {
if (!this.apiClient)
throw new Error('API client not initialized');
this.eInvoiceService = new services_1.EInvoiceService(this.apiClient);
}
return this.eInvoiceService;
}
/**
* @getter
* @description Access master data operations
* @returns {EArchiveService} Instance of EArchiveService
* @throws {Error} If API client is not initialized
*/
get earchive() {
if (!this.earchiveService) {
if (!this.apiClient)
throw new Error('API client not initialized');
this.earchiveService = new services_1.EArchiveService(this.apiClient);
}
return this.earchiveService;
}
/**
* @getter
* @description Access master data operations
* @returns {OldInvoiceService} Instance of OldInvoiceService
* @throws {Error} If API client is not initialized
*/
get oldInvoice() {
if (!this.oldInvoiceService) {
if (!this.apiClient)
throw new Error('API client not initialized');
this.oldInvoiceService = new services_1.OldInvoiceService(this.apiClient);
}
return this.oldInvoiceService;
}
/**
* @getter
* @description Access master data operations
* @returns {GeneralService} Instance of GeneralService
* @throws {Error} If API client is not initialized
*/
get general() {
if (!this.generalService) {
if (!this.apiClient)
throw new Error('API client not initialized');
this.generalService = new services_1.GeneralService(this.apiClient);
}
return this.generalService;
}
}
exports.NilveraApiClient = NilveraApiClient;