diff --git a/src/Pubiblio/ZoteroAPI.class.st b/src/Pubiblio/ZoteroAPI.class.st new file mode 100644 index 0000000..d3f11f0 --- /dev/null +++ b/src/Pubiblio/ZoteroAPI.class.st @@ -0,0 +1,17 @@ +" +I model the information of the Zotero API. I collaborate with other objects to define repetitive API urls. +" +Class { + #name : #ZoteroAPI, + #superclass : #Object, + #category : #Pubiblio +} + +{ #category : #'as yet unclassified' } +ZoteroAPI class >> baseURL [ + "I provide the base URL where the API services are provided. + For more information visit: + + " + ^ 'https://api.zotero.org/' +] diff --git a/src/Pubiblio/ZoteroLibrary.class.st b/src/Pubiblio/ZoteroLibrary.class.st new file mode 100644 index 0000000..586777d --- /dev/null +++ b/src/Pubiblio/ZoteroLibrary.class.st @@ -0,0 +1,113 @@ +" +I allow to query zotero libraries, given the groupID or the userID that the libraries belong to. + +" +Class { + #name : #ZoteroLibrary, + #superclass : #Object, + #instVars : [ + 'groupID', + 'userID' + ], + #category : #Pubiblio +} + +{ #category : #utility } +ZoteroLibrary >> collectionsURL [ + "I provide the common part of the collections URL for the Zotero API" + + ^ self groupURL, '/collections/' +] + +{ #category : #utility } +ZoteroLibrary >> emptyValuesWarning [ + + self inform: 'WARNING! groupID or userID should be non-emtpy. Please fill them to get available collections'. + ^ self +] + +{ #category : #querying } +ZoteroLibrary >> generalInfo [ + "I return the last 25 the public collections for a particular group or user" + ^ NeoJSONReader fromString: (ZnEasy get: self groupURL) contents. +] + +{ #category : #accessing } +ZoteroLibrary >> groupID [ + ^ groupID +] + +{ #category : #accessing } +ZoteroLibrary >> groupID: aString [ + groupID := aString +] + +{ #category : #utility } +ZoteroLibrary >> groupURL [ + "I provide the common part of the group URL for the Zotero API" + + groupID ifNotNil: [ ^ ZoteroAPI baseURL,'groups/',groupID,'/' ]. + userID + ifNotNil: [ ^ ZoteroAPI baseURL,'groups/',userID,'/' ] + ifNil: [ self emptyValuesWarning ] +] + +{ #category : #querying } +ZoteroLibrary >> lastCollections [ + "I return all the public collections for a particular group or user" + ^ NeoJSONReader fromString: (ZnEasy get: self collectionsURL) contents + + +] + +{ #category : #querying } +ZoteroLibrary >> lastItems [ + "I return the last 25 items of the public collections for a particular group or user" + ^ NeoJSONReader fromString: (ZnEasy get: self groupURL,'items') contents +] + +{ #category : #querying } +ZoteroLibrary >> subcollection: keyString [ + "I give the general info for a subcollection, given is alphanumeric key" + + ^ NeoJSONReader fromString: (ZnEasy get: (self subcollectionURL:keyString)) contents. + +] + +{ #category : #querying } +ZoteroLibrary >> subcollectionAsBibTeX: keyString [ + "I give all the items for a subcollection, given is alphanumeric key, excluding notes and attachments, exported as bibtex" + + ^ (ZnEasy get: (self subcollectionURL: keyString,'/items?itemType=-note || attachment &format=bibtex')) contents utf8Decoded. +] + +{ #category : #querying } +ZoteroLibrary >> subcollectionLastItems: keyString [ + "I give the last 25 items for a subcollection, given is alphanumeric key, including notes, attachments" + + ^ NeoJSONReader fromString: (ZnEasy get: (self subcollectionURL: keyString,'/items')) contents. +] + +{ #category : #querying } +ZoteroLibrary >> subcollectionLastParentItems: keyString [ + "I give all the items for a subcollection, given is alphanumeric key, excluding notes and attachments" + + ^ NeoJSONReader fromString: (ZnEasy get: (self subcollectionURL:keyString,'/items?itemType=-note || attachment')) contents. +] + +{ #category : #utility } +ZoteroLibrary >> subcollectionURL: keyString [ + "I provide the common part of the subcollection URL for the Zotero API, given its key string" + + ^ self collectionsURL,keyString +] + +{ #category : #accessing } +ZoteroLibrary >> userID [ + ^ userID +] + +{ #category : #accessing } +ZoteroLibrary >> userID: aString [ + userID := aString +] diff --git a/src/Pubiblio/package.st b/src/Pubiblio/package.st new file mode 100644 index 0000000..ae38061 --- /dev/null +++ b/src/Pubiblio/package.st @@ -0,0 +1 @@ +Package { #name : #Pubiblio }