Skip to content

Commit

Permalink
feat: [IOBP-652,IOBP-656] Add biz-events transaction download pdf (#382)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Hantex9 authored May 29, 2024
1 parent 655f68a commit 6ec8883
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Binary file added assets/payments/receipts/loremIpsum.pdf
Binary file not shown.
27 changes: 27 additions & 0 deletions src/features/payments/routers/transactions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as O from "fp-ts/lib/Option";
import { pipe } from "fp-ts/lib/function";
import TransactionsDB from "../persistence/transactions";
import { sendFileFromRootPath } from "../../../utils/file";

import { TransactionListWrapResponse } from "../../../../generated/definitions/pagopa/transactions/TransactionListWrapResponse";
import { addTransactionHandler } from "./router";
Expand Down Expand Up @@ -64,3 +65,29 @@ addTransactionHandler("get", "/transactions/:transactionId", (req, res) => {
)
);
});

addTransactionHandler("get", "/transactions/:transactionId/pdf", (req, res) => {
pipe(
req.params.transactionId,
O.fromNullable,
O.fold(
() => res.sendStatus(400),
transactionId => {
const transaction = TransactionsDB.getTransactionDetails(transactionId);
return pipe(
transaction,
O.fold(
() => res.sendStatus(404),
_ => {
sendFileFromRootPath(
"assets/payments/receipts/loremIpsum.pdf",
res
);
return res;
}
)
);
}
)
);
});

0 comments on commit 6ec8883

Please sign in to comment.