Skip to content

Commit

Permalink
[#PE-756] Updated CGN search api and added a new /count endpoint (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldisaro authored Nov 4, 2024
1 parent d70b2a1 commit 7287cd3
Show file tree
Hide file tree
Showing 8 changed files with 305 additions and 96 deletions.
66 changes: 44 additions & 22 deletions api_cgn_operator_search.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ paths:
schema:
$ref: "#/definitions/ProblemJson"

"/count":
get:
operationId: count
summary: Count merchants and discounts to search within
description: |
Count merchants and discountsto search within
responses:
"200":
description: Count of merchants/discounts
schema:
$ref: "#/definitions/CountResult"
"400":
description: Bad request.
"401":
description: Login expired.
"500":
description: Service unavailable.
schema:
$ref: "#/definitions/ProblemJson"

"/search":
post:
operationId: search
Expand Down Expand Up @@ -172,49 +192,51 @@ definitions:
ProblemJson:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v21.0.1/openapi/definitions.yaml#/ProblemJson"
Merchant:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/Merchant"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/Merchant"
SupportType:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SupportType"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SupportType"
DiscountCodeType:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/DiscountCodeType"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/DiscountCodeType"
OfflineMerchants:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchants"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchants"
OfflineMerchant:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchant"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchant"
OfflineMerchantSearchRequest:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchantSearchRequest"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OfflineMerchantSearchRequest"
CountResult:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/CountResult"
SearchResult:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchResult"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchResult"
SearchItem:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchItem"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchItem"
OnlineMerchants:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchants"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchants"
OnlineMerchant:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchant"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchant"
SearchRequest:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchRequest"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchRequest"
OnlineMerchantSearchRequest:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchantSearchRequest"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/OnlineMerchantSearchRequest"
Discount:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/Discount"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/Discount"
ProductCategory:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/ProductCategory"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/ProductCategory"
Address:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/Address"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/Address"
Coordinates:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/Coordinates"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/Coordinates"
BoundingBox:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/BoundingBox"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/BoundingBox"
DiscountBucketCode:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/DiscountBucketCode"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/DiscountBucketCode"
PublishedProductCategories:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategories"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategories"
PublishedProductCategoriesWithNewDiscountsCount:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategoriesWithNewDiscountsCount"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategoriesWithNewDiscountsCount"
PublishedProductCategoriesResult:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategoriesResult"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/PublishedProductCategoriesResult"
ProductCategoryWithNewDiscountsCount:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/ProductCategoryWithNewDiscountsCount"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/ProductCategoryWithNewDiscountsCount"
securityDefinitions:
Bearer:
type: apiKey
Expand Down
65 changes: 43 additions & 22 deletions openapi/api_cgn_operator_search.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ paths:
description: Service unavailable.
schema:
$ref: "#/definitions/ProblemJson"
"/count":
get:
operationId: count
summary: Count merchants and discounts to search within
description: |
Count merchants and discountsto search within
responses:
"200":
description: Count of merchants/discounts
schema:
$ref: "#/definitions/CountResult"
"400":
description: Bad request.
"401":
description: Login expired.
"500":
description: Service unavailable.
schema:
$ref: "#/definitions/ProblemJson"
"/search":
post:
operationId: search
Expand Down Expand Up @@ -165,49 +184,51 @@ definitions:
ProblemJson:
$ref: "../node_modules/@pagopa/io-functions-commons/openapi/definitions.yaml#/ProblemJson"
Merchant:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/Merchant"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/Merchant"
SupportType:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/SupportType"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/SupportType"
DiscountCodeType:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/DiscountCodeType"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/DiscountCodeType"
OfflineMerchants:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OfflineMerchants"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OfflineMerchants"
OfflineMerchant:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OfflineMerchant"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OfflineMerchant"
OfflineMerchantSearchRequest:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OfflineMerchantSearchRequest"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OfflineMerchantSearchRequest"
CountResult:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/CountResult"
SearchResult:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchResult"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchResult"
SearchItem:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchItem"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchItem"
OnlineMerchants:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OnlineMerchants"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OnlineMerchants"
OnlineMerchant:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OnlineMerchant"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OnlineMerchant"
SearchRequest:
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml#/definitions/SearchRequest"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml#/definitions/SearchRequest"
OnlineMerchantSearchRequest:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/OnlineMerchantSearchRequest"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/OnlineMerchantSearchRequest"
Discount:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/Discount"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/Discount"
ProductCategory:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/ProductCategory"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/ProductCategory"
Address:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/Address"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/Address"
Coordinates:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/Coordinates"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/Coordinates"
BoundingBox:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/BoundingBox"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/BoundingBox"
DiscountBucketCode:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/DiscountBucketCode"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/DiscountBucketCode"
PublishedProductCategories:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/PublishedProductCategories"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/PublishedProductCategories"
PublishedProductCategoriesWithNewDiscountsCount:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/PublishedProductCategoriesWithNewDiscountsCount"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/PublishedProductCategoriesWithNewDiscountsCount"
PublishedProductCategoriesResult:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/PublishedProductCategoriesResult"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/PublishedProductCategoriesResult"
ProductCategoryWithNewDiscountsCount:
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-cgn-operator-search/v3.1.0/openapi/index.yaml#/definitions/ProductCategoryWithNewDiscountsCount"
$ref: "https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/openapi/index.yaml#/definitions/ProductCategoryWithNewDiscountsCount"
securityDefinitions:
Bearer:
type: apiKey
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"generate:proxy:cgn-operator-search-models": "rimraf generated/cgn-operator-search && gen-api-models --api-spec api_cgn_operator_search.yaml --out-dir generated/cgn-operator-search",
"generate:api:io-bonus": "rimraf generated/io-bonus-api && gen-api-models --api-spec openapi/consumed/fn_bonus.yaml --no-strict --out-dir generated/io-bonus-api --request-types --response-decoders --client",
"generate:api:io-sign": "rimraf generated/io-sign-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-sign/0a9124b7c782b2569dd82c094496e50a17b418f4/apps/io-func-sign-user/openapi.yaml --no-strict --out-dir generated/io-sign-api --request-types --response-decoders --client",
"generate:api:io-cgn-operator-search": "rimraf generated/io-cgn-operator-search-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.2.1/apps/search-func/openapi/index.yaml --no-strict --out-dir generated/io-cgn-operator-search-api --request-types --response-decoders --client",
"generate:api:io-cgn-operator-search": "rimraf generated/io-cgn-operator-search-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-cgn/refs/tags/search-func@3.3.0/apps/search-func/openapi/index.yaml --no-strict --out-dir generated/io-cgn-operator-search-api --request-types --response-decoders --client",
"generate:api:pagopaproxy": "rimraf generated/pagopa-proxy && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-pagopa-proxy/v1.6.0/api-spec/api-for-io.yaml --no-strict --out-dir generated/pagopa-proxy --request-types --response-decoders --client",
"generate:api:lollipop": "rimraf generated/lollipop-api && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-functions-lollipop/724c3ba79d272d4e2555dbc2a8e1657bec9f84ce/openapi/internal.yaml --no-strict --out-dir generated/lollipop-api --request-types --response-decoders --client",
"generate:api:services-app-backend": "rimraf generated/services-app-backend && gen-api-models --api-spec https://raw.githubusercontent.com/pagopa/io-services-cms/d2afbdf73e5b4ffd24aa46b025729ff2a9ed3cce/apps/app-backend/api/internal.yaml --no-strict --out-dir generated/services-app-backend --request-types --response-decoders --client",
Expand Down
6 changes: 6 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,12 @@ function registerCgnOperatorSearchAPIRoutes(
toExpressHandler(cgnOperatorController.getMerchant, cgnOperatorController)
);

app.get(
`${basePath}/count`,
bearerSessionTokenAuth,
toExpressHandler(cgnOperatorController.count, cgnOperatorController)
);

app.post(
`${basePath}/search`,
bearerSessionTokenAuth,
Expand Down
Loading

0 comments on commit 7287cd3

Please sign in to comment.