Skip to content

Commit cc07108

Browse files
committed
Add Route to docs and make public.
1 parent bf3d889 commit cc07108

File tree

3 files changed

+41
-3
lines changed

3 files changed

+41
-3
lines changed

docs/references/utils.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,12 @@ Helpers
3838
.. autofunction:: twitchio.utils.parse_timestamp
3939

4040
.. autofunction:: twitchio.utils.setup_logging
41+
42+
43+
HTTP
44+
----
45+
46+
.. attributetable:: twitchio.Route
47+
48+
.. autoclass:: twitchio.Route()
49+

twitchio/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@
2828
__copyright__ = "Copyright 2017-Present (c) TwitchIO, PythonistaGuild"
2929
__version__ = "3.0.0dev"
3030

31-
from . import types_ as types
32-
33-
from . import authentication as authentication, eventsub as eventsub, utils as utils, web as web
31+
from . import ( # noqa: F401
32+
authentication as authentication,
33+
eventsub as eventsub,
34+
types_ as types,
35+
utils as utils,
36+
web as web,
37+
)
3438
from .assets import Asset as Asset
3539
from .authentication import Scopes as Scopes
3640
from .client import Client as Client
3741
from .exceptions import *
42+
from .http import HTTPAsyncIterator as HTTPAsyncIterator, Route as Route
3843
from .models import *
3944
from .payloads import *
4045
from .user import *

twitchio/http.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,28 @@ async def json_or_text(resp: aiohttp.ClientResponse) -> dict[str, Any] | str:
176176

177177

178178
class Route:
179+
"""Route class used by TwitchIO to prepare HTTP requests to Twitch.
180+
181+
.. warning::
182+
183+
You should not change or instantiate this class manually, as it is used internally.
184+
185+
Attributes
186+
----------
187+
params: dict[str, Any]
188+
A mapping of parameters used in the request.
189+
json: dict[Any, Any]
190+
The JSON used in the body of the request. Could be an empty :class:`dict`.
191+
headers: dict[str, str]
192+
The headers used in the request.
193+
token_for: str
194+
The User ID that was used to gather a token for authentication. Could be an empty :class:`str`.
195+
method: Literal['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD', 'CONNECT', 'TRACE']
196+
The request method used.
197+
path: str
198+
The API endpoint requested.
199+
"""
200+
179201
__slots__ = (
180202
"_base_url",
181203
"_url",
@@ -258,10 +280,12 @@ def encode(cls, value: str, /, safe: str = "", plus: bool = False) -> str:
258280

259281
@property
260282
def url(self) -> str:
283+
"""Property returning the URL used to make a request. Could include query parameters."""
261284
return self._url
262285

263286
@property
264287
def base_url(self) -> str:
288+
"""Property returning the URL used to make a request without query parameters."""
265289
return self._base_url
266290

267291
def update_params(self, params: ParamMapping, *, remove_none: bool = True) -> str:

0 commit comments

Comments
 (0)