Files
Automata/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/execute.ts
Michael Kret 91d7e16c81 n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
2022-08-17 17:50:24 +02:00

40 lines
1009 B
TypeScript

import { IExecuteFunctions } from 'n8n-core';
import { IDataObject, INodeExecutionData } from 'n8n-workflow';
import { apiRequest } from '../../../transport';
export async function createTicket(
this: IExecuteFunctions,
index: number,
): Promise<INodeExecutionData[]> {
const id = this.getNodeParameter('customerId', index) as IDataObject;
const subject = this.getNodeParameter('subject', index) as IDataObject;
const { assetId, dueDate, issueType, status, contactId } = this.getNodeParameter(
'additionalFields',
index,
) as IDataObject;
const qs = {} as IDataObject;
const requestMethod = 'POST';
const endpoint = 'tickets';
let body = {} as IDataObject;
body = {
asset_id: assetId,
//due_date: dueDate,
problem_type: issueType,
status,
contact_id: contactId,
};
body.customer_id = id;
body.subject = subject;
let responseData;
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
return this.helpers.returnJsonArray(responseData.ticket);
}