Basic querying functionality.
This commit is contained in:
parent
c47fd28f40
commit
792f43afa6
|
@ -0,0 +1,115 @@
|
|||
"
|
||||
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 : #Zotero
|
||||
}
|
||||
|
||||
{ #category : #querying }
|
||||
ZoteroLibrary >> collections [
|
||||
"I return all the public collections for a particular group or user"
|
||||
groupID ifNotNil:
|
||||
[ ^ NeoJSONReader fromString: (ZnEasy get: 'https://api.zotero.org/groups/',groupID,'/collections') contents ].
|
||||
userID
|
||||
ifNotNil:
|
||||
[ ^ NeoJSONReader fromString: (ZnEasy get: 'https://api.zotero.org/users/',userID,'/collections') contents ]
|
||||
ifNil:
|
||||
[ self inform: '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"
|
||||
groupID ifNotNil:
|
||||
[ ^ NeoJSONReader fromString: (ZnEasy get: 'https://api.zotero.org/groups/',groupID) contents ].
|
||||
userID
|
||||
ifNotNil:
|
||||
[ ^ NeoJSONReader fromString: (ZnEasy get: 'https://api.zotero.org/users/',userID) contents ]
|
||||
ifNil:
|
||||
[ self inform: 'groupID or userID should be non-emtpy. Please fill them to get the general information'.
|
||||
^ self ].
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
ZoteroLibrary >> groupID [
|
||||
^ groupID
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
ZoteroLibrary >> groupID: anObject [
|
||||
groupID := anObject
|
||||
]
|
||||
|
||||
{ #category : #querying }
|
||||
ZoteroLibrary >> items [
|
||||
"I return the last 25 items of the public collections for a particular group or user"
|
||||
groupID ifNotNil:
|
||||
[ ^ NeoJSONReader fromString: (ZnEasy get: 'https://api.zotero.org/groups/',groupID,'/items') contents ].
|
||||
userID
|
||||
ifNotNil:
|
||||
[ ^ NeoJSONReader fromString: (ZnEasy get: 'https://api.zotero.org/users/',userID,'/items') contents ]
|
||||
ifNil:
|
||||
[ self inform: 'groupID or userID should be non-emtpy. Please fill them to get related items'.
|
||||
^ self ].
|
||||
]
|
||||
|
||||
{ #category : #querying }
|
||||
ZoteroLibrary >> subcollectionInfoForKey: keyString [
|
||||
"I give the general info for a subcollection, given is alphanumeric key"
|
||||
|
||||
groupID ifNotNil:
|
||||
[ ^ NeoJSONReader fromString: (ZnEasy get: 'https://api.zotero.org/groups/',groupID,'/collections/',keyString) contents ].
|
||||
userID
|
||||
ifNotNil: [
|
||||
^ NeoJSONReader fromString: (ZnEasy get: 'https://api.zotero.org/users/',userID,'/collections/',keyString) contents ]
|
||||
ifNil: [ self inform: 'groupID or userID should be not nil. Please fill them to get a proper answer.'.
|
||||
^ self ]
|
||||
]
|
||||
|
||||
{ #category : #querying }
|
||||
ZoteroLibrary >> subcollectionItemsForKey: keyString [
|
||||
"I give all the items for a subcollection, given is alphanumeric key, including notes, attachments"
|
||||
|
||||
groupID ifNotNil:
|
||||
[ ^ NeoJSONReader
|
||||
fromString: (ZnEasy get: 'https://api.zotero.org/groups/',groupID,'/collections/',keyString,'/items') contents ].
|
||||
userID
|
||||
ifNotNil: [
|
||||
^ NeoJSONReader fromString:
|
||||
(ZnEasy get: 'https://api.zotero.org/users/',userID,'/collections/',keyString,'/items') contents ]
|
||||
ifNil: [ self inform: 'groupID or userID should be not nil. Please fill them to get a proper answer.'.
|
||||
^ self ]
|
||||
]
|
||||
|
||||
{ #category : #querying }
|
||||
ZoteroLibrary >> subcollectionParentItemsForKey: keyString [
|
||||
"I give all the items for a subcollection, given is alphanumeric key, excluding notes and attachments"
|
||||
|
||||
groupID ifNotNil:
|
||||
[ ^ NeoJSONReader
|
||||
fromString: (ZnEasy get: 'https://api.zotero.org/groups/',groupID,'/collections/',keyString,'/items?itemType=-note || attachment') contents ].
|
||||
userID
|
||||
ifNotNil: [
|
||||
^ NeoJSONReader fromString:
|
||||
(ZnEasy get: 'https://api.zotero.org/users/',userID,'/collections/',keyString,'/items?itemType=-note || attachment') contents ]
|
||||
ifNil: [ self inform: 'groupID or userID should be not nil. Please fill them to get a proper answer.'.
|
||||
^ self ]
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
ZoteroLibrary >> userID [
|
||||
^ userID
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
ZoteroLibrary >> userID: anObject [
|
||||
userID := anObject
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
Package { #name : #Zotero }
|
Loading…
Reference in New Issue