Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 (gocardless) fix banksync - create singleton client #278

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/app-gocardless/services/gocardless-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,22 @@ import { SecretName, secretsService } from '../../services/secrets-service.js';

const GoCardlessClient = nordigenNode.default;

const getGocardlessClient = () =>
new GoCardlessClient({
const clients = new Map();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can different budgets have different Nordigen secrets? I guess the Map makes sense here 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different budgets can have different secrets, but also the same budget might change its keys. So in that case too we also want to generate a new client.


const getGocardlessClient = () => {
const secrets = {
secretId: secretsService.get(SecretName.nordigen_secretId),
secretKey: secretsService.get(SecretName.nordigen_secretKey),
});
};

const hash = JSON.stringify(secrets);

if (!clients.has(hash)) {
clients.set(hash, new GoCardlessClient(secrets));
}
Comment on lines +31 to +33
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯 nice!


return clients.get(hash);
};

export const handleGoCardlessError = (response) => {
switch (response.status_code) {
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/278.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [MatissJanis]
---

Fix: gocardless bank sync not working as expected after last migration PR merge
Loading