diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2020-01-03 23:32:44 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2020-01-03 23:32:44 +0100 |
commit | 0c76f0c9727a512475e29b5d099b5b7188f72052 (patch) | |
tree | d1c2b59458c62116447fa2d885113afe6a5378da /examples | |
parent | 5f96d9981a6d041f5c8a464cda10a0dc371060f8 (diff) | |
download | rust-zotapi-0c76f0c9727a512475e29b5d099b5b7188f72052.tar.gz rust-zotapi-0c76f0c9727a512475e29b5d099b5b7188f72052.tar.bz2 rust-zotapi-0c76f0c9727a512475e29b5d099b5b7188f72052.zip |
Move Client out of the api objects.
Also make constructor functions in the zotapi namespace.
Diffstat (limited to 'examples')
-rw-r--r-- | examples/zot/abconfig.rs | 2 | ||||
-rw-r--r-- | examples/zot/abook.rs | 2 | ||||
-rw-r--r-- | examples/zot/item.rs | 4 | ||||
-rw-r--r-- | examples/zot/xchan.rs | 6 | ||||
-rw-r--r-- | examples/zotcli.rs | 12 |
5 files changed, 14 insertions, 12 deletions
diff --git a/examples/zot/abconfig.rs b/examples/zot/abconfig.rs index 54d555c..2362408 100644 --- a/examples/zot/abconfig.rs +++ b/examples/zot/abconfig.rs @@ -18,7 +18,7 @@ use zotapi; pub fn fetch(client: &zotapi::Client) { - match client.abconfig().fetch() { + match zotapi::abconfig().fetch(&client) { Ok(payload) => { println!("{}", payload); } diff --git a/examples/zot/abook.rs b/examples/zot/abook.rs index a16f68c..b710fa7 100644 --- a/examples/zot/abook.rs +++ b/examples/zot/abook.rs @@ -16,7 +16,7 @@ */ pub fn fetch(client: &zotapi::Client, raw: bool) { - match client.abook().fetch() { + match zotapi::abook().fetch(&client) { Ok(payload) => { if raw { println!("{}", &payload); diff --git a/examples/zot/item.rs b/examples/zot/item.rs index dec6c8d..2e07561 100644 --- a/examples/zot/item.rs +++ b/examples/zot/item.rs @@ -19,7 +19,7 @@ use clap::ArgMatches; use zotapi; pub fn post(client: &zotapi::Client, args: &ArgMatches) { - let mut msg = client.item(); + let mut msg = zotapi::item(); msg.body(args.value_of("BODY").unwrap()); if let Some(title) = dbg!(args.value_of("TITLE")) { @@ -36,7 +36,7 @@ pub fn post(client: &zotapi::Client, args: &ArgMatches) { } } - match msg.create() { + match msg.create(&client) { Ok(payload) => { println!("Raw payload: {}", payload); } diff --git a/examples/zot/xchan.rs b/examples/zot/xchan.rs index d2d73d0..2995d0b 100644 --- a/examples/zot/xchan.rs +++ b/examples/zot/xchan.rs @@ -25,9 +25,9 @@ pub enum Type { pub fn fetch(client: &zotapi::Client, _raw: bool, t: Type, id: &str) { let res = match t { - Type::Addr => client.xchan().by_address(&id).fetch(), - Type::Hash => client.xchan().by_hash(&id).fetch(), - Type::GUID => client.xchan().by_guid(&id).fetch(), + Type::Addr => zotapi::xchan().by_address(&id).fetch(&client), + Type::Hash => zotapi::xchan().by_hash(&id).fetch(&client), + Type::GUID => zotapi::xchan().by_guid(&id).fetch(&client), }; match res { diff --git a/examples/zotcli.rs b/examples/zotcli.rs index 14bb9ad..02f51e6 100644 --- a/examples/zotcli.rs +++ b/examples/zotcli.rs @@ -94,10 +94,9 @@ fn main() { } ("group", Some(m)) => { if let Some(id) = m.value_of("ID") { - let res = client - .group_members() + let res = zotapi::group_members() .by_group_id(u64::from_str(id).unwrap()) - .fetch() + .fetch(&client) .unwrap(); if m.is_present("raw") { @@ -106,7 +105,10 @@ fn main() { zot::group::list_members(&res); } } else if let Some(gname) = m.value_of("GNAME") { - let res = client.group_members().by_group_name(gname).fetch().unwrap(); + let res = zotapi::group_members() + .by_group_name(gname) + .fetch(&client) + .unwrap(); if m.is_present("raw") { println!("{}", res); @@ -114,7 +116,7 @@ fn main() { zot::group::list_members(&res); } } else { - let res = client.group().fetch().unwrap(); + let res = zotapi::group().fetch(&client).unwrap(); if m.is_present("raw") { println!("{}", res); |