Commit 182ac51e authored by Benjamin Beeker's avatar Benjamin Beeker

static get user information

parent b26ba48a
Pipeline #11212139 passed with stages
in 3 minutes and 15 seconds
......@@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.comhix.twitch</groupId>
<version>0.1.1</version>
<version>0.1.2</version>
<artifactId>twitch-api</artifactId>
<name>Twitch API</name>
<url>https://nozomibk.gitlab.io/twitch-api</url>
......
......@@ -29,7 +29,7 @@ public class TwitchApi {
private final ClientInformation clientInformation;
private final String oauthToken;
private OkHttpClient client = new OkHttpClient.Builder().build();
private static OkHttpClient client = new OkHttpClient.Builder().build();
private boolean closed = false;
......@@ -120,8 +120,7 @@ public class TwitchApi {
/**
* @return The user information of the users given by <code>loginNames</code>
*/
public Observable<List<User>> getUsers(List<String> loginNames) {
checkClosed();
public static Observable<List<User>> getUsers(ClientInformation clientInformation, List<String> loginNames) {
return Observable.fromCallable(() -> {
Request.Builder request = new Request.Builder().url("https://api.twitch.tv/kraken/users?login=" + Joiner.on(",").join(loginNames))
.addHeader("Client-ID", clientInformation.getClientId());
......@@ -129,4 +128,9 @@ public class TwitchApi {
return new Gson().fromJson(new InputStreamReader(body), UsersResponse.class).users;
}).observeOn(Schedulers.io());
}
public Observable<List<User>> getUsers(List<String> loginNames) {
checkClosed();
return getUsers(clientInformation, loginNames);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment