package gueststar import ( "context" "encoding/json" "net/http" "net/url" ) type CreateGuestStarSessionResponse struct { // Summary of the session details. Data []Session `json:"data"` } // Programmatically creates a Guest Star session on behalf of the broadcaster. Requires the broadcaster to be present in the call interface, or the call will be ended automatically. // // Query parameter broadcaster_id must match the user_id in the User-Access token // Requires OAuth Scope: channel:manage:guest_star func (g *GuestStar) CreateGuestStarSession(ctx context.Context, broadcasterID string) (*CreateGuestStarSessionResponse, error) { endpoint := g.baseUrl.ResolveReference(&url.URL{Path: "guest_star/session", RawQuery: url.Values{"broadcaster_id": {broadcasterID}}.Encode()}) req, err := http.NewRequestWithContext(ctx, http.MethodPost, endpoint.String(), nil) if err != nil { return nil, err } res, err := g.client.Do(req) if err != nil { return nil, err } defer res.Body.Close() var data CreateGuestStarSessionResponse if err := json.NewDecoder(res.Body).Decode(&data); err != nil { return nil, err } return &data, nil }