Skip to content

Instantly share code, notes, and snippets.

@niftynei
Created December 17, 2015 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niftynei/b42b39328c9f8cc2f4ce to your computer and use it in GitHub Desktop.
Save niftynei/b42b39328c9f8cc2f4ce to your computer and use it in GitHub Desktop.
public class CreateUserRequest extends ClientNetworkRequest<User, Object> {
// ...
@Override
public NetworkCallResponse<Object> onMakeRequest() throws IOException {
EoLog.d(TAG, "Register a user called");
String bearerString = ClientAuthManager.get().createBearerString();
retrofit.Response<User> userResponse = EoApp.getAppContext()
.getClientRequestManager()
.getAuthApiService()
.createUser(bearerString, mNewUser).execute();
if (!userResponse.isSuccess()) {
return NetworkCallResponse.get(userResponse);
}
// fetch the user's token
boolean wasSuccess = ClientAuthManager.get().fetchUserToken(mNewUser);
if (!wasSuccess) {
return NetworkCallResponse.get(retrofit.Response.error(500, null));
}
return NetworkCallResponse.get(userResponse);
}
@ksarantakos
Copy link

Could you instead of using object use something like

ClientNetworkRequest<User, LisaSuperResponse>

And that LisaSuperResponse enforce a contact similar to what you were doing here: https://gist.github.com/niftynei/0dca2b1a0151788f4ecc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment