feat(api): shortcut methods for following & followers

This commit is contained in:
Paul Woolcock
2018-10-10 10:28:22 -04:00
parent d524a64bfd
commit 4dd40422b3
3 changed files with 80 additions and 0 deletions
+12
View File
@@ -407,6 +407,18 @@ impl<H: HttpSend> MastodonClient<H> for Mastodon<H> {
deserialise(response)
}
/// Get all accounts that follow the authenticated user
fn follows_me(&self) -> Result<Page<Account, H>> {
let me = self.verify_credentials()?;
Ok(self.followers(&me.id)?)
}
/// Get all accounts that the authenticated user follows
fn followed_by_me(&self) -> Result<Page<Account, H>> {
let me = self.verify_credentials()?;
Ok(self.following(&me.id)?)
}
}
impl<H: HttpSend> ops::Deref for Mastodon<H> {
+43
View File
@@ -273,4 +273,47 @@ pub trait MastodonClient<H: HttpSend = HttpSender> {
fn unendorse_user(&self, id: &str) -> Result<Relationship> {
unimplemented!("This method was not implemented");
}
/// Shortcut for: `let me = client.verify_credentials(); client.followers()`
///
/// ```no_run
/// # extern crate elefren;
/// # use std::error::Error;
/// # use elefren::prelude::*;
/// # fn main() -> Result<(), Box<Error>> {
/// # let data = Data {
/// # base: "".into(),
/// # client_id: "".into(),
/// # client_secret: "".into(),
/// # redirect: "".into(),
/// # token: "".into(),
/// # };
/// # let client = Mastodon::from(data);
/// let follows_me = client.follows_me()?;
/// # Ok(())
/// # }
fn follows_me(&self) -> Result<Page<Account, H>> {
unimplemented!("This method was not implemented");
}
/// Shortcut for
/// `let me = client.verify_credentials(); client.following(&me.id)`
///
/// ```no_run
/// # extern crate elefren;
/// # use std::error::Error;
/// # use elefren::prelude::*;
/// # fn main() -> Result<(), Box<Error>> {
/// # let data = Data {
/// # base: "".into(),
/// # client_id: "".into(),
/// # client_secret: "".into(),
/// # redirect: "".into(),
/// # token: "".into(),
/// # };
/// # let client = Mastodon::from(data);
/// let follows_me = client.followed_by_me()?;
/// # Ok(())
/// # }
fn followed_by_me(&self) -> Result<Page<Account, H>> {
unimplemented!("This method was not implemented");
}
}