package users import ( "context" "fmt" "net/http" "net/url" ) // Removes the user from the broadcaster’s list of blocked users. // The user ID in the OAuth token identifies the broadcaster who’s 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() statusOK := res.StatusCode >= 200 && res.StatusCode < 300 if !statusOK { return fmt.Errorf("failed to unblock user (%d)", res.StatusCode) } return nil }