Replace references to "link" by "post"
Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
+16
-16
@@ -8,23 +8,23 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ListingsService handles communication with the link (post)
|
||||
// related methods of the Reddit API
|
||||
// ListingsService handles communication with the post
|
||||
// related methods of the Reddit API.
|
||||
type ListingsService interface {
|
||||
Get(ctx context.Context, ids ...string) ([]Comment, []Link, []Subreddit, *Response, error)
|
||||
GetLinks(ctx context.Context, ids ...string) ([]Link, *Response, error)
|
||||
GetLink(ctx context.Context, id string) (*LinkAndComments, *Response, error)
|
||||
Get(ctx context.Context, ids ...string) ([]Post, []Comment, []Subreddit, *Response, error)
|
||||
GetPosts(ctx context.Context, ids ...string) ([]Post, *Response, error)
|
||||
GetPost(ctx context.Context, id string) (*PostAndComments, *Response, error)
|
||||
}
|
||||
|
||||
// ListingsServiceOp implements the Vote interface
|
||||
// ListingsServiceOp implements the Vote interface.
|
||||
type ListingsServiceOp struct {
|
||||
client *Client
|
||||
}
|
||||
|
||||
var _ ListingsService = &ListingsServiceOp{}
|
||||
|
||||
// Get returns comments, links, and subreddits from their IDs
|
||||
func (s *ListingsServiceOp) Get(ctx context.Context, ids ...string) ([]Comment, []Link, []Subreddit, *Response, error) {
|
||||
// Get returns posts, comments, and subreddits from their IDs.
|
||||
func (s *ListingsServiceOp) Get(ctx context.Context, ids ...string) ([]Post, []Comment, []Subreddit, *Response, error) {
|
||||
type query struct {
|
||||
IDs []string `url:"id,comma"`
|
||||
}
|
||||
@@ -46,15 +46,15 @@ func (s *ListingsServiceOp) Get(ctx context.Context, ids ...string) ([]Comment,
|
||||
return nil, nil, nil, resp, err
|
||||
}
|
||||
|
||||
posts := root.getPosts().Posts
|
||||
comments := root.getComments().Comments
|
||||
links := root.getLinks().Links
|
||||
subreddits := root.getSubreddits().Subreddits
|
||||
|
||||
return comments, links, subreddits, resp, nil
|
||||
return posts, comments, subreddits, resp, nil
|
||||
}
|
||||
|
||||
// GetLinks returns links from their full IDs
|
||||
func (s *ListingsServiceOp) GetLinks(ctx context.Context, ids ...string) ([]Link, *Response, error) {
|
||||
// GetPosts returns posts from their full IDs.
|
||||
func (s *ListingsServiceOp) GetPosts(ctx context.Context, ids ...string) ([]Post, *Response, error) {
|
||||
if len(ids) == 0 {
|
||||
return nil, nil, errors.New("must provide at least 1 id")
|
||||
}
|
||||
@@ -71,18 +71,18 @@ func (s *ListingsServiceOp) GetLinks(ctx context.Context, ids ...string) ([]Link
|
||||
return nil, resp, err
|
||||
}
|
||||
|
||||
return root.getLinks().Links, resp, nil
|
||||
return root.getPosts().Posts, resp, nil
|
||||
}
|
||||
|
||||
// GetLink returns a link with its comments
|
||||
func (s *ListingsServiceOp) GetLink(ctx context.Context, id string) (*LinkAndComments, *Response, error) {
|
||||
// GetPost returns a post with its comments.
|
||||
func (s *ListingsServiceOp) GetPost(ctx context.Context, id string) (*PostAndComments, *Response, error) {
|
||||
path := fmt.Sprintf("comments/%s", id)
|
||||
req, err := s.client.NewRequest(http.MethodGet, path, nil)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
root := new(LinkAndComments)
|
||||
root := new(PostAndComments)
|
||||
resp, err := s.client.Do(ctx, req, root)
|
||||
if err != nil {
|
||||
return nil, resp, err
|
||||
|
||||
Reference in New Issue
Block a user