use http::Method;
use crate::core::operation::Operation;
use crate::error::Result;
#[derive(Debug, Clone, Default)]
pub struct GetMe;
impl Operation for GetMe {
type Output = crate::types::MeResponse;
const METHOD: Method = Method::GET;
fn path(&self) -> String {
"/me".into()
}
}
#[derive(Debug)]
pub struct Account<'c, C> {
pub(crate) client: &'c C,
}
#[cfg(feature = "async")]
impl crate::Client {
pub fn account(&self) -> Account<'_, crate::Client> {
Account { client: self }
}
}
#[cfg(feature = "sync")]
impl crate::BlockingClient {
pub fn account(&self) -> Account<'_, crate::BlockingClient> {
Account { client: self }
}
}
#[cfg(feature = "async")]
impl Account<'_, crate::Client> {
pub async fn get(&self) -> Result<crate::types::MeResponse> {
self.client.send(GetMe).await
}
}
#[cfg(feature = "sync")]
impl Account<'_, crate::BlockingClient> {
pub fn get(&self) -> Result<crate::types::MeResponse> {
self.client.send(GetMe)
}
}
#[cfg(test)]
#[allow(
clippy::unwrap_used,
clippy::expect_used,
clippy::panic,
clippy::print_stdout,
clippy::unreadable_literal
)]
mod tests {
use super::*;
use crate::core::operation::Operation;
#[test]
fn get_me_method_is_get() {
assert_eq!(GetMe::METHOD, http::Method::GET);
}
#[test]
fn get_me_path() {
assert_eq!(GetMe.path(), "/me");
}
}