You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.4 KiB

package com.github.jreddit.request.retrieval.comments;
import java.util.List;
import com.github.jreddit.request.RedditGetRequest;
import com.github.jreddit.request.retrieval.param.CommentSort;
import com.github.jreddit.request.util.KeyValueFormatter;
public class MoreCommentsRequest extends RedditGetRequest {
/** Endpoint format. */
private static final String ENDPOINT_FORMAT = "/api/morechildren.json?%s";
/**
* @param submissionFullname Fullname of the submission (e.g. "t3_dajdkjf")
* @param commentIdentifiers List of comment ID36 identifiers (e.g. ["jdafid9", "jdafid10"])
*
* @see {@link com.github.jreddit.parser.entity.More#getChildren()} is typically used to retrieve the 2nd parameter
*/
public MoreCommentsRequest(String submissionFullname, List<String> commentIdentifiers) {
// Neglected optional "id" parameter, as it is only relevant for HTML
this.addParameter("api_type", "json");
this.addParameter("link_id", submissionFullname);
this.addParameter("children", KeyValueFormatter.formatCommaSeparatedList(commentIdentifiers));
}
public MoreCommentsRequest setSort(CommentSort sort) {
this.addParameter("sort", sort.value());
return this;
}
@Override
public String generateRedditURI() {
return String.format(ENDPOINT_FORMAT, this.generateParameters());
}
}