30 lines
822 B
Go
30 lines
822 B
Go
|
package eventsub
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"net/http"
|
||
|
"net/url"
|
||
|
)
|
||
|
|
||
|
// 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 {
|
||
|
endpoint := e.baseUrl.ResolveReference(&url.URL{Path: "eventsub/subscriptions", RawQuery: "id=" + id})
|
||
|
|
||
|
req, err := http.NewRequestWithContext(ctx, http.MethodDelete, endpoint.String(), nil)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
if _, err := e.client.Do(req); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|