Crate zotero

Source
Expand description

§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));
};

Modules§

data_structure
This module contains all Zotero data structures. This data structures can be used for serialization and deserialization.

Structs§

Zotero
A struct representing a Zotero client.
ZoteroInit
Create a Zotero client for a group library or a user library.

Traits§

Delete
Perform delete operations on Zotero items and collections.
Get
Perform get operations on Zotero items and collections.
Patch
Perform patch operations on Zotero items and collections.
Post
Perform post operations on Zotero items and collections.