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

feat(Bonus Pagamenti Digitali): [#176027175] Adds client for ABI list to static contents #2508

Merged
merged 5 commits into from
Dec 7, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
19 changes: 18 additions & 1 deletion ts/api/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { bpdEnabled, contentRepoUrl } from "../config";
import { CodiceCatastale } from "../types/MunicipalityCodiceCatastale";
import { defaultRetryingFetch } from "../utils/fetch";
import { BonusesAvailable } from "../../definitions/content/BonusesAvailable";
import { AbiListResponse } from "../../definitions/pagopa/walletv2/AbiListResponse";

type GetServiceT = IGetApiRequestType<
{
Expand Down Expand Up @@ -101,6 +102,21 @@ const getAvailableBonusesT: GetBonusListT = {
response_decoder: basicResponseDecoder(BonusesAvailable)
};

type GetAbisListT = IGetApiRequestType<
Record<string, unknown>,
never,
never,
BasicResponseType<AbiListResponse>
>;

const getAbisListT: GetAbisListT = {
method: "get",
url: () => "/status/abi.json",
query: _ => ({}),
headers: () => ({}),
response_decoder: basicResponseDecoder(AbiListResponse)
};

/**
* A client for the static content
*/
Expand All @@ -115,6 +131,7 @@ export function ContentClient(fetchApi: typeof fetch = defaultRetryingFetch()) {
getService: createFetchRequestForApi(getServiceT, options),
getMunicipality: createFetchRequestForApi(getMunicipalityT, options),
getServicesByScope: createFetchRequestForApi(getServicesByScopeT, options),
getContextualHelp: createFetchRequestForApi(getContextualHelpT, options)
getContextualHelp: createFetchRequestForApi(getContextualHelpT, options),
getAbiList: createFetchRequestForApi(getAbisListT, options)
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import {
} from "../../store/actions";
import { convertWalletV2toWalletV1 } from "../../../../../../utils/walletv2";
import { getPaymentMethodHash } from "../../../../../../utils/paymentMethod";
import { ContentClient } from "../../../../../../api/content";

// load all bancomat abi
export function* handleLoadAbi(
getAbi: ReturnType<typeof PaymentManagerClient>["getAbi"],
sessionManager: SessionManager<PaymentManagerToken>
getAbi: ReturnType<typeof ContentClient>["getAbiList"]
) {
try {
const getAbiWithRefresh = sessionManager.withRefresh(getAbi);
const getAbiWithRefreshResult: SagaCallReturnType<typeof getAbiWithRefresh> = yield call(
getAbiWithRefresh
const getAbiWithRefreshResult: SagaCallReturnType<typeof getAbi> = yield call(
getAbi,
{}
);
if (getAbiWithRefreshResult.isRight()) {
if (getAbiWithRefreshResult.value.status === 200) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
walletAddBancomatBack,
walletAddBancomatCancel
} from "../../store/actions";
import { fetchPagoPaTimeout } from "../../../../../../config";
import { SearchBankComponent } from "./SearchBankComponent";

type Props = LightModalContextInterface &
Expand All @@ -38,7 +39,7 @@ const SearchBankScreen: React.FunctionComponent<Props> = (props: Props) => {
if (isUndefined(props.bankRemoveValue)) {
props.loadAbis();
} else if (isError(props.bankRemoveValue)) {
errorRetry = setTimeout(props.loadAbis, 2000);
errorRetry = setTimeout(props.loadAbis, fetchPagoPaTimeout);
}
}, [props.bankRemoveValue]);

Expand Down
10 changes: 4 additions & 6 deletions ts/sagas/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ import {
searchUserSatispay,
walletAddSatispayStart
} from "../features/wallet/onboarding/satispay/store/actions";
import { ContentClient } from "../api/content";

/**
* Configure the max number of retries and delay between retries when polling
Expand Down Expand Up @@ -797,13 +798,10 @@ export function* watchWalletSaga(
);

if (bpdEnabled) {
const contentClient = ContentClient();

// watch for load abi request
yield takeLatest(
loadAbi.request,
handleLoadAbi,
paymentManagerClient.getAbi,
pmSessionManager
);
yield takeLatest(loadAbi.request, handleLoadAbi, contentClient.getAbiList);

// watch for load pans request
yield takeLatest(
Expand Down