Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Retrofit and envelopes
public class LoginContextUnwrappingConverter extends Converter.Factory {
@Override
public Converter<ResponseBody, LoginContext>
responseBodyConverter(Type type,
Annotation[] annotations,
Retrofit retrofit) {
if (type != LoginContext.class) {
return null;
}
final Converter<ResponseBody, LoginResponse> delegate =
retrofit.nextResponseBodyConverter(this,
LoginResponse.class,
annotations);
return body -> {
LoginResponse wrapper = delegate.convert(body);
return wrapper.context();
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment