mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
sync upstream master
This commit is contained in:
25
packages/nodes-base/credentials/FreshdeskApi.credentials.ts
Normal file
25
packages/nodes-base/credentials/FreshdeskApi.credentials.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {
|
||||
ICredentialType,
|
||||
NodePropertyTypes,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
|
||||
export class FreshdeskApi implements ICredentialType {
|
||||
name = 'freshdeskApi';
|
||||
displayName = 'Freshdesk API';
|
||||
properties = [
|
||||
{
|
||||
displayName: 'API Key',
|
||||
name: 'apiKey',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Domain',
|
||||
name: 'domain',
|
||||
type: 'string' as NodePropertyTypes,
|
||||
placeholder: 'https://domain.freshdesk.com',
|
||||
default: ''
|
||||
}
|
||||
];
|
||||
}
|
||||
@@ -16,10 +16,17 @@ import {
|
||||
} from './GenericFunctions';
|
||||
|
||||
enum Status {
|
||||
<<<<<<< HEAD
|
||||
Open = 1,
|
||||
Pending = 2,
|
||||
Resolved = 3,
|
||||
Closed = 4
|
||||
=======
|
||||
Open = 2,
|
||||
Pending = 3,
|
||||
Resolved = 4,
|
||||
Closed = 5,
|
||||
>>>>>>> 0689f4e403043c5e3f13bc393f1164785772cb19
|
||||
}
|
||||
|
||||
enum Priority {
|
||||
@@ -36,7 +43,7 @@ enum Source {
|
||||
Chat = 4,
|
||||
Mobihelp = 5,
|
||||
FeedbackWidget = 6,
|
||||
OutboundEmail = 7
|
||||
OutboundEmail = 7
|
||||
}
|
||||
|
||||
interface ICreateTicketBody {
|
||||
@@ -683,7 +690,6 @@ export class Freshdesk implements INodeType {
|
||||
// @ts-ignore
|
||||
source: Source[capitalize(source)]
|
||||
};
|
||||
|
||||
if (requester === 'requesterId') {
|
||||
// @ts-ignore
|
||||
if (isNaN(value)) {
|
||||
@@ -737,36 +743,39 @@ export class Freshdesk implements INodeType {
|
||||
}
|
||||
|
||||
if (options.agent) {
|
||||
options.responder_id = options.agent as number;
|
||||
body.responder_id = options.agent as number;
|
||||
}
|
||||
|
||||
if (options.company) {
|
||||
options.company_id = options.company as number;
|
||||
body.company_id = options.company as number;
|
||||
}
|
||||
|
||||
if (options.product) {
|
||||
options.product_id = options.product as number;
|
||||
body.product_id = options.product as number;
|
||||
}
|
||||
|
||||
|
||||
if (options.group) {
|
||||
options.group_id = options.group as number;
|
||||
body.group_id = options.group as number;
|
||||
}
|
||||
|
||||
if (options.frDueBy) {
|
||||
options.fr_due_by = options.frDueBy as string;
|
||||
body.fr_due_by = options.frDueBy as string;
|
||||
}
|
||||
|
||||
if (options.emailConfigId) {
|
||||
options.email_config_id = options.emailConfigId as number;
|
||||
body.email_config_id = options.emailConfigId as number;
|
||||
}
|
||||
|
||||
if (options.dueBy) {
|
||||
options.due_by = options.dueBy as string;
|
||||
body.due_by = options.dueBy as string;
|
||||
}
|
||||
|
||||
if (options.tags) {
|
||||
body.tags = (options.tags as string).split(',') as [string];
|
||||
}
|
||||
|
||||
if (options.ccEmails) {
|
||||
// @ts-ignore
|
||||
options.cc_emails = options.ccEmails.split(',') as [string];
|
||||
body.cc_emails = (options.ccEmails as string).split(',') as [string];
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
66
packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts
Normal file
66
packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { OptionsWithUri } from 'request';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IExecuteSingleFunctions,
|
||||
BINARY_ENCODING
|
||||
} from 'n8n-core';
|
||||
|
||||
import * as _ from 'lodash';
|
||||
|
||||
export async function freshdeskApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resource: string, method: string, body: any = {}, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
|
||||
const credentials = this.getCredentials('freshdeskApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
}
|
||||
|
||||
const apiKey = `${credentials.apiKey}:X`;
|
||||
|
||||
const headerWithAuthentication = Object.assign({}, headers, { Authorization: `${Buffer.from(apiKey).toString(BINARY_ENCODING)}` });
|
||||
|
||||
const endpoint = 'freshdesk.com/api/v2/';
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
headers: headerWithAuthentication,
|
||||
method,
|
||||
body,
|
||||
uri: `https://${credentials.domain}.${endpoint}${resource}`,
|
||||
json: true
|
||||
};
|
||||
|
||||
if (_.isEmpty(options.body)) {
|
||||
delete options.body;
|
||||
}
|
||||
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
const errorMessage = error.response.body.message || error.response.body.Message;
|
||||
|
||||
if (errorMessage !== undefined) {
|
||||
throw errorMessage;
|
||||
}
|
||||
throw error.response.body;
|
||||
}
|
||||
}
|
||||
|
||||
export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(json!);
|
||||
} catch (exception) {
|
||||
result = [];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function capitalize (s: string) : string {
|
||||
if (typeof s !== 'string') return '';
|
||||
return s.charAt(0).toUpperCase() + s.slice(1);
|
||||
}
|
||||
BIN
packages/nodes-base/nodes/Freshdesk/freshdesk.png
Normal file
BIN
packages/nodes-base/nodes/Freshdesk/freshdesk.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
@@ -259,6 +259,23 @@ export class Gitlab implements INodeType {
|
||||
},
|
||||
description: 'The body of the issue.',
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date',
|
||||
name: 'due_date',
|
||||
type: 'dateTime',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: [
|
||||
'create',
|
||||
],
|
||||
resource: [
|
||||
'issue',
|
||||
],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Due Date for issue.',
|
||||
},
|
||||
{
|
||||
displayName: 'Labels',
|
||||
name: 'labels',
|
||||
@@ -318,6 +335,7 @@ export class Gitlab implements INodeType {
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
// issue:createComment
|
||||
// ----------------------------------
|
||||
@@ -409,7 +427,7 @@ export class Gitlab implements INodeType {
|
||||
},
|
||||
{
|
||||
displayName: 'Body',
|
||||
name: 'body',
|
||||
name: 'description',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
rows: 5,
|
||||
@@ -474,6 +492,13 @@ export class Gitlab implements INodeType {
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Due Date',
|
||||
name: 'due_date',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Due Date for issue.',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -829,6 +854,7 @@ export class Gitlab implements INodeType {
|
||||
|
||||
body.title = this.getNodeParameter('title', i) as string;
|
||||
body.description = this.getNodeParameter('body', i) as string;
|
||||
body.due_date = this.getNodeParameter('due_date', i) as string;
|
||||
const labels = this.getNodeParameter('labels', i) as IDataObject[];
|
||||
|
||||
const assigneeIds = this.getNodeParameter('assignee_ids', i) as IDataObject[];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "n8n-nodes-base",
|
||||
"version": "0.28.0",
|
||||
"version": "0.29.0",
|
||||
"description": "Base nodes of n8n",
|
||||
"license": "SEE LICENSE IN LICENSE.md",
|
||||
"homepage": "https://n8n.io",
|
||||
@@ -33,6 +33,7 @@
|
||||
"dist/credentials/Aws.credentials.js",
|
||||
"dist/credentials/ChargebeeApi.credentials.js",
|
||||
"dist/credentials/DropboxApi.credentials.js",
|
||||
"dist/credentials/FreshdeskApi.credentials.js",
|
||||
"dist/credentials/GithubApi.credentials.js",
|
||||
"dist/credentials/GitlabApi.credentials.js",
|
||||
"dist/credentials/GoogleApi.credentials.js",
|
||||
@@ -42,6 +43,7 @@
|
||||
"dist/credentials/Imap.credentials.js",
|
||||
"dist/credentials/LinkFishApi.credentials.js",
|
||||
"dist/credentials/MailgunApi.credentials.js",
|
||||
"dist/credentials/MandrillApi.credentials.js",
|
||||
"dist/credentials/MattermostApi.credentials.js",
|
||||
"dist/credentials/MongoDb.credentials.js",
|
||||
"dist/credentials/NextCloudApi.credentials.js",
|
||||
@@ -53,11 +55,10 @@
|
||||
"dist/credentials/Smtp.credentials.js",
|
||||
"dist/credentials/StripeApi.credentials.js",
|
||||
"dist/credentials/TelegramApi.credentials.js",
|
||||
"dist/credentials/TodoistApi.credentials.js",
|
||||
"dist/credentials/TrelloApi.credentials.js",
|
||||
"dist/credentials/TwilioApi.credentials.js",
|
||||
"dist/credentials/TypeformApi.credentials.js",
|
||||
"dist/credentials/MandrillApi.credentials.js",
|
||||
"dist/credentials/TodoistApi.credentials.js"
|
||||
"dist/credentials/TypeformApi.credentials.js"
|
||||
],
|
||||
"nodes": [
|
||||
"dist/nodes/ActiveCampaign/ActiveCampaign.node.js",
|
||||
@@ -78,6 +79,7 @@
|
||||
"dist/nodes/EmailSend.node.js",
|
||||
"dist/nodes/ErrorTrigger.node.js",
|
||||
"dist/nodes/ExecuteCommand.node.js",
|
||||
"dist/nodes/Freshdesk/Freshdesk.node.js",
|
||||
"dist/nodes/Function.node.js",
|
||||
"dist/nodes/FunctionItem.node.js",
|
||||
"dist/nodes/Github/Github.node.js",
|
||||
@@ -92,6 +94,7 @@
|
||||
"dist/nodes/Interval.node.js",
|
||||
"dist/nodes/LinkFish/LinkFish.node.js",
|
||||
"dist/nodes/Mailgun/Mailgun.node.js",
|
||||
"dist/nodes/Mandrill/Mandrill.node.js",
|
||||
"dist/nodes/Mattermost/Mattermost.node.js",
|
||||
"dist/nodes/Merge.node.js",
|
||||
"dist/nodes/MoveBinaryData.node.js",
|
||||
@@ -116,15 +119,14 @@
|
||||
"dist/nodes/Stripe/StripeTrigger.node.js",
|
||||
"dist/nodes/Telegram/Telegram.node.js",
|
||||
"dist/nodes/Telegram/TelegramTrigger.node.js",
|
||||
"dist/nodes/Todoist/Todoist.node.js",
|
||||
"dist/nodes/Trello/Trello.node.js",
|
||||
"dist/nodes/Trello/TrelloTrigger.node.js",
|
||||
"dist/nodes/Twilio/Twilio.node.js",
|
||||
"dist/nodes/Typeform/TypeformTrigger.node.js",
|
||||
"dist/nodes/WriteBinaryFile.node.js",
|
||||
"dist/nodes/Webhook.node.js",
|
||||
"dist/nodes/Xml.node.js",
|
||||
"dist/nodes/Mandrill/Mandrill.node.js",
|
||||
"dist/nodes/Todoist/Todoist.node.js"
|
||||
"dist/nodes/Xml.node.js"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user