Skip to content

Models

Copyright (C) 2024 TheOnlyWayUp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.


Pydantic Models representing Wattpad API Responses. Thanks https://jsontopydantic.com.

ConnectedServicesModel #

Bases: BaseModel

Represents a User's Connected Services.

Source code in src/wattpad/models.py
33
34
35
36
37
class ConnectedServicesModel(BaseModel):
    """Represents a User's Connected Services."""

    facebook: bool
    twitter: bool

FirstPublishedPartModel #

Bases: BaseModel

Represents the first published part of a Story.

Source code in src/wattpad/models.py
 97
 98
 99
100
101
class FirstPublishedPartModel(BaseModel):
    """Represents the first published part of a Story."""

    id: int
    create_date: str = Field(..., alias="createDate")

InboxModel #

Bases: BaseModel

Represents a User's Inbox.

Source code in src/wattpad/models.py
20
21
22
23
24
class InboxModel(BaseModel):
    """Represents a User's Inbox."""

    unread: int
    total: int

LanguageModel #

Bases: BaseModel

Represents a Language.

Source code in src/wattpad/models.py
90
91
92
93
94
class LanguageModel(BaseModel):
    """Represents a Language."""

    id: int
    name: str

LastPublishedPartModel #

Bases: BaseModel

Represents the last (most recent) published part of a Story.

Source code in src/wattpad/models.py
104
105
106
107
108
class LastPublishedPartModel(BaseModel):
    """Represents the last (most recent) published part of a Story."""

    id: int
    create_date: str = Field(..., alias="createDate")

ListModel #

Bases: BaseModel

Represents a User's List.

Source code in src/wattpad/models.py
170
171
172
173
174
175
class ListModel(BaseModel):
    """Represents a User's List."""

    id: int
    name: str
    stories: List[StoryModel]

NotificationsModel #

Bases: BaseModel

Represents a User's Notifications.

Source code in src/wattpad/models.py
27
28
29
30
class NotificationsModel(BaseModel):
    """Represents a User's Notifications."""

    unread: int

PartModel #

Bases: BaseModel

Represents a Part of a Story.

Source code in src/wattpad/models.py
111
112
113
114
115
116
117
118
119
120
121
class PartModel(BaseModel):
    """Represents a Part of a Story."""

    id: int
    title: Optional[str] = None
    url: Optional[str] = None
    modify_date: Optional[str] = Field(None, alias="modifyDate")
    create_date: Optional[str] = Field(None, alias="createDate")
    comment_count: Optional[int] = Field(None, alias="commentCount")
    vote_count: Optional[int] = Field(None, alias="voteCount")
    read_count: Optional[int] = Field(None, alias="readCount")

StoryModel #

Bases: BaseModel

Represents a Story.

Source code in src/wattpad/models.py
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
class StoryModel(BaseModel):
    """Represents a Story."""

    id: str

    title: Optional[str] = None
    create_date: Optional[str] = Field(None, alias="createDate")
    modify_date: Optional[str] = Field(None, alias="modifyDate")
    vote_count: Optional[int] = Field(None, alias="voteCount")
    read_count: Optional[int] = Field(None, alias="readCount")
    comment_count: Optional[int] = Field(None, alias="commentCount")
    description: Optional[str] = None
    completed: Optional[bool] = None
    tags: Optional[List[str]] = None
    rating: Optional[int] = None
    mature: Optional[bool] = None
    url: Optional[str] = None
    is_paywalled: Optional[bool] = Field(None, alias="isPaywalled")
    cover: Optional[str] = None
    cover_timestamp: Optional[str] = None
    categories: Optional[List[int]] = None
    copyright: Optional[int] = None
    first_part_id: Optional[int] = Field(None, alias="firstPartId")
    num_parts: Optional[int] = Field(None, alias="numParts")
    deleted: Optional[bool] = None

    first_published_part: Optional[FirstPublishedPartModel] = Field(
        None, alias="firstPublishedPart"
    )
    last_published_part: Optional[LastPublishedPartModel] = Field(
        None, alias="lastPublishedPart"
    )
    language: Optional[LanguageModel] = None
    user: Optional[UserModel] = None
    parts: List[PartModel] = []
    tag_rankings: list[TagRankingModel] = Field([], alias="tagRankings")

TagRankingModel #

Bases: BaseModel

Represents a Story's Tag Rankings.

Source code in src/wattpad/models.py
124
125
126
127
128
129
class TagRankingModel(BaseModel):
    """Represents a Story's Tag Rankings."""

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

UserModel #

Bases: BaseModel

Represents a User.

Source code in src/wattpad/models.py
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
class UserModel(BaseModel):
    """Represents a User."""

    username: str

    avatar: Optional[str] = None
    is_private: Optional[bool] = Field(None, alias="isPrivate")
    background_url: Optional[str] = Field(None, alias="backgroundUrl")
    follower: Optional[bool] = None
    following: Optional[bool] = None
    name: Optional[str] = None
    description: Optional[str] = None
    status: Optional[str] = None
    gender: Optional[str] = None
    gender_code: Optional[str] = Field(None, alias="genderCode")
    language: Optional[int] = None
    locale: Optional[str] = None
    create_date: Optional[str] = Field(None, alias="createDate")
    modify_date: Optional[str] = Field(None, alias="modifyDate")
    location: Optional[str] = None
    verified: Optional[bool] = None
    ambassador: Optional[bool] = None
    facebook: Optional[str] = None
    twitter: Optional[str] = None
    website: Optional[str] = None
    lulu: Optional[str] = None
    smashwords: Optional[str] = None
    bubok: Optional[str] = None
    votes_received: Optional[int] = Field(None, alias="votesReceived")
    num_stories_published: Optional[int] = Field(None, alias="numStoriesPublished")
    num_following: Optional[int] = Field(None, alias="numFollowing")
    num_followers: Optional[int] = Field(None, alias="numFollowers")
    num_messages: Optional[int] = Field(None, alias="numMessages")
    num_lists: Optional[int] = Field(None, alias="numLists")
    verified_email: Optional[bool] = None
    preferred_categories: Optional[List] = None
    allow_crawler: Optional[bool] = Field(None, alias="allowCrawler")
    deeplink: Optional[str] = None
    is_muted: Optional[bool] = Field(None, alias="isMuted")
    birthdate: Optional[str] = None
    inbox: Optional[InboxModel] = None
    notifications: Optional[NotificationsModel] = None
    connected_services: Optional[ConnectedServicesModel] = Field(
        None, alias="connectedServices"
    )
    age: Optional[int] = None
    email: Optional[str] = None
    has_password: Optional[bool] = None