go-twitch/api/schedule/delete_channel_stream_sched...

46 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 schedule
import (
"context"
"fmt"
"net/http"
"github.com/google/go-querystring/query"
"go.fifitido.net/twitch/api/endpoint"
)
type DeleteChannelStreamScheduleSegmentParams struct {
// The ID of the broadcaster that owns the streaming schedule. This ID must match the user ID in the user access token.
BroadcasterId string `url:"broadcaster_id"`
// The ID of the broadcast segment to remove.
Id string `url:"id"`
}
// Removes a broadcast segment from the broadcasters streaming schedule.
//
// NOTE: For recurring segments, removing a segment removes all segments in the recurring schedule.
//
// Requires a user access token that includes the channel:manage:schedule scope.
func (s *Schedule) DeleteChannelStreamScheduleSegment(ctx context.Context, params *DeleteChannelStreamScheduleSegmentParams) error {
v, _ := query.Values(params)
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(s.baseUrl, "schedule/segment", v), nil)
if err != nil {
return err
}
res, err := s.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 channel stream schedule segment (%d)", res.StatusCode)
}
return nil
}