Remove sticky type

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian 2020-06-22 21:57:00 -04:00
parent f649216b9d
commit 3bb31e2b43
2 changed files with 4 additions and 14 deletions

View file

@ -127,12 +127,12 @@ func (s *SubredditServiceOp) GetModerated(ctx context.Context, opts *ListOptions
// GetSticky1 returns the first stickied post on a subreddit (if it exists). // GetSticky1 returns the first stickied post on a subreddit (if it exists).
func (s *SubredditServiceOp) GetSticky1(ctx context.Context, name string) (*PostAndComments, *Response, error) { func (s *SubredditServiceOp) GetSticky1(ctx context.Context, name string) (*PostAndComments, *Response, error) {
return s.getSticky(ctx, name, sticky1) return s.getSticky(ctx, name, 1)
} }
// GetSticky2 returns the second stickied post on a subreddit (if it exists). // GetSticky2 returns the second stickied post on a subreddit (if it exists).
func (s *SubredditServiceOp) GetSticky2(ctx context.Context, name string) (*PostAndComments, *Response, error) { func (s *SubredditServiceOp) GetSticky2(ctx context.Context, name string) (*PostAndComments, *Response, error) {
return s.getSticky(ctx, name, sticky2) return s.getSticky(ctx, name, 2)
} }
// Subscribe subscribes to subreddits based on their names. // Subscribe subscribes to subreddits based on their names.
@ -249,11 +249,9 @@ func (s *SubredditServiceOp) getSubreddits(ctx context.Context, path string, opt
// getSticky returns one of the 2 stickied posts of the subreddit (if they exist). // 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. // Num should be equal to 1 or 2, depending on which one you want.
// If it's <= 1, it's 1. func (s *SubredditServiceOp) getSticky(ctx context.Context, subreddit string, num int) (*PostAndComments, *Response, error) {
// If it's >= 2, it's 2.
func (s *SubredditServiceOp) getSticky(ctx context.Context, subreddit string, num sticky) (*PostAndComments, *Response, error) {
type query struct { type query struct {
Num sticky `url:"num"` Num int `url:"num"`
} }
path := fmt.Sprintf("r/%s/about/sticky", subreddit) path := fmt.Sprintf("r/%s/about/sticky", subreddit)

View file

@ -82,14 +82,6 @@ func (t Timespan) String() string {
return timespans[t] return timespans[t]
} }
// todo: remove this, it is not needed
type sticky int
const (
sticky1 sticky = iota + 1
sticky2
)
type root struct { type root struct {
Kind string `json:"kind,omitempty"` Kind string `json:"kind,omitempty"`
Data interface{} `json:"data,omitempty"` Data interface{} `json:"data,omitempty"`