Get more replies to a comment via /api/morechildren

Also started using slices of pointers instead of slices of structs. This
is useful especially in the case of adding to the list of replies of a
comment. If the comment is a plain old struct (non-pointer), the change
wouldn't happen

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-07-19 22:03:37 -04:00
parent 0bfff72973
commit 5c376a1af4
8 changed files with 108 additions and 67 deletions
+3 -3
View File
@@ -116,12 +116,12 @@ func (s *SubredditService) GetModerated(ctx context.Context, opts *ListOptions)
}
// GetSticky1 returns the first stickied post on a subreddit (if it exists).
func (s *SubredditService) GetSticky1(ctx context.Context, name string) (*Post, []Comment, *Response, error) {
func (s *SubredditService) GetSticky1(ctx context.Context, name string) (*Post, []*Comment, *Response, error) {
return s.getSticky(ctx, name, 1)
}
// GetSticky2 returns the second stickied post on a subreddit (if it exists).
func (s *SubredditService) GetSticky2(ctx context.Context, name string) (*Post, []Comment, *Response, error) {
func (s *SubredditService) GetSticky2(ctx context.Context, name string) (*Post, []*Comment, *Response, error) {
return s.getSticky(ctx, name, 2)
}
@@ -240,7 +240,7 @@ func (s *SubredditService) getSubreddits(ctx context.Context, path string, opts
// getSticky returns one of the 2 stickied posts of the subreddit (if they exist).
// Num should be equal to 1 or 2, depending on which one you want.
func (s *SubredditService) getSticky(ctx context.Context, subreddit string, num int) (*Post, []Comment, *Response, error) {
func (s *SubredditService) getSticky(ctx context.Context, subreddit string, num int) (*Post, []*Comment, *Response, error) {
type query struct {
Num int `url:"num"`
}