Use ListOptions for parameters instead of functional options
Signed-off-by: Vartan Benohanian <vartanbeno@gmail.com>
This commit is contained in:
+28
-19
@@ -41,11 +41,36 @@ type ModAction struct {
|
||||
|
||||
// GetActions gets a list of moderator actions on a subreddit.
|
||||
// By default, the limit parameter is 25; max is 500.
|
||||
func (s *ModerationService) GetActions(ctx context.Context, subreddit string, opts ...SearchOptionSetter) (*ModActions, *Response, error) {
|
||||
form := newSearchOptions(opts...)
|
||||
func (s *ModerationService) GetActions(ctx context.Context, subreddit string, opts *ListOptions) (*ModActions, *Response, error) {
|
||||
return s.GetActionsByType(ctx, subreddit, "", opts)
|
||||
}
|
||||
|
||||
// GetActionsByType gets a list of moderator actions of the specified type on a subreddit.
|
||||
// By default, the limit parameter is 25; max is 500.
|
||||
// The type should be one of: banuser, unbanuser, spamlink, removelink, approvelink, spamcomment,
|
||||
// removecomment, approvecomment, addmoderator, showcomment, invitemoderator, uninvitemoderator,
|
||||
// acceptmoderatorinvite, removemoderator, addcontributor, removecontributor, editsettings, editflair,
|
||||
// distinguish, marknsfw, wikibanned, wikicontributor, wikiunbanned, wikipagelisted, removewikicontributor,
|
||||
// wikirevise, wikipermlevel, ignorereports, unignorereports, setpermissions, setsuggestedsort, sticky,
|
||||
// unsticky, setcontestmode, unsetcontestmode, lock, unlock, muteuser, unmuteuser, createrule, editrule,
|
||||
// reorderrules, deleterule, spoiler, unspoiler, modmail_enrollment, community_styling, community_widgets,
|
||||
// markoriginalcontent, collections, events, hidden_award, add_community_topics, remove_community_topics,
|
||||
// create_scheduled_post, edit_scheduled_post, delete_scheduled_post, submit_scheduled_post, edit_post_requirements,
|
||||
// invitesubscriber, submit_content_rating_survey.
|
||||
func (s *ModerationService) GetActionsByType(ctx context.Context, subreddit string, actionType string, opts *ListOptions) (*ModActions, *Response, error) {
|
||||
path := fmt.Sprintf("r/%s/about/log", subreddit)
|
||||
path = addQuery(path, form)
|
||||
path, err := addOptions(path, opts)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
type params struct {
|
||||
Type string `url:"type,omitempty"`
|
||||
}
|
||||
path, err = addOptions(path, params{actionType})
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
req, err := s.client.NewRequest(http.MethodGet, path, nil)
|
||||
if err != nil {
|
||||
@@ -61,22 +86,6 @@ func (s *ModerationService) GetActions(ctx context.Context, subreddit string, op
|
||||
return root.getModeratorActions(), resp, nil
|
||||
}
|
||||
|
||||
// GetActionsByType gets a list of moderator actions of the specified type on a subreddit.
|
||||
// By default, the limit parameter is 25; max is 500.
|
||||
// The type should be one of: banuser, unbanuser, spamlink, removelink, approvelink, spamcomment,
|
||||
// removecomment, approvecomment, addmoderator, showcomment, invitemoderator, uninvitemoderator,
|
||||
// acceptmoderatorinvite, removemoderator, addcontributor, removecontributor, editsettings, editflair,
|
||||
// distinguish, marknsfw, wikibanned, wikicontributor, wikiunbanned, wikipagelisted, removewikicontributor,
|
||||
// wikirevise, wikipermlevel, ignorereports, unignorereports, setpermissions, setsuggestedsort, sticky,
|
||||
// unsticky, setcontestmode, unsetcontestmode, lock, unlock, muteuser, unmuteuser, createrule, editrule,
|
||||
// reorderrules, deleterule, spoiler, unspoiler, modmail_enrollment, community_styling, community_widgets,
|
||||
// markoriginalcontent, collections, events, hidden_award, add_community_topics, remove_community_topics,
|
||||
// create_scheduled_post, edit_scheduled_post, delete_scheduled_post, submit_scheduled_post, edit_post_requirements
|
||||
func (s *ModerationService) GetActionsByType(ctx context.Context, subreddit string, actionType string, opts ...SearchOptionSetter) (*ModActions, *Response, error) {
|
||||
opts = append(opts, setType(actionType))
|
||||
return s.GetActions(ctx, subreddit, opts...)
|
||||
}
|
||||
|
||||
// AcceptInvite accepts a pending invite to moderate the specified subreddit.
|
||||
func (s *ModerationService) AcceptInvite(ctx context.Context, subreddit string) (*Response, error) {
|
||||
path := fmt.Sprintf("r/%s/api/accept_moderator_invite", subreddit)
|
||||
|
||||
Reference in New Issue
Block a user