Skip to content

Commit

Permalink
fix(models.TagRankings): Make name field mandatory
Browse files Browse the repository at this point in the history
  • Loading branch information
TheOnlyWayUp committed Feb 1, 2024
1 parent cb59ef9 commit 6029fb3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wattpad/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ class TagRankingModel(BaseModel):
"""Represents a Story's Tag Rankings."""

name: str
rank: int
total: int
rank: Optional[int] = None
total: Optional[int] = None


class StoryModel(BaseModel):
Expand Down
4 changes: 4 additions & 0 deletions src/wattpad/wattpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ async def fetch_stories(self, include: bool | StoryModelFieldsType = False) -> d

include_fields["id"] = True

if "tagRankings" in include_fields:
if type(include_fields["tagRankings"]) is dict:
include_fields["tagRankings"]["name"] = True

url = (
build_url(f"users/{self.data.username}/stories", fields=None)
+ f"&fields=stories({construct_fields(dict(include_fields))})" # ! The field format for story retrieval differs here. It's /stories?fields=stories(<fields>). Compared to the usual /path?fields=<fields>. For this reason, we need to manually edit the fields in.
Expand Down

0 comments on commit 6029fb3

Please sign in to comment.