pub struct ZoteroWebClient {
client: Client,
api_key: String,
base_url: String,
}Expand description
Blocking client for the Zotero Web API v3.
Fields§
§client: Client§api_key: String§base_url: StringImplementations§
Source§impl ZoteroWebClient
impl ZoteroWebClient
Sourcepub fn new(api_key: &str, library_id: &str, library_type: &str) -> Self
pub fn new(api_key: &str, library_id: &str, library_type: &str) -> Self
Create a new client for a user library.
Sourcepub fn with_base_url(api_key: &str, base_url: &str) -> Self
pub fn with_base_url(api_key: &str, base_url: &str) -> Self
Create a client with a custom base URL (for testing).
Sourcepub fn children(&self, key: &str) -> Result<Vec<Value>>
pub fn children(&self, key: &str) -> Result<Vec<Value>>
GET children of an item (attachments, notes).
Sourcepub fn item_template(&self, item_type: &str) -> Result<Value>
pub fn item_template(&self, item_type: &str) -> Result<Value>
GET an item template for a given type.
Note: the template endpoint is global (/items/new), not scoped
to a user library. We use the API root, not self.base_url.
Sourcepub fn create_items(&self, items: &[Value]) -> Result<Value>
pub fn create_items(&self, items: &[Value]) -> Result<Value>
POST new items to the library.
Sourcepub fn update_item(&self, key: &str, data: &Value, version: i32) -> Result<()>
pub fn update_item(&self, key: &str, data: &Value, version: i32) -> Result<()>
PATCH (update) an existing item.
Requires the item’s current version for optimistic concurrency.
Sourcepub fn get_collections(&self) -> Result<Vec<Value>>
pub fn get_collections(&self) -> Result<Vec<Value>>
GET all collections.
Sourcepub fn create_collections(&self, collections: &[Value]) -> Result<Value>
pub fn create_collections(&self, collections: &[Value]) -> Result<Value>
POST new collections.
Sourcepub fn download_file(&self, url: &str, dest: &Path) -> Result<()>
pub fn download_file(&self, url: &str, dest: &Path) -> Result<()>
Download a file from a URL to a local path.
Sourcepub fn attach_file(
&self,
parent_key: &str,
file_path: &Path,
title: &str,
) -> Result<Value>
pub fn attach_file( &self, parent_key: &str, file_path: &Path, title: &str, ) -> Result<Value>
Upload a file attachment to an item.
Implements the full Zotero file upload protocol:
- Create attachment item metadata
- Get upload authorization (with file hash)
- Upload file bytes to S3
- Register the upload with Zotero
Step 2: Get upload authorization from Zotero.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ZoteroWebClient
impl !RefUnwindSafe for ZoteroWebClient
impl Send for ZoteroWebClient
impl Sync for ZoteroWebClient
impl Unpin for ZoteroWebClient
impl !UnwindSafe for ZoteroWebClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more