-
Notifications
You must be signed in to change notification settings - Fork 222
Expand file tree
/
Copy pathUserManager.java
More file actions
34 lines (29 loc) · 1.07 KB
/
UserManager.java
File metadata and controls
34 lines (29 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package frogermcs.io.githubclient.data.api;
import frogermcs.io.githubclient.data.api.response.UserResponse;
import frogermcs.io.githubclient.data.model.User;
import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.functions.Func1;
import rx.schedulers.Schedulers;
/**
* Created by Miroslaw Stanek on 22.04.15.
*/
public class UserManager {
private GithubApiService githubApiService;
public UserManager(GithubApiService githubApiService) {
this.githubApiService = githubApiService;
}
public Observable<User> getUser(String username) {
return githubApiService.getUser(username)
.map(userResponse -> {
User user = new User();
user.login = userResponse.login;
user.id = userResponse.id;
user.url = userResponse.url;
user.email = userResponse.email;
return user;
})
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread());
}
}