mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Fixed some lint and cosmetic issues
This commit is contained in:
@@ -3,21 +3,21 @@ import { OptionsWithUri } from 'request';
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IExecuteSingleFunctions
|
||||
ILoadOptionsFunctions,
|
||||
IExecuteSingleFunctions
|
||||
} from 'n8n-core';
|
||||
|
||||
import * as _ from 'lodash';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
|
||||
export async function mandrillApiRequest(this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, resource: string, method: string, action: string, body: any = {}, headers?: object): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('mandrillApi');
|
||||
const credentials = this.getCredentials('mandrillApi');
|
||||
|
||||
if (credentials === undefined) {
|
||||
if (credentials === undefined) {
|
||||
throw new Error('No credentials got returned!');
|
||||
}
|
||||
|
||||
const data = Object.assign({ }, body, { key: credentials.apiKey });
|
||||
}
|
||||
|
||||
const data = Object.assign({}, body, { key: credentials.apiKey });
|
||||
|
||||
const endpoint = 'mandrillapp.com/api/1.0';
|
||||
|
||||
@@ -25,13 +25,13 @@ export async function mandrillApiRequest(this: IHookFunctions | IExecuteFunction
|
||||
headers,
|
||||
method,
|
||||
uri: `https://${endpoint}${resource}${action}.json`,
|
||||
body: data,
|
||||
json: true
|
||||
};
|
||||
|
||||
body: data,
|
||||
json: true
|
||||
};
|
||||
|
||||
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
@@ -40,62 +40,62 @@ export async function mandrillApiRequest(this: IHookFunctions | IExecuteFunction
|
||||
throw new Error('The provided API key is not a valid Mandrill API key');
|
||||
} else if (error.name === 'ValidationError') {
|
||||
throw new Error('The parameters passed to the API call are invalid or not provided when required');
|
||||
} else if (error.name === 'GeneralError') {
|
||||
} else if (error.name === 'GeneralError') {
|
||||
throw new Error('An unexpected error occurred processing the request. Mandrill developers will be notified.');
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessage !== undefined) {
|
||||
throw errorMessage;
|
||||
}
|
||||
throw error.response.body;
|
||||
}
|
||||
}
|
||||
}
|
||||
// @ts-ignore
|
||||
export function getToEmailArray(toEmail: string): any {
|
||||
let toEmailArray;
|
||||
if (toEmail.split(',').length > 0) {
|
||||
const array = toEmail.split(',');
|
||||
toEmailArray = _.map(array, (email) => {
|
||||
return {
|
||||
email,
|
||||
type: 'to'
|
||||
};
|
||||
});
|
||||
} else {
|
||||
toEmailArray = [{
|
||||
email: toEmail,
|
||||
type: 'to'
|
||||
}];
|
||||
}
|
||||
return toEmailArray;
|
||||
}
|
||||
|
||||
export function getGoogleAnalyticsDomainsArray(s: string): string[] {
|
||||
let array: string[] = [];
|
||||
if (s.split(',').length > 0) {
|
||||
array = s.split(',');
|
||||
} else {
|
||||
array = [s];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
export function getToEmailArray(toEmail: string): any { // tslint:disable-line:no-any
|
||||
let toEmailArray;
|
||||
if (toEmail.split(',').length > 0) {
|
||||
const array = toEmail.split(',');
|
||||
toEmailArray = _.map(array, (email) => {
|
||||
return {
|
||||
email,
|
||||
type: 'to'
|
||||
};
|
||||
});
|
||||
} else {
|
||||
toEmailArray = [{
|
||||
email: toEmail,
|
||||
type: 'to'
|
||||
}];
|
||||
}
|
||||
return toEmailArray;
|
||||
}
|
||||
|
||||
export function getTags(s: string): Array<any> {
|
||||
let array = [];
|
||||
if (s.split(',').length > 0) {
|
||||
array = s.split(',');
|
||||
} else {
|
||||
array = [s];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
export function getGoogleAnalyticsDomainsArray(s: string): string[] {
|
||||
let array: string[] = [];
|
||||
if (s.split(',').length > 0) {
|
||||
array = s.split(',');
|
||||
} else {
|
||||
array = [s];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
export function validateJSON(json: string | undefined): any {
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(json!);
|
||||
} catch (exception) {
|
||||
result = [];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
export function getTags(s: string): any[] { // tslint:disable-line:no-any
|
||||
let array = [];
|
||||
if (s.split(',').length > 0) {
|
||||
array = s.split(',');
|
||||
} else {
|
||||
array = [s];
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
export function validateJSON(json: string | undefined): any { // tslint:disable-line:no-any
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(json!);
|
||||
} catch (exception) {
|
||||
result = [];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user