Skip to content

Instantly share code, notes, and snippets.

@miguelcardo
Last active August 29, 2015 14:10
Show Gist options
  • Save miguelcardo/2c095795e59d7c056d2d to your computer and use it in GitHub Desktop.
Save miguelcardo/2c095795e59d7c056d2d to your computer and use it in GitHub Desktop.
Initiate service delivery process
// 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