From 4afb3c3d7405c496857415920afd04d2db01c987 Mon Sep 17 00:00:00 2001 From: Ranfdev Date: Thu, 25 Jun 2020 12:37:47 +0200 Subject: [PATCH] added methods returning pages for timelines home, local, federated, hashtag --- src/lib.rs | 7 ++++--- src/mastodon_client.rs | 10 +++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 747ebe6..4345abf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -212,6 +212,8 @@ impl MastodonClient for Mastodon { (get) domain_blocks: "domain_blocks" => String, (get) follow_requests: "follow_requests" => Account, (get) get_home_timeline: "timelines/home" => Status, + (get) get_local_timeline: "timelines/public?local=true" => Status, + (get) get_federated_timeline: "timelines/public?local=false" => Status, (get) get_emojis: "custom_emojis" => Emoji, (get) mutes: "mutes" => Account, (get) notifications: "notifications" => Notification, @@ -236,7 +238,6 @@ impl MastodonClient for Mastodon { (post (id: &str,)) authorize_follow_request: "accounts/follow_requests/authorize" => Empty, (post (id: &str,)) reject_follow_request: "accounts/follow_requests/reject" => Empty, (get (q: &'a str, resolve: bool,)) search: "search" => SearchResult, - (get (local: bool,)) get_public_timeline: "timelines/public" => Vec, (post (uri: Cow<'static, str>,)) follows: "follows" => Account, (post multipart (file: Cow<'static, str>,)) media: "media" => Attachment, (post) clear_notifications: "notifications/clear" => Empty, @@ -335,7 +336,7 @@ impl MastodonClient for Mastodon { /// Get timeline filtered by a hashtag(eg. `#coffee`) either locally or /// federated. - fn get_tagged_timeline(&self, hashtag: String, local: bool) -> Result> { + fn get_hashtag_timeline(&self, hashtag: &str, local: bool) -> Result> { let base = "/api/v1/timelines/tag/"; let url = if local { self.route(&format!("{}{}?local=1", base, hashtag)) @@ -343,7 +344,7 @@ impl MastodonClient for Mastodon { self.route(&format!("{}{}", base, hashtag)) }; - self.get(url) + Page::new(self, self.send(self.client.get(&url))?) } /// Get statuses of a single account by id. Optionally only with pictures diff --git a/src/mastodon_client.rs b/src/mastodon_client.rs index e338e96..f65eda7 100644 --- a/src/mastodon_client.rs +++ b/src/mastodon_client.rs @@ -196,12 +196,16 @@ pub trait MastodonClient { fn new_status(&self, status: NewStatus) -> Result { unimplemented!("This method was not implemented"); } - /// GET /api/v1/timelines/public - fn get_public_timeline(&self, local: bool) -> Result> { +/// GET /api/v1/timelines/public?local=true + fn get_local_timeline(&self) -> Result> { + unimplemented!("This method was not implemented"); + } +/// GET /api/v1/timelines/public?local=false + fn get_federated_timeline(&self) -> Result> { unimplemented!("This method was not implemented"); } /// GET /api/v1/timelines/tag/:hashtag - fn get_tagged_timeline(&self, hashtag: String, local: bool) -> Result> { + fn get_hashtag_timeline(&self, hashtag: &str, local: bool) -> Result> { unimplemented!("This method was not implemented"); } /// GET /api/v1/accounts/:id/statuses