public ExampleClient() {
wsClient = new WebServiceClient(new ServerConfig(SERVER_BASE_URL));
}
public Order placeOrder(Cart cart, String authToken) {
WebServiceCallSpec spec = SampleJsonService.PLACE_ORDER;
Gson gson = spec.addTypeAdapters(new GsonBuilder()).create();
HeaderMap requestHeaders = new HeaderMap.Builder(spec.getRequestSpec().getHeadersSpec())
.put(TypedKeys.Request.AUTH_TOKEN, authToken)
.build();
UrlParams urlParams = new UrlParams.Builder(spec.getRequestSpec().getUrlParamsSpec())
.build();
RequestBody requestBody = new RequestBody.Builder(spec.getRequestSpec().getBodySpec())
.put(TypedKeys.RequestBody.CART, cart)
.build();
WebServiceRequest request = new WebServiceRequest(
HttpMethod.POST, requestHeaders, urlParams, requestBody, false);
WebServiceResponse response = wsClient.getResponse(spec, request, gson);