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

[VAS-1133] feat: Add new api key for printPaymentsNotice product #584

Merged
merged 7 commits into from
Jun 27, 2024
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
3 changes: 2 additions & 1 deletion src/locale/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@
"FDR_ORG": "FdR - Flussi di Rendicontazione (EC)",
"FDR_PSP": "FdR - Flussi di Rendicontazione (PSP)",
"BO_EXT_EC": "Backoffice External (EC)",
"BO_EXT_PSP": "Backoffice External (PSP)"
"BO_EXT_PSP": "Backoffice External (PSP)",
"PRINT_NOTICE": "Stampa Avvisi"
}
},
"channelsPage": {
Expand Down
90 changes: 45 additions & 45 deletions src/model/ApiKey.tsx
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
import {ENV} from "../utils/env";
import { ENV } from '../utils/env';

export type ProductKeys = {
id: string;
displayName: string;
primaryKey: string;
secondaryKey: string;
id: string;
displayName: string;
primaryKey: string;
secondaryKey: string;
};

export type AvailableProductKeys = {
id: string;
title: string;
disabled: boolean;
id: string;
title: string;
disabled: boolean;
};

export type ConfiguredProductKeys = {
id: string;
key: string;
id: string;
key: string;
};

export const NODOAUTH = 'Connessione con nodo';
export const GPD = 'GPD - Posizioni Debitorie';
export const GPD_REP = 'GPD - Gestione flussi di rendicontazione';
export const GPD_PAY = 'GPD - Recupero ricevute';
export const BIZ = 'BIZ - Recupero ricevute Ente Creditore';
export const FDR_ORG = 'FdR - Flussi di Rendicontazione (EC)';
export const FDR_PSP = 'FdR - Flussi di Rendicontazione (PSP)';
export const BO_EXT_EC = 'Backoffice External (EC)';
export const BO_EXT_PSP = 'Backoffice External (PSP)';

export const API_KEY_PSP_PRODUCTS = (): Array<ConfiguredProductKeys> => {
const list = [
{id: 'NODOAUTH', key: NODOAUTH},
{id: 'BO_EXT_PSP', key: BO_EXT_PSP}
];

if (ENV.FEATURES.FDR.ENABLED) {
return [...list, {id: 'FDR_PSP', key: FDR_PSP}];
}
return list;
export const API_KEY_PRODUCTS = {
NODOAUTH: { id: 'NODOAUTH', key: 'nodauth-' },
GPD: { id: 'GPD', key: 'gdp-' },
GPD_REP: { id: 'GPD_REP', key: 'gpdrep-' },
GPD_PAY: { id: 'GPD_PAY', key: 'gpdpay-' },
BIZ: { id: 'BIZ', key: 'biz-' },
FDR_ORG: { id: 'FDR_ORG', key: 'fdrorg-' },
FDR_PSP: { id: 'FDR_PSP', key: 'fdrpsp-' },
BO_EXT_EC: { id: 'BO_EXT_EC', key: 'selfcareboexternalec-' },
BO_EXT_PSP: { id: 'BO_EXT_PSP', key: 'selfcareboexternalpsp-' },
PRINT_NOTICE: { id: 'PRINT_NOTICE', key: 'printnotice-' },
};


export const API_KEY_PRODUCTS = (): Array<ConfiguredProductKeys> => {
const list = [
{id: 'NODOAUTH', key: NODOAUTH},
{id: 'GPD', key: GPD},
{id: 'GPD_PAY', key: GPD_PAY},
{id: 'GPD_REP', key: GPD_REP},
{id: 'BIZ', key: BIZ},
{id: 'BO_EXT_EC', key: BO_EXT_EC}
];

if (ENV.FEATURES.FDR.ENABLED) {
return [...list, {id: 'FDR_ORG', key: FDR_ORG}];
}
return list;
export const getApiKeyProducts = (
isPsp: boolean,
flagPrintNotice: boolean
): Array<ConfiguredProductKeys> => {
const list = isPsp
? [API_KEY_PRODUCTS.NODOAUTH, API_KEY_PRODUCTS.BO_EXT_PSP]
: [
API_KEY_PRODUCTS.NODOAUTH,
API_KEY_PRODUCTS.GPD,
API_KEY_PRODUCTS.GPD_PAY,
API_KEY_PRODUCTS.GPD_REP,
API_KEY_PRODUCTS.BIZ,
API_KEY_PRODUCTS.BO_EXT_EC,
];

if (ENV.FEATURES.FDR.ENABLED) {
// eslint-disable-next-line functional/immutable-data
list.push(isPsp ? API_KEY_PRODUCTS.FDR_PSP : API_KEY_PRODUCTS.FDR_ORG);
}
if (flagPrintNotice && !isPsp) {
// eslint-disable-next-line functional/immutable-data
list.push(API_KEY_PRODUCTS.PRINT_NOTICE);
}
return list;
};
18 changes: 18 additions & 0 deletions src/model/__tests__/ApiKey.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { API_KEY_PRODUCTS, getApiKeyProducts } from '../ApiKey';
describe("Test ApiKey model methods", ()=> {
test("Test getApiKeysProducts as PSP", () => {
expect(getApiKeyProducts(true, true)).toEqual([API_KEY_PRODUCTS.NODOAUTH, API_KEY_PRODUCTS.BO_EXT_PSP, API_KEY_PRODUCTS.FDR_PSP])
})
test("Test getApiKeysProducts as EC", () => {
expect(getApiKeyProducts(false, true)).toEqual([
API_KEY_PRODUCTS.NODOAUTH,
API_KEY_PRODUCTS.GPD,
API_KEY_PRODUCTS.GPD_PAY,
API_KEY_PRODUCTS.GPD_REP,
API_KEY_PRODUCTS.BIZ,
API_KEY_PRODUCTS.BO_EXT_EC,
API_KEY_PRODUCTS.FDR_ORG,
API_KEY_PRODUCTS.PRINT_NOTICE
])
})
})
Loading
Loading