aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2019-06-09 22:51:27 +0200
committerHarald Eilertsen <haraldei@anduin.net>2019-06-09 22:51:27 +0200
commitc9ac54435649973c1aa0543434cc344e66cf33f8 (patch)
tree6209b40117a60896c0d018b09a68d3e3a3690c46 /src
parent051e884f55162498bae05e796b431e9122313c11 (diff)
downloadrust-zotapi-c9ac54435649973c1aa0543434cc344e66cf33f8.tar.gz
rust-zotapi-c9ac54435649973c1aa0543434cc344e66cf33f8.tar.bz2
rust-zotapi-c9ac54435649973c1aa0543434cc344e66cf33f8.zip
Fetch privacy groups.
Diffstat (limited to 'src')
-rw-r--r--src/client.rs6
-rw-r--r--src/group.rs34
-rw-r--r--src/lib.rs1
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, &())
+ }
+}
diff --git a/src/lib.rs b/src/lib.rs
index be8cb9c..9ec45e4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -22,6 +22,7 @@ mod abconfig;
mod abook;
mod client;
mod error;
+mod group;
mod item;
mod xchan;