Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. private static final String SUMMONER_DETAILS_TEMPLATE = "/api/lol/{region}/v1.4/summoner/by-name/{summonerName}";
  2.     @Override
  3.     public CompletableFuture<Summoner> getSummoner(String region, String summonerName) {
  4.         return CompletableFuture.supplyAsync(() -> {
  5.             String uriPath = SUMMONER_DETAILS_TEMPLATE.replace("{region}", region.toLowerCase());
  6.             uriPath = uriPath.replace("{summonerName}", summonerName.toLowerCase().replaceAll("%s", ""));
  7.             String completedUrl = getLocationForRegion(region) + uriPath;
  8.  
  9.             try {
  10.                 String json = prepareAndIssueRequest(completedUrl);
  11.                 HashMap response = OBJECT_MAPPER.readValue(json, HashMap.class);
  12.                 return OBJECT_MAPPER.convertValue(getSummonerFromResponse(response, summonerName), Summoner.class);
  13.             } catch (IOException e) {
  14.                 e.printStackTrace();
  15.                 return null;
  16.             }
  17.         });
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement