use of org.folio.circulation.domain.notice.session.PatronActionType in project mod-circulation by folio-org.
the class EndPatronSessionRequest method from.
public static List<Result<EndPatronSessionRequest>> from(JsonObject jsonObject) {
final String END_SESSIONS = "endSessions";
List<Result<EndPatronSessionRequest>> resultListOfEndPatronSessionRequests = new ArrayList<>();
JsonArray endSessions = jsonObject.getJsonArray(END_SESSIONS);
for (int i = 0; i < endSessions.size(); i++) {
JsonObject endSession = endSessions.getJsonObject(i);
final String patronIdFromJson = getProperty(endSession, PATRON_ID);
if (isBlank(patronIdFromJson)) {
return singletonList(failedValidation("End patron session request must have patron id", PATRON_ID, null));
}
String actionTypeRepresentation = getProperty(endSession, ACTION_TYPE);
if (isBlank(actionTypeRepresentation)) {
return singletonList(failedValidation("End patron session request must have action type", ACTION_TYPE, null));
}
resultListOfEndPatronSessionRequests.add(PatronActionType.from(actionTypeRepresentation).map(patronActionType -> new EndPatronSessionRequest(patronIdFromJson, patronActionType)).map(Result::succeeded).orElse(failedValidation("Invalid patron action type value", ACTION_TYPE, actionTypeRepresentation)));
}
return resultListOfEndPatronSessionRequests;
}
Aggregations