first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
import { createSign } from 'crypto';
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
IHttpRequestOptions,
|
||||
ILoadOptionsFunctions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
/**
|
||||
* Make an authenticated API request to Wise.
|
||||
*/
|
||||
export async function wiseApiRequest(
|
||||
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'HEAD' | 'PATCH',
|
||||
endpoint: string,
|
||||
body: IDataObject = {},
|
||||
qs: IDataObject = {},
|
||||
option: IDataObject = {},
|
||||
) {
|
||||
const { apiToken, environment, privateKey } = await this.getCredentials<{
|
||||
apiToken: string;
|
||||
environment: 'live' | 'test';
|
||||
privateKey?: string;
|
||||
}>('wiseApi');
|
||||
|
||||
const rootUrl =
|
||||
environment === 'live'
|
||||
? 'https://api.transferwise.com/'
|
||||
: 'https://api.sandbox.transferwise.tech/';
|
||||
|
||||
const options: IHttpRequestOptions = {
|
||||
headers: {
|
||||
'user-agent': 'n8n',
|
||||
Authorization: `Bearer ${apiToken}`,
|
||||
},
|
||||
method,
|
||||
url: `${rootUrl}${endpoint}`,
|
||||
qs,
|
||||
body,
|
||||
json: true,
|
||||
returnFullResponse: true,
|
||||
ignoreHttpStatusErrors: true,
|
||||
};
|
||||
|
||||
if (!Object.keys(body).length) {
|
||||
delete options.body;
|
||||
}
|
||||
|
||||
if (!Object.keys(qs).length) {
|
||||
delete options.qs;
|
||||
}
|
||||
|
||||
if (option.encoding) {
|
||||
delete options.json;
|
||||
}
|
||||
|
||||
if (Object.keys(option)) {
|
||||
Object.assign(options, option);
|
||||
}
|
||||
|
||||
let response;
|
||||
try {
|
||||
response = await this.helpers.httpRequest(options);
|
||||
} catch (error) {
|
||||
delete error.config;
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
|
||||
if (response.statusCode >= 200 && response.statusCode < 300) {
|
||||
return response.body;
|
||||
}
|
||||
|
||||
// Request requires SCA approval
|
||||
if (response.statusCode === 403 && response.headers['x-2fa-approval']) {
|
||||
if (!privateKey) {
|
||||
throw new NodeApiError(this.getNode(), {
|
||||
message:
|
||||
'This request requires Strong Customer Authentication (SCA). Please add a key pair to your account and n8n credentials. See https://api-docs.transferwise.com/#strong-customer-authentication-personal-token',
|
||||
headers: response.headers,
|
||||
body: response.body,
|
||||
});
|
||||
}
|
||||
// Sign the x-2fa-approval
|
||||
const oneTimeToken = response.headers['x-2fa-approval'] as string;
|
||||
const signerObject = createSign('RSA-SHA256').update(oneTimeToken);
|
||||
try {
|
||||
const signature = signerObject.sign(privateKey, 'base64');
|
||||
delete option.ignoreHttpStatusErrors;
|
||||
options.headers = {
|
||||
...options.headers,
|
||||
'X-Signature': signature,
|
||||
'x-2fa-approval': oneTimeToken,
|
||||
};
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), {
|
||||
message: 'Error signing SCA request, check your private key',
|
||||
...(error as JsonObject),
|
||||
});
|
||||
}
|
||||
// Retry the request with signed token
|
||||
try {
|
||||
response = await this.helpers.httpRequest(options);
|
||||
return response.body;
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), {
|
||||
message: 'SCA request failed, check your private key is valid',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw new NodeApiError(this.getNode(), {
|
||||
...(response as JsonObject),
|
||||
message: response.statusMessage,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function getTriggerName(eventName: string) {
|
||||
const events: IDataObject = {
|
||||
tranferStateChange: 'transfers#state-change',
|
||||
transferActiveCases: 'transfers#active-cases',
|
||||
balanceCredit: 'balances#credit',
|
||||
balanceUpdate: 'balances#update',
|
||||
};
|
||||
return events[eventName];
|
||||
}
|
||||
|
||||
export type BorderlessAccount = {
|
||||
id: number;
|
||||
balances: Array<{ currency: string }>;
|
||||
};
|
||||
|
||||
export type ExchangeRateAdditionalFields = {
|
||||
interval: 'day' | 'hour' | 'minute';
|
||||
range: {
|
||||
rangeProperties: { from: string; to: string };
|
||||
};
|
||||
time: string;
|
||||
};
|
||||
|
||||
export type Profile = {
|
||||
id: number;
|
||||
type: 'business' | 'personal';
|
||||
};
|
||||
|
||||
export type Recipient = {
|
||||
active: boolean;
|
||||
id: number;
|
||||
accountHolderName: string;
|
||||
country: string | null;
|
||||
currency: string;
|
||||
type: string;
|
||||
};
|
||||
|
||||
export type StatementAdditionalFields = {
|
||||
lineStyle: 'COMPACT' | 'FLAT';
|
||||
range: {
|
||||
rangeProperties: { intervalStart: string; intervalEnd: string };
|
||||
};
|
||||
};
|
||||
|
||||
export type TransferFilters = {
|
||||
[key: string]: string | IDataObject;
|
||||
range: {
|
||||
rangeProperties: { createdDateStart: string; createdDateEnd: string };
|
||||
};
|
||||
sourceCurrency: string;
|
||||
status: string;
|
||||
targetCurrency: string;
|
||||
};
|
||||
|
||||
export const livePublicKey = `
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvO8vXV+JksBzZAY6GhSO
|
||||
XdoTCfhXaaiZ+qAbtaDBiu2AGkGVpmEygFmWP4Li9m5+Ni85BhVvZOodM9epgW3F
|
||||
bA5Q1SexvAF1PPjX4JpMstak/QhAgl1qMSqEevL8cmUeTgcMuVWCJmlge9h7B1CS
|
||||
D4rtlimGZozG39rUBDg6Qt2K+P4wBfLblL0k4C4YUdLnpGYEDIth+i8XsRpFlogx
|
||||
CAFyH9+knYsDbR43UJ9shtc42Ybd40Afihj8KnYKXzchyQ42aC8aZ/h5hyZ28yVy
|
||||
Oj3Vos0VdBIs/gAyJ/4yyQFCXYte64I7ssrlbGRaco4nKF3HmaNhxwyKyJafz19e
|
||||
HwIDAQAB
|
||||
-----END PUBLIC KEY-----`;
|
||||
|
||||
export const testPublicKey = `
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwpb91cEYuyJNQepZAVfP
|
||||
ZIlPZfNUefH+n6w9SW3fykqKu938cR7WadQv87oF2VuT+fDt7kqeRziTmPSUhqPU
|
||||
ys/V2Q1rlfJuXbE+Gga37t7zwd0egQ+KyOEHQOpcTwKmtZ81ieGHynAQzsn1We3j
|
||||
wt760MsCPJ7GMT141ByQM+yW1Bx+4SG3IGjXWyqOWrcXsxAvIXkpUD/jK/L958Cg
|
||||
nZEgz0BSEh0QxYLITnW1lLokSx/dTianWPFEhMC9BgijempgNXHNfcVirg1lPSyg
|
||||
z7KqoKUN0oHqWLr2U1A+7kqrl6O2nx3CKs1bj1hToT1+p4kcMoHXA7kA+VBLUpEs
|
||||
VwIDAQAB
|
||||
-----END PUBLIC KEY-----`;
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.wise",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Finance & Accounting"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/wise/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.wise/"
|
||||
}
|
||||
]
|
||||
},
|
||||
"alias": ["Currency"]
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
import omit from 'lodash/omit';
|
||||
import moment from 'moment-timezone';
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
import { v4 as uuid } from 'uuid';
|
||||
|
||||
import {
|
||||
accountFields,
|
||||
accountOperations,
|
||||
exchangeRateFields,
|
||||
exchangeRateOperations,
|
||||
profileFields,
|
||||
profileOperations,
|
||||
quoteFields,
|
||||
quoteOperations,
|
||||
recipientFields,
|
||||
recipientOperations,
|
||||
transferFields,
|
||||
transferOperations,
|
||||
} from './descriptions';
|
||||
import type {
|
||||
BorderlessAccount,
|
||||
ExchangeRateAdditionalFields,
|
||||
Profile,
|
||||
Recipient,
|
||||
StatementAdditionalFields,
|
||||
TransferFilters,
|
||||
} from './GenericFunctions';
|
||||
import { wiseApiRequest } from './GenericFunctions';
|
||||
|
||||
export class Wise implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Wise',
|
||||
name: 'wise',
|
||||
icon: 'file:wise.svg',
|
||||
group: ['transform'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume the Wise API',
|
||||
defaults: {
|
||||
name: 'Wise',
|
||||
},
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'wiseApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Account',
|
||||
value: 'account',
|
||||
},
|
||||
{
|
||||
name: 'Exchange Rate',
|
||||
value: 'exchangeRate',
|
||||
},
|
||||
{
|
||||
name: 'Profile',
|
||||
value: 'profile',
|
||||
},
|
||||
{
|
||||
name: 'Quote',
|
||||
value: 'quote',
|
||||
},
|
||||
{
|
||||
name: 'Recipient',
|
||||
value: 'recipient',
|
||||
},
|
||||
{
|
||||
name: 'Transfer',
|
||||
value: 'transfer',
|
||||
},
|
||||
],
|
||||
default: 'account',
|
||||
},
|
||||
...accountOperations,
|
||||
...accountFields,
|
||||
...exchangeRateOperations,
|
||||
...exchangeRateFields,
|
||||
...profileOperations,
|
||||
...profileFields,
|
||||
...quoteOperations,
|
||||
...quoteFields,
|
||||
...recipientOperations,
|
||||
...recipientFields,
|
||||
...transferOperations,
|
||||
...transferFields,
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
async getBorderlessAccounts(this: ILoadOptionsFunctions) {
|
||||
const qs = {
|
||||
profileId: this.getNodeParameter('profileId', 0),
|
||||
};
|
||||
|
||||
const accounts = await wiseApiRequest.call(this, 'GET', 'v1/borderless-accounts', {}, qs);
|
||||
|
||||
return accounts.map(({ id, balances }: BorderlessAccount) => ({
|
||||
name: balances.map(({ currency }) => currency).join(' - '),
|
||||
value: id,
|
||||
}));
|
||||
},
|
||||
|
||||
async getProfiles(this: ILoadOptionsFunctions) {
|
||||
const profiles = await wiseApiRequest.call(this, 'GET', 'v1/profiles');
|
||||
|
||||
return profiles.map(({ id, type }: Profile) => ({
|
||||
name: type.charAt(0).toUpperCase() + type.slice(1),
|
||||
value: id,
|
||||
}));
|
||||
},
|
||||
|
||||
async getRecipients(this: ILoadOptionsFunctions) {
|
||||
const qs = {
|
||||
profileId: this.getNodeParameter('profileId', 0),
|
||||
};
|
||||
|
||||
const recipients = (await wiseApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'v1/accounts',
|
||||
{},
|
||||
qs,
|
||||
)) as Recipient[];
|
||||
|
||||
return recipients.reduce<INodePropertyOptions[]>(
|
||||
(activeRecipients, { active, id, accountHolderName, currency, country, type }) => {
|
||||
if (active) {
|
||||
const recipient = {
|
||||
name: `[${currency}] ${accountHolderName} - (${
|
||||
country !== null ? country + ' - ' : ''
|
||||
}${type})`,
|
||||
value: id,
|
||||
};
|
||||
activeRecipients.push(recipient);
|
||||
}
|
||||
return activeRecipients;
|
||||
},
|
||||
[],
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions) {
|
||||
const items = this.getInputData();
|
||||
|
||||
const resource = this.getNodeParameter('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
|
||||
const timezone = this.getTimezone();
|
||||
|
||||
let responseData;
|
||||
const returnData: IDataObject[] = [];
|
||||
let binaryOutput = false;
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
try {
|
||||
if (resource === 'account') {
|
||||
// *********************************************************************
|
||||
// account
|
||||
// *********************************************************************
|
||||
|
||||
if (operation === 'getBalances') {
|
||||
// ----------------------------------
|
||||
// account: getBalances
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#borderless-accounts-get-account-balance
|
||||
|
||||
const qs = {
|
||||
profileId: this.getNodeParameter('profileId', i),
|
||||
};
|
||||
|
||||
responseData = await wiseApiRequest.call(this, 'GET', 'v1/borderless-accounts', {}, qs);
|
||||
} else if (operation === 'getCurrencies') {
|
||||
// ----------------------------------
|
||||
// account: getCurrencies
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#borderless-accounts-get-available-currencies
|
||||
|
||||
responseData = await wiseApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
'v1/borderless-accounts/balance-currencies',
|
||||
);
|
||||
} else if (operation === 'getStatement') {
|
||||
// ----------------------------------
|
||||
// account: getStatement
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#borderless-accounts-get-account-statement
|
||||
|
||||
const profileId = this.getNodeParameter('profileId', i);
|
||||
const borderlessAccountId = this.getNodeParameter('borderlessAccountId', i);
|
||||
const format = this.getNodeParameter('format', i) as 'json' | 'csv' | 'pdf' | 'xml';
|
||||
const endpoint = `v3/profiles/${profileId}/borderless-accounts/${borderlessAccountId}/statement.${format}`;
|
||||
|
||||
const qs = {
|
||||
currency: this.getNodeParameter('currency', i),
|
||||
} as IDataObject;
|
||||
|
||||
const { lineStyle, range } = this.getNodeParameter(
|
||||
'additionalFields',
|
||||
i,
|
||||
) as StatementAdditionalFields;
|
||||
|
||||
if (lineStyle !== undefined) {
|
||||
qs.type = lineStyle;
|
||||
}
|
||||
|
||||
if (range !== undefined) {
|
||||
qs.intervalStart = moment
|
||||
.tz(range.rangeProperties.intervalStart, timezone)
|
||||
.utc()
|
||||
.format();
|
||||
qs.intervalEnd = moment
|
||||
.tz(range.rangeProperties.intervalEnd, timezone)
|
||||
.utc()
|
||||
.format();
|
||||
} else {
|
||||
qs.intervalStart = moment().subtract(1, 'months').utc().format();
|
||||
qs.intervalEnd = moment().utc().format();
|
||||
}
|
||||
|
||||
if (format === 'json') {
|
||||
responseData = await wiseApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
} else {
|
||||
const data = await wiseApiRequest.call(this, 'GET', endpoint, {}, qs, {
|
||||
encoding: 'arraybuffer',
|
||||
});
|
||||
const binaryProperty = this.getNodeParameter('binaryProperty', i);
|
||||
|
||||
items[i].binary = items[i].binary ?? {};
|
||||
items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(
|
||||
data as Buffer,
|
||||
this.getNodeParameter('fileName', i) as string,
|
||||
);
|
||||
|
||||
responseData = items;
|
||||
binaryOutput = true;
|
||||
}
|
||||
}
|
||||
} else if (resource === 'exchangeRate') {
|
||||
// *********************************************************************
|
||||
// exchangeRate
|
||||
// *********************************************************************
|
||||
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// exchangeRate: get
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#exchange-rates-list
|
||||
|
||||
const qs = {
|
||||
source: this.getNodeParameter('source', i),
|
||||
target: this.getNodeParameter('target', i),
|
||||
} as IDataObject;
|
||||
|
||||
const { interval, range, time } = this.getNodeParameter(
|
||||
'additionalFields',
|
||||
i,
|
||||
) as ExchangeRateAdditionalFields;
|
||||
|
||||
if (interval !== undefined) {
|
||||
qs.group = interval;
|
||||
}
|
||||
|
||||
if (time !== undefined) {
|
||||
qs.time = time;
|
||||
}
|
||||
|
||||
if (range !== undefined && time === undefined) {
|
||||
qs.from = moment.tz(range.rangeProperties.from, timezone).utc().format();
|
||||
qs.to = moment.tz(range.rangeProperties.to, timezone).utc().format();
|
||||
} else if (time === undefined) {
|
||||
qs.from = moment().subtract(1, 'months').utc().format();
|
||||
qs.to = moment().utc().format();
|
||||
}
|
||||
|
||||
responseData = await wiseApiRequest.call(this, 'GET', 'v1/rates', {}, qs);
|
||||
}
|
||||
} else if (resource === 'profile') {
|
||||
// *********************************************************************
|
||||
// profile
|
||||
// *********************************************************************
|
||||
|
||||
if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// profile: get
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#user-profiles-get-by-id
|
||||
|
||||
const profileId = this.getNodeParameter('profileId', i);
|
||||
responseData = await wiseApiRequest.call(this, 'GET', `v1/profiles/${profileId}`);
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// profile: getAll
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#user-profiles-list
|
||||
|
||||
responseData = await wiseApiRequest.call(this, 'GET', 'v1/profiles');
|
||||
}
|
||||
} else if (resource === 'recipient') {
|
||||
// *********************************************************************
|
||||
// recipient
|
||||
// *********************************************************************
|
||||
|
||||
if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// recipient: getAll
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#recipient-accounts-list
|
||||
|
||||
responseData = await wiseApiRequest.call(this, 'GET', 'v1/accounts');
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
responseData = responseData.slice(0, limit);
|
||||
}
|
||||
}
|
||||
} else if (resource === 'quote') {
|
||||
// *********************************************************************
|
||||
// quote
|
||||
// *********************************************************************
|
||||
|
||||
if (operation === 'create') {
|
||||
// ----------------------------------
|
||||
// quote: create
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#quotes-create
|
||||
|
||||
const body = {
|
||||
profile: this.getNodeParameter('profileId', i),
|
||||
sourceCurrency: (this.getNodeParameter('sourceCurrency', i) as string).toUpperCase(),
|
||||
targetCurrency: (this.getNodeParameter('targetCurrency', i) as string).toUpperCase(),
|
||||
} as IDataObject;
|
||||
|
||||
const amountType = this.getNodeParameter('amountType', i) as 'source' | 'target';
|
||||
|
||||
if (amountType === 'source') {
|
||||
body.sourceAmount = this.getNodeParameter('amount', i);
|
||||
} else if (amountType === 'target') {
|
||||
body.targetAmount = this.getNodeParameter('amount', i);
|
||||
}
|
||||
|
||||
responseData = await wiseApiRequest.call(this, 'POST', 'v2/quotes', body, {});
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// quote: get
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#quotes-get-by-id
|
||||
|
||||
const quoteId = this.getNodeParameter('quoteId', i);
|
||||
responseData = await wiseApiRequest.call(this, 'GET', `v2/quotes/${quoteId}`);
|
||||
}
|
||||
} else if (resource === 'transfer') {
|
||||
// *********************************************************************
|
||||
// transfer
|
||||
// *********************************************************************
|
||||
|
||||
if (operation === 'create') {
|
||||
// ----------------------------------
|
||||
// transfer: create
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#transfers-create
|
||||
|
||||
const body = {
|
||||
quoteUuid: this.getNodeParameter('quoteId', i),
|
||||
targetAccount: this.getNodeParameter('targetAccountId', i),
|
||||
customerTransactionId: uuid(),
|
||||
} as IDataObject;
|
||||
|
||||
const { reference } = this.getNodeParameter('additionalFields', i) as {
|
||||
reference: string;
|
||||
};
|
||||
|
||||
if (reference !== undefined) {
|
||||
body.details = { reference };
|
||||
}
|
||||
|
||||
responseData = await wiseApiRequest.call(this, 'POST', 'v1/transfers', body, {});
|
||||
} else if (operation === 'delete') {
|
||||
// ----------------------------------
|
||||
// transfer: delete
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#transfers-cancel
|
||||
|
||||
const transferId = this.getNodeParameter('transferId', i);
|
||||
responseData = await wiseApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`v1/transfers/${transferId}/cancel`,
|
||||
);
|
||||
} else if (operation === 'execute') {
|
||||
// ----------------------------------
|
||||
// transfer: execute
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#transfers-fund
|
||||
|
||||
const profileId = this.getNodeParameter('profileId', i);
|
||||
const transferId = this.getNodeParameter('transferId', i) as string;
|
||||
|
||||
const endpoint = `v3/profiles/${profileId}/transfers/${transferId}/payments`;
|
||||
responseData = await wiseApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
endpoint,
|
||||
{ type: 'BALANCE' },
|
||||
{},
|
||||
);
|
||||
|
||||
// in sandbox, simulate transfer completion so that PDF receipt can be downloaded
|
||||
|
||||
const { environment } = await this.getCredentials('wiseApi');
|
||||
|
||||
if (environment === 'test') {
|
||||
for (const testEndpoint of [
|
||||
'processing',
|
||||
'funds_converted',
|
||||
'outgoing_payment_sent',
|
||||
]) {
|
||||
await wiseApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`v1/simulation/transfers/${transferId}/${testEndpoint}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
} else if (operation === 'get') {
|
||||
// ----------------------------------
|
||||
// transfer: get
|
||||
// ----------------------------------
|
||||
|
||||
const transferId = this.getNodeParameter('transferId', i);
|
||||
const downloadReceipt = this.getNodeParameter('downloadReceipt', i) as boolean;
|
||||
|
||||
if (downloadReceipt) {
|
||||
// https://api-docs.transferwise.com/#transfers-get-receipt-pdf
|
||||
|
||||
const data = await wiseApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`v1/transfers/${transferId}/receipt.pdf`,
|
||||
{},
|
||||
{},
|
||||
{ encoding: 'arraybuffer' },
|
||||
);
|
||||
const binaryProperty = this.getNodeParameter('binaryProperty', i);
|
||||
|
||||
items[i].binary = items[i].binary ?? {};
|
||||
items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(
|
||||
data as Buffer,
|
||||
this.getNodeParameter('fileName', i) as string,
|
||||
);
|
||||
|
||||
responseData = items;
|
||||
binaryOutput = true;
|
||||
} else {
|
||||
// https://api-docs.transferwise.com/#transfers-get-by-id
|
||||
|
||||
responseData = await wiseApiRequest.call(this, 'GET', `v1/transfers/${transferId}`);
|
||||
}
|
||||
} else if (operation === 'getAll') {
|
||||
// ----------------------------------
|
||||
// transfer: getAll
|
||||
// ----------------------------------
|
||||
|
||||
// https://api-docs.transferwise.com/#transfers-list
|
||||
|
||||
const qs = {
|
||||
profile: this.getNodeParameter('profileId', i),
|
||||
} as IDataObject;
|
||||
|
||||
const filters = this.getNodeParameter('filters', i) as TransferFilters;
|
||||
|
||||
Object.keys(omit(filters, 'range')).forEach((key) => {
|
||||
qs[key] = filters[key];
|
||||
});
|
||||
|
||||
if (filters.range !== undefined) {
|
||||
qs.createdDateStart = moment
|
||||
.tz(filters.range.rangeProperties.createdDateStart, timezone)
|
||||
.utc()
|
||||
.format();
|
||||
qs.createdDateEnd = moment
|
||||
.tz(filters.range.rangeProperties.createdDateEnd, timezone)
|
||||
.utc()
|
||||
.format();
|
||||
} else {
|
||||
qs.createdDateStart = moment().subtract(1, 'months').utc().format();
|
||||
qs.createdDateEnd = moment().utc().format();
|
||||
}
|
||||
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
if (!returnAll) {
|
||||
qs.limit = this.getNodeParameter('limit', i);
|
||||
}
|
||||
|
||||
responseData = await wiseApiRequest.call(this, 'GET', 'v1/transfers', {}, qs);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
returnData.push({ error: error.toString() });
|
||||
continue;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
Array.isArray(responseData)
|
||||
? returnData.push(...(responseData as IDataObject[]))
|
||||
: returnData.push(responseData as IDataObject);
|
||||
}
|
||||
|
||||
if (binaryOutput && responseData !== undefined) {
|
||||
return [responseData as INodeExecutionData[]];
|
||||
}
|
||||
|
||||
return [this.helpers.returnJsonArray(returnData)];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.wiseTrigger",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Finance & Accounting"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/wise/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/trigger-nodes/n8n-nodes-base.wisetrigger/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
import { createVerify } from 'crypto';
|
||||
import type {
|
||||
IHookFunctions,
|
||||
IWebhookFunctions,
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
IWebhookResponseData,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
import type { Profile } from './GenericFunctions';
|
||||
import { getTriggerName, livePublicKey, testPublicKey, wiseApiRequest } from './GenericFunctions';
|
||||
|
||||
export class WiseTrigger implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Wise Trigger',
|
||||
name: 'wiseTrigger',
|
||||
icon: 'file:wise.svg',
|
||||
group: ['trigger'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["event"]}}',
|
||||
description: 'Handle Wise events via webhooks',
|
||||
defaults: {
|
||||
name: 'Wise Trigger',
|
||||
},
|
||||
inputs: [],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'wiseApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
webhooks: [
|
||||
{
|
||||
name: 'default',
|
||||
httpMethod: 'POST',
|
||||
responseMode: 'onReceived',
|
||||
path: 'webhook',
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Profile Name or ID',
|
||||
name: 'profileId',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getProfiles',
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Event',
|
||||
name: 'event',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: '',
|
||||
options: [
|
||||
{
|
||||
name: 'Balance Credit',
|
||||
value: 'balanceCredit',
|
||||
description: 'Triggered every time a balance account is credited',
|
||||
},
|
||||
{
|
||||
name: 'Balance Update',
|
||||
value: 'balanceUpdate',
|
||||
description: 'Triggered every time a balance account is credited or debited',
|
||||
},
|
||||
{
|
||||
name: 'Transfer Active Case',
|
||||
value: 'transferActiveCases',
|
||||
description: "Triggered every time a transfer's list of active cases is updated",
|
||||
},
|
||||
{
|
||||
name: 'Transfer State Changed',
|
||||
value: 'tranferStateChange',
|
||||
description: "Triggered every time a transfer's status is updated",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
async getProfiles(this: ILoadOptionsFunctions) {
|
||||
const profiles = await wiseApiRequest.call(this, 'GET', 'v1/profiles');
|
||||
return profiles.map(({ id, type }: Profile) => ({
|
||||
name: type.charAt(0).toUpperCase() + type.slice(1),
|
||||
value: id,
|
||||
}));
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const profileId = this.getNodeParameter('profileId') as string;
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
const webhooks = await wiseApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`v3/profiles/${profileId}/subscriptions`,
|
||||
);
|
||||
const trigger = getTriggerName(event);
|
||||
for (const webhook of webhooks) {
|
||||
if (
|
||||
webhook.delivery.url === webhookUrl &&
|
||||
webhook.scope.id === profileId &&
|
||||
webhook.trigger_on === trigger
|
||||
) {
|
||||
webhookData.webhookId = webhook.id;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const profileId = this.getNodeParameter('profileId') as string;
|
||||
const event = this.getNodeParameter('event') as string;
|
||||
const trigger = getTriggerName(event);
|
||||
const body: IDataObject = {
|
||||
name: 'n8n Webhook',
|
||||
trigger_on: trigger,
|
||||
delivery: {
|
||||
version: '2.0.0',
|
||||
url: webhookUrl,
|
||||
},
|
||||
};
|
||||
const webhook = await wiseApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`v3/profiles/${profileId}/subscriptions`,
|
||||
body,
|
||||
);
|
||||
webhookData.webhookId = webhook.id;
|
||||
return true;
|
||||
},
|
||||
async delete(this: IHookFunctions): Promise<boolean> {
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const profileId = this.getNodeParameter('profileId') as string;
|
||||
try {
|
||||
await wiseApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`v3/profiles/${profileId}/subscriptions/${webhookData.webhookId}`,
|
||||
);
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
delete webhookData.webhookId;
|
||||
return true;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
const req = this.getRequestObject();
|
||||
const headers = this.getHeaderData() as IDataObject;
|
||||
const credentials = await this.getCredentials('wiseApi');
|
||||
|
||||
if (headers['x-test-notification'] === 'true') {
|
||||
const res = this.getResponseObject();
|
||||
res.status(200).end();
|
||||
return {
|
||||
noWebhookResponse: true,
|
||||
};
|
||||
}
|
||||
|
||||
const signature = headers['x-signature'] as string;
|
||||
|
||||
const publicKey =
|
||||
credentials.environment === 'test' ? testPublicKey : (livePublicKey as string);
|
||||
|
||||
const sig = createVerify('RSA-SHA1').update(req.rawBody);
|
||||
const verified = sig.verify(publicKey, signature, 'base64');
|
||||
|
||||
if (!verified) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return {
|
||||
workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"active": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"balances": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"amount": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"currency": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"balanceType": {
|
||||
"type": "string"
|
||||
},
|
||||
"currency": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"reservedAmount": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"currency": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"creationTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"eligible": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"id": {
|
||||
"type": "integer"
|
||||
},
|
||||
"modificationTime": {
|
||||
"type": "string"
|
||||
},
|
||||
"profileId": {
|
||||
"type": "integer"
|
||||
},
|
||||
"recipientId": {
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"rate": {
|
||||
"type": "number"
|
||||
},
|
||||
"source": {
|
||||
"type": "string"
|
||||
},
|
||||
"target": {
|
||||
"type": "string"
|
||||
},
|
||||
"time": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"version": 2
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const accountOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
default: 'getBalances',
|
||||
options: [
|
||||
{
|
||||
name: 'Get Balances',
|
||||
value: 'getBalances',
|
||||
description: 'Retrieve balances for all account currencies of this user',
|
||||
action: 'Get balances',
|
||||
},
|
||||
{
|
||||
name: 'Get Currencies',
|
||||
value: 'getCurrencies',
|
||||
description: 'Retrieve currencies in the borderless account of this user',
|
||||
action: 'Get currencies',
|
||||
},
|
||||
{
|
||||
name: 'Get Statement',
|
||||
value: 'getStatement',
|
||||
description: 'Retrieve the statement for the borderless account of this user',
|
||||
action: 'Get a statement',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['account'],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const accountFields: INodeProperties[] = [
|
||||
// ----------------------------------
|
||||
// account: getBalances
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Profile Name or ID',
|
||||
name: 'profileId',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: [],
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getProfiles',
|
||||
},
|
||||
description:
|
||||
'ID of the user profile to retrieve the balance of. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['account'],
|
||||
operation: ['getBalances'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// account: getStatement
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Profile Name or ID',
|
||||
name: 'profileId',
|
||||
type: 'options',
|
||||
default: [],
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getProfiles',
|
||||
},
|
||||
description:
|
||||
'ID of the user profile whose account to retrieve the statement of. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['account'],
|
||||
operation: ['getStatement'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Borderless Account Name or ID',
|
||||
name: 'borderlessAccountId',
|
||||
type: 'options',
|
||||
default: [],
|
||||
required: true,
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getBorderlessAccounts',
|
||||
loadOptionsDependsOn: ['profileId'],
|
||||
},
|
||||
description:
|
||||
'ID of the borderless account to retrieve the statement of. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['account'],
|
||||
operation: ['getStatement'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Currency',
|
||||
name: 'currency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
// TODO: preload
|
||||
description: 'Code of the currency of the borderless account to retrieve the statement of',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['account'],
|
||||
operation: ['getStatement'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Format',
|
||||
name: 'format',
|
||||
type: 'options',
|
||||
default: 'json',
|
||||
description: 'File format to retrieve the statement in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['account'],
|
||||
operation: ['getStatement'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'JSON',
|
||||
value: 'json',
|
||||
},
|
||||
{
|
||||
name: 'CSV',
|
||||
value: 'csv',
|
||||
},
|
||||
{
|
||||
name: 'PDF',
|
||||
value: 'pdf',
|
||||
},
|
||||
{
|
||||
name: 'XML (CAMT.053)',
|
||||
value: 'xml',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Put Output File in Field',
|
||||
name: 'binaryProperty',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: 'data',
|
||||
hint: 'The name of the output binary field to put the file in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['account'],
|
||||
operation: ['getStatement'],
|
||||
format: ['csv', 'pdf', 'xml'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'File Name',
|
||||
name: 'fileName',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
placeholder: 'data.pdf',
|
||||
description: 'Name of the file that will be downloaded',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['account'],
|
||||
operation: ['getStatement'],
|
||||
format: ['csv', 'pdf', 'xml'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['account'],
|
||||
operation: ['getStatement'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Line Style',
|
||||
name: 'lineStyle',
|
||||
type: 'options',
|
||||
default: 'COMPACT',
|
||||
description: 'Line style to retrieve the statement in',
|
||||
options: [
|
||||
{
|
||||
name: 'Compact',
|
||||
value: 'COMPACT',
|
||||
description: 'Single line per transaction',
|
||||
},
|
||||
{
|
||||
name: 'Flat',
|
||||
value: 'FLAT',
|
||||
description: 'Separate lines for transaction fees',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Range',
|
||||
name: 'range',
|
||||
type: 'fixedCollection',
|
||||
placeholder: 'Add Range',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Range Properties',
|
||||
name: 'rangeProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Range Start',
|
||||
name: 'intervalStart',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Range End',
|
||||
name: 'intervalEnd',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,125 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const exchangeRateOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
default: 'get',
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
action: 'Get an exchange rate',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['exchangeRate'],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const exchangeRateFields: INodeProperties[] = [
|
||||
// ----------------------------------
|
||||
// exchangeRate: get
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Source Currency',
|
||||
name: 'source',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Code of the source currency to retrieve the exchange rate for',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['exchangeRate'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Target Currency',
|
||||
name: 'target',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Code of the target currency to retrieve the exchange rate for',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['exchangeRate'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['exchangeRate'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Interval',
|
||||
name: 'interval',
|
||||
type: 'options',
|
||||
default: 'day',
|
||||
options: [
|
||||
{
|
||||
name: 'Day',
|
||||
value: 'day',
|
||||
},
|
||||
{
|
||||
name: 'Hour',
|
||||
value: 'hour',
|
||||
},
|
||||
{
|
||||
name: 'Minute',
|
||||
value: 'minute',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Range',
|
||||
name: 'range',
|
||||
type: 'fixedCollection',
|
||||
placeholder: 'Add Range',
|
||||
description: 'Range of time to retrieve the exchange rate for',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Range Properties',
|
||||
name: 'rangeProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Range Start',
|
||||
name: 'from',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Range End',
|
||||
name: 'to',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Time',
|
||||
name: 'time',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description: 'Point in time to retrieve the exchange rate for',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,52 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const profileOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
default: 'get',
|
||||
options: [
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
action: 'Get a profile',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
action: 'Get many profiles',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['profile'],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const profileFields: INodeProperties[] = [
|
||||
// ----------------------------------
|
||||
// profile: get
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Profile Name or ID',
|
||||
name: 'profileId',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: [],
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getProfiles',
|
||||
},
|
||||
description:
|
||||
'ID of the user profile to retrieve. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['profile'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,153 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const quoteOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
default: 'get',
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
action: 'Create a quote',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
action: 'Get a quote',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['quote'],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const quoteFields: INodeProperties[] = [
|
||||
// ----------------------------------
|
||||
// quote: create
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Profile Name or ID',
|
||||
name: 'profileId',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: [],
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getProfiles',
|
||||
},
|
||||
description:
|
||||
'ID of the user profile to create the quote under. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['quote'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Target Account Name or ID',
|
||||
name: 'targetAccountId',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: [],
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getRecipients',
|
||||
},
|
||||
description:
|
||||
'ID of the account that will receive the funds. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['quote'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Amount Type',
|
||||
name: 'amountType',
|
||||
type: 'options',
|
||||
default: 'source',
|
||||
options: [
|
||||
{
|
||||
name: 'Source',
|
||||
value: 'source',
|
||||
},
|
||||
{
|
||||
name: 'Target',
|
||||
value: 'target',
|
||||
},
|
||||
],
|
||||
description: 'Whether the amount is to be sent or received',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['quote'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Amount',
|
||||
name: 'amount',
|
||||
type: 'number',
|
||||
default: 1,
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
},
|
||||
description: 'Amount of funds for the quote to create',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['quote'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Source Currency',
|
||||
name: 'sourceCurrency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Code of the currency to send for the quote to create',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['quote'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Target Currency',
|
||||
name: 'targetCurrency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Code of the currency to receive for the quote to create',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['quote'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// quote: get
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Quote ID',
|
||||
name: 'quoteId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'ID of the quote to retrieve',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['quote'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,60 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const recipientOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
default: 'getAll',
|
||||
options: [
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
action: 'Get many recipients',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['recipient'],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const recipientFields: INodeProperties[] = [
|
||||
// ----------------------------------
|
||||
// recipient: getAll
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['recipient'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'Max number of results to return',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['recipient'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,398 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const transferOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
default: 'get',
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
action: 'Create a transfer',
|
||||
},
|
||||
{
|
||||
name: 'Delete',
|
||||
value: 'delete',
|
||||
action: 'Delete a transfer',
|
||||
},
|
||||
{
|
||||
name: 'Execute',
|
||||
value: 'execute',
|
||||
action: 'Execute a transfer',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
action: 'Get a transfer',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
action: 'Get many transfers',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const transferFields: INodeProperties[] = [
|
||||
// ----------------------------------
|
||||
// transfer: create
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Profile Name or ID',
|
||||
name: 'profileId',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: [],
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getProfiles',
|
||||
loadOptionsDependsOn: ['profileId'],
|
||||
},
|
||||
description:
|
||||
'ID of the user profile to retrieve the balance of. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Quote ID',
|
||||
name: 'quoteId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'ID of the quote based on which to create the transfer',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Target Account Name or ID',
|
||||
name: 'targetAccountId',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: [],
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getRecipients',
|
||||
},
|
||||
description:
|
||||
'ID of the account that will receive the funds. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Reference',
|
||||
name: 'reference',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: "Reference text to show in the recipient's bank statement",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// transfer: delete
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Transfer ID',
|
||||
name: 'transferId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'ID of the transfer to delete',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['delete'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// transfer: execute
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Profile Name or ID',
|
||||
name: 'profileId',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: [],
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getProfiles',
|
||||
},
|
||||
description:
|
||||
'ID of the user profile to execute the transfer under. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['execute'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Transfer ID',
|
||||
name: 'transferId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'ID of the transfer to execute',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['execute'],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// transfer: get
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Transfer ID',
|
||||
name: 'transferId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
description: 'ID of the transfer to retrieve',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Download Receipt',
|
||||
name: 'downloadReceipt',
|
||||
type: 'boolean',
|
||||
required: true,
|
||||
default: false,
|
||||
description:
|
||||
"Whether to download the transfer receipt as a PDF file. Only for executed transfers, having status 'Outgoing Payment Sent'.",
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Put Output File in Field',
|
||||
name: 'binaryProperty',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: 'data',
|
||||
hint: 'The name of the output binary field to put the file in',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['get'],
|
||||
downloadReceipt: [true],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'File Name',
|
||||
name: 'fileName',
|
||||
type: 'string',
|
||||
required: true,
|
||||
default: '',
|
||||
placeholder: 'data.pdf',
|
||||
description: 'Name of the file that will be downloaded',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['get'],
|
||||
downloadReceipt: [true],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
// transfer: getAll
|
||||
// ----------------------------------
|
||||
{
|
||||
displayName: 'Profile Name or ID',
|
||||
name: 'profileId',
|
||||
type: 'options',
|
||||
required: true,
|
||||
default: [],
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getProfiles',
|
||||
},
|
||||
description:
|
||||
'ID of the user profile to retrieve. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
description: 'Max number of results to return',
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 1000,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Filters',
|
||||
name: 'filters',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Filter',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['transfer'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Range',
|
||||
name: 'range',
|
||||
type: 'fixedCollection',
|
||||
placeholder: 'Add Range',
|
||||
description: 'Range of time for filtering the transfers',
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Range Properties',
|
||||
name: 'rangeProperties',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Created Date Start',
|
||||
name: 'createdDateStart',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Created Date End',
|
||||
name: 'createdDateEnd',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Source Currency',
|
||||
name: 'sourceCurrency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Code of the source currency for filtering the transfers',
|
||||
},
|
||||
{
|
||||
displayName: 'Status',
|
||||
name: 'status',
|
||||
type: 'options',
|
||||
default: 'processing',
|
||||
options: [
|
||||
{
|
||||
name: 'Bounced Back',
|
||||
value: 'bounced_back',
|
||||
},
|
||||
{
|
||||
name: 'Cancelled',
|
||||
value: 'cancelled',
|
||||
},
|
||||
{
|
||||
name: 'Charged Back',
|
||||
value: 'charged_back',
|
||||
},
|
||||
{
|
||||
name: 'Funds Converted',
|
||||
value: 'funds_converted',
|
||||
},
|
||||
{
|
||||
name: 'Funds Refunded',
|
||||
value: 'funds_refunded',
|
||||
},
|
||||
{
|
||||
name: 'Incoming Payment Waiting',
|
||||
value: 'incoming_payment_waiting',
|
||||
},
|
||||
{
|
||||
name: 'Outgoing Payment Sent',
|
||||
value: 'outgoing_payment_sent',
|
||||
},
|
||||
{
|
||||
name: 'Processing',
|
||||
value: 'processing',
|
||||
},
|
||||
{
|
||||
name: 'Unknown',
|
||||
value: 'unknown',
|
||||
},
|
||||
{
|
||||
name: 'Waiting for Recipient Input to Proceed',
|
||||
value: 'waiting_recipient_input_to_proceed',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Target Currency',
|
||||
name: 'targetCurrency',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'Code of the target currency for filtering the transfers',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,6 @@
|
||||
export * from './AccountDescription';
|
||||
export * from './ExchangeRateDescription';
|
||||
export * from './ProfileDescription';
|
||||
export * from './QuoteDescription';
|
||||
export * from './RecipientDescription';
|
||||
export * from './TransferDescription';
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-2 -3 25 26"><path fill="#00cdff" d="m2.471 0 3.282 5.496L0 10.983h9.947l.935-2.199H5.394l3.32-3.302-1.94-3.283h9.051L7.88 20.966h2.722L19.486 0z"/></svg>
|
||||
|
After Width: | Height: | Size: 203 B |
Reference in New Issue
Block a user