mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
import {
|
||||
OptionsWithUri
|
||||
} from 'request';
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { OptionsWithUri } from 'request';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
ICredentialsDecrypted,
|
||||
ICredentialTestFunctions,
|
||||
@@ -27,12 +23,8 @@ import {
|
||||
ISenderBatchHeader,
|
||||
RecipientType,
|
||||
RecipientWallet,
|
||||
} from './PaymentInteface';
|
||||
import {
|
||||
payPalApiRequest,
|
||||
payPalApiRequestAllItems,
|
||||
validateJSON,
|
||||
} from './GenericFunctions';
|
||||
} from './PaymentInteface';
|
||||
import { payPalApiRequest, payPalApiRequestAllItems, validateJSON } from './GenericFunctions';
|
||||
|
||||
export class PayPal implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -84,7 +76,10 @@ export class PayPal implements INodeType {
|
||||
|
||||
methods = {
|
||||
credentialTest: {
|
||||
async payPalApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult> {
|
||||
async payPalApiTest(
|
||||
this: ICredentialTestFunctions,
|
||||
credential: ICredentialsDecrypted,
|
||||
): Promise<INodeCredentialTestResult> {
|
||||
const credentials = credential.data;
|
||||
const clientId = credentials!.clientId;
|
||||
const clientSecret = credentials!.secret;
|
||||
@@ -108,7 +103,7 @@ export class PayPal implements INodeType {
|
||||
|
||||
const options: OptionsWithUri = {
|
||||
headers: {
|
||||
'Authorization': `Basic ${base64Key}`,
|
||||
Authorization: `Basic ${base64Key}`,
|
||||
},
|
||||
method: 'POST',
|
||||
uri: `${baseUrl}/v1/oauth2/token`,
|
||||
@@ -123,8 +118,7 @@ export class PayPal implements INodeType {
|
||||
status: 'OK',
|
||||
message: 'Authentication successful!',
|
||||
};
|
||||
}
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
return {
|
||||
status: 'Error',
|
||||
message: `Connection details not valid: ${error.message}`,
|
||||
@@ -166,51 +160,78 @@ export class PayPal implements INodeType {
|
||||
body.sender_batch_header = header;
|
||||
if (!jsonActive) {
|
||||
const payoutItems: IItem[] = [];
|
||||
const itemsValues = (this.getNodeParameter('itemsUi', i) as IDataObject).itemsValues as IDataObject[];
|
||||
const itemsValues = (this.getNodeParameter('itemsUi', i) as IDataObject)
|
||||
.itemsValues as IDataObject[];
|
||||
if (itemsValues && itemsValues.length > 0) {
|
||||
itemsValues.forEach(o => {
|
||||
itemsValues.forEach((o) => {
|
||||
const payoutItem: IItem = {};
|
||||
const amount: IAmount = {};
|
||||
amount.currency = o.currency as string;
|
||||
amount.value = parseFloat(o.amount as string);
|
||||
payoutItem.amount = amount;
|
||||
payoutItem.note = o.note as string || '';
|
||||
payoutItem.note = (o.note as string) || '';
|
||||
payoutItem.receiver = o.receiverValue as string;
|
||||
payoutItem.recipient_type = o.recipientType as RecipientType;
|
||||
payoutItem.recipient_wallet = o.recipientWallet as RecipientWallet;
|
||||
payoutItem.sender_item_id = o.senderItemId as string || '';
|
||||
payoutItem.sender_item_id = (o.senderItemId as string) || '';
|
||||
payoutItems.push(payoutItem);
|
||||
});
|
||||
body.items = payoutItems;
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), 'You must have at least one item.', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'You must have at least one item.', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const itemsJson = validateJSON(this.getNodeParameter('itemsJson', i) as string);
|
||||
body.items = itemsJson;
|
||||
}
|
||||
responseData = await payPalApiRequest.call(this, '/payments/payouts', 'POST', body);
|
||||
|
||||
}
|
||||
if (operation === 'get') {
|
||||
const payoutBatchId = this.getNodeParameter('payoutBatchId', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', 0) as boolean;
|
||||
if (returnAll === true) {
|
||||
responseData = await payPalApiRequestAllItems.call(this, 'items', `/payments/payouts/${payoutBatchId}`, 'GET', {}, qs);
|
||||
responseData = await payPalApiRequestAllItems.call(
|
||||
this,
|
||||
'items',
|
||||
`/payments/payouts/${payoutBatchId}`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.page_size = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await payPalApiRequest.call(this, `/payments/payouts/${payoutBatchId}`, 'GET', {}, qs);
|
||||
responseData = await payPalApiRequest.call(
|
||||
this,
|
||||
`/payments/payouts/${payoutBatchId}`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.items;
|
||||
}
|
||||
}
|
||||
} else if (resource === 'payoutItem') {
|
||||
if (operation === 'get') {
|
||||
const payoutItemId = this.getNodeParameter('payoutItemId', i) as string;
|
||||
responseData = await payPalApiRequest.call(this,`/payments/payouts-item/${payoutItemId}`, 'GET', {}, qs);
|
||||
responseData = await payPalApiRequest.call(
|
||||
this,
|
||||
`/payments/payouts-item/${payoutItemId}`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
}
|
||||
if (operation === 'cancel') {
|
||||
const payoutItemId = this.getNodeParameter('payoutItemId', i) as string;
|
||||
responseData = await payPalApiRequest.call(this,`/payments/payouts-item/${payoutItemId}/cancel`, 'POST', {}, qs);
|
||||
responseData = await payPalApiRequest.call(
|
||||
this,
|
||||
`/payments/payouts-item/${payoutItemId}/cancel`,
|
||||
'POST',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (Array.isArray(responseData)) {
|
||||
@@ -227,6 +248,5 @@ export class PayPal implements INodeType {
|
||||
}
|
||||
}
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user