go-twitch/api/videos/delete_videos.go

39 lines
934 B
Go

package videos
import (
"context"
"encoding/json"
"net/http"
"net/url"
)
type DeleteVideosResponse struct {
// The list of IDs of the videos that were deleted.
Data []string `json:"data"`
}
// Deletes one or more videos. You may delete past broadcasts, highlights, or uploads.
//
// Requires a user access token that includes the channel:manage:videos scope.
func (v *Videos) DeleteVideos(ctx context.Context, ids []string) (*DeleteVideosResponse, error) {
endpoint := v.baseUrl.ResolveReference(&url.URL{Path: "videos", RawQuery: url.Values{"id": ids}.Encode()})
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
if err != nil {
return nil, err
}
res, err := v.client.Do(req)
if err != nil {
return nil, err
}
defer res.Body.Close()
var data DeleteVideosResponse
if err := json.NewDecoder(res.Body).Decode(&data); err != nil {
return nil, err
}
return &data, nil
}