LoginResponse和LoginRequest是我的模型类。我显示错误 响应类来自改造库,真的无法解决这个问题。 Rxjava flatmap Func1 to retrofit.Response class。
public Observable<LoginResponse> performLogin(String emailId, String password) {
LoginRequest requestBody = new LoginRequest(emailId,password);
Log.d("LoginRequestBody",requestBody.getLoginId());
return mSamparkService.performLogin(requestBody)
.flatMap(new Func1<Response<LoginResponse>, Observable<LoginResponse>>() {
@Override
public Observable<LoginResponse> call(Response<LoginResponse> response) {
//TODO: remove sensitive debug logs
Timber.d("status code: %s", response.code());
Timber.d("body: %s", response.body());
Timber.d("error body: %s", response.errorBody());
Timber.d("message: %s", response.message());
try {
Log.d(TAG,"in dtl attnd switch case");
switch (response.code()) {
case 200:
return Observable.just(response.body());
case 401:
case 403:
return Observable.error(new UnauthorizedException(response.errorBody().string()));
default:
return Observable.empty();
}
} catch (IOException e) {
Timber.e(e, "error while signIn");
return Observable.error(e);
}
}
});
}
错误: