Skip to content

A local-first personal finance app

:recycle: rename nordigen to gocardless (#231)

Matiss Janis Aboltins20c2f1950b4a
diff --git a/src/app-nordigen/README.md b/src/app-gocardless/README.md
similarity index 93%
rename from src/app-nordigen/README.md
rename to src/app-gocardless/README.md
index 74f11c3bd4..bb190ef1c1 100644
--- a/src/app-nordigen/README.md
+++ b/src/app-gocardless/README.md
@@ -3,7 +3,7 @@
Find in [doc](https://docs.google.com/spreadsheets/d/1ogpzydzotOltbssrc3IQ8rhBLlIZbQgm5QCiiNJrkyA/edit#gid=489769432) what is id of bank which you want to integrate
Add the `institution_id` and your name to list of possible options in the frontend
-project `actual/packages/loot-design/src/components/modals/NordigenExternalMsg.js`
+project `actual` in file `GoCardlessExternalMsg.js`
```jsx
<Strong>Choose your banks:</Strong>
@@ -23,7 +23,7 @@ Create new linked account selecting the institution which you added recently.
In the server logs you can find all required information to create class for
your bank.
-Create new a bank class based on `app-nordigen/banks/sandboxfinance-sfin0000.js`. Name of the file and class should be
+Create new a bank class based on `app-gocardless/banks/sandboxfinance-sfin0000.js`. Name of the file and class should be
created based on the ID of the integrated institution.
Fill the logic of `normalizeAccount`, `sortTransactions`, and `calculateStartingBalance` functions.
@@ -56,6 +56,6 @@ Available (first 10) transactions properties for new integration of institution
}
```
-Add new bank integration to `BankFactory` class in file `actual-server/app-nordigen/bank-factory.js`
+Add new bank integration to `BankFactory` class in file `actual-server/app-gocardless/bank-factory.js`
Remember to add tests for new bank integration in
diff --git a/src/app-nordigen/app-nordigen.js b/src/app-gocardless/app-gocardless.js
similarity index 87%
rename from src/app-nordigen/app-nordigen.js
rename to src/app-gocardless/app-gocardless.js
index fbc519d8ce..9c1d1f05f4 100644
--- a/src/app-nordigen/app-nordigen.js
+++ b/src/app-gocardless/app-gocardless.js
@@ -3,11 +3,11 @@ import express from 'express';
import path from 'path';
import { inspect } from 'util';
-import { nordigenService } from './services/nordigen-service.js';
+import { goCardlessService } from './services/gocardless-service.js';
import {
RequisitionNotLinked,
AccountNotLinedToRequisition,
- GenericNordigenError,
+ GenericGoCardlessError,
} from './errors.js';
import { handleError } from './util/handle-error.js';
import { sha256String } from '../util/hash.js';
@@ -15,7 +15,7 @@ import validateUser from '../util/validate-user.js';
const app = express();
app.get('/link', function (req, res) {
- res.sendFile('link.html', { root: path.resolve('./src/app-nordigen') });
+ res.sendFile('link.html', { root: path.resolve('./src/app-gocardless') });
});
export { app as handlers };
@@ -32,7 +32,7 @@ app.post('/status', async (req, res) => {
res.send({
status: 'ok',
data: {
- configured: nordigenService.isConfigured(),
+ configured: goCardlessService.isConfigured(),
},
});
});
@@ -43,7 +43,7 @@ app.post(
const { accessValidForDays, institutionId } = req.body;
const { origin } = req.headers;
- const { link, requisitionId } = await nordigenService.createRequisition({
+ const { link, requisitionId } = await goCardlessService.createRequisition({
accessValidForDays,
institutionId,
host: origin,
@@ -66,7 +66,7 @@ app.post(
try {
const { requisition, accounts } =
- await nordigenService.getRequisitionWithAccounts(requisitionId);
+ await goCardlessService.getRequisitionWithAccounts(requisitionId);
res.send({
status: 'ok',
@@ -99,8 +99,8 @@ app.post(
handleError(async (req, res) => {
let { country, showDemo = false } = req.body;
- await nordigenService.setToken();
- const data = await nordigenService.getInstitutions(country);
+ await goCardlessService.setToken();
+ const data = await goCardlessService.getInstitutions(country);
res.send({
status: 'ok',
@@ -122,7 +122,7 @@ app.post(
handleError(async (req, res) => {
let { requisitionId } = req.body;
- const data = await nordigenService.deleteRequisition(requisitionId);
+ const data = await goCardlessService.deleteRequisition(requisitionId);
if (data.summary === 'Requisition deleted') {
res.send({
status: 'ok',
@@ -152,7 +152,7 @@ app.post(
institutionId,
startingBalance,
transactions: { booked, pending, all },
- } = await nordigenService.getTransactionsWithBalance(
+ } = await goCardlessService.getTransactionsWithBalance(
requisitionId,
accountId,
startDate,
@@ -195,7 +195,7 @@ app.post(
reason: 'Account not linked with this requisition',
});
break;
- case error instanceof GenericNordigenError:
+ case error instanceof GenericGoCardlessError:
console.log('Something went wrong', inspect(error, { depth: null }));
sendErrorResponse({
error_type: 'SYNC_ERROR',
diff --git a/src/app-nordigen/bank-factory.js b/src/app-gocardless/bank-factory.js
similarity index 100%
rename from src/app-nordigen/bank-factory.js
rename to src/app-gocardless/bank-factory.js
diff --git a/src/app-nordigen/banks/bank.interface.ts b/src/app-gocardless/banks/bank.interface.ts
similarity index 87%
rename from src/app-nordigen/banks/bank.interface.ts
rename to src/app-gocardless/banks/bank.interface.ts
index 8e1a91deed..bec93b10fa 100644
--- a/src/app-nordigen/banks/bank.interface.ts
+++ b/src/app-gocardless/banks/bank.interface.ts
@@ -1,8 +1,8 @@
import {
DetailedAccountWithInstitution,
NormalizedAccountDetails,
-} from '../nordigen.types.js';
-import { Transaction, Balance } from '../nordigen-node.types.js';
+} from '../gocardless.types.js';
+import { Transaction, Balance } from '../gocardless-node.types.js';
export interface IBank {
institutionId: string;
diff --git a/src/app-nordigen/banks/ing-pl-ingbplpw.js b/src/app-gocardless/banks/ing-pl-ingbplpw.js
similarity index 100%
rename from src/app-nordigen/banks/ing-pl-ingbplpw.js
rename to src/app-gocardless/banks/ing-pl-ingbplpw.js
diff --git a/src/app-nordigen/banks/integration-bank.js b/src/app-gocardless/banks/integration-bank.js
similarity index 100%
rename from src/app-nordigen/banks/integration-bank.js
rename to src/app-gocardless/banks/integration-bank.js
diff --git a/src/app-nordigen/banks/mbank-retail-brexplpw.js b/src/app-gocardless/banks/mbank-retail-brexplpw.js
similarity index 100%
rename from src/app-nordigen/banks/mbank-retail-brexplpw.js
rename to src/app-gocardless/banks/mbank-retail-brexplpw.js
diff --git a/src/app-nordigen/banks/sandboxfinance-sfin0000.js b/src/app-gocardless/banks/sandboxfinance-sfin0000.js
similarity index 100%
rename from src/app-nordigen/banks/sandboxfinance-sfin0000.js
rename to src/app-gocardless/banks/sandboxfinance-sfin0000.js
diff --git a/src/app-nordigen/banks/tests/ing-pl-ingbplpw.spec.js b/src/app-gocardless/banks/tests/ing-pl-ingbplpw.spec.js
similarity index 95%
rename from src/app-nordigen/banks/tests/ing-pl-ingbplpw.spec.js
rename to src/app-gocardless/banks/tests/ing-pl-ingbplpw.spec.js
index eb60d8b7da..ac8699ef60 100644
--- a/src/app-nordigen/banks/tests/ing-pl-ingbplpw.spec.js
+++ b/src/app-gocardless/banks/tests/ing-pl-ingbplpw.spec.js
@@ -3,7 +3,7 @@ import { mockTransactionAmount } from '../../services/tests/fixtures.js';
describe('IngPlIngbplpw', () => {
describe('#normalizeAccount', () => {
- /** @type {import('../../nordigen.types.js').DetailedAccountWithInstitution} */
+ /** @type {import('../../gocardless.types.js').DetailedAccountWithInstitution} */
const accountRaw = {
resourceId: 'PL00000000000000000987654321',
iban: 'PL00000000000000000987654321',
@@ -137,7 +137,7 @@ describe('IngPlIngbplpw', () => {
describe('#countStartingBalance', () => {
it('should calculate the starting balance correctly', () => {
- /** @type {import('../../nordigen-node.types.js').Transaction[]} */
+ /** @type {import('../../gocardless-node.types.js').Transaction[]} */
const sortedTransactions = [
{
transactionAmount: { amount: '-100.00', currency: 'USD' },
@@ -162,7 +162,7 @@ describe('IngPlIngbplpw', () => {
},
];
- /** @type {import('../../nordigen-node.types.js').Balance[]} */
+ /** @type {import('../../gocardless-node.types.js').Balance[]} */
const balances = [
{
balanceType: 'interimBooked',
@@ -185,7 +185,7 @@ describe('IngPlIngbplpw', () => {
it('returns the same balance amount when no transactions', () => {
const transactions = [];
- /** @type {import('../../nordigen-node.types.js').Balance[]} */
+ /** @type {import('../../gocardless-node.types.js').Balance[]} */
const balances = [
{
balanceType: 'interimBooked',
diff --git a/src/app-nordigen/banks/tests/integration-bank.spec.js b/src/app-gocardless/banks/tests/integration-bank.spec.js
similarity index 97%
rename from src/app-nordigen/banks/tests/integration-bank.spec.js
rename to src/app-gocardless/banks/tests/integration-bank.spec.js
index 17c97f3bb2..7f1f235d38 100644
--- a/src/app-nordigen/banks/tests/integration-bank.spec.js
+++ b/src/app-gocardless/banks/tests/integration-bank.spec.js
@@ -106,7 +106,7 @@ describe('IntegrationBank', () => {
});
describe('calculateStartingBalance', () => {
- /** @type {import('../../nordigen-node.types.js').Transaction[]} */
+ /** @type {import('../../gocardless-node.types.js').Transaction[]} */
const transactions = [
{
bookingDate: '2022-01-01',
@@ -122,7 +122,7 @@ describe('IntegrationBank', () => {
},
];
- /** @type {import('../../nordigen-node.types.js').Balance[]} */
+ /** @type {import('../../gocardless-node.types.js').Balance[]} */
const balances = [
{
balanceAmount: { amount: '1000.00', currency: 'EUR' },
diff --git a/src/app-nordigen/banks/tests/mbank-retail-brexplpw.spec.js b/src/app-gocardless/banks/tests/mbank-retail-brexplpw.spec.js
similarity index 97%
rename from src/app-nordigen/banks/tests/mbank-retail-brexplpw.spec.js
rename to src/app-gocardless/banks/tests/mbank-retail-brexplpw.spec.js
index f14dba2e88..d8212b2604 100644
--- a/src/app-nordigen/banks/tests/mbank-retail-brexplpw.spec.js
+++ b/src/app-gocardless/banks/tests/mbank-retail-brexplpw.spec.js
@@ -2,7 +2,7 @@ import MbankRetailBrexplpw from '../mbank-retail-brexplpw.js';
describe('MbankRetailBrexplpw', () => {
describe('#normalizeAccount', () => {
- /** @type {import('../../nordigen.types.js').DetailedAccountWithInstitution} */
+ /** @type {import('../../gocardless.types.js').DetailedAccountWithInstitution} */
const accountRaw = {
iban: 'PL00000000000000000987654321',
currency: 'PLN',
@@ -135,7 +135,7 @@ describe('MbankRetailBrexplpw', () => {
});
describe('#countStartingBalance', () => {
- /** @type {import('../../nordigen-node.types.js').Balance[]} */
+ /** @type {import('../../gocardless-node.types.js').Balance[]} */
const balances = [
{
balanceAmount: { amount: '1000.00', currency: 'PLN' },
diff --git a/src/app-nordigen/banks/tests/sandboxfinance-sfin0000.spec.js b/src/app-gocardless/banks/tests/sandboxfinance-sfin0000.spec.js
similarity index 95%
rename from src/app-nordigen/banks/tests/sandboxfinance-sfin0000.spec.js
rename to src/app-gocardless/banks/tests/sandboxfinance-sfin0000.spec.js
index ce610df6d8..ab885167e1 100644
--- a/src/app-nordigen/banks/tests/sandboxfinance-sfin0000.spec.js
+++ b/src/app-gocardless/banks/tests/sandboxfinance-sfin0000.spec.js
@@ -3,7 +3,7 @@ import { mockTransactionAmount } from '../../services/tests/fixtures.js';
describe('SandboxfinanceSfin0000', () => {
describe('#normalizeAccount', () => {
- /** @type {import('../../nordigen.types.js').DetailedAccountWithInstitution} */
+ /** @type {import('../../gocardless.types.js').DetailedAccountWithInstitution} */
const accountRaw = {
resourceId: '01F3NS5ASCNMVCTEJDT0G215YE',
iban: 'GL0865354374424724',
@@ -122,7 +122,7 @@ describe('SandboxfinanceSfin0000', () => {
});
describe('#countStartingBalance', () => {
- /** @type {import('../../nordigen-node.types.js').Balance[]} */
+ /** @type {import('../../gocardless-node.types.js').Balance[]} */
const balances = [
{
balanceAmount: { amount: '1000.00', currency: 'PLN' },
@@ -163,7 +163,7 @@ describe('SandboxfinanceSfin0000', () => {
});
it('returns the balance minus the available transactions', () => {
- /** @type {import('../../nordigen-node.types.js').Transaction[]} */
+ /** @type {import('../../gocardless-node.types.js').Transaction[]} */
const transactions = [
{
transactionAmount: { amount: '200.00', currency: 'PLN' },
diff --git a/src/app-nordigen/errors.js b/src/app-gocardless/errors.js
similarity index 67%
rename from src/app-nordigen/errors.js
rename to src/app-gocardless/errors.js
index 02e92d26c0..8208425114 100644
--- a/src/app-nordigen/errors.js
+++ b/src/app-gocardless/errors.js
@@ -15,45 +15,45 @@ export class AccountNotLinedToRequisition extends Error {
}
}
-export class GenericNordigenError extends Error {
+export class GenericGoCardlessError extends Error {
constructor(data = {}) {
- super('Nordigen returned error');
+ super('GoCardless returned error');
this.details = data;
}
}
-export class NordigenClientError extends Error {
+export class GoCardlessClientError extends Error {
constructor(message, details) {
super(message);
this.details = details;
}
}
-export class InvalidInputDataError extends NordigenClientError {
+export class InvalidInputDataError extends GoCardlessClientError {
constructor(response) {
super('Invalid provided parameters', response);
}
}
-export class InvalidNordigenTokenError extends NordigenClientError {
+export class InvalidGoCardlessTokenError extends GoCardlessClientError {
constructor(response) {
super('Token is invalid or expired', response);
}
}
-export class AccessDeniedError extends NordigenClientError {
+export class AccessDeniedError extends GoCardlessClientError {
constructor(response) {
super('IP address access denied', response);
}
}
-export class NotFoundError extends NordigenClientError {
+export class NotFoundError extends GoCardlessClientError {
constructor(response) {
super('Resource not found', response);
}
}
-export class ResourceSuspended extends NordigenClientError {
+export class ResourceSuspended extends GoCardlessClientError {
constructor(response) {
super(
'Resource was suspended due to numerous errors that occurred while accessing it',
@@ -62,7 +62,7 @@ export class ResourceSuspended extends NordigenClientError {
}
}
-export class RateLimitError extends NordigenClientError {
+export class RateLimitError extends GoCardlessClientError {
constructor(response) {
super(
'Daily request limit set by the Institution has been exceeded',
@@ -71,13 +71,13 @@ export class RateLimitError extends NordigenClientError {
}
}
-export class UnknownError extends NordigenClientError {
+export class UnknownError extends GoCardlessClientError {
constructor(response) {
super('Request to Institution returned an error', response);
}
}
-export class ServiceError extends NordigenClientError {
+export class ServiceError extends GoCardlessClientError {
constructor(response) {
super('Institution service unavailable', response);
}
diff --git a/src/app-nordigen/nordigen-node.types.ts b/src/app-gocardless/gocardless-node.types.ts
similarity index 93%
rename from src/app-nordigen/nordigen-node.types.ts
rename to src/app-gocardless/gocardless-node.types.ts
index 518748428e..1f79a92b01 100644
--- a/src/app-nordigen/nordigen-node.types.ts
+++ b/src/app-gocardless/gocardless-node.types.ts
@@ -79,10 +79,10 @@ export type Requisition = {
};
/**
- * Object representing Nordigen account details
+ * Object representing GoCardless account details
* Account details will be returned in Berlin Group PSD2 format.
*/
-export type NordigenAccountDetails = {
+export type GoCardlessAccountDetails = {
/**
* Resource id of the account
*/
@@ -174,31 +174,31 @@ export type NordigenAccountDetails = {
};
/**
- * Representation of the Nordigen account metadata
+ * Representation of the GoCardless account metadata
*/
-export type NordigenAccountMetadata = {
+export type GoCardlessAccountMetadata = {
/**
- * ID of the Nordigen account metadata
+ * ID of the GoCardless account metadata
*/
id: string;
/**
- * Date when the Nordigen account metadata was created
+ * Date when the GoCardless account metadata was created
*/
created: string;
/**
- * Date of the last access to the Nordigen account metadata
+ * Date of the last access to the GoCardless account metadata
*/
last_accessed: string;
/**
- * IBAN of the Nordigen account metadata
+ * IBAN of the GoCardless account metadata
*/
iban: string;
/**
- * ID of the institution associated with the Nordigen account metadata
+ * ID of the institution associated with the GoCardless account metadata
*/
institution_id: string;
/**
- * Status of the Nordigen account
+ * Status of the GoCardless account
* DISCOVERED: User has successfully authenticated and account is discovered
* PROCESSING: Account is being processed by the Institution
* ERROR: An error was encountered when processing account
@@ -214,7 +214,7 @@ export type NordigenAccountMetadata = {
| 'READY'
| 'SUSPENDED';
/**
- * Name of the owner of the Nordigen account metadata
+ * Name of the owner of the GoCardless account metadata
*/
owner_name: string;
};
@@ -406,7 +406,7 @@ export type Transaction = {
entryReference?: string;
/**
- * Transaction identifier given by Nordigen
+ * Transaction identifier given by GoCardless
*/
internalTransactionId?: string;
diff --git a/src/app-nordigen/nordigen.types.ts b/src/app-gocardless/gocardless.types.ts
similarity index 85%
rename from src/app-nordigen/nordigen.types.ts
rename to src/app-gocardless/gocardless.types.ts
index d5c89d876f..3e2f920c25 100644
--- a/src/app-nordigen/nordigen.types.ts
+++ b/src/app-gocardless/gocardless.types.ts
@@ -1,14 +1,14 @@
import {
- NordigenAccountMetadata,
- NordigenAccountDetails,
+ GoCardlessAccountMetadata,
+ GoCardlessAccountDetails,
Institution,
Transactions,
Balance,
Transaction,
-} from './nordigen-node.types.js';
+} from './gocardless-node.types.js';
-export type DetailedAccount = Omit<NordigenAccountDetails, 'status'> &
- NordigenAccountMetadata;
+export type DetailedAccount = Omit<GoCardlessAccountDetails, 'status'> &
+ GoCardlessAccountMetadata;
export type DetailedAccountWithInstitution = DetailedAccount & {
institution: Institution;
};
@@ -53,7 +53,7 @@ export type NormalizedAccountDetails = {
export type GetTransactionsParams = {
/**
- * Id of account from the nordigen app
+ * Id of account from the GoCardless app
*/
accountId: string;
diff --git a/src/app-nordigen/link.html b/src/app-gocardless/link.html
similarity index 100%
rename from src/app-nordigen/link.html
rename to src/app-gocardless/link.html
diff --git a/src/app-nordigen/services/nordigen-service.js b/src/app-gocardless/services/gocardless-service.js
similarity index 72%
rename from src/app-nordigen/services/nordigen-service.js
rename to src/app-gocardless/services/gocardless-service.js
index 8f483d57be..0dce71d47c 100644
--- a/src/app-nordigen/services/nordigen-service.js
+++ b/src/app-gocardless/services/gocardless-service.js
@@ -3,7 +3,7 @@ import {
RequisitionNotLinked,
AccountNotLinedToRequisition,
InvalidInputDataError,
- InvalidNordigenTokenError,
+ InvalidGoCardlessTokenError,
AccessDeniedError,
NotFoundError,
ResourceSuspended,
@@ -16,25 +16,25 @@ import * as uuid from 'uuid';
import jwt from 'jws';
import { SecretName, secretsService } from '../../services/secrets-service.js';
-const NordigenClient = nordigenNode.default;
-const nordigenClient = new NordigenClient({
+const GoCardlessClient = nordigenNode.default;
+const goCardlessClient = new GoCardlessClient({
secretId: secretsService.get(SecretName.nordigen_secretId),
secretKey: secretsService.get(SecretName.nordigen_secretKey),
});
secretsService.onUpdate(SecretName.nordigen_secretId, (newSecret) => {
- nordigenClient.secretId = newSecret;
+ goCardlessClient.secretId = newSecret;
});
secretsService.onUpdate(SecretName.nordigen_secretKey, (newSecret) => {
- nordigenClient.secretKey = newSecret;
+ goCardlessClient.secretKey = newSecret;
});
-export const handleNordigenError = (response) => {
+export const handleGoCardlessError = (response) => {
switch (response.status_code) {
case 400:
throw new InvalidInputDataError(response);
case 401:
- throw new InvalidNordigenTokenError(response);
+ throw new InvalidGoCardlessTokenError(response);
case 403:
throw new AccessDeniedError(response);
case 404:
@@ -52,13 +52,13 @@ export const handleNordigenError = (response) => {
}
};
-export const nordigenService = {
+export const goCardlessService = {
/**
- * Check if the Nordigen service is configured to be used.
+ * Check if the GoCardless service is configured to be used.
* @returns {boolean}
*/
isConfigured: () => {
- return !!(nordigenClient.secretId && nordigenClient.secretKey);
+ return !!(goCardlessClient.secretId && goCardlessClient.secretKey);
},
/**
@@ -76,11 +76,11 @@ export const nordigenService = {
return clockTimestamp >= payload.exp;
};
- if (isExpiredJwtToken(nordigenClient.token)) {
+ if (isExpiredJwtToken(goCardlessClient.token)) {
// Generate new access token. Token is valid for 24 hours
// Note: access_token is automatically injected to other requests after you successfully obtain it
const tokenData = await client.generateToken();
- handleNordigenError(tokenData);
+ handleGoCardlessError(tokenData);
}
},
@@ -89,17 +89,17 @@ export const nordigenService = {
* @param requisitionId
* @throws {RequisitionNotLinked} Will throw an error if requisition is not in Linked
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
* @throws {RateLimitError}
* @throws {UnknownError}
* @throws {ServiceError}
- * @returns {Promise<import('../nordigen-node.types.js').Requisition>}
+ * @returns {Promise<import('../gocardless-node.types.js').Requisition>}
*/
getLinkedRequisition: async (requisitionId) => {
- const requisition = await nordigenService.getRequisition(requisitionId);
+ const requisition = await goCardlessService.getRequisition(requisitionId);
const { status } = requisition;
@@ -118,24 +118,24 @@ export const nordigenService = {
* @param requisitionId
* @throws {RequisitionNotLinked} Will throw an error if requisition is not in Linked
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
* @throws {RateLimitError}
* @throws {UnknownError}
* @throws {ServiceError}
- * @returns {Promise<{requisition: import('../nordigen-node.types.js').Requisition, accounts: Array<import('../nordigen.types.js').NormalizedAccountDetails>}>}
+ * @returns {Promise<{requisition: import('../gocardless-node.types.js').Requisition, accounts: Array<import('../gocardless.types.js').NormalizedAccountDetails>}>}
*/
getRequisitionWithAccounts: async (requisitionId) => {
- const requisition = await nordigenService.getLinkedRequisition(
+ const requisition = await goCardlessService.getLinkedRequisition(
requisitionId,
);
let institutionIdSet = new Set();
const detailedAccounts = await Promise.all(
requisition.accounts.map(async (accountId) => {
- const account = await nordigenService.getDetailedAccount(accountId);
+ const account = await goCardlessService.getDetailedAccount(accountId);
institutionIdSet.add(account.institution_id);
return account;
}),
@@ -143,12 +143,12 @@ export const nordigenService = {
const institutions = await Promise.all(
Array.from(institutionIdSet).map(async (institutionId) => {
- return await nordigenService.getInstitution(institutionId);
+ return await goCardlessService.getInstitution(institutionId);
}),
);
const extendedAccounts =
- await nordigenService.extendAccountsAboutInstitutions({
+ await goCardlessService.extendAccountsAboutInstitutions({
accounts: detailedAccounts,
institutions,
});
@@ -170,14 +170,14 @@ export const nordigenService = {
* @throws {AccountNotLinedToRequisition} Will throw an error if requisition not includes provided account id
* @throws {RequisitionNotLinked} Will throw an error if requisition is not in Linked
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
* @throws {RateLimitError}
* @throws {UnknownError}
* @throws {ServiceError}
- * @returns {Promise<{iban: string, balances: Array<import('../nordigen-node.types.js').Balance>, institutionId: string, transactions: {booked: Array<import('../nordigen-node.types.js').Transaction>, pending: Array<import('../nordigen-node.types.js').Transaction>, all: Array<import('../nordigen.types.js').TransactionWithBookedStatus>}, startingBalance: number}>}
+ * @returns {Promise<{iban: string, balances: Array<import('../gocardless-node.types.js').Balance>, institutionId: string, transactions: {booked: Array<import('../gocardless-node.types.js').Transaction>, pending: Array<import('../gocardless-node.types.js').Transaction>, all: Array<import('../gocardless.types.js').TransactionWithBookedStatus>}, startingBalance: number}>}
*/
getTransactionsWithBalance: async (
requisitionId,
@@ -186,20 +186,20 @@ export const nordigenService = {
endDate,
) => {
const { institution_id, accounts: accountIds } =
- await nordigenService.getLinkedRequisition(requisitionId);
+ await goCardlessService.getLinkedRequisition(requisitionId);
if (!accountIds.includes(accountId)) {
throw new AccountNotLinedToRequisition(accountId, requisitionId);
}
const [accountMetadata, transactions, accountBalance] = await Promise.all([
- nordigenService.getAccountMetadata(accountId),
- nordigenService.getTransactions({
+ goCardlessService.getAccountMetadata(accountId),
+ goCardlessService.getTransactions({
accountId,
startDate,
endDate,
}),
- nordigenService.getBalances(accountId),
+ goCardlessService.getBalances(accountId),
]);
const bank = BankFactory(institution_id);
@@ -237,9 +237,9 @@ export const nordigenService = {
/**
*
- * @param {import('../nordigen.types.js').CreateRequisitionParams} params
+ * @param {import('../gocardless.types.js').CreateRequisitionParams} params
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
@@ -249,7 +249,7 @@ export const nordigenService = {
* @returns {Promise<{requisitionId, link}>}
*/
createRequisition: async ({ institutionId, accessValidForDays, host }) => {
- await nordigenService.setToken();
+ await goCardlessService.setToken();
const response = await client.initSession({
redirectUrl: host + '/nordigen/link',
@@ -263,7 +263,7 @@ export const nordigenService = {
accountSelection: false,
});
- handleNordigenError(response);
+ handleGoCardlessError(response);
const { link, id: requisitionId } = response;
@@ -277,7 +277,7 @@ export const nordigenService = {
* Deletes requisition by provided ID
* @param requisitionId
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
@@ -287,10 +287,10 @@ export const nordigenService = {
* @returns {Promise<{summary: string, detail: string}>}
*/
deleteRequisition: async (requisitionId) => {
- await nordigenService.getRequisition(requisitionId);
+ await goCardlessService.getRequisition(requisitionId);
const response = client.deleteRequisition(requisitionId);
- handleNordigenError(response);
+ handleGoCardlessError(response);
return response;
},
@@ -299,21 +299,21 @@ export const nordigenService = {
* https://nordigen.com/en/docs/account-information/integration/parameters-and-responses/#/requisitions/requisition%20by%20id
* @param { string } requisitionId
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
* @throws {RateLimitError}
* @throws {UnknownError}
* @throws {ServiceError}
- * @returns { Promise<import('../nordigen-node.types.js').Requisition> }
+ * @returns { Promise<import('../gocardless-node.types.js').Requisition> }
*/
getRequisition: async (requisitionId) => {
- await nordigenService.setToken();
+ await goCardlessService.setToken();
const response = client.getRequisitionById(requisitionId);
- handleNordigenError(response);
+ handleGoCardlessError(response);
return response;
},
@@ -321,7 +321,7 @@ export const nordigenService = {
/**
* Retrieve an detailed account by account id
* @param accountId
- * @returns {Promise<import('../nordigen.types.js').DetailedAccount>}
+ * @returns {Promise<import('../gocardless.types.js').DetailedAccount>}
*/
getDetailedAccount: async (accountId) => {
const [detailedAccount, metadataAccount] = await Promise.all([
@@ -329,8 +329,8 @@ export const nordigenService = {
client.getMetadata(accountId),
]);
- handleNordigenError(detailedAccount);
- handleNordigenError(metadataAccount);
+ handleGoCardlessError(detailedAccount);
+ handleGoCardlessError(metadataAccount);
return {
...detailedAccount.account,
@@ -344,12 +344,12 @@ export const nordigenService = {
* Unlike getDetailedAccount, this method is not affected by institution rate-limits.
*
* @param accountId
- * @returns {Promise<import('../nordigen-node.types.js').NordigenAccountMetadata>}
+ * @returns {Promise<import('../gocardless-node.types.js').GoCardlessAccountMetadata>}
*/
getAccountMetadata: async (accountId) => {
const response = await client.getMetadata(accountId);
- handleNordigenError(response);
+ handleGoCardlessError(response);
return response;
},
@@ -358,19 +358,19 @@ export const nordigenService = {
* Retrieve details about all Institutions in a specific country
* @param country
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
* @throws {RateLimitError}
* @throws {UnknownError}
* @throws {ServiceError}
- * @returns {Promise<Array<import('../nordigen-node.types.js').Institution>>}
+ * @returns {Promise<Array<import('../gocardless-node.types.js').Institution>>}
*/
getInstitutions: async (country) => {
const response = await client.getInstitutions(country);
- handleNordigenError(response);
+ handleGoCardlessError(response);
return response;
},
@@ -379,27 +379,27 @@ export const nordigenService = {
* Retrieve details about a specific Institution
* @param institutionId
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
* @throws {RateLimitError}
* @throws {UnknownError}
* @throws {ServiceError}
- * @returns {Promise<import('../nordigen-node.types.js').Institution>}
+ * @returns {Promise<import('../gocardless-node.types.js').Institution>}
*/
getInstitution: async (institutionId) => {
const response = await client.getInstitutionById(institutionId);
- handleNordigenError(response);
+ handleGoCardlessError(response);
return response;
},
/**
* Extends provided accounts about details of their institution
- * @param {{accounts: Array<import('../nordigen.types.js').DetailedAccount>, institutions: Array<import('../nordigen-node.types.js').Institution>}} params
- * @returns {Promise<Array<import('../nordigen.types.js').DetailedAccount&{institution: import('../nordigen-node.types.js').Institution}>>}
+ * @param {{accounts: Array<import('../gocardless.types.js').DetailedAccount>, institutions: Array<import('../gocardless-node.types.js').Institution>}} params
+ * @returns {Promise<Array<import('../gocardless.types.js').DetailedAccount&{institution: import('../gocardless-node.types.js').Institution}>>}
*/
extendAccountsAboutInstitutions: async ({ accounts, institutions }) => {
const institutionsById = institutions.reduce((acc, institution) => {
@@ -418,16 +418,16 @@ export const nordigenService = {
/**
* Returns account transaction in provided dates
- * @param {import('../nordigen.types.js').GetTransactionsParams} params
+ * @param {import('../gocardless.types.js').GetTransactionsParams} params
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
* @throws {RateLimitError}
* @throws {UnknownError}
* @throws {ServiceError}
- * @returns {Promise<import('../nordigen.types.js').GetTransactionsResponse>}
+ * @returns {Promise<import('../gocardless.types.js').GetTransactionsResponse>}
*/
getTransactions: async ({ accountId, startDate, endDate }) => {
const response = await client.getTransactions({
@@ -436,7 +436,7 @@ export const nordigenService = {
dateTo: endDate,
});
- handleNordigenError(response);
+ handleGoCardlessError(response);
return response;
},
@@ -445,50 +445,50 @@ export const nordigenService = {
* Returns account available balances
* @param accountId
* @throws {InvalidInputDataError}
- * @throws {InvalidNordigenTokenError}
+ * @throws {InvalidGoCardlessTokenError}
* @throws {AccessDeniedError}
* @throws {NotFoundError}
* @throws {ResourceSuspended}
* @throws {RateLimitError}
* @throws {UnknownError}
* @throws {ServiceError}
- * @returns {Promise<import('../nordigen.types.js').GetBalances>}
+ * @returns {Promise<import('../gocardless.types.js').GetBalances>}
*/
getBalances: async (accountId) => {
const response = await client.getBalances(accountId);
- handleNordigenError(response);
+ handleGoCardlessError(response);
return response;
},
};
/**
- * All executions of nordigenClient should be here for testing purposes,
+ * All executions of goCardlessClient should be here for testing purposes,
* as the nordigen-node library is not written in a way that is conducive to testing.
* In that way we can mock the `client` const instead of nordigen library
*/
export const client = {
getBalances: async (accountId) =>
- await nordigenClient.account(accountId).getBalances(),
+ await goCardlessClient.account(accountId).getBalances(),
getTransactions: async ({ accountId, dateFrom, dateTo }) =>
- await nordigenClient.account(accountId).getTransactions({
+ await goCardlessClient.account(accountId).getTransactions({
dateFrom,
dateTo,
country: undefined,
}),
getInstitutions: async (country) =>
- await nordigenClient.institution.getInstitutions({ country }),
+ await goCardlessClient.institution.getInstitutions({ country }),
getInstitutionById: async (institutionId) =>
- await nordigenClient.institution.getInstitutionById(institutionId),
+ await goCardlessClient.institution.getInstitutionById(institutionId),
getDetails: async (accountId) =>
- await nordigenClient.account(accountId).getDetails(),
+ await goCardlessClient.account(accountId).getDetails(),
getMetadata: async (accountId) =>
- await nordigenClient.account(accountId).getMetadata(),
+ await goCardlessClient.account(accountId).getMetadata(),
getRequisitionById: async (requisitionId) =>
- await nordigenClient.requisition.getRequisitionById(requisitionId),
+ await goCardlessClient.requisition.getRequisitionById(requisitionId),
deleteRequisition: async (requisitionId) =>
- await nordigenClient.requisition.deleteRequisition(requisitionId),
+ await goCardlessClient.requisition.deleteRequisition(requisitionId),
initSession: async ({
redirectUrl,
institutionId,
@@ -500,7 +500,7 @@ export const client = {
redirectImmediate,
accountSelection,
}) =>
- await nordigenClient.initSession({
+ await goCardlessClient.initSession({
redirectUrl,
institutionId,
referenceId,
@@ -511,7 +511,7 @@ export const client = {
redirectImmediate,
accountSelection,
}),
- generateToken: async () => await nordigenClient.generateToken(),
+ generateToken: async () => await goCardlessClient.generateToken(),
exchangeToken: async ({ refreshToken }) =>
- await nordigenClient.exchangeToken({ refreshToken }),
+ await goCardlessClient.exchangeToken({ refreshToken }),
};
diff --git a/src/app-nordigen/services/tests/fixtures.js b/src/app-gocardless/services/tests/fixtures.js
similarity index 84%
rename from src/app-nordigen/services/tests/fixtures.js
rename to src/app-gocardless/services/tests/fixtures.js
index 47d569fa6a..5e373e5a34 100644
--- a/src/app-nordigen/services/tests/fixtures.js
+++ b/src/app-gocardless/services/tests/fixtures.js
@@ -1,4 +1,4 @@
-/** @type {{balances: import('../../nordigen-node.types.js').Balance[]}} */
+/** @type {{balances: import('../../gocardless-node.types.js').Balance[]}} */
export const mockedBalances = {
balances: [
{
@@ -20,7 +20,7 @@ export const mockedBalances = {
],
};
-/** @type {{transactions: import('../../nordigen-node.types.js').Transactions}} */
+/** @type {{transactions: import('../../gocardless-node.types.js').Transactions}} */
export const mockTransactions = {
transactions: {
booked: [
@@ -68,7 +68,7 @@ export const mockUnknownError = {
status_code: 500,
};
-/** @type {{account: import('../../nordigen-node.types.js').NordigenAccountDetails}} */
+/** @type {{account: import('../../gocardless-node.types.js').GoCardlessAccountDetails}} */
export const mockAccountDetails = {
account: {
resourceId: 'PL00000000000000000987654321',
@@ -81,7 +81,7 @@ export const mockAccountDetails = {
},
};
-/** @type {import('../../nordigen-node.types.js').NordigenAccountMetadata} */
+/** @type {import('../../gocardless-node.types.js').GoCardlessAccountMetadata} */
export const mockAccountMetaData = {
id: 'f0e49aa6-f6db-48fc-94ca-4a62372fadf4',
created: '2022-07-24T20:45:47.847062Z',
@@ -92,13 +92,13 @@ export const mockAccountMetaData = {
owner_name: 'JOHN EXAMPLE',
};
-/** @type {import('../../nordigen.types.js').DetailedAccount} */
+/** @type {import('../../gocardless.types.js').DetailedAccount} */
export const mockDetailedAccount = {
...mockAccountDetails.account,
...mockAccountMetaData,
};
-/** @type {import('../../nordigen-node.types.js').Institution} */
+/** @type {import('../../gocardless-node.types.js').Institution} */
export const mockInstitution = {
id: 'N26_NTSBDEB1',
name: 'N26 Bank',
@@ -108,7 +108,7 @@ export const mockInstitution = {
logo: 'https://cdn.nordigen.com/ais/N26_SANDBOX_NTSBDEB1.png',
};
-/** @type {import('../../nordigen-node.types.js').Requisition} */
+/** @type {import('../../gocardless-node.types.js').Requisition} */
export const mockRequisition = {
id: '3fa85f64-5717-4562-b3fc-2c963f66afa6',
created: '2023-01-31T18:15:50.172Z',
@@ -147,19 +147,19 @@ export const mockCreateRequisition = {
redirect_immediate: false,
};
-/** @type {import('../../nordigen.types.js').DetailedAccount} */
+/** @type {import('../../gocardless.types.js').DetailedAccount} */
export const mockDetailedAccountExample1 = {
...mockDetailedAccount,
name: 'account-example-one',
};
-/** @type {import('../../nordigen.types.js').DetailedAccount} */
+/** @type {import('../../gocardless.types.js').DetailedAccount} */
export const mockDetailedAccountExample2 = {
...mockDetailedAccount,
name: 'account-example-two',
};
-/** @type {import('../../nordigen.types.js').DetailedAccountWithInstitution[]} */
+/** @type {import('../../gocardless.types.js').DetailedAccountWithInstitution[]} */
export const mockExtendAccountsAboutInstitutions = [
{
...mockDetailedAccountExample1,
diff --git a/src/app-nordigen/services/tests/nordigen-service.spec.js b/src/app-gocardless/services/tests/gocardless-service.spec.js
similarity index 79%
rename from src/app-nordigen/services/tests/nordigen-service.spec.js
rename to src/app-gocardless/services/tests/gocardless-service.spec.js
index f9d0b2bdee..a0460037ea 100644
--- a/src/app-nordigen/services/tests/nordigen-service.spec.js
+++ b/src/app-gocardless/services/tests/gocardless-service.spec.js
@@ -1,7 +1,7 @@
import { jest } from '@jest/globals';
import {
InvalidInputDataError,
- InvalidNordigenTokenError,
+ InvalidGoCardlessTokenError,
AccessDeniedError,
NotFoundError,
ResourceSuspended,
@@ -30,12 +30,12 @@ import {
} from './fixtures.js';
import {
- nordigenService,
- handleNordigenError,
+ goCardlessService,
+ handleGoCardlessError,
client,
-} from '../nordigen-service.js';
+} from '../gocardless-service.js';
-describe('nordigenService', () => {
+describe('goCardlessService', () => {
const accountId = mockAccountMetaData.id;
const requisitionId = mockRequisition.id;
@@ -60,7 +60,7 @@ describe('nordigenService', () => {
getTransactionsSpy = jest.spyOn(client, 'getTransactions');
getDetailsSpy = jest.spyOn(client, 'getDetails');
getMetadataSpy = jest.spyOn(client, 'getMetadata');
- setTokenSpy = jest.spyOn(nordigenService, 'setToken');
+ setTokenSpy = jest.spyOn(goCardlessService, 'setToken');
});
afterEach(() => {
@@ -72,23 +72,23 @@ describe('nordigenService', () => {
setTokenSpy.mockResolvedValue();
jest
- .spyOn(nordigenService, 'getRequisition')
+ .spyOn(goCardlessService, 'getRequisition')
.mockResolvedValue(mockRequisition);
- expect(await nordigenService.getLinkedRequisition(requisitionId)).toEqual(
- mockRequisition,
- );
+ expect(
+ await goCardlessService.getLinkedRequisition(requisitionId),
+ ).toEqual(mockRequisition);
});
it('throws RequisitionNotLinked error if requisition status is different than LN', async () => {
setTokenSpy.mockResolvedValue();
jest
- .spyOn(nordigenService, 'getRequisition')
+ .spyOn(goCardlessService, 'getRequisition')
.mockResolvedValue({ ...mockRequisition, status: 'ER' });
await expect(() =>
- nordigenService.getLinkedRequisition(requisitionId),
+ goCardlessService.getLinkedRequisition(requisitionId),
).rejects.toThrow(RequisitionNotLinked);
});
});
@@ -96,19 +96,19 @@ describe('nordigenService', () => {
describe('#getRequisitionWithAccounts', () => {
it('returns combined data', async () => {
jest
- .spyOn(nordigenService, 'getRequisition')
+ .spyOn(goCardlessService, 'getRequisition')
.mockResolvedValue(mockRequisitionWithExampleAccounts);
jest
- .spyOn(nordigenService, 'getDetailedAccount')
+ .spyOn(goCardlessService, 'getDetailedAccount')
.mockResolvedValueOnce(mockDetailedAccountExample1);
jest
- .spyOn(nordigenService, 'getDetailedAccount')
+ .spyOn(goCardlessService, 'getDetailedAccount')
.mockResolvedValueOnce(mockDetailedAccountExample2);
jest
- .spyOn(nordigenService, 'getInstitution')
+ .spyOn(goCardlessService, 'getInstitution')
.mockResolvedValue(mockInstitution);
jest
- .spyOn(nordigenService, 'extendAccountsAboutInstitutions')
+ .spyOn(goCardlessService, 'extendAccountsAboutInstitutions')
.mockResolvedValue([
{
...mockExtendAccountsAboutInstitutions[0],
@@ -120,7 +120,7 @@ describe('nordigenService', () => {
},
]);
- const response = await nordigenService.getRequisitionWithAccounts(
+ const response = await goCardlessService.getRequisitionWithAccounts(
mockRequisitionWithExampleAccounts.id,
);
@@ -147,20 +147,20 @@ describe('nordigenService', () => {
const requisitionId = mockRequisition.id;
it('returns transaction with starting balance', async () => {
jest
- .spyOn(nordigenService, 'getLinkedRequisition')
+ .spyOn(goCardlessService, 'getLinkedRequisition')
.mockResolvedValue(mockRequisition);
jest
- .spyOn(nordigenService, 'getAccountMetadata')
+ .spyOn(goCardlessService, 'getAccountMetadata')
.mockResolvedValue(mockAccountMetaData);
jest
- .spyOn(nordigenService, 'getTransactions')
+ .spyOn(goCardlessService, 'getTransactions')
.mockResolvedValue(mockTransactions);
jest
- .spyOn(nordigenService, 'getBalances')
+ .spyOn(goCardlessService, 'getBalances')
.mockResolvedValue(mockedBalances);
expect(
- await nordigenService.getTransactionsWithBalance(
+ await goCardlessService.getTransactionsWithBalance(
requisitionId,
accountId,
undefined,
@@ -218,11 +218,11 @@ describe('nordigenService', () => {
it('throws AccountNotLinedToRequisition error if requisition accounts not includes requested account', async () => {
jest
- .spyOn(nordigenService, 'getLinkedRequisition')
+ .spyOn(goCardlessService, 'getLinkedRequisition')
.mockResolvedValue(mockRequisition);
await expect(() =>
- nordigenService.getTransactionsWithBalance({
+ goCardlessService.getTransactionsWithBalance({
requisitionId,
accountId: 'some-unknown-account-id',
startDate: undefined,
@@ -240,12 +240,12 @@ describe('nordigenService', () => {
accessValidForDays: 90,
};
- it('calls nordigenClient and delete requisition', async () => {
+ it('calls goCardlessClient and delete requisition', async () => {
setTokenSpy.mockResolvedValue();
createRequisitionSpy.mockResolvedValue(mockCreateRequisition);
- expect(await nordigenService.createRequisition(params)).toEqual({
+ expect(await goCardlessService.createRequisition(params)).toEqual({
link: expect.any(String),
requisitionId: expect.any(String),
});
@@ -259,7 +259,7 @@ describe('nordigenService', () => {
createRequisitionSpy.mockResolvedValue(mockUnknownError);
await expect(() =>
- nordigenService.createRequisition(params),
+ goCardlessService.createRequisition(params),
).rejects.toThrow(UnknownError);
});
});
@@ -267,13 +267,13 @@ describe('nordigenService', () => {
describe('#deleteRequisition', () => {
const requisitionId = 'some-requisition-id';
- it('calls nordigenClient and delete requisition', async () => {
+ it('calls goCardlessClient and delete requisition', async () => {
setTokenSpy.mockResolvedValue();
getRequisitionsSpy.mockResolvedValue(mockRequisition);
deleteRequisitionsSpy.mockResolvedValue(mockDeleteRequisition);
- expect(await nordigenService.deleteRequisition(requisitionId)).toEqual(
+ expect(await goCardlessService.deleteRequisition(requisitionId)).toEqual(
mockDeleteRequisition,
);
@@ -288,7 +288,7 @@ describe('nordigenService', () => {
deleteRequisitionsSpy.mockReturnValue(mockUnknownError);
await expect(() =>
- nordigenService.deleteRequisition(requisitionId),
+ goCardlessService.deleteRequisition(requisitionId),
).rejects.toThrow(UnknownError);
});
});
@@ -296,11 +296,11 @@ describe('nordigenService', () => {
describe('#getRequisition', () => {
const requisitionId = 'some-requisition-id';
- it('calls nordigenClient and fetch requisition', async () => {
+ it('calls goCardlessClient and fetch requisition', async () => {
setTokenSpy.mockResolvedValue();
getRequisitionsSpy.mockResolvedValue(mockRequisition);
- expect(await nordigenService.getRequisition(requisitionId)).toEqual(
+ expect(await goCardlessService.getRequisition(requisitionId)).toEqual(
mockRequisition,
);
@@ -314,7 +314,7 @@ describe('nordigenService', () => {
getRequisitionsSpy.mockReturnValue(mockUnknownError);
await expect(() =>
- nordigenService.getRequisition(requisitionId),
+ goCardlessService.getRequisition(requisitionId),
).rejects.toThrow(UnknownError);
});
});
@@ -324,7 +324,7 @@ describe('nordigenService', () => {
getDetailsSpy.mockResolvedValue(mockAccountDetails);
getMetadataSpy.mockResolvedValue(mockAccountMetaData);
- expect(await nordigenService.getDetailedAccount(accountId)).toEqual({
+ expect(await goCardlessService.getDetailedAccount(accountId)).toEqual({
...mockAccountMetaData,
...mockAccountDetails.account,
});
@@ -337,7 +337,7 @@ describe('nordigenService', () => {
getMetadataSpy.mockResolvedValue(mockAccountMetaData);
await expect(() =>
- nordigenService.getDetailedAccount(accountId),
+ goCardlessService.getDetailedAccount(accountId),
).rejects.toThrow(UnknownError);
expect(getDetailsSpy).toBeCalledTimes(1);
@@ -349,7 +349,7 @@ describe('nordigenService', () => {
getMetadataSpy.mockResolvedValue(mockUnknownError);
await expect(() =>
- nordigenService.getDetailedAccount(accountId),
+ goCardlessService.getDetailedAccount(accountId),
).rejects.toThrow(UnknownError);
expect(getDetailsSpy).toBeCalledTimes(1);
@@ -359,10 +359,10 @@ describe('nordigenService', () => {
describe('#getInstitutions', () => {
const country = 'IE';
- it('calls nordigenClient and fetch institution details', async () => {
+ it('calls goCardlessClient and fetch institution details', async () => {
getInstitutionsSpy.mockResolvedValue([mockInstitution]);
- expect(await nordigenService.getInstitutions({ country })).toEqual([
+ expect(await goCardlessService.getInstitutions({ country })).toEqual([
mockInstitution,
]);
expect(getInstitutionsSpy).toBeCalledTimes(1);
@@ -372,17 +372,17 @@ describe('nordigenService', () => {
getInstitutionsSpy.mockResolvedValue(mockUnknownError);
await expect(() =>
- nordigenService.getInstitutions({ country }),
+ goCardlessService.getInstitutions({ country }),
).rejects.toThrow(UnknownError);
});
});
describe('#getInstitution', () => {
const institutionId = 'fake-institution-id';
- it('calls nordigenClient and fetch institution details', async () => {
+ it('calls goCardlessClient and fetch institution details', async () => {
getInstitutionSpy.mockResolvedValue(mockInstitution);
- expect(await nordigenService.getInstitution(institutionId)).toEqual(
+ expect(await goCardlessService.getInstitution(institutionId)).toEqual(
mockInstitution,
);
expect(getInstitutionSpy).toBeCalledTimes(1);
@@ -392,7 +392,7 @@ describe('nordigenService', () => {
getInstitutionSpy.mockResolvedValue(mockUnknownError);
await expect(() =>
- nordigenService.getInstitution(institutionId),
+ goCardlessService.getInstitution(institutionId),
).rejects.toThrow(UnknownError);
});
});
@@ -426,7 +426,7 @@ describe('nordigenService', () => {
},
];
- const result = await nordigenService.extendAccountsAboutInstitutions({
+ const result = await goCardlessService.extendAccountsAboutInstitutions({
accounts,
institutions,
});
@@ -462,7 +462,7 @@ describe('nordigenService', () => {
},
];
- const result = await nordigenService.extendAccountsAboutInstitutions({
+ const result = await goCardlessService.extendAccountsAboutInstitutions({
accounts,
institutions,
});
@@ -472,11 +472,11 @@ describe('nordigenService', () => {
});
describe('#getTransactions', () => {
- it('calls nordigenClient and fetch transactions for provided accountId', async () => {
+ it('calls goCardlessClient and fetch transactions for provided accountId', async () => {
getTransactionsSpy.mockResolvedValue(mockTransactions);
expect(
- await nordigenService.getTransactions({
+ await goCardlessService.getTransactions({
accountId,
startDate: '',
endDate: '',
@@ -529,7 +529,7 @@ describe('nordigenService', () => {
getTransactionsSpy.mockResolvedValue(mockUnknownError);
await expect(() =>
- nordigenService.getTransactions({
+ goCardlessService.getTransactions({
accountId,
startDate: '',
endDate: '',
@@ -539,10 +539,10 @@ describe('nordigenService', () => {
});
describe('#getBalances', () => {
- it('calls nordigenClient and fetch balances for provided accountId', async () => {
+ it('calls goCardlessClient and fetch balances for provided accountId', async () => {
getBalancesSpy.mockResolvedValue(mockedBalances);
- expect(await nordigenService.getBalances(accountId)).toEqual(
+ expect(await goCardlessService.getBalances(accountId)).toEqual(
mockedBalances,
);
expect(getBalancesSpy).toBeCalledTimes(1);
@@ -552,62 +552,64 @@ describe('nordigenService', () => {
getBalancesSpy.mockResolvedValue(mockUnknownError);
await expect(() =>
- nordigenService.getBalances(accountId),
+ goCardlessService.getBalances(accountId),
).rejects.toThrow(UnknownError);
});
});
});
-describe('#handleNordigenError', () => {
+describe('#handleGoCardlessError', () => {
it('throws InvalidInputDataError for status code 400', () => {
const response = { status_code: 400 };
- expect(() => handleNordigenError(response)).toThrow(InvalidInputDataError);
+ expect(() => handleGoCardlessError(response)).toThrow(
+ InvalidInputDataError,
+ );
});
- it('throws InvalidNordigenTokenError for status code 401', () => {
+ it('throws InvalidGoCardlessTokenError for status code 401', () => {
const response = { status_code: 401 };
- expect(() => handleNordigenError(response)).toThrow(
- InvalidNordigenTokenError,
+ expect(() => handleGoCardlessError(response)).toThrow(
+ InvalidGoCardlessTokenError,
);
});
it('throws AccessDeniedError for status code 403', () => {
const response = { status_code: 403 };
- expect(() => handleNordigenError(response)).toThrow(AccessDeniedError);
+ expect(() => handleGoCardlessError(response)).toThrow(AccessDeniedError);
});
it('throws NotFoundError for status code 404', () => {
const response = { status_code: 404 };
- expect(() => handleNordigenError(response)).toThrow(NotFoundError);
+ expect(() => handleGoCardlessError(response)).toThrow(NotFoundError);
});
it('throws ResourceSuspended for status code 409', () => {
const response = { status_code: 409 };
- expect(() => handleNordigenError(response)).toThrow(ResourceSuspended);
+ expect(() => handleGoCardlessError(response)).toThrow(ResourceSuspended);
});
it('throws RateLimitError for status code 429', () => {
const response = { status_code: 429 };
- expect(() => handleNordigenError(response)).toThrow(RateLimitError);
+ expect(() => handleGoCardlessError(response)).toThrow(RateLimitError);
});
it('throws UnknownError for status code 500', () => {
const response = { status_code: 500 };
- expect(() => handleNordigenError(response)).toThrow(UnknownError);
+ expect(() => handleGoCardlessError(response)).toThrow(UnknownError);
});
it('throws ServiceError for status code 503', () => {
const response = { status_code: 503 };
- expect(() => handleNordigenError(response)).toThrow(ServiceError);
+ expect(() => handleGoCardlessError(response)).toThrow(ServiceError);
});
it('does not throw an error for status code 200', () => {
const response = { status_code: 200 };
- expect(() => handleNordigenError(response)).not.toThrow();
+ expect(() => handleGoCardlessError(response)).not.toThrow();
});
it('does not throw an error when status code is not present', () => {
const response = { foo: 'bar' };
- expect(() => handleNordigenError(response)).not.toThrow();
+ expect(() => handleGoCardlessError(response)).not.toThrow();
});
});
diff --git a/src/app-nordigen/tests/bank-factory.spec.js b/src/app-gocardless/tests/bank-factory.spec.js
similarity index 100%
rename from src/app-nordigen/tests/bank-factory.spec.js
rename to src/app-gocardless/tests/bank-factory.spec.js
diff --git a/src/app-nordigen/tests/utils.spec.js b/src/app-gocardless/tests/utils.spec.js
similarity index 100%
rename from src/app-nordigen/tests/utils.spec.js
rename to src/app-gocardless/tests/utils.spec.js
diff --git a/src/app-nordigen/util/handle-error.js b/src/app-gocardless/util/handle-error.js
similarity index 100%
rename from src/app-nordigen/util/handle-error.js
rename to src/app-gocardless/util/handle-error.js
diff --git a/src/app-nordigen/utils.js b/src/app-gocardless/utils.js
similarity index 100%
rename from src/app-nordigen/utils.js
rename to src/app-gocardless/utils.js
diff --git a/src/app.js b/src/app.js
index 7204ee41c7..d75cb46af3 100644
--- a/src/app.js
+++ b/src/app.js
@@ -8,7 +8,7 @@ import rateLimit from 'express-rate-limit';
import * as accountApp from './app-account.js';
import * as syncApp from './app-sync.js';
-import * as nordigenApp from './app-nordigen/app-nordigen.js';
+import * as goCardlessApp from './app-gocardless/app-gocardless.js';
import * as secretApp from './app-secrets.js';
const app = express();
@@ -32,8 +32,8 @@ app.use(bodyParser.raw({ type: 'application/encrypted-file', limit: '50mb' }));
app.use('/sync', syncApp.handlers);
app.use('/account', accountApp.handlers);
-app.use('/nordigen', nordigenApp.handlers);
-app.use('/gocardless', nordigenApp.handlers);
+app.use('/nordigen', goCardlessApp.handlers);
+app.use('/gocardless', goCardlessApp.handlers);
app.use('/secret', secretApp.handlers);
app.get('/mode', (req, res) => {
diff --git a/src/services/secrets-service.js b/src/services/secrets-service.js
index b5177fad88..34c0d0ef8f 100644
--- a/src/services/secrets-service.js
+++ b/src/services/secrets-service.js
@@ -19,11 +19,11 @@ class SecretsDb {
this.debug = createDebug('actual:secrets-db');
this.db = null;
this.initialize();
- this.migrateNordigen();
+ this.migrateGoCardless();
}
- /// Migrates nordigen from config.json or process.env to app secret
- migrateNordigen() {
+ /// Migrates GoCardless from config.json or process.env to app secret
+ migrateGoCardless() {
if (
config.nordigen &&
(!this.get(SecretName.nordigen_secretId) ||
diff --git a/upcoming-release-notes/231.md b/upcoming-release-notes/231.md
new file mode 100644
index 0000000000..a0d531dfea
--- /dev/null
+++ b/upcoming-release-notes/231.md
@@ -0,0 +1,6 @@
+---
+category: Maintenance
+authors: [MatissJanis]
+---
+
+Rename Nordigen to GoCardless