From 9b6a4e99e4dffdec6457b7816628dbf70336f7ec Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Sat, 14 Dec 2024 17:37:42 +0530 Subject: [PATCH 01/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- .../java/org/folio/edge/patron/Constants.java | 1 + .../org/folio/edge/patron/MainVerticle.java | 3 ++ .../org/folio/edge/patron/PatronHandler.java | 50 ++++++++++++------- .../edge/patron/utils/PatronOkapiClient.java | 11 ++++ .../folio/edge/patron/MainVerticleTest.java | 18 +++++++ .../edge/patron/utils/PatronMockOkapi.java | 39 +++++++++++++++ .../staging-users-put-error-response.json | 27 ++++++++++ .../resources/staging-users-put-request.json | 27 ++++++++++ .../resources/staging-users-put-response.json | 34 +++++++++++++ 9 files changed, 191 insertions(+), 19 deletions(-) create mode 100644 src/test/resources/staging-users-put-error-response.json create mode 100644 src/test/resources/staging-users-put-request.json create mode 100644 src/test/resources/staging-users-put-response.json diff --git a/src/main/java/org/folio/edge/patron/Constants.java b/src/main/java/org/folio/edge/patron/Constants.java index 7b60082..55acea8 100644 --- a/src/main/java/org/folio/edge/patron/Constants.java +++ b/src/main/java/org/folio/edge/patron/Constants.java @@ -34,6 +34,7 @@ public class Constants { public static final String PARAM_INSTANCE_ID = "instanceId"; public static final String PARAM_HOLD_ID = "holdId"; public static final String PARAM_EMAIL_ID = "emailId"; + public static final String PARAM_EXTERNAL_SYSTEM_ID = "externalSystemId"; public static final String PARAM_REQUEST_ID = "requestId"; public static final String MSG_ACCESS_DENIED = "Access Denied"; diff --git a/src/main/java/org/folio/edge/patron/MainVerticle.java b/src/main/java/org/folio/edge/patron/MainVerticle.java index 8c92363..b5a3bd6 100644 --- a/src/main/java/org/folio/edge/patron/MainVerticle.java +++ b/src/main/java/org/folio/edge/patron/MainVerticle.java @@ -104,6 +104,9 @@ public Router defineRoutes() { router.route(HttpMethod.POST, "/patron") .handler(patronHandler::handlePostPatronRequest); + router.route(HttpMethod.PUT, "/patron/:externalSystemId") + .handler(patronHandler::handlePutPatronRequest); + router.route(HttpMethod.POST, "/patron/account/:patronId/instance/:instanceId/hold") .handler(patronHandler::handlePlaceInstanceHold); diff --git a/src/main/java/org/folio/edge/patron/PatronHandler.java b/src/main/java/org/folio/edge/patron/PatronHandler.java index 7b71aa0..ab5bd88 100644 --- a/src/main/java/org/folio/edge/patron/PatronHandler.java +++ b/src/main/java/org/folio/edge/patron/PatronHandler.java @@ -3,25 +3,7 @@ import static org.folio.edge.core.Constants.APPLICATION_JSON; import static org.folio.edge.core.Constants.X_OKAPI_TENANT; import static org.folio.edge.core.Constants.X_OKAPI_TOKEN; -import static org.folio.edge.patron.Constants.EXTERNAL_SYSTEM_ID_CLAIM; -import static org.folio.edge.patron.Constants.FIELD_EXPIRATION_DATE; -import static org.folio.edge.patron.Constants.FIELD_REQUEST_DATE; -import static org.folio.edge.patron.Constants.MSG_ACCESS_DENIED; -import static org.folio.edge.patron.Constants.MSG_HOLD_NOBODY; -import static org.folio.edge.patron.Constants.MSG_INTERNAL_SERVER_ERROR; -import static org.folio.edge.patron.Constants.MSG_REQUEST_TIMEOUT; -import static org.folio.edge.patron.Constants.PARAM_EMAIL_ID; -import static org.folio.edge.patron.Constants.PARAM_HOLD_ID; -import static org.folio.edge.patron.Constants.PARAM_INCLUDE_CHARGES; -import static org.folio.edge.patron.Constants.PARAM_INCLUDE_HOLDS; -import static org.folio.edge.patron.Constants.PARAM_INCLUDE_LOANS; -import static org.folio.edge.patron.Constants.PARAM_INSTANCE_ID; -import static org.folio.edge.patron.Constants.PARAM_ITEM_ID; -import static org.folio.edge.patron.Constants.PARAM_LIMIT; -import static org.folio.edge.patron.Constants.PARAM_OFFSET; -import static org.folio.edge.patron.Constants.PARAM_PATRON_ID; -import static org.folio.edge.patron.Constants.PARAM_SORT_BY; -import static org.folio.edge.patron.Constants.VIP_CLAIM; +import static org.folio.edge.patron.Constants.*; import static org.folio.edge.patron.model.HoldCancellationValidator.validateCancelHoldRequest; import com.amazonaws.util.StringUtils; @@ -227,6 +209,36 @@ public void handlePostPatronRequest(RoutingContext ctx) { }); } + public void handlePutPatronRequest(RoutingContext ctx) { + if (ctx.body().asJsonObject() == null) { + logger.warn("handlePutPatronRequest:: missing body found"); + ctx.response() + .setStatusCode(400) + .putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .end(getErrorMsg("MISSING_BODY", "Request body must not null")); + return; + } + String externalSystemId = ctx.request().getParam(PARAM_EXTERNAL_SYSTEM_ID); + if(StringUtils.isNullOrEmpty(externalSystemId)) { + logger.warn("handlePutPatronRequest:: Missing or empty externalSystemId"); + ctx.response() + .setStatusCode(400) + .putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .end(getErrorMsg("EXTERNAL_SYSTEM_ID_NOT_PROVIDED", "externalSystemId is missing in the request")); + return; + } + + final String body = String.valueOf(ctx.body().asJsonObject()); + super.handleCommon(ctx, new String[]{}, new String[]{}, (client, params) -> { + String alternateTenantId = ctx.request().getParam("alternateTenantId", client.tenant); + final PatronOkapiClient patronClient = new PatronOkapiClient(client, alternateTenantId); + patronClient.putPatron(externalSystemId, body, + resp -> handleProxyResponse(ctx, resp), + t -> handleProxyException(ctx, t)); + }); + } + + public void handleCancelHold(RoutingContext ctx) { String validationResult = validateCancelHoldRequest(ctx.body().asJsonObject()); if ( validationResult != null) { diff --git a/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java b/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java index 81a32c1..b3b2688 100644 --- a/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java +++ b/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java @@ -175,6 +175,17 @@ public void postPatron(String requestBody, exceptionHandler); } + public void putPatron(String externalSystemId, String requestBody, + Handler> responseHandler, Handler exceptionHandler) { + post( + format("%s/patron/%s", okapiURL, externalSystemId), + tenant, + requestBody, + null, + responseHandler, + exceptionHandler); + } + public void cancelHold(String patronId, String holdId, JsonObject holdCancellationRequest, Handler> responseHandler, Handler exceptionHandler) { getRequest(holdId, diff --git a/src/test/java/org/folio/edge/patron/MainVerticleTest.java b/src/test/java/org/folio/edge/patron/MainVerticleTest.java index ecc3f70..35866d3 100644 --- a/src/test/java/org/folio/edge/patron/MainVerticleTest.java +++ b/src/test/java/org/folio/edge/patron/MainVerticleTest.java @@ -81,6 +81,7 @@ public class MainVerticleTest { private static final String itemId = UUID.randomUUID().toString(); private static final String instanceId = UUID.randomUUID().toString(); private static final String holdId = UUID.randomUUID().toString(); + private static final String externalSystemId = UUID.randomUUID().toString(); private static final String apiKey = ApiKeyUtils.generateApiKey(10, "diku", "diku"); private static final String badApiKey = apiKey + "0000"; private static final String unknownTenantApiKey = ApiKeyUtils.generateApiKey(10, "bogus", "diku"); @@ -970,6 +971,23 @@ public void testPostPatron_201(TestContext context) { .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON); } + @Test + public void testPutPatron_200(TestContext context) { + logger.info("=== testPutPatron_200 ==="); + JsonObject jsonObject = new JsonObject(readMockFile("/staging-users-put-request.json")); + jsonObject.getJsonObject("generalInfo").put("firstName", "TEST_STATUS_CODE_200"); + RestAssured + .with() + .body(jsonObject.encode()) + .contentType(APPLICATION_JSON) + .put( + String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + .then() + .statusCode(200) + .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON); + } + + @Test public void testPostPatron_200(TestContext context) { logger.info("=== testPostPatron_200 ==="); diff --git a/src/test/java/org/folio/edge/patron/utils/PatronMockOkapi.java b/src/test/java/org/folio/edge/patron/utils/PatronMockOkapi.java index 5f29689..b4004f8 100644 --- a/src/test/java/org/folio/edge/patron/utils/PatronMockOkapi.java +++ b/src/test/java/org/folio/edge/patron/utils/PatronMockOkapi.java @@ -147,6 +147,9 @@ public Router defineRoutes() { router.route(HttpMethod.POST, "/patron") .handler(this::postPatronMock); + router.route(HttpMethod.PUT, "/patron/:externalSystemId") + .handler(this::putPatronMock); + router.route(HttpMethod.POST, "/patron/account/:patronId/instance/:instanceId/hold") .handler(this::placeInstanceHoldHandler); @@ -440,6 +443,42 @@ public void postPatronMock(RoutingContext ctx) { } } + public void putPatronMock(RoutingContext ctx) { + try { + String firstName = ctx.body().asJsonObject().getJsonObject("generalInfo").getString("firstName"); + String mockResponseBody = readMockFile("/staging-users-put-response.json"); + String mockResponse422ErrorBody = readMockFile("/staging-users-put-error-response.json"); + if ("TEST_STATUS_CODE_200".equals(firstName)) { + ctx.response() + .setStatusCode(200) + .putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .end(mockResponseBody); + } else if ("TEST_STATUS_CODE_400".equals(firstName)) { + ctx.response() + .setStatusCode(400) + .putHeader(HttpHeaders.CONTENT_TYPE, TEXT_PLAIN) + .end("A bad exception occurred"); + } else if ("TEST_STATUS_CODE_422".equals(firstName)) { + ctx.response() + .setStatusCode(422) + .putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .end(mockResponse422ErrorBody); + } else if ("TEST_STATUS_CODE_500".equals(firstName)) { + ctx.response() + .setStatusCode(500) + .putHeader(HttpHeaders.CONTENT_TYPE, TEXT_PLAIN) + .end("Server exception occurred"); + } + } catch (Exception e) { + logger.error("Exception parsing request payload", e); + ctx.response() + .setStatusCode(400) + .putHeader(HttpHeaders.CONTENT_TYPE, TEXT_PLAIN) + .end("Bad Request: " + e.toString()); + } + } + + public void getRequestHandler(RoutingContext ctx) { String requestId = ctx.request().getParam(PARAM_REQUEST_ID); String token = ctx.request().getHeader(X_OKAPI_TOKEN); diff --git a/src/test/resources/staging-users-put-error-response.json b/src/test/resources/staging-users-put-error-response.json new file mode 100644 index 0000000..dabed5f --- /dev/null +++ b/src/test/resources/staging-users-put-error-response.json @@ -0,0 +1,27 @@ +{ + "total_records": 2, + "errors": [ + { + "message": "ABC is required", + "type": "STANDARD_TYPE", + "code": "ERROR_CODE", + "parameters": [ + { + "key": "KEY-1", + "value": "VALUE-1" + } + ] + }, + { + "message": "XYZ is required", + "type": "STANDARD_TYPE", + "code": "ERROR_CODE", + "parameters": [ + { + "key": "KEY-2", + "value": "VALUE-2" + } + ] + } + ] +} diff --git a/src/test/resources/staging-users-put-request.json b/src/test/resources/staging-users-put-request.json new file mode 100644 index 0000000..2405a0b --- /dev/null +++ b/src/test/resources/staging-users-put-request.json @@ -0,0 +1,27 @@ +{ + "isEmailVerified": false, + "status": "TIER-1", + "generalInfo": { + "firstName": "TEST_STATUS_CODE_200", + "middleName": "www", + "lastName": "new-record-1" + }, + "addressInfo": { + "addressLine0": "123 Main St", + "addressLine1": "Apt 4B", + "city": "Metropolis", + "province": "NY", + "zip": "12345", + "country": "USA" + }, + "contactInfo": { + "phone": "555-123456", + "mobilePhone": "555-5678", + "email": "new-record-kapil_new3@test.com" + }, + "preferredEmailCommunication": [ + "Programs", + "Support", + "Services" + ] +} diff --git a/src/test/resources/staging-users-put-response.json b/src/test/resources/staging-users-put-response.json new file mode 100644 index 0000000..9e2bc31 --- /dev/null +++ b/src/test/resources/staging-users-put-response.json @@ -0,0 +1,34 @@ +{ + "id": "http_status_200", + "isEmailVerified": true, + "status": "TIER-1", + "generalInfo": { + "firstName": "test1", + "middleName": "www", + "lastName": "new-record-1" + }, + "addressInfo": { + "addressLine0": "123 Main St", + "addressLine1": "Apt 4B", + "city": "Metropolis", + "province": "NY", + "zip": "12345", + "country": "USA" + }, + "contactInfo": { + "phone": "555-123456", + "mobilePhone": "555-5678", + "email": "new-record-kapil_new3@test.com" + }, + "preferredEmailCommunication": [ + "Programs", + "Support", + "Services" + ], + "metadata": { + "createdDate": "2024-10-15T10:50:36.267+00:00", + "createdByUserId": "21457ab5-4635-4e56-906a-908f05e9233b", + "updatedDate": "2024-10-17T09:32:24.840+00:00", + "updatedByUserId": "21457ab5-4635-4e56-906a-908f05e9233b" + } +} From 7f367e83ece6ad3c48382256fff265c981462d1b Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Sat, 14 Dec 2024 17:54:25 +0530 Subject: [PATCH 02/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- .../java/org/folio/edge/patron/utils/PatronOkapiClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java b/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java index b3b2688..fef94e3 100644 --- a/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java +++ b/src/main/java/org/folio/edge/patron/utils/PatronOkapiClient.java @@ -177,7 +177,7 @@ public void postPatron(String requestBody, public void putPatron(String externalSystemId, String requestBody, Handler> responseHandler, Handler exceptionHandler) { - post( + put( format("%s/patron/%s", okapiURL, externalSystemId), tenant, requestBody, From 6c8b93d6c0769a998c2359e937fb0e94688b81df Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Sat, 14 Dec 2024 18:34:42 +0530 Subject: [PATCH 03/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- .../org/folio/edge/patron/PatronHandler.java | 11 +-- .../folio/edge/patron/MainVerticleTest.java | 85 +++++++++++++++++++ 2 files changed, 86 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/folio/edge/patron/PatronHandler.java b/src/main/java/org/folio/edge/patron/PatronHandler.java index ab5bd88..1e49d80 100644 --- a/src/main/java/org/folio/edge/patron/PatronHandler.java +++ b/src/main/java/org/folio/edge/patron/PatronHandler.java @@ -218,21 +218,12 @@ public void handlePutPatronRequest(RoutingContext ctx) { .end(getErrorMsg("MISSING_BODY", "Request body must not null")); return; } - String externalSystemId = ctx.request().getParam(PARAM_EXTERNAL_SYSTEM_ID); - if(StringUtils.isNullOrEmpty(externalSystemId)) { - logger.warn("handlePutPatronRequest:: Missing or empty externalSystemId"); - ctx.response() - .setStatusCode(400) - .putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) - .end(getErrorMsg("EXTERNAL_SYSTEM_ID_NOT_PROVIDED", "externalSystemId is missing in the request")); - return; - } final String body = String.valueOf(ctx.body().asJsonObject()); super.handleCommon(ctx, new String[]{}, new String[]{}, (client, params) -> { String alternateTenantId = ctx.request().getParam("alternateTenantId", client.tenant); final PatronOkapiClient patronClient = new PatronOkapiClient(client, alternateTenantId); - patronClient.putPatron(externalSystemId, body, + patronClient.putPatron(ctx.request().getParam(PARAM_EXTERNAL_SYSTEM_ID), body, resp -> handleProxyResponse(ctx, resp), t -> handleProxyException(ctx, t)); }); diff --git a/src/test/java/org/folio/edge/patron/MainVerticleTest.java b/src/test/java/org/folio/edge/patron/MainVerticleTest.java index 35866d3..7a2569b 100644 --- a/src/test/java/org/folio/edge/patron/MainVerticleTest.java +++ b/src/test/java/org/folio/edge/patron/MainVerticleTest.java @@ -1022,6 +1022,25 @@ public void testPostPatron_400(TestContext context) { .body("code", is(400)); } + @Test + public void testPutPatron_400(TestContext context) { + logger.info("=== testPutPatron_400 ==="); + JsonObject jsonObject = new JsonObject(readMockFile("/staging-users-put-request.json")); + jsonObject.getJsonObject("generalInfo").put("firstName", "TEST_STATUS_CODE_400"); + RestAssured + .with() + .body(jsonObject.encode()) + .contentType(APPLICATION_JSON) + .put( + String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + .then() + .statusCode(400) + .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .body("errorMessage", is("A bad exception occurred")) + .body("code", is(400)); + } + + @Test public void testPostPatron_422(TestContext context) { logger.info("=== testPostPatron_422 ==="); @@ -1040,6 +1059,24 @@ public void testPostPatron_422(TestContext context) { .body("code", is(422)); } + @Test + public void testPutPatron_422(TestContext context) { + logger.info("=== testPutPatron_422 ==="); + JsonObject jsonObject = new JsonObject(readMockFile("/staging-users-put-request.json")); + jsonObject.getJsonObject("generalInfo").put("firstName", "TEST_STATUS_CODE_422"); + RestAssured + .with() + .body(jsonObject.encode()) + .contentType(APPLICATION_JSON) + .put( + String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + .then() + .statusCode(422) + .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .body("errorMessage", is("ABC is required")) + .body("code", is(422)); + } + @Test public void testPostPatron_500(TestContext context) { logger.info("=== testPostPatron_500 ==="); @@ -1073,6 +1110,54 @@ public void testPostPatron_NoRequestBody(TestContext context) { .body("code", is("MISSING_BODY")); } + @Test + public void testPutPatron_500(TestContext context) { + logger.info("=== testPutPatron_500 ==="); + JsonObject jsonObject = new JsonObject(readMockFile("/staging-users-put-request.json")); + jsonObject.getJsonObject("generalInfo").put("firstName", "TEST_STATUS_CODE_500"); + RestAssured + .with() + .body(jsonObject.encode()) + .contentType(APPLICATION_JSON) + .put( + String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + .then() + .statusCode(500) + .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .body("errorMessage", is("Server exception occurred")) + .body("code", is(500)); + } + + @Test + public void testPutPatron_NoRequestBody(TestContext context) { + logger.info("=== testPutPatron_NoRequestBody ==="); + RestAssured + .with() + .contentType(APPLICATION_JSON) + .put( + String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + .then() + .statusCode(400) + .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) + .body("errorMessage", is("Request body must not null")) + .body("code", is("MISSING_BODY")); + } + + @Test + public void testPutPatron_NoParam(TestContext context) { + logger.info("=== testPutPatron_NoParam ==="); + JsonObject jsonObject = new JsonObject(readMockFile("/staging-users-put-request.json")); + jsonObject.getJsonObject("generalInfo").put("firstName", "TEST_STATUS_CODE_405"); + RestAssured + .with() + .body(jsonObject.encode()) + .contentType(APPLICATION_JSON) + .put( + String.format("/patron/%s?apikey=%s", "", apiKey)) + .then() + .statusCode(405); + } + @Test public void testPlaceInstanceHoldInstanceNotFound(TestContext context) throws Exception { logger.info("=== Test place instance hold w/ instance not found ==="); From 95108ac55d55066a660a5e2e6471fb16a2f80f70 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Sat, 14 Dec 2024 18:43:50 +0530 Subject: [PATCH 04/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- .../org/folio/edge/patron/PatronHandler.java | 33 ++++++++----------- .../folio/edge/patron/MainVerticleTest.java | 4 +-- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/folio/edge/patron/PatronHandler.java b/src/main/java/org/folio/edge/patron/PatronHandler.java index 1e49d80..b7b5501 100644 --- a/src/main/java/org/folio/edge/patron/PatronHandler.java +++ b/src/main/java/org/folio/edge/patron/PatronHandler.java @@ -23,6 +23,7 @@ import java.util.Map; import java.util.Objects; import java.util.TimeZone; +import java.util.function.BiConsumer; import java.util.function.Consumer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -189,13 +190,13 @@ public void handleSecurePlaceItemHold(RoutingContext ctx) { handleSecureCommon(ctx, this::handlePlaceItemHold); } - public void handlePostPatronRequest(RoutingContext ctx) { + public void handlePatronRequest(RoutingContext ctx, BiConsumer patronAction) { if (ctx.body().asJsonObject() == null) { - logger.warn("handlePostPatronRequest:: missing body found"); + logger.warn("handlePatronRequest:: missing body found"); ctx.response() .setStatusCode(400) .putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) - .end(getErrorMsg("MISSING_BODY", "Request body must not null")); + .end(getErrorMsg("MISSING_BODY", "Request body must not be null")); return; } @@ -203,30 +204,22 @@ public void handlePostPatronRequest(RoutingContext ctx) { super.handleCommon(ctx, new String[]{}, new String[]{}, (client, params) -> { String alternateTenantId = ctx.request().getParam("alternateTenantId", client.tenant); final PatronOkapiClient patronClient = new PatronOkapiClient(client, alternateTenantId); + patronAction.accept(patronClient, body); + }); + } + + public void handlePostPatronRequest(RoutingContext ctx) { + handlePatronRequest(ctx, (patronClient, body) -> patronClient.postPatron(body, resp -> handleProxyResponse(ctx, resp), - t -> handleProxyException(ctx, t)); - }); + t -> handleProxyException(ctx, t))); } public void handlePutPatronRequest(RoutingContext ctx) { - if (ctx.body().asJsonObject() == null) { - logger.warn("handlePutPatronRequest:: missing body found"); - ctx.response() - .setStatusCode(400) - .putHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) - .end(getErrorMsg("MISSING_BODY", "Request body must not null")); - return; - } - - final String body = String.valueOf(ctx.body().asJsonObject()); - super.handleCommon(ctx, new String[]{}, new String[]{}, (client, params) -> { - String alternateTenantId = ctx.request().getParam("alternateTenantId", client.tenant); - final PatronOkapiClient patronClient = new PatronOkapiClient(client, alternateTenantId); + handlePatronRequest(ctx, (patronClient, body) -> patronClient.putPatron(ctx.request().getParam(PARAM_EXTERNAL_SYSTEM_ID), body, resp -> handleProxyResponse(ctx, resp), - t -> handleProxyException(ctx, t)); - }); + t -> handleProxyException(ctx, t))); } diff --git a/src/test/java/org/folio/edge/patron/MainVerticleTest.java b/src/test/java/org/folio/edge/patron/MainVerticleTest.java index 7a2569b..7253925 100644 --- a/src/test/java/org/folio/edge/patron/MainVerticleTest.java +++ b/src/test/java/org/folio/edge/patron/MainVerticleTest.java @@ -1106,7 +1106,7 @@ public void testPostPatron_NoRequestBody(TestContext context) { .then() .statusCode(400) .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) - .body("errorMessage", is("Request body must not null")) + .body("errorMessage", is("Request body must not be null")) .body("code", is("MISSING_BODY")); } @@ -1139,7 +1139,7 @@ public void testPutPatron_NoRequestBody(TestContext context) { .then() .statusCode(400) .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) - .body("errorMessage", is("Request body must not null")) + .body("errorMessage", is("Request body must not be null")) .body("code", is("MISSING_BODY")); } From 42dfc7e30d6a3d2e9e59dfaa5db701afce99efec Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Sat, 14 Dec 2024 18:50:25 +0530 Subject: [PATCH 05/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- .../java/org/folio/edge/patron/MainVerticleTest.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/folio/edge/patron/MainVerticleTest.java b/src/test/java/org/folio/edge/patron/MainVerticleTest.java index 7253925..1346c32 100644 --- a/src/test/java/org/folio/edge/patron/MainVerticleTest.java +++ b/src/test/java/org/folio/edge/patron/MainVerticleTest.java @@ -81,7 +81,7 @@ public class MainVerticleTest { private static final String itemId = UUID.randomUUID().toString(); private static final String instanceId = UUID.randomUUID().toString(); private static final String holdId = UUID.randomUUID().toString(); - private static final String externalSystemId = UUID.randomUUID().toString(); + private static final String EXTERNAL_SYSTEM_ID = UUID.randomUUID().toString(); private static final String apiKey = ApiKeyUtils.generateApiKey(10, "diku", "diku"); private static final String badApiKey = apiKey + "0000"; private static final String unknownTenantApiKey = ApiKeyUtils.generateApiKey(10, "bogus", "diku"); @@ -981,7 +981,7 @@ public void testPutPatron_200(TestContext context) { .body(jsonObject.encode()) .contentType(APPLICATION_JSON) .put( - String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + String.format("/patron/%s?apikey=%s", EXTERNAL_SYSTEM_ID, apiKey)) .then() .statusCode(200) .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON); @@ -1032,7 +1032,7 @@ public void testPutPatron_400(TestContext context) { .body(jsonObject.encode()) .contentType(APPLICATION_JSON) .put( - String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + String.format("/patron/%s?apikey=%s", EXTERNAL_SYSTEM_ID, apiKey)) .then() .statusCode(400) .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) @@ -1069,7 +1069,7 @@ public void testPutPatron_422(TestContext context) { .body(jsonObject.encode()) .contentType(APPLICATION_JSON) .put( - String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + String.format("/patron/%s?apikey=%s", EXTERNAL_SYSTEM_ID, apiKey)) .then() .statusCode(422) .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) @@ -1120,7 +1120,7 @@ public void testPutPatron_500(TestContext context) { .body(jsonObject.encode()) .contentType(APPLICATION_JSON) .put( - String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + String.format("/patron/%s?apikey=%s", EXTERNAL_SYSTEM_ID, apiKey)) .then() .statusCode(500) .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) @@ -1135,7 +1135,7 @@ public void testPutPatron_NoRequestBody(TestContext context) { .with() .contentType(APPLICATION_JSON) .put( - String.format("/patron/%s?apikey=%s", externalSystemId, apiKey)) + String.format("/patron/%s?apikey=%s", EXTERNAL_SYSTEM_ID, apiKey)) .then() .statusCode(400) .header(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON) From 8ee0678b43cdd88c7c3ecf0ea8c00ca4536eb752 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Wed, 18 Dec 2024 13:11:30 +0530 Subject: [PATCH 06/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- ramls/edge-patron.raml | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/ramls/edge-patron.raml b/ramls/edge-patron.raml index e994c65..ec0aacd 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -87,6 +87,71 @@ types: body: text/plain: example: internal server error, contact administrator + put: + description: | + Update a staging user based on external system Id. + /{externalSystemId}: + uriParameters: + externalSystemId: + description: The UUID of a FOLIO user + type: string + pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$ + queryParameters: + apikey: + description: "API Key" + type: string + body: + application/json: + type: staging_user + example: !include examples/staging_user.json + responses: + 200: + description: | + staging user updated successfully + body: + application/json: + type: staging_user + example: !include examples/staging_user.json + 201: + description: | + staging user created successfully + body: + application/json: + type: staging_user + example: !include examples/staging_user.json + 400: + description: Bad request + body: + text/plain: + example: unable to process request + 401: + description: Not authorized to perform requested action + body: + text/plain: + example: unable to create request + 403: + description: Access Denied + body: + text/plain: + example: Access Denied + 422: + description: Validation error + body: + text/plain: + example: Validation error + 500: + description: | + Internal server error, e.g. due to misconfiguration + body: + text/plain: + example: internal server error, contact administrator + 404: + description: Item with a given ID not found + body: + application/json: + type: external_patron_error_404 + example: !include examples/external_patron_error.json + /account: post: description: | From 0f22b74e0c170dce0de98abf54fdfcc1ad5f4951 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Wed, 18 Dec 2024 15:27:35 +0530 Subject: [PATCH 07/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- ramls/schemas/user_error_404.schema | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ramls/schemas/user_error_404.schema b/ramls/schemas/user_error_404.schema index 31d65bb..75fcb82 100644 --- a/ramls/schemas/user_error_404.schema +++ b/ramls/schemas/user_error_404.schema @@ -9,7 +9,8 @@ "description": "Error code", "examples": [ "USER_ACCOUNT_INACTIVE", - "USER_NOT_FOUND" + "USER_NOT_FOUND", + STAGING_USER_NOT_FOUND ] }, "errorMessage": { From 57bea138fb8566dba281b8f766d03ea6cef766e5 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Wed, 18 Dec 2024 15:47:58 +0530 Subject: [PATCH 08/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- .../org/folio/edge/patron/PatronHandler.java | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/folio/edge/patron/PatronHandler.java b/src/main/java/org/folio/edge/patron/PatronHandler.java index b7b5501..69f79a2 100644 --- a/src/main/java/org/folio/edge/patron/PatronHandler.java +++ b/src/main/java/org/folio/edge/patron/PatronHandler.java @@ -218,7 +218,7 @@ public void handlePostPatronRequest(RoutingContext ctx) { public void handlePutPatronRequest(RoutingContext ctx) { handlePatronRequest(ctx, (patronClient, body) -> patronClient.putPatron(ctx.request().getParam(PARAM_EXTERNAL_SYSTEM_ID), body, - resp -> handleProxyResponse(ctx, resp), + resp -> handlePutPatronResponse(ctx, resp), t -> handleProxyException(ctx, t))); } @@ -422,6 +422,33 @@ protected void handleRegistrationStatusResponse(RoutingContext ctx, HttpResponse } } + protected void handlePutPatronResponse(RoutingContext ctx, HttpResponse resp) { + HttpServerResponse serverResponse = ctx.response(); + + int statusCode = resp.statusCode(); + serverResponse.setStatusCode(statusCode); + + String respBody = resp.bodyAsString(); + if (logger.isDebugEnabled() ) { + logger.debug("handlePutPatronResponse:: response {} ", respBody); + } + + String contentType = resp.getHeader(HttpHeaders.CONTENT_TYPE.toString()); + + if (resp.statusCode() < 400 && Objects.nonNull(respBody)){ + setContentType(serverResponse, contentType); + serverResponse.end(respBody); //not an error case, pass on the response body as received + } + else { + String errorMsg = (statusCode == 404 || statusCode == 400) + ? getFormattedErrorMsg(statusCode, respBody) + : getErrorMessage(statusCode, respBody); + setContentType(serverResponse, APPLICATION_JSON); + serverResponse.end(errorMsg); + } + } + + @Override protected void handleProxyException(RoutingContext ctx, Throwable t) { logger.error("Exception retrieving data from mod-patron:", t); From 9e9d293e90a0c3ce0d00b8ecc45619397665af55 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Wed, 18 Dec 2024 16:36:02 +0530 Subject: [PATCH 09/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- ramls/schemas/user_error_404.schema | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ramls/schemas/user_error_404.schema b/ramls/schemas/user_error_404.schema index 75fcb82..31d65bb 100644 --- a/ramls/schemas/user_error_404.schema +++ b/ramls/schemas/user_error_404.schema @@ -9,8 +9,7 @@ "description": "Error code", "examples": [ "USER_ACCOUNT_INACTIVE", - "USER_NOT_FOUND", - STAGING_USER_NOT_FOUND + "USER_NOT_FOUND" ] }, "errorMessage": { From 8e4a27e074605f57fdb81c06a26f75a527e051c7 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Wed, 18 Dec 2024 16:44:20 +0530 Subject: [PATCH 10/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- ramls/edge-patron.raml | 130 +++++++++++++++++++++-------------------- 1 file changed, 66 insertions(+), 64 deletions(-) diff --git a/ramls/edge-patron.raml b/ramls/edge-patron.raml index ec0aacd..f0302ed 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -87,70 +87,72 @@ types: body: text/plain: example: internal server error, contact administrator - put: - description: | - Update a staging user based on external system Id. - /{externalSystemId}: - uriParameters: - externalSystemId: - description: The UUID of a FOLIO user - type: string - pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$ - queryParameters: - apikey: - description: "API Key" - type: string - body: - application/json: - type: staging_user - example: !include examples/staging_user.json - responses: - 200: - description: | - staging user updated successfully - body: - application/json: - type: staging_user - example: !include examples/staging_user.json - 201: - description: | - staging user created successfully - body: - application/json: - type: staging_user - example: !include examples/staging_user.json - 400: - description: Bad request - body: - text/plain: - example: unable to process request - 401: - description: Not authorized to perform requested action - body: - text/plain: - example: unable to create request - 403: - description: Access Denied - body: - text/plain: - example: Access Denied - 422: - description: Validation error - body: - text/plain: - example: Validation error - 500: - description: | - Internal server error, e.g. due to misconfiguration - body: - text/plain: - example: internal server error, contact administrator - 404: - description: Item with a given ID not found - body: - application/json: - type: external_patron_error_404 - example: !include examples/external_patron_error.json + + /{externalSystemId}: + uriParameters: + externalSystemId: + description: The UUID of a FOLIO user + type: string + pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$ + put: + description: | + Update a staging user based on external system ID. + queryParameters: + apikey: + description: "API Key" + type: string + body: + application/json: + type: staging_user + example: !include examples/staging_user.json + responses: + 200: + description: | + staging user updated successfully + body: + application/json: + type: staging_user + example: !include examples/staging_user.json + 201: + description: | + staging user created successfully + body: + application/json: + type: staging_user + example: !include examples/staging_user.json + 400: + description: Bad request + body: + text/plain: + example: unable to process request + 401: + description: Not authorized to perform requested action + body: + text/plain: + example: unable to create request + 403: + description: Access Denied + body: + text/plain: + example: Access Denied + 422: + description: Validation error + body: + text/plain: + example: Validation error + 500: + description: | + Internal server error, e.g. due to misconfiguration + body: + text/plain: + example: internal server error, contact administrator + 404: + description: Item with a given ID not found + body: + application/json: + type: external_patron_error_404 + example: !include examples/external_patron_error.json + /account: post: From 4fc663b1bdedd456ae09df85cc258f1dbd119da6 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Wed, 18 Dec 2024 16:59:55 +0530 Subject: [PATCH 11/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- .../org/folio/edge/patron/PatronHandler.java | 46 ++++++------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/folio/edge/patron/PatronHandler.java b/src/main/java/org/folio/edge/patron/PatronHandler.java index 69f79a2..9f88086 100644 --- a/src/main/java/org/folio/edge/patron/PatronHandler.java +++ b/src/main/java/org/folio/edge/patron/PatronHandler.java @@ -25,6 +25,8 @@ import java.util.TimeZone; import java.util.function.BiConsumer; import java.util.function.Consumer; +import java.util.function.Function; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.folio.edge.core.Handler; @@ -396,56 +398,38 @@ protected void handleProxyResponse(RoutingContext ctx, HttpResponse resp } } - protected void handleRegistrationStatusResponse(RoutingContext ctx, HttpResponse resp) { + protected void handleResponse(RoutingContext ctx, HttpResponse resp, String logPrefix, + Function errorMessageFunction) { HttpServerResponse serverResponse = ctx.response(); int statusCode = resp.statusCode(); serverResponse.setStatusCode(statusCode); String respBody = resp.bodyAsString(); - if (logger.isDebugEnabled() ) { - logger.debug("handleRegistrationStatusResponse:: response {} ", respBody); + if (logger.isDebugEnabled()) { + logger.debug("{}:: response {}", logPrefix, respBody); } String contentType = resp.getHeader(HttpHeaders.CONTENT_TYPE.toString()); - if (resp.statusCode() < 400 && Objects.nonNull(respBody)){ + if (statusCode < 400 && Objects.nonNull(respBody)) { setContentType(serverResponse, contentType); - serverResponse.end(respBody); //not an error case, pass on the response body as received - } - else { + serverResponse.end(respBody); // Not an error case, pass on the response body as received + } else { String errorMsg = (statusCode == 404 || statusCode == 400) ? getFormattedErrorMsg(statusCode, respBody) - : getStructuredErrorMessage(statusCode, respBody); + : errorMessageFunction.apply(respBody); setContentType(serverResponse, APPLICATION_JSON); serverResponse.end(errorMsg); } } - protected void handlePutPatronResponse(RoutingContext ctx, HttpResponse resp) { - HttpServerResponse serverResponse = ctx.response(); - - int statusCode = resp.statusCode(); - serverResponse.setStatusCode(statusCode); - - String respBody = resp.bodyAsString(); - if (logger.isDebugEnabled() ) { - logger.debug("handlePutPatronResponse:: response {} ", respBody); - } - - String contentType = resp.getHeader(HttpHeaders.CONTENT_TYPE.toString()); + protected void handleRegistrationStatusResponse(RoutingContext ctx, HttpResponse resp) { + handleResponse(ctx, resp, "handleRegistrationStatusResponse", body -> getStructuredErrorMessage(resp.statusCode(), body)); + } - if (resp.statusCode() < 400 && Objects.nonNull(respBody)){ - setContentType(serverResponse, contentType); - serverResponse.end(respBody); //not an error case, pass on the response body as received - } - else { - String errorMsg = (statusCode == 404 || statusCode == 400) - ? getFormattedErrorMsg(statusCode, respBody) - : getErrorMessage(statusCode, respBody); - setContentType(serverResponse, APPLICATION_JSON); - serverResponse.end(errorMsg); - } + protected void handlePutPatronResponse(RoutingContext ctx, HttpResponse resp) { + handleResponse(ctx, resp, "handlePutPatronResponse", body -> getErrorMessage(resp.statusCode(), body)); } From da0a17e36c005f3efd1d2ffd4cdc4ecbc222cc08 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Wed, 18 Dec 2024 18:53:12 +0530 Subject: [PATCH 12/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- src/main/java/org/folio/edge/patron/PatronHandler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/folio/edge/patron/PatronHandler.java b/src/main/java/org/folio/edge/patron/PatronHandler.java index 9f88086..26631ea 100644 --- a/src/main/java/org/folio/edge/patron/PatronHandler.java +++ b/src/main/java/org/folio/edge/patron/PatronHandler.java @@ -25,7 +25,7 @@ import java.util.TimeZone; import java.util.function.BiConsumer; import java.util.function.Consumer; -import java.util.function.Function; +import java.util.function.UnaryOperator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -399,7 +399,7 @@ protected void handleProxyResponse(RoutingContext ctx, HttpResponse resp } protected void handleResponse(RoutingContext ctx, HttpResponse resp, String logPrefix, - Function errorMessageFunction) { + UnaryOperator errorMessageFunction) { HttpServerResponse serverResponse = ctx.response(); int statusCode = resp.statusCode(); From ac69dec8fee49f5e89b097349d9043e24a7f9b32 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Thu, 19 Dec 2024 19:18:11 +0530 Subject: [PATCH 13/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- descriptors/ModuleDescriptor-template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 0cdb237..3cbe691 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -5,7 +5,7 @@ "requires": [ { "id": "patron", - "version": "6.0" + "version": "6.3" }, { "id": "circulation", From b8ada70636de5d887ba604cf11f266dcf91c99f1 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Fri, 20 Dec 2024 05:37:46 +0530 Subject: [PATCH 14/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- ramls/edge-patron.raml | 16 ++++--------- ramls/examples/staging_user.json | 1 + ramls/examples/staging_user_error.json | 4 ++++ ramls/schemas/staging_user_error_404.schema | 26 +++++++++++++++++++++ ramls/staging_user.json | 4 ++++ 5 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 ramls/examples/staging_user_error.json create mode 100644 ramls/schemas/staging_user_error_404.schema diff --git a/ramls/edge-patron.raml b/ramls/edge-patron.raml index f0302ed..4dcc99d 100644 --- a/ramls/edge-patron.raml +++ b/ramls/edge-patron.raml @@ -25,6 +25,7 @@ types: hold-cancellation: !include hold-cancellation.json errors: !include raml-util/schemas/errors.schema external_patron_error_404: !include schemas/external_patron_error_404.schema + staging_user_error_404: !include schemas/staging_user_error_404.schema external_patron_error_get_422: !include schemas/external_patron_error_get_422.schema external_patron_error_post_422: !include schemas/external_patron_error_post_422.schema external_patron_error_put_422: !include schemas/external_patron_error_put_422.schema @@ -91,7 +92,7 @@ types: /{externalSystemId}: uriParameters: externalSystemId: - description: The UUID of a FOLIO user + description: The UUID of a staging user type: string pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$ put: @@ -113,13 +114,6 @@ types: application/json: type: staging_user example: !include examples/staging_user.json - 201: - description: | - staging user created successfully - body: - application/json: - type: staging_user - example: !include examples/staging_user.json 400: description: Bad request body: @@ -147,11 +141,11 @@ types: text/plain: example: internal server error, contact administrator 404: - description: Item with a given ID not found + description: Staging user with a given external system Id not found body: application/json: - type: external_patron_error_404 - example: !include examples/external_patron_error.json + type: staging_user_error_404 + example: !include examples/staging_user_error.json /account: diff --git a/ramls/examples/staging_user.json b/ramls/examples/staging_user.json index 771b0e5..ee53a21 100644 --- a/ramls/examples/staging_user.json +++ b/ramls/examples/staging_user.json @@ -1,6 +1,7 @@ { "isEmailVerified": true, "status": "TIER-1", + "externalSystemId": "9eb67301-6f6e-468f-9b1a-6134dc39a684", "generalInfo": { "firstName": "John", "preferredFirstName": "John", diff --git a/ramls/examples/staging_user_error.json b/ramls/examples/staging_user_error.json new file mode 100644 index 0000000..2460b8f --- /dev/null +++ b/ramls/examples/staging_user_error.json @@ -0,0 +1,4 @@ +{ + "code": "STAGING_USER_NOT_FOUND", + "errorMessage": "Staging user does not exist" +} diff --git a/ramls/schemas/staging_user_error_404.schema b/ramls/schemas/staging_user_error_404.schema new file mode 100644 index 0000000..b111dfe --- /dev/null +++ b/ramls/schemas/staging_user_error_404.schema @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "id": "external_patron_error.schema", + "description": "An external_patron user error", + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "Error code" + }, + "errorMessage": { + "type": "string", + "description": "Error message text", + "examples": [ + { + "code": "STAGING_USER_NOT_FOUND", + "errorMessage": "Staging user does not exist" + } + ] + } + }, + "required": [ + "code", + "errorMessage" + ] +} diff --git a/ramls/staging_user.json b/ramls/staging_user.json index 330f13d..1dcfc17 100644 --- a/ramls/staging_user.json +++ b/ramls/staging_user.json @@ -13,6 +13,10 @@ "type": "string", "enum": ["TIER-1", "TIER-2"] }, + "externalSystemId": { + "description": "A unique ID (UUID) that corresponds to an external authority", + "type": "string" + }, "generalInfo": { "type": "object", "description": "General info of external patron", From 461b1206aa3d7e01721f595cbe0182ae64c6fb57 Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Fri, 20 Dec 2024 05:43:21 +0530 Subject: [PATCH 15/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- ramls/examples/staging_user_error.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ramls/examples/staging_user_error.json b/ramls/examples/staging_user_error.json index 2460b8f..e346f8f 100644 --- a/ramls/examples/staging_user_error.json +++ b/ramls/examples/staging_user_error.json @@ -1,4 +1,4 @@ { - "code": "STAGING_USER_NOT_FOUND", + "code": "404", "errorMessage": "Staging user does not exist" } From b3257454d91be39f788514e4dfb8ec065fec60fd Mon Sep 17 00:00:00 2001 From: gurleenkaurbp Date: Fri, 20 Dec 2024 05:48:10 +0530 Subject: [PATCH 16/16] [EDGPATRON-160] - Add put API for /patron/{externalSystemId} --- ramls/examples/staging_user_error.json | 2 +- ramls/schemas/staging_user_error_404.schema | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ramls/examples/staging_user_error.json b/ramls/examples/staging_user_error.json index e346f8f..2460b8f 100644 --- a/ramls/examples/staging_user_error.json +++ b/ramls/examples/staging_user_error.json @@ -1,4 +1,4 @@ { - "code": "404", + "code": "STAGING_USER_NOT_FOUND", "errorMessage": "Staging user does not exist" } diff --git a/ramls/schemas/staging_user_error_404.schema b/ramls/schemas/staging_user_error_404.schema index b111dfe..58bbc14 100644 --- a/ramls/schemas/staging_user_error_404.schema +++ b/ramls/schemas/staging_user_error_404.schema @@ -5,7 +5,7 @@ "type": "object", "properties": { "code": { - "type": "integer", + "type": "string", "description": "Error code" }, "errorMessage": {