***** Update *****
Here is what I currently have:
@Subscribe
public void onLeave(LeaveRequest event) {
System.out.println("inside api repo - making leave request");
mRailsApi.leave(event.getEmail(), event.getPassword(),
new RailsApiCallback<LeaveResponse>(mBus, new LeaveResponse() ));
}
public class RailsApiCallback<T extends BaseResponse> implements Callback<T> {
private Bus mBus;
private T mResponse;
public RailsApiCallback(Bus bus, T response) {
super();
mBus = bus;
mResponse = response;
}
@Override
public void failure(RetrofitError retrofitError) {
System.out.println(retrofitError.toString());
T response = (T) retrofitError.getBody() != null ? (T) retrofitError.getBody() : mResponse ;
response.setRawResponse(retrofitError.getResponse());
response.setSuccessful(false);
mBus.post(response);
}
@Override
public void success(T convertedResponse, Response rawResponse) {
System.out.println(rawResponse.getBody());
T response = convertedResponse != null ? convertedResponse : mResponse ;
response.setSuccessful(true);
response.setRawResponse(rawResponse);
mBus.post(response);
}
}