Move GetPost method to PostService

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian
2020-07-18 10:02:43 -04:00
parent c85bb5485f
commit 0bfff72973
4 changed files with 322 additions and 19 deletions
-19
View File
@@ -64,22 +64,3 @@ func (s *ListingsService) GetPosts(ctx context.Context, ids ...string) ([]Post,
return root.getPosts().Posts, resp, nil
}
// GetPost returns a post with its comments.
// The id here is the ID36 of the post, not its full id.
// Example: instead of t3_abc123, use abc123.
func (s *ListingsService) GetPost(ctx context.Context, id string) (*Post, []Comment, *Response, error) {
path := fmt.Sprintf("comments/%s", id)
req, err := s.client.NewRequest(http.MethodGet, path, nil)
if err != nil {
return nil, nil, nil, err
}
root := new(postAndComments)
resp, err := s.client.Do(ctx, req, root)
if err != nil {
return nil, nil, resp, err
}
return root.Post, root.Comments, resp, nil
}