2024-03-03 16:30:10 -05:00
|
|
|
|
package schedule
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2024-03-07 19:41:05 -05:00
|
|
|
|
"fmt"
|
2024-03-03 16:30:10 -05:00
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
|
|
"github.com/google/go-querystring/query"
|
2024-03-07 20:52:42 -05:00
|
|
|
|
"go.fifitido.net/twitch/api/endpoint"
|
2024-03-03 16:30:10 -05:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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 broadcaster’s 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)
|
|
|
|
|
|
2024-03-07 20:52:42 -05:00
|
|
|
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(s.baseUrl, "schedule/segment", v), nil)
|
2024-03-03 16:30:10 -05:00
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
res, err := s.client.Do(req)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
defer res.Body.Close()
|
|
|
|
|
|
2024-03-07 19:41:05 -05:00
|
|
|
|
statusOK := res.StatusCode >= 200 && res.StatusCode < 300
|
|
|
|
|
if !statusOK {
|
|
|
|
|
return fmt.Errorf("failed to delete channel stream schedule segment (%d)", res.StatusCode)
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-03 16:30:10 -05:00
|
|
|
|
return nil
|
|
|
|
|
}
|