UNPKG

n8n-nodes-base

Version:

Base nodes of n8n

31 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.updateTicket = updateTicket; const n8n_workflow_1 = require("n8n-workflow"); const transport_1 = require("../../../transport"); async function updateTicket(index) { const id = this.getNodeParameter('ticketId', index); const { assetId, customerId, dueDate, issueType, status, subject, ticketType, contactId } = this.getNodeParameter('updateFields', index); const qs = {}; const requestMethod = 'PUT'; const endpoint = `tickets/${id}`; let body = {}; body = { ...(assetId && { asset_id: assetId }), ...(customerId && { customer_id: customerId }), ...(dueDate && { due_date: dueDate }), ...(issueType && { problem_type: issueType }), ...(status && { status }), ...(subject && { subject }), ...(ticketType && { ticket_type: ticketType }), ...(contactId && { contact_id: contactId }), }; if (!Object.keys(body).length) { throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'At least one update fields has to be defined', { itemIndex: index, }); } const responseData = await transport_1.apiRequest.call(this, requestMethod, endpoint, body, qs); return this.helpers.returnJsonArray(responseData.ticket); } //# sourceMappingURL=execute.js.map