|
1 | | -from typing import TYPE_CHECKING, Tuple, Dict, Type, Union |
| 1 | +from __future__ import annotations |
| 2 | +from typing import TYPE_CHECKING, Tuple, Dict, Type, Union, Optional |
2 | 3 | from ...http import Route |
3 | 4 |
|
4 | 5 | from . import models |
|
11 | 12 |
|
12 | 13 |
|
13 | 14 | class EventSubHTTP: |
14 | | - def __init__(self, client: "EventSubClient"): |
| 15 | + def __init__(self, client: EventSubClient, token: Optional[str]): |
15 | 16 | self._client = client |
16 | 17 | self._http = client.client._http |
| 18 | + self._token = token or self._http.token |
17 | 19 |
|
18 | | - async def create_subscription(self, event_type: Tuple[str, int, Type["EventData"]], condition: Dict[str, str]): |
| 20 | + async def create_subscription(self, event_type: Tuple[str, int, Type[EventData]], condition: Dict[str, str]): |
19 | 21 | payload = { |
20 | 22 | "type": event_type[0], |
21 | 23 | "version": str(event_type[1]), |
22 | 24 | "condition": condition, |
23 | 25 | "transport": {"method": "webhook", "callback": self._client.route, "secret": self._client.secret}, |
24 | 26 | } |
25 | | - route = Route("POST", "eventsub/subscriptions", body=payload) |
| 27 | + route = Route("POST", "eventsub/subscriptions", body=payload, token=self._token) |
26 | 28 | return await self._http.request(route, paginate=False) |
27 | 29 |
|
28 | | - async def delete_subscription(self, substription: Union[str, "Subscription"]): |
| 30 | + async def delete_subscription(self, substription: Union[str, Subscription]): |
29 | 31 | if isinstance(substription, models.Subscription): |
30 | 32 | return await self._http.request( |
31 | 33 | Route("DELETE", "eventsub/subscriptions", query=[("id", substription.id)]), paginate=False |
|
0 commit comments