aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/hubzilla-post.rs2
-rw-r--r--src/lib.rs20
2 files changed, 1 insertions, 21 deletions
diff --git a/examples/hubzilla-post.rs b/examples/hubzilla-post.rs
index 8b9773a..5eb7826 100644
--- a/examples/hubzilla-post.rs
+++ b/examples/hubzilla-post.rs
@@ -36,7 +36,7 @@ fn main() {
let client = zotapi::client(&site, &user, &password);
- match client.create_item(&body) {
+ match client.item().body(&body).create() {
Ok(payload) => {
println!("Raw payload: {}", payload);
},
diff --git a/src/lib.rs b/src/lib.rs
index 4852a94..57724ad 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -105,26 +105,6 @@ impl Client {
ItemBuilder::new(self)
}
- pub fn create_item(&self, body: &str) -> Result<String, Error> {
- let url = self.url(ZOTAPI_ITEM_UPDATE_PATH);
- let mut res = self.inner.post(&url)
- .header(Accept(vec![qitem(mime::APPLICATION_JSON)]))
- .header(ContentType::form_url_encoded())
- .basic_auth(self.user.clone(), Some(self.pw.clone()))
- .form(&[("body", body)])
- .send()?;
-
- match res.status() {
- StatusCode::Unauthorized => Err(Error::Unauthorized),
- StatusCode::Ok => {
- let mut body = String::new();
- res.read_to_string(&mut body)?;
- Ok(body)
- },
- _ => Err(Error::Unknown)
- }
- }
-
fn url(&self, path: &str) -> String {
self.base_url.clone() + path
}