UNPKG

@digitalstories/n8n-nodes-infomaniak

Version:

n8n nodes to interact with Infomaniak services (Kchat)

63 lines 2.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.KchatService = void 0; const ApiService_1 = require("../../core/ApiService"); class KchatService extends ApiService_1.ApiService { constructor(executeFunctions, credentials) { super(executeFunctions, credentials); this.serviceName = 'Kchat'; } getCredentialsTeamSlug() { var _a; return (_a = this.credentials) === null || _a === void 0 ? void 0 : _a.teamSlug; } getDebugBaseUrl() { return this.getBaseUrl(); } getBaseUrl() { if (!this.credentials.teamSlug) { throw new Error('Le "Team Slug" est requis pour accéder à l\'API Kchat'); } return `https://${this.credentials.teamSlug}.kchat.infomaniak.com/api/v4`; } async getChannels() { return this.request('GET', '/channels'); } async createPost(channelId, message, fileIds) { const body = { channel_id: channelId, message, }; if (fileIds && fileIds.length > 0) { body.file_ids = fileIds; } return this.request('POST', '/posts', body); } async listPosts(channelId) { return this.request('GET', `/channels/${channelId}/posts`); } async uploadFile(channelId, fileData, fileName, mimeType) { const formData = { channel_id: channelId, files: { value: fileData, options: { filename: fileName, contentType: mimeType, }, }, }; return this.request('POST', '/files', undefined, undefined, formData); } async getFileDetails(fileId) { return this.request('GET', `/files/${fileId}`); } async listUsers() { return this.request('GET', '/users'); } async getUser(userId) { return this.request('GET', `/users/${userId}`); } } exports.KchatService = KchatService; //# sourceMappingURL=KchatService.js.map