aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client.rs16
-rw-r--r--src/item.rs2
-rw-r--r--src/lib.rs6
3 files changed, 10 insertions, 14 deletions
diff --git a/src/client.rs b/src/client.rs
index fcafed3..d37133f 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -33,16 +33,16 @@ pub struct Client {
pw: String,
}
-impl Client {
- pub fn new(base_url: &str, user: &str, pw: &str) -> Client {
- Client {
- inner: reqwest::Client::new(),
- base_url: Url::parse(base_url).unwrap().join("api/z/1.0/").unwrap(),
- user: String::from(user),
- pw: String::from(pw),
- }
+pub fn client(url: &str, user: &str, pw: &str) -> Client {
+ Client {
+ inner: reqwest::Client::new(),
+ base_url: Url::parse(url).unwrap().join("api/z/1.0/").unwrap(),
+ user: String::from(user),
+ pw: String::from(pw),
}
+}
+impl Client {
fn url<T>(&self, path: &str, args: &T) -> String
where
T: Serialize + std::fmt::Debug,
diff --git a/src/item.rs b/src/item.rs
index 52492aa..846c674 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -74,7 +74,7 @@ fn convert_itemdata_list_with_one_member_to_a_string() {
/// Typical usage:
///
/// ```no_run
-/// let client = zotapi::Client::new("https://myhub.com", "mychannel", "mypw");
+/// let client = zotapi::client("https://myhub.com", "mychannel", "mypw");
/// let new_post = zotapi::item()
/// .title("A title")
/// .body("The body of the post")
diff --git a/src/lib.rs b/src/lib.rs
index d89eb46..12396ca 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -27,17 +27,13 @@ mod xchan;
pub use abconfig::abconfig;
pub use abook::abook;
pub use channel_stream::channel_stream;
-pub use client::Client;
+pub use client::*;
pub use error::Error;
pub use group::{group, group_members};
pub use item::item;
pub use network_stream::network_stream;
pub use xchan::xchan;
-pub fn client(url: &str, user: &str, pw: &str) -> Client {
- Client::new(url, user, pw)
-}
-
#[cfg(test)]
mod tests {
#[test]