Skip to content

Commit

Permalink
[VAS-1133] feat: Add new api key for printPaymentsNotice product (#584)
Browse files Browse the repository at this point in the history
* [VAS-1133] feat: Introduce print notice api key list element

* [VAS-1133] fix: Api key products psp

* [VAS-1133] feat: Refactor api key products

* [VAS-1133] feat: Introduce flag print notice for api keys

* [VAS-1133] chore: Api key unit test coverage
  • Loading branch information
svariant authored Jun 27, 2024
1 parent cb5c707 commit ae6d1fd
Show file tree
Hide file tree
Showing 5 changed files with 391 additions and 325 deletions.
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

0 comments on commit ae6d1fd

Please sign in to comment.