59 lines
2.0 KiB
Go
59 lines
2.0 KiB
Go
package gueststar
|
||
|
||
import (
|
||
"context"
|
||
"fmt"
|
||
"net/http"
|
||
|
||
"github.com/google/go-querystring/query"
|
||
"go.fifitido.net/twitch/api/endpoint"
|
||
)
|
||
|
||
type DeleteGuestStarSlotParams struct {
|
||
// The ID of the broadcaster running the Guest Star session.
|
||
BroadcasterID string `url:"broadcaster_id"`
|
||
|
||
// The ID of the broadcaster or a user that has permission to moderate the broadcaster’s chat room.
|
||
// This ID must match the user ID in the user access token.
|
||
ModeratorID string `url:"moderator_id"`
|
||
|
||
// The ID of the Guest Star session in which to remove the slot assignment.
|
||
SessionID string `url:"session_id"`
|
||
|
||
// The Twitch User ID corresponding to the guest to remove from the session.
|
||
// This user must already have an invite to this session, and have indicated that they are ready to join.
|
||
GuestID string `url:"guest_id"`
|
||
|
||
// The slot ID representing the slot assignment to remove from the session.
|
||
SlotID int `url:"slot_id"`
|
||
|
||
// Flag signaling that the guest should be reinvited to the session, sending them back to the invite queue.
|
||
ShouldReinviteGuest *bool `url:"should_reinvite_guest,omitempty"`
|
||
}
|
||
|
||
// Allows a caller to remove a slot assignment from a user participating in an active Guest Star session. This revokes their access to the session immediately and disables their access to publish or subscribe to media within the session.
|
||
//
|
||
// Query parameter moderator_id must match the user_id in the User-Access token
|
||
// Requires OAuth Scope: channel:manage:guest_star or moderator:manage:guest_star
|
||
func (g *GuestStar) DeleteGuestStarSlot(ctx context.Context, params *DeleteGuestStarSlotParams) error {
|
||
v, _ := query.Values(params)
|
||
|
||
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(g.baseUrl, "guest_star/slot", v), nil)
|
||
if err != nil {
|
||
return err
|
||
}
|
||
|
||
res, err := g.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 delete guest star slot (%d)", res.StatusCode)
|
||
}
|
||
|
||
return nil
|
||
}
|