Skip to content

Commit

Permalink
feat: [PE-763] CGN partner search (#432)
Browse files Browse the repository at this point in the history
* add: cgn partner search endpoint

* update: api definitions

* add: cgn partners count

* format

* fix: package.json

---------

Co-authored-by: Emanuele Dall'Ara <[email protected]>
  • Loading branch information
freddi301 and LeleDallas authored Nov 12, 2024
1 parent db5f6c5 commit 75aa572
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"io_session_manager_api": "https://raw.githubusercontent.com/pagopa/io-auth-n-identity-domain/[email protected]/apps/io-session-manager/api/internal.yaml",
"io_session_manager_public_api": "https://raw.githubusercontent.com/pagopa/io-auth-n-identity-domain/[email protected]/apps/io-session-manager/api/public.yaml",
"api_public_specs": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_public.yaml",
"api_cgn": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_cgn.yaml",
"api_cgn_merchants": "https://raw.githubusercontent.com/pagopa/io-backend/v14.3.0-RELEASE/api_cgn_operator_search.yaml",
"api_cgn": "https://raw.githubusercontent.com/pagopa/io-backend/v16.2.0-RELEASE/api_cgn.yaml",
"api_cgn_merchants": "https://raw.githubusercontent.com/pagopa/io-backend/v16.2.0-RELEASE/api_cgn_operator_search.yaml",
"api_cgn_geo": "https://raw.githubusercontent.com/pagopa/io-backend/here_geoapi_integration/api_geo.yaml",
"content_specs": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.45/definitions.yml",
"api_pagopa_walletv2": "https://raw.githubusercontent.com/pagopa/io-services-metadata/1.0.44/bonus/specs/bpd/pm/walletv2.json",
Expand Down
34 changes: 34 additions & 0 deletions src/routers/features/cgn/merchants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { addHandler } from "../../../payloads/response";
import { sendFileFromRootPath } from "../../../utils/file";
import { addApiV1Prefix } from "../../../utils/strings";
import { publicRouter } from "../../public";
import { SearchRequest } from "../../../../generated/definitions/cgn/merchants/SearchRequest";

export const cgnMerchantsRouter = Router();

Expand Down Expand Up @@ -74,6 +75,39 @@ addHandler(
}
);

addHandler(cgnMerchantsRouter, "get", addPrefix("/count"), (req, res) => {
if (SearchRequest.is(req.body)) {
return res.status(200).json({
count: merchantsAll.length
});
}
return res.status(500);
});

addHandler(cgnMerchantsRouter, "post", addPrefix("/search"), (req, res) => {
if (SearchRequest.is(req.body)) {
return res.status(200).json({
items: merchantsAll
.filter(
merchant =>
merchant.name
.toLowerCase()
.includes(req.body.token.toLowerCase()) ||
merchant.description
?.toLowerCase()
.includes(req.body.token.toLowerCase())
)
.map(merchant => ({
id: merchant.id,
name: merchant.name,
description: merchant.description,
newDiscounts: faker.datatype.boolean()
}))
});
}
return res.status(500);
});

addHandler(
cgnMerchantsRouter,
"post",
Expand Down

0 comments on commit 75aa572

Please sign in to comment.