UNPKG

n8n-nodes-cativa

Version:

This is an n8n community node to communicate with Cativa.

39 lines 1.77 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resourcePost = void 0; const GenericFunctions_1 = require("../GenericFunctions"); async function resourcePost(operation, i) { const credentials = (await this.getCredentials('cativaApi')); const headers = { Authorization: `${credentials.apiKey}`, }; let responseData; if (operation === 'commentOnPost') { let endpoint = 'https://social-api.cativalab.digital/v1.1/post/{{postId}}/comment'; const postId = this.getNodeParameter('postId', i); endpoint = endpoint.replace('{{postId}}', postId); const body = { content: this.getNodeParameter('content', i), }; responseData = await GenericFunctions_1.apiRequest.call(this, 'POST', endpoint, body, {}, headers); } else if (operation === 'postOnGroup') { let endpoint = 'https://social-api.cativalab.digital/v1.1/group/{{groupId}}/post'; const groupId = this.getNodeParameter('groupId', i); endpoint = endpoint.replace('{{groupId}}', groupId); const body = { content: this.getNodeParameter('content', i), }; responseData = await GenericFunctions_1.apiRequest.call(this, 'POST', endpoint, body, {}, headers); } else if (operation === 'postOnPublicFeed') { const endpoint = 'https://social-api.cativalab.digital/v1.1/post'; const body = { content: this.getNodeParameter('content', i), }; responseData = await GenericFunctions_1.apiRequest.call(this, 'POST', endpoint, body, {}, headers); } return responseData; } exports.resourcePost = resourcePost; //# sourceMappingURL=PostMethods.js.map