From c9ac54435649973c1aa0543434cc344e66cf33f8 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 9 Jun 2019 22:51:27 +0200 Subject: Fetch privacy groups. --- src/client.rs | 6 ++++++ src/group.rs | 34 ++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 3 files changed, 41 insertions(+) create mode 100644 src/group.rs (limited to 'src') 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 +// +// 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 . + +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 { + 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; -- cgit v1.2.3