go-twitch/api/users/unblock_user.go

29 lines
744 B
Go
Raw 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 users
import (
"context"
"net/http"
"net/url"
)
// Removes the user from the broadcasters list of blocked users.
// The user ID in the OAuth token identifies the broadcaster whos removing the block.
//
// Requires a user access token that includes the user:manage:blocked_users scope.
func (u *Users) UnblockUser(ctx context.Context, targetUserID string) error {
endpoint := u.baseUrl.ResolveReference(&url.URL{Path: "users/blocks", RawQuery: url.Values{"target_user_id": {targetUserID}}.Encode()})
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
if err != nil {
return err
}
res, err := u.client.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
return nil
}