{@code + * curl -s --json '{"first-name":"Frank","last-name":"Helidon","date-of-birth":"15-09-2018","ssn":"1"}' localhost:8080/credit-score | jq + * { + * "first-name": "Frank", + * "last-name": "Helidon", + * "date-of-birth": "15-09-2018", + * "ssn": "00000001", + * "score": 552 + * } + * }+ * + * @param request the server request + * @param response the server response + */ + private void postMethodCreditScore(final ServerRequest request, final ServerResponse response) { + JsonObject reqJson = request.content() + .as(JsonObject.class); + + logger.log(INFO, "Request: {0}", reqJson); + + int creditScore = calculateCreditScore(reqJson.getString("firstname"), + reqJson.getString("lastname"), + reqJson.getString("dateofbirth"), + reqJson.getString("ssn")); + + JsonObject resJson = Json.createObjectBuilder(reqJson) + .add("score", creditScore) + .build(); + + response.send(resJson); + } + + /** + * Calculate credit score based on customer's properties. + * + * @param firstName first name + * @param lastName last name + * @param dateOfBirth date of birth + * @param ssn social security number + * @return calculated credit score + */ + private int calculateCreditScore(String firstName, String lastName, String dateOfBirth, String ssn) { + + int score = Math.abs(firstName.hashCode() + lastName.hashCode() + dateOfBirth.hashCode() + ssn.hashCode()); + + score = score % SCORE_MAX; + + while (score < SCORE_MIN) { + score = score + 100; + } + return score; + } + + }
WJ-}d0zEC~9SW+jAwpbMw
zUi*E8_`?=;x|J9}__EfoSRzF+_9fbQJK{bW;WJ|iTB(KcNIvi9h8*#ks2+&zEN|jD
zahOr6Df+e>F?=3|J7hQ8_BTGF_gx)F%8q8{N8_F2TK^OCl8!*dWUZPP{07imZ7=@!
zm1SU~>>Bz=fHb8pJ{WEWd>y|RueNdyXdLsJL2*ebflWRr_jb0MaVmP+0mnDpJWP*X
zF95o$S*j#k&}kB^h_E2iaML-8y8VPuQ=n##Z>cIh1Lc?GeN8O~k1v0;vr`FJ@36N)
z{T_FIWdYa%E?m)loosXZcB!{(O8FB9g8tPh!wFz7?OY)#8NhQ@>Ic~Tep_+04`Z9>
zXXbXNjL2{cp7%&O4+v3z4xHluEdLEpyhum}V4S{y81L8MMw>rJ=rqJ~>7z(~@O)Gp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