forked from pagopa/io-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(IDPay): [IODPAY-152] IDPay client refactoring with merged API d…
…efinitions (pagopa#4379) ## Short description This PR introduces a single IDPay API client that combines all the IDPay API definitions. The old separated API clients was removed, resulting in a more streamlined and easy-to-understand code structure. ## List of changes proposed in this pull request - Removed old, splitted, IDPay APIs clients (wallet, initiative, onboarding, timeline) - Added a new IDPay API client shared between all IDPay sub-features - Refactoring of imports and folders to match new definitions - Added `generate:idpay` script to generate IDPay API definitions ## How to test `yarn test`
- Loading branch information
Showing
57 changed files
with
393 additions
and
460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const mockIDPayClient = { | ||
getInitiativeData: jest.fn(), | ||
checkPrerequisites: jest.fn(), | ||
consentOnboarding: jest.fn(), | ||
onboardingCitizen: jest.fn(), | ||
onboardingStatus: jest.fn(), | ||
deleteInstrument: jest.fn(), | ||
enrollIban: jest.fn(), | ||
enrollInstrument: jest.fn(), | ||
getIban: jest.fn(), | ||
getIbanList: jest.fn(), | ||
getInstrumentList: jest.fn(), | ||
getTimeline: jest.fn(), | ||
getTimelineDetail: jest.fn(), | ||
getWallet: jest.fn(), | ||
getWalletDetail: jest.fn(), | ||
getWalletStatus: jest.fn(), | ||
unsubscribe: jest.fn(), | ||
getInitiativesWithInstrument: jest.fn() | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { createClient } from "../../../../../definitions/idpay/client"; | ||
import { defaultRetryingFetch } from "../../../../utils/fetch"; | ||
|
||
const createIDPayClient = (baseUrl: string) => | ||
createClient({ | ||
baseUrl, | ||
fetchApi: defaultRetryingFetch() | ||
}); | ||
|
||
export type IDPayClient = ReturnType<typeof createIDPayClient>; | ||
|
||
export { createIDPayClient }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { pipe } from "fp-ts/lib/function"; | ||
import * as O from "fp-ts/lib/Option"; | ||
import { SagaIterator } from "redux-saga"; | ||
import { fork, select } from "typed-redux-saga/macro"; | ||
import { PreferredLanguageEnum } from "../../../../../definitions/backend/PreferredLanguage"; | ||
import { | ||
idPayApiBaseUrl, | ||
idPayApiUatBaseUrl, | ||
idPayTestToken | ||
} from "../../../../config"; | ||
import { | ||
isPagoPATestEnabledSelector, | ||
preferredLanguageSelector | ||
} from "../../../../store/reducers/persistedPreferences"; | ||
import { fromLocaleToPreferredLanguage } from "../../../../utils/locale"; | ||
import { watchIDPayInitiativeDetailsSaga } from "../../initiative/details/saga"; | ||
import { watchIDPayWalletSaga } from "../../wallet/saga"; | ||
import { createIDPayClient } from "../api/client"; | ||
|
||
export function* watchIDPaySaga(bpdToken: string): SagaIterator { | ||
const isPagoPATestEnabled = yield* select(isPagoPATestEnabledSelector); | ||
|
||
const baseUrl = isPagoPATestEnabled ? idPayApiUatBaseUrl : idPayApiBaseUrl; | ||
const token = idPayTestToken ?? bpdToken; | ||
|
||
const language = yield* select(preferredLanguageSelector); | ||
|
||
const preferredLanguage = pipe( | ||
language, | ||
O.map(fromLocaleToPreferredLanguage), | ||
O.getOrElse(() => PreferredLanguageEnum.it_IT) | ||
); | ||
|
||
const client = createIDPayClient(baseUrl); | ||
|
||
yield* fork(watchIDPayWalletSaga, client, token, preferredLanguage); | ||
yield* fork( | ||
watchIDPayInitiativeDetailsSaga, | ||
client, | ||
token, | ||
preferredLanguage | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 0 additions & 12 deletions
12
ts/features/idpay/initiative/configuration/iban/api/client.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
...creens/IbanConfigurationLandingScreen.tsx → ...creens/IbanConfigurationLandingScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
...ns/__test__/IbanEnrollmentScreen.test.tsx → ...ns/__test__/IbanEnrollmentScreen.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.