use of net.dean.jraw.http.RestResponse in project Slide by ccrama.
the class SubmissionComments method getSubmissionNode.
public JsonNode getSubmissionNode(SubmissionRequest request) {
Map<String, String> args = new HashMap<>();
if (request.getDepth() != null)
args.put("depth", Integer.toString(request.getDepth()));
if (request.getContext() != null)
args.put("context", Integer.toString(request.getContext()));
if (request.getLimit() != null)
args.put("limit", Integer.toString(request.getLimit()));
if (request.getFocus() != null && request.getFocus().length() >= 3 && !JrawUtils.isFullname(request.getFocus()))
args.put("comment", request.getFocus());
args.put("feature", "link_preview");
args.put("sr_detail", "true");
args.put("expand_srs", "true");
args.put("from_detail", "true");
args.put("always_show_media", "1");
CommentSort sort = request.getSort();
if (sort == null)
// Reddit sorts by confidence by default
sort = CommentSort.CONFIDENCE;
args.put("sort", sort.name().toLowerCase(Locale.ENGLISH));
RestResponse response = Authentication.reddit.execute(Authentication.reddit.request().path(String.format("/comments/%s", request.getId())).query(args).build());
return response.getJson();
}
use of net.dean.jraw.http.RestResponse in project Slide by ccrama.
the class CommentCacheAsync method getSubmission.
public JsonNode getSubmission(SubmissionRequest request) throws NetworkException {
Map<String, String> args = new HashMap<>();
if (request.getDepth() != null)
args.put("depth", Integer.toString(request.getDepth()));
if (request.getContext() != null) {
args.put("context", Integer.toString(request.getContext()));
}
if (request.getLimit() != null)
args.put("limit", Integer.toString(request.getLimit()));
if (request.getFocus() != null && !JrawUtils.isFullname(request.getFocus())) {
args.put("comment", request.getFocus());
}
CommentSort sort = request.getSort();
if (sort == null) // Reddit sorts by confidence by default
{
sort = CommentSort.CONFIDENCE;
}
args.put("sort", sort.name().toLowerCase(Locale.ENGLISH));
try {
RestResponse response = Authentication.reddit.execute(Authentication.reddit.request().path(String.format("/comments/%s", request.getId())).query(args).build());
return response.getJson();
} catch (Exception e) {
return null;
}
}
Aggregations