-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathusing_query_params.py
35 lines (24 loc) · 1.51 KB
/
using_query_params.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import asyncio
import hondana
async def main() -> None:
async with hondana.Client() as client:
# We can use the `.none()` classmethod to specify no includes, since the library defaults to using all of them.
manga_list_includes = hondana.query.MangaIncludes.none()
# Now our collection will have the minimal payload data as we don't need all the extra reference expansion data.
collection = await client.manga_list(includes=manga_list_includes)
print(len(collection.manga))
# Since our default is all possible expansions,
# you can just call an empty constructor, and it will populate accordingly.
chapter_list_includes = hondana.query.ChapterIncludes()
# We also have the `all()` classmethod should you wish to use that.
# These chapters will have all possible expansion data.
feed = await client.chapter_list(includes=chapter_list_includes)
print(len(feed.chapters))
# if you wish to manually choose which to include/exclude, you can do things like so:
custom_list_includes = hondana.query.CustomListIncludes(manga=False, user=True, owner=True)
# The `=True` aren't necessary since they are the default, but I added for example reasons.
# You can also edit these attributes post-creation:
custom_list_includes.manga = True
# Now our payload will have the necessary data as we requested.
await client.get_custom_list("...", includes=custom_list_includes)
asyncio.run(main())