use zotero_api::{Zotero, ZoteroApi, ZoteroApiExecutor};
use zotero_data::item::{BookData, BookDataBuilder, Creator, CreatorBuilder};
let z = Zotero::set_user("123456789", "bZARysJ579K5SdmYuaAJ");
let creators : Vec<Creator> = vec![
CreatorBuilder::default()
.creator_type("author")
.first_name("John")
.last_name("Doe")
.build()
.unwrap()
];
let new_book : BookData = BookDataBuilder::default()
.title("Sample_2")
.creators(creators)
.item_type("book")
.build()
.unwrap();
let _: Result<(), _> = z.create_new_item(new_book).execute(&z);
use zotero_api::{Zotero, ZoteroApi, ZoteroApiExecutor};
use zotero_data::item::ItemType;
let z = Zotero::set_user("123456789", "bZARysJ579K5SdmYuaAJ");
let item: Result<ItemType, _> = z.get_item("Q8GNE36F", None).execute(&z);
if let Ok(mut result) = item {
if let ItemType::Book(bookdata) = &mut result {
bookdata.title = "A new title".to_string();
bookdata.publisher = "A new publisher".to_string();
let _: Result<(),_> =z.update_item(&bookdata.key, &bookdata).execute(&z);
};
println!("{:?}", serde_json::to_string(&result));
};
use zotero_api::{Zotero, ZoteroApi, ZoteroApiAsyncExecutor};
use zotero_data::Item;
let z = Zotero::set_user("123456789", "bZARysJ579K5SdmYuaAJ");
let item_result: Result<Item, _> = z.get_item("Q8GNE36F", None).execute(&z).await;
println!("{item_result:#?}")