Unexport post/comment service. Rename github workflow

Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
Vartan Benohanian 2020-08-02 19:04:53 -04:00
parent a0ad61f28c
commit c3b2ab00c2
6 changed files with 20 additions and 22 deletions

View file

@ -1,4 +1,4 @@
name: CI name: tests
on: [push, pull_request] on: [push, pull_request]

View file

@ -1,6 +1,6 @@
# go-reddit # go-reddit
[![Actions Status](https://github.com/vartanbeno/go-reddit/workflows/CI/badge.svg)](https://github.com/vartanbeno/go-reddit/actions) [![Actions Status](https://github.com/vartanbeno/go-reddit/workflows/tests/badge.svg)](https://github.com/vartanbeno/go-reddit/actions)
go-reddit is a Go client library for accessing the Reddit API. go-reddit is a Go client library for accessing the Reddit API.

View file

@ -12,7 +12,7 @@ import (
// //
// Reddit API docs: https://www.reddit.com/dev/api/#section_links_and_comments // Reddit API docs: https://www.reddit.com/dev/api/#section_links_and_comments
type CommentService struct { type CommentService struct {
*PostAndCommentService *postAndCommentService
client *Client client *Client
} }

View file

@ -7,14 +7,12 @@ import (
"net/url" "net/url"
) )
// PostAndCommentService handles communication with the post and comment // postAndCommentService handles communication with the post and comment
// related methods of the Reddit API. // related methods of the Reddit API.
// This service holds functionality common to both posts and comments. // This service holds functionality common to both posts and comments.
// //
// Reddit API docs: https://www.reddit.com/dev/api/#section_links_and_comments // Reddit API docs: https://www.reddit.com/dev/api/#section_links_and_comments
// type postAndCommentService struct {
// todo: this is ugly, find a solution
type PostAndCommentService struct {
client *Client client *Client
} }
@ -28,7 +26,7 @@ const (
) )
// Delete deletes a post or comment via its full ID. // Delete deletes a post or comment via its full ID.
func (s *PostAndCommentService) Delete(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) Delete(ctx context.Context, id string) (*Response, error) {
path := "api/del" path := "api/del"
form := url.Values{} form := url.Values{}
@ -43,7 +41,7 @@ func (s *PostAndCommentService) Delete(ctx context.Context, id string) (*Respons
} }
// Save saves a post or comment. // Save saves a post or comment.
func (s *PostAndCommentService) Save(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) Save(ctx context.Context, id string) (*Response, error) {
path := "api/save" path := "api/save"
form := url.Values{} form := url.Values{}
@ -58,7 +56,7 @@ func (s *PostAndCommentService) Save(ctx context.Context, id string) (*Response,
} }
// Unsave unsaves a post or comment. // Unsave unsaves a post or comment.
func (s *PostAndCommentService) Unsave(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) Unsave(ctx context.Context, id string) (*Response, error) {
path := "api/unsave" path := "api/unsave"
form := url.Values{} form := url.Values{}
@ -73,7 +71,7 @@ func (s *PostAndCommentService) Unsave(ctx context.Context, id string) (*Respons
} }
// EnableReplies enables inbox replies for one of your posts or comments. // EnableReplies enables inbox replies for one of your posts or comments.
func (s *PostAndCommentService) EnableReplies(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) EnableReplies(ctx context.Context, id string) (*Response, error) {
path := "api/sendreplies" path := "api/sendreplies"
form := url.Values{} form := url.Values{}
@ -89,7 +87,7 @@ func (s *PostAndCommentService) EnableReplies(ctx context.Context, id string) (*
} }
// DisableReplies dsables inbox replies for one of your posts or comments. // DisableReplies dsables inbox replies for one of your posts or comments.
func (s *PostAndCommentService) DisableReplies(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) DisableReplies(ctx context.Context, id string) (*Response, error) {
path := "api/sendreplies" path := "api/sendreplies"
form := url.Values{} form := url.Values{}
@ -105,7 +103,7 @@ func (s *PostAndCommentService) DisableReplies(ctx context.Context, id string) (
} }
// Lock locks a post or comment, preventing it from receiving new comments. // Lock locks a post or comment, preventing it from receiving new comments.
func (s *PostAndCommentService) Lock(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) Lock(ctx context.Context, id string) (*Response, error) {
path := "api/lock" path := "api/lock"
form := url.Values{} form := url.Values{}
@ -120,7 +118,7 @@ func (s *PostAndCommentService) Lock(ctx context.Context, id string) (*Response,
} }
// Unlock unlocks a post or comment, allowing it to receive new comments. // Unlock unlocks a post or comment, allowing it to receive new comments.
func (s *PostAndCommentService) Unlock(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) Unlock(ctx context.Context, id string) (*Response, error) {
path := "api/unlock" path := "api/unlock"
form := url.Values{} form := url.Values{}
@ -134,7 +132,7 @@ func (s *PostAndCommentService) Unlock(ctx context.Context, id string) (*Respons
return s.client.Do(ctx, req, nil) return s.client.Do(ctx, req, nil)
} }
func (s *PostAndCommentService) vote(ctx context.Context, id string, vote vote) (*Response, error) { func (s *postAndCommentService) vote(ctx context.Context, id string, vote vote) (*Response, error) {
path := "api/vote" path := "api/vote"
form := url.Values{} form := url.Values{}
@ -151,16 +149,16 @@ func (s *PostAndCommentService) vote(ctx context.Context, id string, vote vote)
} }
// Upvote upvotes a post or a comment. // Upvote upvotes a post or a comment.
func (s *PostAndCommentService) Upvote(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) Upvote(ctx context.Context, id string) (*Response, error) {
return s.vote(ctx, id, upvote) return s.vote(ctx, id, upvote)
} }
// Downvote downvotes a post or a comment. // Downvote downvotes a post or a comment.
func (s *PostAndCommentService) Downvote(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) Downvote(ctx context.Context, id string) (*Response, error) {
return s.vote(ctx, id, downvote) return s.vote(ctx, id, downvote)
} }
// RemoveVote removes your vote on a post or a comment. // RemoveVote removes your vote on a post or a comment.
func (s *PostAndCommentService) RemoveVote(ctx context.Context, id string) (*Response, error) { func (s *postAndCommentService) RemoveVote(ctx context.Context, id string) (*Response, error) {
return s.vote(ctx, id, novote) return s.vote(ctx, id, novote)
} }

View file

@ -16,7 +16,7 @@ import (
// //
// Reddit API docs: https://www.reddit.com/dev/api/#section_links_and_comments // Reddit API docs: https://www.reddit.com/dev/api/#section_links_and_comments
type PostService struct { type PostService struct {
*PostAndCommentService *postAndCommentService
client *Client client *Client
} }

View file

@ -146,9 +146,9 @@ func newClient(httpClient *http.Client) *Client {
c.Subreddit = &SubredditService{client: c} c.Subreddit = &SubredditService{client: c}
c.User = &UserService{client: c} c.User = &UserService{client: c}
postAndCommentService := &PostAndCommentService{client: c} postAndCommentService := &postAndCommentService{client: c}
c.Comment = &CommentService{client: c, PostAndCommentService: postAndCommentService} c.Comment = &CommentService{client: c, postAndCommentService: postAndCommentService}
c.Post = &PostService{client: c, PostAndCommentService: postAndCommentService} c.Post = &PostService{client: c, postAndCommentService: postAndCommentService}
return c return c
} }