mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 19:11:13 +00:00
36 lines
965 B
TypeScript
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[]);
|
|
}
|