Skip to content

Commit 6ec8883

Browse files
authored
feat: [IOBP-652,IOBP-656] Add biz-events transaction download pdf (#382)
* feat: Add transactions biz-events definitions & apis * chore: Renamed folder from `wallet` to `payments` * chore: changed prefix of biz events transactions * feat: Pagination transactions * chore: updated biz events apis * chore: prettify * fix: linter * chore: add bizevents basepath * chore: added continuation header token * chore: Add random cart creation * chore: upgraded biz-events definitions * chore: Adapted new swagger * chore: Add calculate total * fix: total amount calculation * chore: transaction generation refinements * chore: Add random date past generation * chore: prettify * feat: Add download biz-events transaction receipt pdf * chore: prettify * chore: upgrade definition openapi * chore: prettify
1 parent 655f68a commit 6ec8883

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
75.3 KB
Binary file not shown.

src/features/payments/routers/transactions.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as O from "fp-ts/lib/Option";
22
import { pipe } from "fp-ts/lib/function";
33
import TransactionsDB from "../persistence/transactions";
4+
import { sendFileFromRootPath } from "../../../utils/file";
45

56
import { TransactionListWrapResponse } from "../../../../generated/definitions/pagopa/transactions/TransactionListWrapResponse";
67
import { addTransactionHandler } from "./router";
@@ -64,3 +65,29 @@ addTransactionHandler("get", "/transactions/:transactionId", (req, res) => {
6465
)
6566
);
6667
});
68+
69+
addTransactionHandler("get", "/transactions/:transactionId/pdf", (req, res) => {
70+
pipe(
71+
req.params.transactionId,
72+
O.fromNullable,
73+
O.fold(
74+
() => res.sendStatus(400),
75+
transactionId => {
76+
const transaction = TransactionsDB.getTransactionDetails(transactionId);
77+
return pipe(
78+
transaction,
79+
O.fold(
80+
() => res.sendStatus(404),
81+
_ => {
82+
sendFileFromRootPath(
83+
"assets/payments/receipts/loremIpsum.pdf",
84+
res
85+
);
86+
return res;
87+
}
88+
)
89+
);
90+
}
91+
)
92+
);
93+
});

0 commit comments

Comments
 (0)