Advertisement
BoberDiversant

Untitled

Jun 14th, 2019
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. public ApiResponse checkQuote(ApiRequest apiRequest) {
  2.         ApiResponse apiResponse = new ApiResponse();
  3.         String url = String.format("qwerty/%s/%s", apiRequest.getCampaignId(), apiRequest.getQuota());
  4.         HttpGet httpGet = new HttpGet(url);
  5.         try {
  6.             CloseableHttpResponse response = httpClient.execute(httpGet);
  7.             int responseStatusCode = response.getStatusLine().getStatusCode();
  8.             if (200 == responseStatusCode) {
  9.                 String jsonResult = new BasicResponseHandler().handleResponse(response);
  10.                 boolean success = GSON.fromJson(jsonResult, Boolean.class);
  11.                 apiResponse.setSuccess(success);
  12.             }
  13.         } catch (IOException e) {
  14.            apiResponse.setSuccess(false);
  15.         }
  16.         return apiResponse;
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement