use of com.discordbolt.boltbot.system.twitch.objects.TwitchUserDataResponse in project BoltBot by DiscordBolt.
the class TwitchUser method getUserData.
public Optional<TwitchUserData> getUserData(String username) throws IOException {
HttpUrl userURL = HttpUrl.parse(USER_INFO_URL).newBuilder().addQueryParameter("login", username).build();
Request request = new Request.Builder().url(userURL).addHeader("Client-ID", api.getClientID()).addHeader("Accept", "application/vnd.twitchtv.v5+json").build();
try (Response response = api.getClient().newCall(request).execute()) {
TwitchUserDataResponse users = api.getGson().fromJson(response.body().string(), TwitchUserDataResponse.class);
return users.getUsers().stream().findFirst();
}
}
Aggregations