mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
refactor(core): Remove linting exceptions in nodes-base (no-changelog) (#4944)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user