This commit is contained in:
2022-07-10 13:30:03 +00:00
committed by GitHub
parent 0005c67fad
commit ff2c93ee8f
6 changed files with 133 additions and 5 deletions

View File

@@ -28,7 +28,11 @@ impl FanboxArticleParagraphBoldStyle {
impl CheckUnkown for FanboxArticleParagraphBoldStyle {
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
check_json_keys!("offset"+, "length"+, "type",);
check_json_keys!(
"offset"+,
"length"+,
"type",
);
Ok(())
}
}
@@ -95,7 +99,11 @@ impl FanboxArticleParagraphBlock {
impl CheckUnkown for FanboxArticleParagraphBlock {
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
check_json_keys!("styles", "text"+, "type",);
check_json_keys!(
"styles",
"text"+,
"type",
);
match self.styles() {
Some(styles) => {
for style in styles {

View File

@@ -41,7 +41,13 @@ impl FanboxArticleBody {
impl CheckUnkown for FanboxArticleBody {
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
check_json_keys!("blocks"+, "imageMap", "fileMap", "embedMap", "urlEmbedMap",);
check_json_keys!(
"blocks"+,
"imageMap",
"fileMap",
"embedMap",
"urlEmbedMap",
);
match self.blocks() {
Some(blocks) => {
for i in blocks {

View File

@@ -87,7 +87,30 @@ impl FanboxComment {
impl CheckUnkown for FanboxComment {
fn check_unknown(&self) -> Result<(), super::error::FanboxAPIError> {
check_json_keys!("id"+, "body"+, "createdDatetime"+, "isLiked"+, "isOwn"+, "likeCount"+, "parentCommentId", "replies", "rootCommentId", "user": ["userId"+user_id, "name"+, "iconUrl"]);
check_json_keys!(
"id"+,
"body"+,
"createdDatetime"+,
"isLiked"+,
"isOwn"+,
"likeCount"+,
"parentCommentId",
"replies",
"rootCommentId",
"user": [
"userId"+user_id,
"name"+,
"iconUrl",
],
);
match self.replies() {
Some(replies) => {
for i in replies {
i.check_unknown()?;
}
}
None => {}
}
Ok(())
}
}

View File

@@ -1,3 +1,4 @@
use super::check::CheckUnkown;
use super::comment::FanboxComment;
#[cfg(test)]
use super::post::FanboxPost;
@@ -71,6 +72,15 @@ impl FanboxCommentList {
}
}
impl CheckUnkown for FanboxCommentList {
fn check_unknown(&self) -> Result<(), super::error::FanboxAPIError> {
for i in self.items.iter() {
i.check_unknown()?;
}
Ok(())
}
}
impl Debug for FanboxCommentList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FanboxCommentList")

View File

@@ -1,7 +1,9 @@
use super::check::CheckUnkown;
use super::error::FanboxAPIError;
use crate::fanbox_api::FanboxClientInternal;
use crate::parser::json::parse_u64;
use json::JsonValue;
use proc_macros::check_json_keys;
use std::convert::From;
use std::fmt::Debug;
use std::ops::Deref;
@@ -42,6 +44,17 @@ impl FanboxProfileImage {
}
}
impl CheckUnkown for FanboxProfileImage {
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
check_json_keys!(
"id"+,
"imageUrl"+,
"thumbnailUrl",
);
Ok(())
}
}
impl Debug for FanboxProfileImage {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FanboxProfileImage")
@@ -53,7 +66,7 @@ impl Debug for FanboxProfileImage {
}
/// Profile item
#[derive(Debug)]
#[derive(proc_macros::CheckUnkown, Debug)]
pub enum FanboxProfileItem {
/// Image
Image(FanboxProfileImage),
@@ -100,6 +113,15 @@ impl FanboxProfileItems {
}
}
impl CheckUnkown for FanboxProfileItems {
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
for i in self.list.iter() {
i.check_unknown()?;
}
Ok(())
}
}
impl Debug for FanboxProfileItems {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.list.fmt(f)
@@ -222,6 +244,33 @@ impl FanboxCreator {
}
}
impl CheckUnkown for FanboxCreator {
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
check_json_keys!(
"creatorId"+,
"coverImageUrl",
"description"+,
"hasAdultContent"+,
"hasBoothShop"+,
"isAcceptingRequest"+,
"isFollowed"+,
"isStopped"+,
"isSupported"+,
"profileItems",
"profileLinks"+,
"user": [
"userId"+user_id,
"iconUrl",
"name"+,
],
);
for i in self.profile_items()?.iter() {
i.check_unknown()?;
}
Ok(())
}
}
impl Debug for FanboxCreator {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FanboxCreator")

View File

@@ -1,7 +1,9 @@
use super::check::CheckUnkown;
use super::error::FanboxAPIError;
use crate::gettext;
use crate::parser::json::parse_u64;
use json::JsonValue;
use proc_macros::check_json_keys;
use std::fmt::Debug;
use std::ops::Deref;
use std::ops::DerefMut;
@@ -69,6 +71,27 @@ impl FanboxPlan {
}
}
impl CheckUnkown for FanboxPlan {
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
check_json_keys!(
"id"+,
"coverImageUrl",
"creatorId"+,
"description"+,
"fee"+,
"hasAdultContent"+,
"paymentMethod",
"title"+,
"user": [
"iconUrl",
"userId"+user_id,
"name"+,
],
);
Ok(())
}
}
impl Debug for FanboxPlan {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("FanboxPlan")
@@ -128,6 +151,15 @@ impl FanboxPlanList {
}
}
impl CheckUnkown for FanboxPlanList {
fn check_unknown(&self) -> Result<(), FanboxAPIError> {
for i in self.list.iter() {
i.check_unknown()?;
}
Ok(())
}
}
impl Debug for FanboxPlanList {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_list().entries(self.list.iter()).finish()