I have a retrofit service that contains the following interface
public interface ApiService {
@GET("/users/me")
Observable<Account> authenticateUser(@Header("Authorization") String auth);
@GET("/membership/{userId}")
SubscriptionStatus getSubscriptionStatus(@Path("userId") String userId);
}
I would like to define a method to make an api call to get the Account which contains the userId, and then use this ID to make a second API call to get The users subscription status. SubscriptionStatus contains a boolean and if its true I would like the method to return Observable.
This is how I have gone about it so far :
public Observable<Account> doLogin(ApiService service , String credentials) {
return service.authenticateuser(base64) // gets Account observable
.doOnNext(account -> {
currentAccount = account; // setting the Account Variable
})
.flatMap(account -> service.getSubscriptionStatus(account.getUserId())) // get Account Subscription status
... //unsure where to go from here I need to check
//the subscriptionStatus object and return account
//observable if condition is valid
}