From 730da4685d6ed5ea229c237fde6b56b2bf31309d Mon Sep 17 00:00:00 2001 From: Vartan Benohanian Date: Sun, 2 Aug 2020 15:33:06 -0400 Subject: [PATCH] Edit comments, change field type Signed-off-by: Vartan Benohanian --- search.go | 1 + subreddit.go | 6 +++--- things.go | 11 +++++------ user.go | 6 +++--- user_test.go | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/search.go b/search.go index 6eede9a..26a250d 100644 --- a/search.go +++ b/search.go @@ -92,6 +92,7 @@ func SortByActivity(opts url.Values) { // SortByNumberOfComments sets the sort option to return the results with the highest // number of comments first. +// This can be used when searching for posts within a subreddit. func SortByNumberOfComments(opts url.Values) { opts.Set("sort", "comments") } diff --git a/subreddit.go b/subreddit.go index ea48cc0..aa2f088 100644 --- a/subreddit.go +++ b/subreddit.go @@ -142,17 +142,17 @@ func (s *SubredditService) GetDefault(ctx context.Context, opts *ListOptions) (* return s.getSubreddits(ctx, "subreddits/default", opts) } -// GetSubscribed returns the list of subreddits the client is subscribed to. +// GetSubscribed returns the list of subreddits you are subscribed to. func (s *SubredditService) GetSubscribed(ctx context.Context, opts *ListOptions) (*Subreddits, *Response, error) { return s.getSubreddits(ctx, "subreddits/mine/subscriber", opts) } -// GetApproved returns the list of subreddits the client is an approved user in. +// GetApproved returns the list of subreddits you are an approved user in. func (s *SubredditService) GetApproved(ctx context.Context, opts *ListOptions) (*Subreddits, *Response, error) { return s.getSubreddits(ctx, "subreddits/mine/contributor", opts) } -// GetModerated returns the list of subreddits the client is a moderator of. +// GetModerated returns the list of subreddits you are a moderator of. func (s *SubredditService) GetModerated(ctx context.Context, opts *ListOptions) (*Subreddits, *Response, error) { return s.getSubreddits(ctx, "subreddits/mine/moderator", opts) } diff --git a/things.go b/things.go index 40a6223..128a7e2 100644 --- a/things.go +++ b/things.go @@ -160,15 +160,14 @@ type Comment struct { SubredditNamePrefixed string `json:"subreddit_name_prefixed,omitempty"` SubredditID string `json:"subreddit_id,omitempty"` - // Indicates if the client has upvote/downvoted (true/false) - // If neither, it will be nil + // Indicates if you've upvote/downvoted (true/false). + // If neither, it will be nil. Likes *bool `json:"likes"` Score int `json:"score"` Controversiality int `json:"controversiality"` PostID string `json:"link_id,omitempty"` - // This doesn't appear when submitting a comment. PostTitle string `json:"link_title,omitempty"` // This doesn't appear when submitting a comment. @@ -177,7 +176,7 @@ type Comment struct { PostAuthor string `json:"link_author,omitempty"` // This doesn't appear when submitting a comment // or when getting a post with its comments. - PostNumComments int `json:"num_comments"` + PostNumComments *int `json:"num_comments,omitempty"` IsSubmitter bool `json:"is_submitter"` ScoreHidden bool `json:"score_hidden"` @@ -251,8 +250,8 @@ type Post struct { Title string `json:"title,omitempty"` Body string `json:"selftext,omitempty"` - // Indicates if the client has upvote/downvoted (true/false) - // If neither, it will be nil + // Indicates if you've upvote/downvoted (true/false). + // If neither, it will be nil. Likes *bool `json:"likes"` Score int `json:"score"` diff --git a/user.go b/user.go index 56a0402..143fcef 100644 --- a/user.go +++ b/user.go @@ -153,7 +153,7 @@ func (s *UserService) UsernameAvailable(ctx context.Context, username string) (b return *root, resp, nil } -// Overview returns a list of the client's posts and comments. +// Overview returns a list of your posts and comments. func (s *UserService) Overview(ctx context.Context, opts ...SearchOptionSetter) (*Posts, *Comments, *Response, error) { return s.OverviewOf(ctx, s.client.Username, opts...) } @@ -179,7 +179,7 @@ func (s *UserService) OverviewOf(ctx context.Context, username string, opts ...S return root.getPosts(), root.getComments(), resp, nil } -// Posts returns a list of the client's posts. +// Posts returns a list of your posts. func (s *UserService) Posts(ctx context.Context, opts ...SearchOptionSetter) (*Posts, *Response, error) { return s.PostsOf(ctx, s.client.Username, opts...) } @@ -205,7 +205,7 @@ func (s *UserService) PostsOf(ctx context.Context, username string, opts ...Sear return root.getPosts(), resp, nil } -// Comments returns a list of the client's comments. +// Comments returns a list of your comments. func (s *UserService) Comments(ctx context.Context, opts ...SearchOptionSetter) (*Comments, *Response, error) { return s.CommentsOf(ctx, s.client.Username, opts...) } diff --git a/user_test.go b/user_test.go index b9c62c4..1e6c80f 100644 --- a/user_test.go +++ b/user_test.go @@ -100,7 +100,7 @@ var expectedComment = &Comment{ PostTitle: "I'm giving away an iPhone 11 Pro to a commenter at random to celebrate Apollo for Reddit's new iOS 13 update and as a thank you to the community! Just leave a comment on this post and the winner will be selected randomly and announced tomorrow at 8 PM GMT. Details inside, and good luck!", PostPermalink: "https://www.reddit.com/r/apple/comments/d7ejpn/im_giving_away_an_iphone_11_pro_to_a_commenter_at/", PostAuthor: "iamthatis", - PostNumComments: 89751, + PostNumComments: Int(89751), } var expectedRelationship = &Relationship{