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

chore: [IOBP-909] Adapt IDPay definitions mock API #416

Merged
merged 3 commits into from
Oct 4, 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"api_cdc": "https://raw.githubusercontent.com/pagopa/io-app/master/assets/CdcSwagger.yml",
"api_fci": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_io_sign.yaml",
"api_pn": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_pn.yaml",
"api_idpay": "https://raw.githubusercontent.com/pagopa/cstar-infrastructure/v6.5.0/src/domains/idpay-app/api/idpay_appio_full/openapi.appio.full.yml",
"api_idpay": "https://raw.githubusercontent.com/pagopa/cstar-infrastructure/v8.25.1/src/domains/idpay-app/api/idpay_appio_full/openapi.appio.full.yml",
"api_fast_login": "https://raw.githubusercontent.com/pagopa/io-auth-n-identity-domain/io-session-manager@1.0.0/apps/io-session-manager/api/fast-login.yaml",
"api_trial_system": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_trial_system.yaml",
"api_pagopa_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/v1.64.0/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_openapi.json.tpl",
Expand Down
2 changes: 1 addition & 1 deletion src/payloads/features/idpay/get-timeline-detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const generateRandomOperationDetailDTO = (
case "TRANSACTION":
return {
...operation,
accrued: operation.accrued || faker.datatype.number(100),
accruedCents: operation.accruedCents || faker.datatype.number(10000),
idTrxAcquirer: ulid(),
idTrxIssuer: ulid()
};
Expand Down
22 changes: 11 additions & 11 deletions src/persistence/idpay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,19 @@ const { idPay: walletConfig } = ioDevServerConfig.wallet;
const pagoPaWallet: WalletV2 = getWalletV2()[0];

const generateRandomInitiativeDTO = (): InitiativeDTO => {
const amount = faker.datatype.number({ min: 50, max: 200, precision: 10 });
const accrued = faker.datatype.number({ max: 200, precision: 10 });
const refunded = faker.datatype.number({ max: accrued, precision: 10 });
const amountCents = faker.datatype.number({ min: 5000, max: 20000 });
const accruedCents = faker.datatype.number({ max: 20000 });
const refundedCents = faker.datatype.number({ max: accruedCents });

return {
initiativeId: ulid(),
initiativeName: faker.company.name(),
status: getRandomEnumValue(InitiativeStatus),
endDate: faker.date.future(1),
amount,
accrued,
amountCents,
accruedCents,
initiativeRewardType: getRandomEnumValue(InitiativeRewardTypeEnum),
refunded,
refundedCents,
lastCounterUpdate: faker.date.recent(1),
iban: faker.helpers.arrayElement(ibanList)?.iban || "",
nInstr: 1,
Expand Down Expand Up @@ -107,8 +107,8 @@ const generateRandomTransactionOperationDTO = (
operationType: getRandomEnumValue(TransactionOperationTypeEnum),
operationDate: new Date(),
operationId: ulid(),
accrued: faker.datatype.number({ min: 5, max: 25 }),
amount: faker.datatype.number({ min: 50, max: 100 }),
accruedCents: faker.datatype.number({ min: 500, max: 2500 }),
amountCents: faker.datatype.number({ min: 5000, max: 10000 }),
brand,
circuitType: "01",
brandLogo,
Expand All @@ -128,7 +128,7 @@ const generateRandomRefundOperationDTO = (
operationDate: new Date(),
operationId: ulid(),
eventId: ulid(),
amount: faker.datatype.number({ min: 5, max: 100 }),
amountCents: faker.datatype.number({ min: 500, max: 10000 }),
...withInfo
});

Expand Down Expand Up @@ -525,8 +525,8 @@ range(0, walletConfig.discountCount).forEach(() => {
status: InitiativeStatus.REFUNDABLE,
iban: undefined,
nInstr: 0,
accrued: 0,
refunded: 0
accruedCents: 0,
refundedCents: 0
};

const { initiativeId } = initiative;
Expand Down
8 changes: 4 additions & 4 deletions src/routers/features/idpay/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ import { addIdPayHandler } from "./router";

const generateRandomAuthPaymentResponseDTO = (): AuthPaymentResponseDTO => {
const amount = faker.datatype.number({
min: 100,
max: 10000
min: 10000,
max: 1000000
});

return {
id: ulid(),
initiativeId: Object.values(initiatives)[0]?.initiativeId ?? ulid(),
status: getRandomEnumValue(PaymentStatusEnum),
trxCode: faker.datatype.string(),
reward: amount,
rewardCents: amount,
amountCents: amount,
businessName: faker.commerce.productName(),
initiativeName: faker.company.name(),
trxDate: faker.date.recent(0),
residualBudget: faker.datatype.number({
residualBudgetCents: faker.datatype.number({
min: 1000,
max: 20000
})
Expand Down
Loading