From 2cdba7b3ec5a264cec1dc36d075168f563657371 Mon Sep 17 00:00:00 2001 From: vijay-eis Date: Sat, 28 Sep 2024 09:56:29 -0400 Subject: [PATCH] Add support for getting service points for item --- ramls/edge-patron.raml | 33 +++++++++++++++++++ .../org/folio/edge/patron/MainVerticle.java | 5 ++- .../org/folio/edge/patron/PatronHandler.java | 13 +++++++- 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/ramls/edge-patron.raml b/ramls/edge-patron.raml index 592dd19..eee2ce1 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -473,6 +473,39 @@ types: body: text/plain: example: internal server error, contact administrator + /allowed-service-points: + displayName: Allowed service points + description: Service that provides a list of allowed pickup service points + get: + description: | + Returns a list of pickup service points allowed for a particular patron and instance + queryParameters: + apikey: + description: "API Key" + type: string + body: + application/json: + type: allowedServicePoints + example: !include examples/allowed-service-points-response.json + responses: + 200: + description: | + Successfully returns a list of allowed service points + body: + application/json: + type: allowedServicePoints + example: !include examples/allowed-service-points-response.json + 422: + description: Validation error + body: + application/json: + type: errors + 500: + description: | + Internal server error, e.g. due to misconfiguration + body: + text/plain: + example: internal server error, contact administrator /instance: /{instanceId}: uriParameters: diff --git a/src/main/java/org/folio/edge/patron/MainVerticle.java b/src/main/java/org/folio/edge/patron/MainVerticle.java index 8219ef6..6555c67 100644 --- a/src/main/java/org/folio/edge/patron/MainVerticle.java +++ b/src/main/java/org/folio/edge/patron/MainVerticle.java @@ -79,7 +79,10 @@ public Router defineRoutes() { .handler(patronHandler::handlePlaceInstanceHold); router.route(HttpMethod.GET, "/patron/account/:patronId/instance/:instanceId/" + - "allowed-service-points").handler(patronHandler::handleGetAllowedServicePoints); + "allowed-service-points").handler(patronHandler::handleGetAllowedServicePointsForInstance); + + router.route(HttpMethod.GET, "/patron/account/:patronId/item/:itemId/" + + "allowed-service-points").handler(patronHandler::handleGetAllowedServicePointsForItem); router.route(HttpMethod.POST, "/patron/account/:patronId/hold/:holdId/cancel") .handler(patronHandler::handleCancelHold); diff --git a/src/main/java/org/folio/edge/patron/PatronHandler.java b/src/main/java/org/folio/edge/patron/PatronHandler.java index d4c0830..9abcc69 100644 --- a/src/main/java/org/folio/edge/patron/PatronHandler.java +++ b/src/main/java/org/folio/edge/patron/PatronHandler.java @@ -249,7 +249,7 @@ public void handlePlaceInstanceHold(RoutingContext ctx) { t -> handleProxyException(ctx, t))); } - public void handleGetAllowedServicePoints(RoutingContext ctx) { + public void handleGetAllowedServicePointsForInstance(RoutingContext ctx) { handleCommon(ctx, new String[] { PARAM_PATRON_ID, PARAM_INSTANCE_ID }, new String[] {}, @@ -260,6 +260,17 @@ public void handleGetAllowedServicePoints(RoutingContext ctx) { t -> handleProxyException(ctx, t))); } + public void handleGetAllowedServicePointsForItem(RoutingContext ctx) { + handleCommon(ctx, + new String[] { PARAM_PATRON_ID, PARAM_ITEM_ID }, + new String[] {}, + (client, params) -> ((PatronOkapiClient) client).getAllowedServicePoints( + params.get(PARAM_PATRON_ID), + params.get(PARAM_ITEM_ID), + resp -> handleProxyResponse(ctx, resp), + t -> handleProxyException(ctx, t))); + } + @Override protected void invalidApiKey(RoutingContext ctx, String msg) { accessDenied(ctx, msg);