Skip to content

Commit

Permalink
Add support for getting service points for item
Browse files Browse the repository at this point in the history
  • Loading branch information
vijay-eis committed Sep 28, 2024
1 parent 7365c9e commit 153cce3
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
33 changes: 33 additions & 0 deletions ramls/edge-patron.raml
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,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:
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/folio/edge/patron/MainVerticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/org/folio/edge/patron/PatronHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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[] {},
Expand All @@ -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);
Expand Down

0 comments on commit 153cce3

Please sign in to comment.