diff options
Diffstat (limited to 'crates/bot-http/src/teawie.rs')
| -rw-r--r-- | crates/bot-http/src/teawie.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/crates/bot-http/src/teawie.rs b/crates/bot-http/src/teawie.rs new file mode 100644 index 0000000..ea4f53e --- /dev/null +++ b/crates/bot-http/src/teawie.rs @@ -0,0 +1,24 @@ +use super::{ClientExt as _, Error}; +use crate::model::RandomTeawie; + +use std::future::Future; + +const TEAWIE_API: &str = "https://api.getchoo.com"; + +pub trait ClientExt { + /// Get a random teawie + /// + /// # Errors + /// + /// Will return [`Err`] if the request fails or the response cannot be deserialized + fn random_teawie(&self) -> impl Future<Output = Result<Option<String>, Error>> + Send; +} + +impl ClientExt for super::Client { + async fn random_teawie(&self) -> Result<Option<String>, Error> { + let url = format!("{TEAWIE_API}/random_teawie"); + let resp: RandomTeawie = self.get_json(&url).await?; + + Ok(resp.url) + } +} |
