UNPKG

@eleva-io/erp-sdk

Version:

SDK oficial para el ERP de Eleva

57 lines 1.97 kB
import pino from 'pino'; import { HTTPClient } from './utils/http'; import { HorizontalAPI } from './modules/horizontal'; import { TicketingAPI } from './modules/ticketing'; import { ContactsAPI } from './modules/contacts/api'; import { GlobalAPI } from './modules/global/api'; import { DomainAPI } from './modules/domain/api'; import { BankAccountsAPI } from './modules/bank_accounts'; import { TagsAPI } from './modules/tags'; export class ERPClient { _baseUrl = '/api/v1'; _httpClient; constructor(config) { if (!config.baseURL) { throw new Error('Missing required baseURL configuration'); } if ('token' in config) { if (!config.token) { throw new Error('Token is required when using token authentication'); } } else { if (!config.apiKey || !config.apiSecret) { throw new Error('API key and secret are required when using API key authentication'); } } let logger = config.logger?.instance; if (!logger) { logger = pino(); logger.level = config.logger?.level || 'info'; } logger = logger.child({ client: 'eleva-erp' }); this._httpClient = new HTTPClient(config, logger); } domain() { return new DomainAPI(this._httpClient, this._baseUrl); // TODO: auth http client } global() { return new GlobalAPI(this._httpClient, this._baseUrl); } contacts() { return new ContactsAPI(this._httpClient, this._baseUrl); } horizontal() { return new HorizontalAPI(this._httpClient, this._baseUrl); } ticketing() { return new TicketingAPI(this._httpClient, this._baseUrl); } bankAccounts() { return new BankAccountsAPI(this._httpClient, this._baseUrl); } tags(id) { return new TagsAPI(this._httpClient, this._baseUrl, id); } } //# sourceMappingURL=erp.js.map