public FutureData<PreparedHistoricsQuery> prepare(String hash, long start, long end, String name, int sample,
String... sources) {
FutureData<PreparedHistoricsQuery> future = new FutureData<PreparedHistoricsQuery>();
URI uri = newParams().forURL(config.newAPIEndpointURI(PREPARE));
POST request = config.http().POST(uri, new PageReader(newRequestCallback(future, new PreparedHistoricsQuery())))
.form("hash", hash)
.form("start", start)
.form("end", end)
.form("name", name);
if (sample > 0) {
request.form("sample", sample);
}
if (sources == null || sources.length == 0) {
sources = new String[]{ "twitter" };
}
StringBuilder b = new StringBuilder();
for (String source : sources) {
b.append(source).append(",");
}
request.form("sources", b.toString().substring(0, b.length() - 1));
applyConfig(request).execute();
return future;
}