wp_mini/field/story_field.rs
1use crate::field::user_stub_field::UserStubField;
2use crate::field::{part_reference_field::PartReferenceField, part_stub_field::PartStubField, LanguageField};
3use crate::field::{AuthRequiredFields, DefaultableFields};
4use crate::impl_field_display;
5use strum_macros::AsRefStr;
6
7/// Represents the fields that can be requested for a `Story` object from the Wattpad API.
8#[derive(Debug, Clone, AsRefStr, PartialEq, Eq, Ord, PartialOrd, Hash)]
9#[strum(serialize_all = "camelCase")]
10pub enum StoryField {
11 /// The unique numerical identifier of the story.
12 Id,
13 /// The title of the story.
14 Title,
15 /// The estimated reading time of the story in seconds.
16 Length,
17 /// The timestamp when the story was created.
18 CreatedDate,
19 /// The timestamp when the story was last modified.
20 ModifyDate,
21 /// The total number of votes the story has received.
22 VoteCount,
23 /// The total number of reads the story has received.
24 ReadCount,
25 /// The total number of comments on the story.
26 CommentCount,
27 /// The numerical identifier for the story's language.
28 Language(Vec<LanguageField>),
29
30 /// A complex field representing the author of the story, with selectable sub-fields.
31 #[strum(disabled)]
32 User(Vec<UserStubField>),
33
34 /// The story's description or synopsis.
35 Description,
36 /// The URL for the story's cover image.
37 Cover,
38
39 /// The timestamp when the cover image was last updated.
40 #[strum(serialize = "cover_timestamp")]
41 CoverTimestamp,
42
43 /// A boolean flag indicating whether the story is marked as complete.
44 Completed,
45 /// A list of category IDs that the story belongs to.
46 Categories,
47 /// A list of user-defined tags associated with the story.
48 Tags,
49 /// The content rating of the story (e.g., Everyone, Mature).
50 Rating,
51 /// A boolean flag indicating if the story is intended for a mature audience.
52 Mature,
53 /// The copyright or license identifier for the story.
54 Copyright,
55 /// A direct URL to the story on the Wattpad website.
56 Url,
57 /// The total number of published parts in the story.
58 NumParts,
59 /// The unique identifier of the first part of the story.
60 FirstPartId,
61
62 /// A complex field for a lightweight reference to the first published part, with sub-fields.
63 #[strum(disabled)]
64 FirstPublishedPart(Vec<PartReferenceField>),
65
66 /// A complex field for a lightweight reference to the last published part, with sub-fields.
67 #[strum(disabled)]
68 LastPublishedPart(Vec<PartReferenceField>),
69
70 /// A complex field for the list of parts in the story, with selectable sub-fields for each part.
71 #[strum(disabled)]
72 Parts(Vec<PartStubField>),
73
74 /// A boolean flag indicating whether the story has been deleted.
75 Deleted,
76}
77
78impl_field_display!(
79 StoryField,
80 User => "user",
81 FirstPublishedPart => "firstPublishedPart",
82 LastPublishedPart => "lastPublishedPart",
83 Parts => "parts"
84);
85
86impl AuthRequiredFields for StoryField {}
87
88impl DefaultableFields for StoryField {
89 fn default_fields() -> Vec<Self> {
90 vec![
91 Self::Id,
92 Self::Title,
93 Self::Length,
94 Self::CreatedDate,
95 Self::ModifyDate,
96 Self::VoteCount,
97 Self::ReadCount,
98 Self::CommentCount,
99 Self::Language(vec![LanguageField::Id]),
100 Self::Description,
101 Self::Cover,
102 Self::CoverTimestamp,
103 Self::Completed,
104 Self::Categories,
105 Self::Tags,
106 Self::Rating,
107 Self::Mature,
108 Self::Copyright,
109 Self::Url,
110 Self::NumParts,
111 Self::FirstPublishedPart(vec![PartReferenceField::Id]),
112 Self::LastPublishedPart(vec![PartReferenceField::Id]),
113 Self::Parts(vec![PartStubField::Id]),
114 Self::Deleted,
115 Self::User(vec![UserStubField::Username]),
116 ]
117 }
118}