aboutsummaryrefslogtreecommitdiffstats
path: root/src/item.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/item.rs')
-rw-r--r--src/item.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/item.rs b/src/item.rs
index 7fb751d..3440fd5 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -16,25 +16,32 @@
use client::{self, Client};
use error::Error;
+use std::collections::BTreeMap;
pub struct ItemBuilder<'a> {
client : &'a Client,
- body: &'a str,
+ data : BTreeMap<&'a str, &'a str>,
}
impl<'a> ItemBuilder<'a> {
pub fn new(client: &'a Client) -> ItemBuilder<'a> {
ItemBuilder {
client: client,
- body: "",
+ data: BTreeMap::new(),
}
}
+
+ pub fn title(&mut self, text: &'a str) -> &mut ItemBuilder<'a> {
+ self.data.insert("title", text);
+ self
+ }
+
pub fn body(&mut self, text: &'a str) -> &mut ItemBuilder<'a> {
- self.body = text;
+ self.data.insert("body", text);
self
}
pub fn create(&self) -> Result<String, Error> {
- self.client.post_data(client::ZOTAPI_ITEM_UPDATE_PATH, &[("body", self.body)])
+ self.client.post_data(client::ZOTAPI_ITEM_UPDATE_PATH, &self.data)
}
}