UNPKG

digi-tech-sdk

Version:

SDK oficial para integrar con la API de Digi

54 lines (53 loc) 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RecordService = void 0; class RecordService { constructor(client, authManager) { this.client = client; this.authManager = authManager; } /** * Gets the API version path prefix * @returns The API version path (e.g. "/1.0") */ getApiVersionPath() { const version = this.authManager.getApiVersion() || '1.0'; return `/${version}`; } /** * Creates a new record * @param data The data for the new record * @param strategy Creation strategy (IGNORE, COMPLETE, OVERRIDE) * @returns The created record */ async create(data, strategy) { const headers = {}; if (strategy) { headers['strategy'] = strategy; } const response = await this.client.post(`${this.getApiVersionPath()}/legajo`, data, { headers }); return response.data; } /** * Gets a record by ID * @param recordId The ID of the record * @returns The record */ async get(recordId) { const response = await this.client.get(`${this.getApiVersionPath()}/legajo/${recordId}`); return response.data; } /** * Updates a record * @param recordId The ID of the record to update * @param data The data to update * @returns The updated record */ async update(recordId, data) { const response = await this.client.put(`${this.getApiVersionPath()}/legajo/${recordId}`, data); return response.data; } } exports.RecordService = RecordService;