/** * Retrieves an {@link rx.Observable} which will emit an {@link UserEntity}. * * @return The user entity to be emitted */ public Observable<UserEntity> getUserProfile() { return mUshAccessTokenManager .getValidAccessToken() .concatMap( authorizationHeader -> mUshAccessTokenManager.getRestfulService().getUser(authorizationHeader)); }
/** * Retrieves an {@link rx.Observable} which will emit an {@link OAuth2AccessToken}. * * @param userAccountEntity The user account entity to get it's access token * @return The OAuth access token to be emitted */ public Observable<OAuth2AccessToken> loginUserAccount(UserAccountEntity userAccountEntity) { return mUshAccessTokenManager .login(userAccountEntity) .grantNewAccessToken() .doOnNext( oAuth2AccessToken -> mUshAccessTokenManager.getStorage().storeAccessToken(oAuth2AccessToken)); }