Last active
August 29, 2015 14:10
-
-
Save miguelcardo/2c095795e59d7c056d2d to your computer and use it in GitHub Desktop.
Initiate service delivery process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Endpoint for the Service Delivery Request | |
put(new Route("/deliver") { | |
@Override | |
public Object handle(Request request, Response response) { | |
JSONObject jsonParameters = (JSONObject) JSONValue.parse(request.body()); | |
String serviceId = (String) jsonParameters.get("serviceId"); | |
// launch first operation for each of the two services or return 404 if serviceId unknown | |
if (serviceId.equals(Constants.invokeServiceId)){ | |
// first operation is GET CARD | |
if (cardClient.getCard(sessionId, pendingOperations) != HTTP_OK) handleFailure(sessionId); | |
} else if (serviceId.equals(Constants.deleteServiceId)) { | |
// first operation is DELETE CARD | |
if (cardClient.deleteCard(sessionId, pendingOperations) != HTTP_OK) handleFailure(sessionId); | |
} else { | |
response.status(HTTP_NOT_FOUND); | |
return "HTTP 404 - Service not found"; | |
} | |
response.status(HTTP_OK); | |
return ""; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment