refactor(core): Remove linting exceptions in nodes-base (no-changelog) (#4944)

This commit is contained in:
Michael Kret
2023-01-13 19:11:56 +02:00
committed by GitHub
parent d7732ea150
commit 6608e69457
254 changed files with 2687 additions and 2675 deletions

View File

@@ -11,44 +11,7 @@ import {
import { IDataObject, NodeApiError, NodeOperationError } from 'n8n-workflow';
export async function payPalApiRequest(
this:
| IHookFunctions
| IExecuteFunctions
| IExecuteSingleFunctions
| ILoadOptionsFunctions
| IWebhookFunctions,
endpoint: string,
method: string,
body: any = {},
query?: IDataObject,
uri?: string,
): Promise<any> {
const credentials = await this.getCredentials('payPalApi');
const env = getEnvironment(credentials.env as string);
const tokenInfo = await getAccessToken.call(this);
const headerWithAuthentication = Object.assign(
{},
{ Authorization: `Bearer ${tokenInfo.access_token}`, 'Content-Type': 'application/json' },
);
const options = {
headers: headerWithAuthentication,
method,
qs: query || {},
uri: uri || `${env}/v1${endpoint}`,
body,
json: true,
};
try {
return await this.helpers.request(options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}
function getEnvironment(env: string): string {
// @ts-ignore
function getEnvironment(env: string) {
return {
sanbox: 'https://api-m.sandbox.paypal.com',
live: 'https://api-m.paypal.com',
@@ -88,6 +51,51 @@ async function getAccessToken(
}
}
export async function payPalApiRequest(
this:
| IHookFunctions
| IExecuteFunctions
| IExecuteSingleFunctions
| ILoadOptionsFunctions
| IWebhookFunctions,
endpoint: string,
method: string,
body: any = {},
query?: IDataObject,
uri?: string,
): Promise<any> {
const credentials = await this.getCredentials('payPalApi');
const env = getEnvironment(credentials.env as string);
const tokenInfo = await getAccessToken.call(this);
const headerWithAuthentication = Object.assign(
{},
{ Authorization: `Bearer ${tokenInfo.access_token}`, 'Content-Type': 'application/json' },
);
const options = {
headers: headerWithAuthentication,
method,
qs: query ?? {},
uri: uri ?? `${env}/v1${endpoint}`,
body,
json: true,
};
try {
return await this.helpers.request(options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}
function getNext(links: IDataObject[]): string | undefined {
for (const link of links) {
if (link.rel === 'next') {
return link.href as string;
}
}
return undefined;
}
/**
* Make an API request to paginated paypal endpoint
* and return all results
@@ -117,15 +125,6 @@ export async function payPalApiRequestAllItems(
return returnData;
}
function getNext(links: IDataObject[]): string | undefined {
for (const link of links) {
if (link.rel === 'next') {
return link.href as string;
}
}
return undefined;
}
export function validateJSON(json: string | undefined): any {
let result;
try {