fix(HelpScout Node): Fix issue with thread types not working correctly (#10084)

This commit is contained in:
Jon 2024-07-17 14:57:26 +01:00 committed by GitHub
parent 76c290655d
commit 68d3bebfee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -459,6 +459,13 @@ export class HelpScout implements INodeType {
const text = this.getNodeParameter('text', i) as string; const text = this.getNodeParameter('text', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i); const additionalFields = this.getNodeParameter('additionalFields', i);
const attachments = this.getNodeParameter('attachmentsUi', i) as IDataObject; const attachments = this.getNodeParameter('attachmentsUi', i) as IDataObject;
let threadType = this.getNodeParameter('type', i) as string;
// We need to update the types to match the API - Avoids a breaking change
const singular = ['reply', 'customer'];
if (!singular.includes(threadType)) {
threadType = `${threadType}s`;
}
const body: IThread = { const body: IThread = {
text, text,
attachments: [], attachments: [],
@ -527,7 +534,7 @@ export class HelpScout implements INodeType {
responseData = await helpscoutApiRequest.call( responseData = await helpscoutApiRequest.call(
this, this,
'POST', 'POST',
`/v2/conversations/${conversationId}/chats`, `/v2/conversations/${conversationId}/${threadType}`,
body, body,
); );
responseData = { success: true }; responseData = { success: true };