From 9bc82e4715b342f7d084709f937eddda5f2a741d Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 3 Jul 2022 10:27:21 +0000 Subject: [PATCH] Update --- src/fanbox/post.rs | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/fanbox/post.rs b/src/fanbox/post.rs index 362f3ea..76b2ed0 100644 --- a/src/fanbox/post.rs +++ b/src/fanbox/post.rs @@ -13,21 +13,61 @@ pub struct FanboxPostArticle { } impl FanboxPostArticle { + #[inline] + pub fn comment_count(&self) -> Option { + self.data["commentCount"].as_u64() + } + #[inline] pub fn cover_image_url(&self) -> Option<&str> { self.data["coverImageUrl"].as_str() } + #[inline] + pub fn creator_id(&self) -> Option<&str> { + self.data["creatorId"].as_str() + } + + #[inline] + pub fn excerpt(&self) -> Option<&str> { + self.data["excerpt"].as_str() + } + #[inline] pub fn fee_required(&self) -> Option { self.data["feeRequired"].as_u64() } + #[inline] + pub fn has_adult_content(&self) -> Option { + self.data["hasAdultContent"].as_bool() + } + #[inline] pub fn id(&self) -> Option { parse_u64(&self.data["id"]) } + #[inline] + pub fn image_for_share(&self) -> Option<&str> { + self.data["imageForShare"].as_str() + } + + #[inline] + pub fn is_liked(&self) -> Option { + self.data["isLiked"].as_bool() + } + + #[inline] + pub fn is_restricted(&self) -> Option { + self.data["isRestricted"].as_bool() + } + + #[inline] + pub fn like_count(&self) -> Option { + self.data["likeCount"].as_u64() + } + #[inline] /// Create a new instance pub fn new(data: &JsonValue, client: Arc) -> Self { @@ -51,17 +91,43 @@ impl FanboxPostArticle { pub fn updated_datetime(&self) -> Option<&str> { self.data["updatedDatetime"].as_str() } + + #[inline] + pub fn user_icon_url(&self) -> Option<&str> { + self.data["user"]["iconUrl"].as_str() + } + + #[inline] + pub fn user_id(&self) -> Option { + parse_u64(&self.data["user"]["userId"]) + } + + #[inline] + pub fn user_name(&self) -> Option<&str> { + self.data["user"]["name"].as_str() + } } impl Debug for FanboxPostArticle { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("FanboxPostArticle") .field("id", &self.id()) + .field("comment_count", &self.comment_count()) .field("cover_image_url", &self.cover_image_url()) + .field("creator_id", &self.creator_id()) + .field("excerpt", &self.excerpt()) .field("fee_required", &self.fee_required()) + .field("has_adult_content", &self.has_adult_content()) + .field("image_for_share", &self.image_for_share()) + .field("is_liked", &self.is_liked()) + .field("is_restricted", &self.is_restricted()) + .field("like_count", &self.like_count()) .field("published_datetime", &self.published_datetime()) .field("title", &self.title()) .field("updated_datetime", &self.updated_datetime()) + .field("user_icon_url", &self.user_icon_url()) + .field("user_id", &self.user_id()) + .field("user_name", &self.user_name()) .finish_non_exhaustive() } }