Since no one seems to have a good way of achieving this, I'm adding my solution(not the nicest one) in case some one else has a similar need.
Im subclassing SpringAndroidSpiceRequest and in loadDataFromNetwork() i get the RestTemplate and simply make x many requests and merge them my self and then return the combined data as the result for the spiceRequest.
I'm gonna replace this code when i find a nicer way of doing it but for now it does the job.
public class LargeSpiceRequest extends SpringAndroidSpiceRequest<LargeResponse>{
private String mUrl;
public LargeSpiceRequest(String url) {
super(LargeResponse.class);
mUrl = url;
}
@Override
public LargeResponse loadDataFromNetwork() throws Exception {
RestTemplate restTemplate = getRestTemplate();
ResponseEntity<LargeResponse> largeResponseResponseEntity = restTemplate.exchange(URI.create(mUrl), HttpMethod.GET, null, LargeResponse.class);
LargeResponse largeResponse = largeResponseResponseEntity.getBody();
ArrayList<SubRequest> subRequests = largeResponse.getSubRequests();
for(SubRequest subRequest : subRequests){
try{
String url = subRequest.getUrl();
ResponseEntity<SubRequestResponse> subRequestResponseEntity = restTemplate.exchange(URI.create(url), HttpMethod.GET, null, SubRequestResponse.class);
SubRequestResponse subRequestResponse = subRequestResponseEntity.getBody();
// merge somethingResponse with largeResponse
largeResponse.mergeIn(subRequestResponse);
} catch (RestClientException e) {
// Handle this if you want
}
}
// the merged largeResponse will be stored in the cache
return largeResponse;
}
}