5 releases

0.0.3-alpha Oct 20, 2019
0.0.2 Oct 21, 2019
0.0.2-alpha Oct 20, 2019
0.0.1 Oct 20, 2019

#1276 in Data structures

MIT license

200KB
4.5K SLoC

Zotero

Build Status Coverage Status License: MIT contributions welcome

API documentation

Creating items and collections

extern crate zotero;
use zotero::ZoteroInit;
use zotero::Post;
use zotero::data_structure::item::{BookData, BookDataBuilder, Creator, CreatorBuilder};

let z = ZoteroInit::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();
    
z.create_new_item(new_book);

Updating items and collections

extern crate zotero;
use zotero::ZoteroInit;
use zotero::Patch;
use zotero::Get;
use zotero::data_structure::item::ItemType;

let z = ZoteroInit::set_user("123456789", "bZARysJ579K5SdmYuaAJ");

let item = z.get_item("Q8GNE36F", None);

if let Ok(mut result) = item {
    if let ItemType::Book(bookdata) = &mut result.data {
        bookdata.title = "A new title".to_string();
        bookdata.publisher = "A new publisher".to_string();
        z.update_item(&bookdata.key, &bookdata);
    };
    println!("{:?}", serde_json::to_string(&result.data));
};

Dependencies

~20MB
~433K SLoC