UNPKG

n8n-nodes-megaapi

Version:

N8N Community Node for MegaAPI WhatsApp automation - Complete WhatsApp integration with messaging, groups, media, and more

53 lines 2.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.restartInstance = restartInstance; const megaapiRequest_1 = require("../megaapiRequest"); async function restartInstance(itemIndex) { var _a; const credentials = await this.getCredentials('megaApiCredentialsApi'); const instanceKey = credentials.instanceKey; console.log('🔐 MegaAPI Credentials loaded'); console.log(`📋 Operation: restart (item ${itemIndex + 1})`); console.log(`🔄 Instance Key: ${instanceKey}`); try { const url = `/rest/instance/${instanceKey}/restart`; console.log(`🌐 Full URL: ${credentials.host}${url}`); console.log('📤 Request Options'); console.log(` Method: DELETE`); console.log(` Authorization: Bearer ${(_a = credentials.token) === null || _a === void 0 ? void 0 : _a.substring(0, 10)}...`); console.log(` Content-Type: application/json`); console.log('🔄 Making restart request to MegaAPI...'); const response = await megaapiRequest_1.megaapiRequest.call(this, 'DELETE', url, {}); console.log('📥 Response received', typeof response === 'string' ? response.substring(0, 50) + '...' : response); let restartData; if (typeof response === 'string') { try { restartData = JSON.parse(response); } catch { restartData = { message: response, status: 'success' }; } } else { restartData = response; } console.log('✅ Instance restart initiated successfully', typeof restartData === 'string' ? restartData.substring(0, 50) + '...' : 'Object received'); return { json: { success: true, operation: 'restart', instanceKey, message: 'Instance restart initiated successfully', data: restartData, timestamp: new Date().toISOString(), }, pairedItem: { item: itemIndex }, }; } catch (error) { console.log('💥 Error in MegaAPI Restart operation'); console.log(error); throw error; } } //# sourceMappingURL=restart.js.map