package eventsub import ( "context" "fmt" "net/http" "net/url" "go.fifitido.net/twitch/api/endpoint" ) // Deletes an EventSub subscription. // // If you use webhooks to receive events, the request must specify an app access token. // The request will fail if you use a user access token. // // If you use WebSockets to receive events, the request must specify a user access token. // The request will fail if you use an app access token. The token may include any scopes. func (e *EventSub) DeleteEventSubSubscription(ctx context.Context, id string) error { v := url.Values{"id": {id}} req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.Make(e.baseUrl, "eventsub/subscriptions", v), nil) if err != nil { return err } res, err := e.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 EventSub subscription (%d)", res.StatusCode) } return nil }