go-twitch/api/moderation/remove_blocked_term.go

48 lines
1.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package moderation
import (
"context"
"fmt"
"net/http"
"github.com/google/go-querystring/query"
"go.fifitido.net/twitch/api/endpoint"
)
type RemoveBlockedTermParams struct {
// The ID of the broadcaster that owns the list of blocked terms.
BroadcasterID string `url:"broadcaster_id"`
// The ID of the broadcaster or a user that has permission to moderate the broadcasters chat room.
// This ID must match the user ID in the user access token.
ModeratorID string `url:"moderator_id"`
// The ID of the blocked term to remove from the broadcasters list of blocked terms.
ID string `url:"id"`
}
// Removes the word or phrase from the broadcasters list of blocked terms.
//
// Requires a user access token that includes the moderator:manage:blocked_terms scope.
func (m *Moderation) RemoveBlockedTerm(ctx context.Context, params *RemoveBlockedTermParams) error {
v, _ := query.Values(params)
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(m.baseUrl, "moderation/blocks", v), nil)
if err != nil {
return err
}
res, err := m.client.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
if !statusOK {
return fmt.Errorf("failed to remove blocked term (%d)", res.StatusCode)
}
return nil
}