diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/client.rs | 6 | ||||
-rw-r--r-- | src/group.rs | 34 | ||||
-rw-r--r-- | src/lib.rs | 1 |
3 files changed, 41 insertions, 0 deletions
diff --git a/src/client.rs b/src/client.rs index 138b80c..d5d264a 100644 --- a/src/client.rs +++ b/src/client.rs @@ -16,6 +16,7 @@ use crate::{ error::Error, + group::GroupFetcher, item::ItemBuilder, abook::AbookFetcher, abconfig::ABConfigFetcher, @@ -35,6 +36,7 @@ pub const ZOTAPI_ABOOK_PATH : &str = "/api/z/1.0/abook"; pub const ZOTAPI_ABCONFIG_PATH : &str = "/api/z/1.0/abconfig"; pub const ZOTAPI_CHANNEL_STREAM_PATH : &str = "/api/z/1.0/channel/stream"; pub const ZOTAPI_NETWORK_STREAM_PATH : &str = "/api/z/1.0/network/stream"; +pub const ZOTAPI_GROUP_PATH : &str = "/api/z/1.0/group"; pub const ZOTAPI_ITEM_UPDATE_PATH : &str = "/api/z/1.0/item/update"; pub const ZOTAPI_XCHAN_PATH : &str = "/api/z/1.0/xchan"; @@ -71,6 +73,10 @@ impl Client { self.fetch_stream(ZOTAPI_NETWORK_STREAM_PATH, &()) } + pub fn group(&self) -> GroupFetcher { + GroupFetcher::new(self) + } + pub fn item(&self) -> ItemBuilder { ItemBuilder::new(self) } diff --git a/src/group.rs b/src/group.rs new file mode 100644 index 0000000..64a6847 --- /dev/null +++ b/src/group.rs @@ -0,0 +1,34 @@ +// zotapi - Rust wrapper for Sot API as implemented by Hubzilla +// Copyright (C) 2018 Harald Eilertsen <haraldei@anduin.net> +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <https://www.gnu.org/licenses/>. + +use crate::{ + client::{self, Client}, + error::Error, +}; + +pub struct GroupFetcher<'a> { + client: &'a Client, +} + +impl<'a> GroupFetcher<'a> { + pub fn new(client: &'a Client) -> GroupFetcher<'a> { + GroupFetcher { client } + } + + pub fn fetch(&self) -> Result<String, Error> { + self.client.fetch_stream(client::ZOTAPI_GROUP_PATH, &()) + } +} @@ -22,6 +22,7 @@ mod abconfig; mod abook; mod client; mod error; +mod group; mod item; mod xchan; |