From f9c4705fb79321001f20c7158e1ad910d3b646c3 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sat, 16 Jul 2022 00:53:30 +0000 Subject: [PATCH] Handle html.card --- src/fanbox/article/url_embed.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/fanbox/article/url_embed.rs b/src/fanbox/article/url_embed.rs index 2cf2fce..e4c0e67 100644 --- a/src/fanbox/article/url_embed.rs +++ b/src/fanbox/article/url_embed.rs @@ -4,6 +4,7 @@ use super::super::error::FanboxAPIError; use crate::fanbox_api::FanboxClientInternal; use json::JsonValue; use proc_macros::check_json_keys; +use proc_macros::fanbox_api_test; use std::fmt::Debug; use std::sync::Arc; @@ -114,6 +115,7 @@ impl Debug for FanboxArticleUrlEmbedHTML { pub enum FanboxArticleUrlEmbed { FanboxCreator(FanboxArticleUrlEmbedFanboxCreator), HTML(FanboxArticleUrlEmbedHTML), + HTMLCard(FanboxArticleUrlEmbedHTML), Unknown(JsonValue), } @@ -127,6 +129,7 @@ impl FanboxArticleUrlEmbed { Self::FanboxCreator(FanboxArticleUrlEmbedFanboxCreator::new(data, client)) } "html" => Self::HTML(FanboxArticleUrlEmbedHTML::new(data, client)), + "html.card" => Self::HTMLCard(FanboxArticleUrlEmbedHTML::new(data, client)), _ => Self::Unknown(data.clone()), }, None => Self::Unknown(data.clone()), @@ -184,3 +187,22 @@ impl Debug for FanboxArticleUrlEmbedMap { d.finish_non_exhaustive() } } + +fanbox_api_test!(test_html_card, { + match client.get_post_info(4135937).await { + Some(post) => { + assert_eq!(post.title(), Some("第255話 夏の新刊入稿しました!ジュエハキャラバンの話")); + assert_eq!(post.creator_id(), Some("shiratamaco")); + println!("{:#?}", post); + match post.check_unknown() { + Ok(_) => {} + Err(e) => { + panic!("Check unknown: {}", e); + } + } + } + None => { + panic!("Failed to get post(第255話 夏の新刊入稿しました!ジュエハキャラバンの話).") + } + } +});