Files
n8n-enterprise-unlocked/packages/nodes-base/nodes/SyncroMSP/v1/actions/ticket/create/execute.ts
कारतोफ्फेलस्क्रिप्ट™ 7a4e9ef5fa refactor: Remove n8n-core dependency in nodes-base (no-changelog) (#5649)
2023-03-09 18:13:15 +01:00

36 lines
965 B
TypeScript

import type { IExecuteFunctions, 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, issueType, status, contactId } = this.getNodeParameter(
'additionalFields',
index,
);
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;
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
return this.helpers.returnJsonArray(responseData.ticket as IDataObject[]);
}