mod item_data;
pub use item_data::ArtworkData;
pub use item_data::ArtworkDataBuilder;
pub use item_data::AttachmentData;
pub use item_data::AttachmentDataBuilder;
pub use item_data::AudioRecordingData;
pub use item_data::AudioRecordingDataBuilder;
pub use item_data::BillData;
pub use item_data::BillDataBuilder;
pub use item_data::BlogPostData;
pub use item_data::BlogPostDataBuilder;
pub use item_data::BookData;
pub use item_data::BookDataBuilder;
pub use item_data::BookSectionData;
pub use item_data::BookSectionDataBuilder;
pub use item_data::CaseData;
pub use item_data::CaseDataBuilder;
pub use item_data::ComputerProgramData;
pub use item_data::ComputerProgramDataBuilder;
pub use item_data::ConferencePaperData;
pub use item_data::ConferencePaperDataBuilder;
pub use item_data::DictionaryEntryData;
pub use item_data::DictionaryEntryDataBuilder;
pub use item_data::DocumentData;
pub use item_data::DocumentDataBuilder;
pub use item_data::EmailData;
pub use item_data::EmailDataBuilder;
pub use item_data::EncyclopediaArticleData;
pub use item_data::EncyclopediaArticleDataBuilder;
pub use item_data::FilmData;
pub use item_data::FilmDataBuilder;
pub use item_data::ForumPostData;
pub use item_data::ForumPostDataBuilder;
pub use item_data::HearingData;
pub use item_data::HearingDataBuilder;
pub use item_data::InstantMessageData;
pub use item_data::InstantMessageDataBuilder;
pub use item_data::InterviewData;
pub use item_data::InterviewDataBuilder;
pub use item_data::JournalArticleData;
pub use item_data::JournalArticleDataBuilder;
pub use item_data::LetterData;
pub use item_data::LetterDataBuilder;
pub use item_data::MagazineArticleData;
pub use item_data::MagazineArticleDataBuilder;
pub use item_data::ManuscriptData;
pub use item_data::ManuscriptDataBuilder;
pub use item_data::MapData;
pub use item_data::MapDataBuilder;
pub use item_data::NewspaperArticleData;
pub use item_data::NewspaperArticleDataBuilder;
pub use item_data::NoteData;
pub use item_data::NoteDataBuilder;
pub use item_data::PatentData;
pub use item_data::PatentDataBuilder;
pub use item_data::PodcastData;
pub use item_data::PodcastDataBuilder;
pub use item_data::PresentationData;
pub use item_data::PresentationDataBuilder;
pub use item_data::RadioBroadcastData;
pub use item_data::RadioBroadcastDataBuilder;
pub use item_data::ReportData;
pub use item_data::ReportDataBuilder;
pub use item_data::StatuteData;
pub use item_data::StatuteDataBuilder;
pub use item_data::ThesisData;
pub use item_data::ThesisDataBuilder;
pub use item_data::TvBroadcastData;
pub use item_data::TvBroadcastDataBuilder;
pub use item_data::VideoRecordingData;
pub use item_data::VideoRecordingDataBuilder;
pub use item_data::WebpageData;
pub use item_data::WebpageDataBuilder;
use crate::data_structure::shared_fields::{Library, Links};
use derive_builder::Builder;
use serde::Deserialize;
use serde::Serialize;
#[derive(Deserialize, Serialize, Debug, Clone)]
#[serde(rename_all = "camelCase", tag = "itemType")]
pub enum ItemType {
Artwork(ArtworkData),
AudioRecording(AudioRecordingData),
Bill(BillData),
BlogPost(BlogPostData),
Book(BookData),
BookSection(BookSectionData),
Case(CaseData),
ComputerProgram(ComputerProgramData),
ConferencePaper(ConferencePaperData),
DictionaryEntry(DictionaryEntryData),
Document(DocumentData),
Email(EmailData),
EncyclopediaArticle(EncyclopediaArticleData),
Film(FilmData),
ForumPost(ForumPostData),
Hearing(HearingData),
InstantMessage(InstantMessageData),
Interview(InterviewData),
JournalArticle(JournalArticleData),
Letter(LetterData),
MagazineArticle(MagazineArticleData),
Manuscript(ManuscriptData),
Map(MapData),
NewspaperArticle(NewspaperArticleData),
Patent(PatentData),
Podcast(PodcastData),
Presentation(PresentationData),
RadioBroadcast(RadioBroadcastData),
Report(ReportData),
Statute(StatuteData),
Thesis(ThesisData),
TvBroadcast(TvBroadcastData),
VideoRecording(VideoRecordingData),
Webpage(WebpageData),
Attachment(AttachmentData),
Note(NoteData),
}
#[derive(Deserialize, Serialize, Debug, Clone)]
pub struct Item {
pub key: String,
pub version: usize,
pub library: Library,
pub links: Links,
pub meta: ItemMeta,
pub data: ItemType,
}
#[derive(Deserialize, Serialize, Default, Clone, Debug, Builder, PartialEq)]
#[serde(rename_all(deserialize = "camelCase", serialize = "camelCase"))]
#[builder(setter(into), default)]
pub struct Creator {
#[serde(alias = "creatorType")]
pub creator_type: String,
#[serde(alias = "firstName")]
pub first_name: String,
#[serde(alias = "lastName")]
pub last_name: String,
}
#[derive(Deserialize, Serialize, Debug, PartialEq, Clone)]
#[serde(rename_all(deserialize = "camelCase", serialize = "camelCase"))]
pub struct ItemMeta {
pub creator_summary: Option<String>,
pub parsed_date: Option<String>,
pub num_children: Option<usize>,
pub num_collections: Option<usize>,
pub num_items: Option<usize>,
}
#[cfg(test)]
mod test_item_deserialization {
use super::*;
#[test]
fn item_deserialization() {
let input = r#"
{
"key": "4X5CQGQA",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/4X5CQGQA",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/4X5CQGQA",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "4X5CQGQA",
"version": 2444,
"itemType": "bookSection",
"title": "",
"creators": [],
"abstractNote": "",
"bookTitle": "",
"series": "",
"seriesNumber": "",
"volume": "",
"numberOfVolumes": "",
"edition": "",
"place": "",
"publisher": "",
"date": "",
"pages": "",
"language": "",
"ISBN": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:17:23Z",
"dateModified": "2019-10-01T21:17:23Z"
}
}
"#;
serde_json::from_str::<Item>(input).expect("Failed to parse zotero data");
assert!(true)
}
#[test]
fn items_deserialization() {
let input = r#"
[
{
"key": "4X5CQGQA",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/4X5CQGQA",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/4X5CQGQA",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "4X5CQGQA",
"version": 2444,
"itemType": "bookSection",
"title": "",
"creators": [
{
"creatorType": "author",
"firstName": "John",
"lastName": "Doe"
}
],
"abstractNote": "",
"bookTitle": "",
"series": "",
"seriesNumber": "",
"volume": "",
"numberOfVolumes": "",
"edition": "",
"place": "",
"publisher": "",
"date": "",
"pages": "",
"language": "",
"ISBN": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:17:23Z",
"dateModified": "2019-10-01T21:17:23Z"
}
},
{
"key": "4H5SBMDE",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/4H5SBMDE",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/4H5SBMDE",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "4H5SBMDE",
"version": 2444,
"itemType": "map",
"title": "",
"creators": [],
"abstractNote": "",
"mapType": "",
"scale": "",
"seriesTitle": "",
"edition": "",
"place": "",
"publisher": "",
"date": "",
"language": "",
"ISBN": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:17:19Z",
"dateModified": "2019-10-01T21:17:19Z"
}
},
{
"key": "SAU7PP79",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/SAU7PP79",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/SAU7PP79",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "SAU7PP79",
"version": 2444,
"itemType": "patent",
"title": "",
"creators": [],
"abstractNote": "",
"place": "",
"country": "",
"assignee": "",
"issuingAuthority": "",
"patentNumber": "",
"filingDate": "",
"pages": "",
"applicationNumber": "",
"priorityNumbers": "",
"issueDate": "",
"references": "",
"legalStatus": "",
"language": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:17:16Z",
"dateModified": "2019-10-01T21:17:16Z"
}
},
{
"key": "25DYFG56",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/25DYFG56",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/25DYFG56",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "25DYFG56",
"version": 2444,
"itemType": "blogPost",
"title": "",
"creators": [],
"abstractNote": "",
"blogTitle": "",
"websiteType": "",
"date": "",
"url": "",
"accessDate": "",
"language": "",
"shortTitle": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:17:13Z",
"dateModified": "2019-10-01T21:17:13Z"
}
},
{
"key": "U4AP5MUH",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/U4AP5MUH",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/U4AP5MUH",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "U4AP5MUH",
"version": 2444,
"itemType": "podcast",
"title": "",
"creators": [],
"abstractNote": "",
"seriesTitle": "",
"episodeNumber": "",
"audioFileType": "",
"runningTime": "",
"url": "",
"accessDate": "",
"language": "",
"shortTitle": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:17:10Z",
"dateModified": "2019-10-01T21:17:10Z"
}
},
{
"key": "SD5EWBBC",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/SD5EWBBC",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/SD5EWBBC",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "SD5EWBBC",
"version": 2444,
"itemType": "journalArticle",
"title": "",
"creators": [],
"abstractNote": "",
"publicationTitle": "",
"volume": "",
"issue": "",
"pages": "",
"date": "",
"series": "",
"seriesTitle": "",
"seriesText": "",
"journalAbbreviation": "",
"language": "",
"DOI": "",
"ISSN": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:16:58Z",
"dateModified": "2019-10-01T21:16:58Z"
}
},
{
"key": "9XZ2W4RU",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/9XZ2W4RU",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/9XZ2W4RU",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "9XZ2W4RU",
"version": 2444,
"itemType": "magazineArticle",
"title": "",
"creators": [],
"abstractNote": "",
"publicationTitle": "",
"volume": "",
"issue": "",
"date": "",
"pages": "",
"language": "",
"ISSN": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:16:56Z",
"dateModified": "2019-10-01T21:16:56Z"
}
},
{
"key": "EFZTBRBT",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/EFZTBRBT",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/EFZTBRBT",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "EFZTBRBT",
"version": 2444,
"itemType": "newspaperArticle",
"title": "",
"creators": [],
"abstractNote": "",
"publicationTitle": "",
"place": "",
"edition": "",
"date": "",
"section": "",
"pages": "",
"language": "",
"shortTitle": "",
"ISSN": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:16:53Z",
"dateModified": "2019-10-01T21:16:53Z"
}
},
{
"key": "5G7FQMJH",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/5G7FQMJH",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/5G7FQMJH",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "5G7FQMJH",
"version": 2444,
"itemType": "conferencePaper",
"title": "",
"creators": [],
"abstractNote": "",
"date": "",
"proceedingsTitle": "",
"conferenceName": "",
"place": "",
"publisher": "",
"volume": "",
"pages": "",
"series": "",
"language": "",
"DOI": "",
"ISBN": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:16:50Z",
"dateModified": "2019-10-01T21:16:50Z"
}
},
{
"key": "48UAQNNN",
"version": 2444,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/48UAQNNN",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/48UAQNNN",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "48UAQNNN",
"version": 2444,
"itemType": "encyclopediaArticle",
"title": "",
"creators": [],
"abstractNote": "",
"encyclopediaTitle": "",
"series": "",
"seriesNumber": "",
"volume": "",
"numberOfVolumes": "",
"edition": "",
"place": "",
"publisher": "",
"date": "",
"pages": "",
"ISBN": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"language": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T21:16:45Z",
"dateModified": "2019-10-01T21:16:45Z"
}
},
{
"key": "5I47RLH3",
"version": 2438,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/5I47RLH3",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/5I47RLH3",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "5I47RLH3",
"version": 2438,
"itemType": "videoRecording",
"title": "",
"creators": [],
"abstractNote": "",
"videoRecordingFormat": "",
"seriesTitle": "",
"volume": "",
"numberOfVolumes": "",
"place": "",
"studio": "",
"date": "",
"runningTime": "",
"language": "",
"ISBN": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:36:01Z",
"dateModified": "2019-10-01T13:36:01Z"
}
},
{
"key": "T9GKB3IR",
"version": 2438,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/T9GKB3IR",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/T9GKB3IR",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "T9GKB3IR",
"version": 2438,
"itemType": "radioBroadcast",
"title": "",
"creators": [],
"abstractNote": "",
"programTitle": "",
"episodeNumber": "",
"audioRecordingFormat": "",
"place": "",
"network": "",
"date": "",
"runningTime": "",
"language": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:35:16Z",
"dateModified": "2019-10-01T13:35:16Z"
}
},
{
"key": "QPDKPRGL",
"version": 2437,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/QPDKPRGL",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/QPDKPRGL",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "QPDKPRGL",
"version": 2437,
"itemType": "patent",
"title": "",
"creators": [],
"abstractNote": "",
"place": "",
"country": "",
"assignee": "",
"issuingAuthority": "",
"patentNumber": "",
"filingDate": "",
"pages": "",
"applicationNumber": "",
"priorityNumbers": "",
"issueDate": "",
"references": "",
"legalStatus": "",
"language": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:35:07Z",
"dateModified": "2019-10-01T13:35:07Z"
}
},
{
"key": "MD62TVCE",
"version": 2437,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/MD62TVCE",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/MD62TVCE",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "MD62TVCE",
"version": 2437,
"itemType": "map",
"title": "",
"creators": [],
"abstractNote": "",
"mapType": "",
"scale": "",
"seriesTitle": "",
"edition": "",
"place": "",
"publisher": "",
"date": "",
"language": "",
"ISBN": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"archive": "",
"archiveLocation": "",
"libraryCatalog": "",
"callNumber": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:35:01Z",
"dateModified": "2019-10-01T13:35:01Z"
}
},
{
"key": "L77RMQ8J",
"version": 2437,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/L77RMQ8J",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/L77RMQ8J",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "L77RMQ8J",
"version": 2437,
"itemType": "instantMessage",
"title": "",
"creators": [],
"abstractNote": "",
"date": "",
"language": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:34:56Z",
"dateModified": "2019-10-01T13:34:56Z"
}
},
{
"key": "77NPSQY5",
"version": 2437,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/77NPSQY5",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/77NPSQY5",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "77NPSQY5",
"version": 2437,
"itemType": "hearing",
"title": "",
"creators": [],
"abstractNote": "",
"committee": "",
"place": "",
"publisher": "",
"numberOfVolumes": "",
"documentNumber": "",
"pages": "",
"legislativeBody": "",
"session": "",
"history": "",
"date": "",
"language": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:34:50Z",
"dateModified": "2019-10-01T13:34:50Z"
}
},
{
"key": "3L59IWHK",
"version": 2437,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/3L59IWHK",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/3L59IWHK",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "3L59IWHK",
"version": 2437,
"itemType": "statute",
"nameOfAct": "",
"creators": [],
"abstractNote": "",
"code": "",
"codeNumber": "",
"publicLawNumber": "",
"dateEnacted": "",
"pages": "",
"section": "",
"session": "",
"history": "",
"language": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:34:43Z",
"dateModified": "2019-10-01T13:34:43Z"
}
},
{
"key": "QFRII6XJ",
"version": 2437,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/0000000/items/QFRII6XJ",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/QFRII6XJ",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "QFRII6XJ",
"version": 2437,
"itemType": "case",
"caseName": "",
"creators": [],
"abstractNote": "",
"reporter": "",
"reporterVolume": "",
"court": "",
"docketNumber": "",
"firstPage": "",
"history": "",
"dateDecided": "",
"language": "",
"shortTitle": "",
"url": "",
"accessDate": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:34:40Z",
"dateModified": "2019-10-01T13:34:40Z"
}
},
{
"key": "K36LXQI5",
"version": 2437,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/1000000/items/K36LXQI5",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/K36LXQI5",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "K36LXQI5",
"version": 2437,
"itemType": "bill",
"title": "",
"creators": [],
"abstractNote": "",
"billNumber": "",
"code": "",
"codeVolume": "",
"section": "",
"codePages": "",
"legislativeBody": "",
"session": "",
"history": "",
"date": "",
"language": "",
"url": "",
"accessDate": "",
"shortTitle": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:34:30Z",
"dateModified": "2019-10-01T13:34:30Z"
}
}
]
"#;
serde_json::from_str::<Vec<Item>>(input).expect("Failed to parse zotero data");
assert!(true);
}
#[test]
fn test_deserialize_creators() {
let expected_output = Creator {
creator_type: "author".into(),
first_name: "John".into(),
last_name: "Doe".into(),
};
let input = r#"
{
"creatorType": "author",
"firstName": "John",
"lastName": "Doe"
}
"#;
let result = serde_json::from_str::<Creator>(input).unwrap();
assert_eq!(result, expected_output);
}
#[test]
fn test_item_meta_deserialization() {
let expected_output = ItemMeta {
creator_summary: Some("Lorem".into()),
parsed_date: Some("25-2-2019".into()),
num_children: Some(1 as usize),
num_collections: Some(1 as usize),
num_items: Some(0 as usize),
};
let input = r#"
{
"creatorSummary" : "Lorem",
"parsedDate": "25-2-2019",
"numChildren": 1,
"numCollections": 1,
"numItems": 0
}
"#;
let result = serde_json::from_str::<ItemMeta>(input).unwrap();
assert_eq!(result, expected_output);
}
#[test]
fn test_item_deserialization() {
let input = r#"
{
"key": "K36LXQI5",
"version": 2437,
"library": {
"type": "user",
"id": 1000000,
"name": "john.doe",
"links": {
"alternate": {
"href": "https://www.zotero.org/john.doe",
"type": "text/html"
}
}
},
"links": {
"self": {
"href": "https://api.zotero.org/users/1000000/items/K36LXQI5",
"type": "application/json"
},
"alternate": {
"href": "https://www.zotero.org/john.doe/items/K36LXQI5",
"type": "text/html"
}
},
"meta": {
"numChildren": 0
},
"data": {
"key": "K36LXQI5",
"version": 2437,
"itemType": "bill",
"title": "",
"creators": [],
"abstractNote": "",
"billNumber": "",
"code": "",
"codeVolume": "",
"section": "",
"codePages": "",
"legislativeBody": "",
"session": "",
"history": "",
"date": "",
"language": "",
"url": "",
"accessDate": "",
"shortTitle": "",
"rights": "",
"extra": "",
"tags": [],
"collections": [
"TYPDZEZF"
],
"relations": {},
"dateAdded": "2019-10-01T13:34:30Z",
"dateModified": "2019-10-01T13:34:30Z"
}
}
"#;
serde_json::from_str::<Item>(input).expect("Failed to deserialize item");
assert!(true);
}
}