|
|
@@ -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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|