Item class
- class almapiwrapper.inventory.Item(mms_id: str | None = None, holding_id: str | None = None, item_id: str | None = None, zone: str | None = None, env: Literal['P', 'S'] | None = 'P', holding: Holding | None = None, barcode: str | None = None, data: Element | None = None, create_item: bool | None = False)
Bases:
RecordClass representing an item.
- There are several possibilities to get item information:
‘get_items’ method of
almapiwrapper.inventory.HoldingobjectItem(mms_id, holding_id, item_id, zone, env)
Item(holding=:class:almapiwrapper.inventory.Holding, item_id=item_id)
Item(barcode=’barcode’, zone=’zone’, env=’env’)
- Create an item:
Item(holding=:class:almapiwrapper.inventory.Holding, data=`almapiwrapper.record.XmlData`, create_item=True)
- Variables:
item_id – numerical ID of the item
zone – zone of the record
env – environment of the entity: ‘P’ for production and ‘S’ for sandbox
holding –
almapiwrapper.inventory.Holdingobjectdata –
almapiwrapper.record.XmlDataobject, useful to force update a record from a backuperror – boolean indicating if an error occurred during the last operation
error_msg – string containing the error message if an error occurred during the last operation
api_base_url_items – base URL for items API calls
api_base_url_bibs – base URL for bibs API calls
area – area of the API
format – format of the data xml for items
- Parameters:
barcode – string with barcode of the item
mms_id – bib record mms_id
holding_id – holding record ID
item_id – numerical ID of the item
zone – zone of the record
env – environment of the entity: ‘P’ for production and ‘S’ for sandbox
holding –
almapiwrapper.inventory.Holdingobjectdata –
almapiwrapper.record.XmlDataobject or etree.Element, useful to force update a record from a backup or to create a new itemcreate_item – when True, create a new item
- static api_call(method: Literal['get', 'put', 'post', 'delete'], *args, **kwargs) Response | None
Static method to handle http errors. Quit the program after 3 failed tries
- Parameters:
method – ‘get’, ‘put’, ‘post’ or ‘delete’ according to the api method call
- Item.barcode -> Optional[str]
Property of the item returning the barcode
- Returns:
str, library code
- property bib: IzBib | None
Property of the item returning the
almapiwrapper.inventory.IzBibobject- Returns:
almapiwrapper.inventory.IzBibor None
- static build_headers(data_format: Literal['json', 'xml'], zone: str, area: str, rights: Literal['R', 'RW'] = 'RW', env: Literal['P', 'S'] | None = 'P') Dict
Build the headers for the API calls.
- Parameters:
data_format – “json” or “xml”
zone – optional, if indicated allow to make the query in an other IZ
area – area of the record, bibs, users for example
rights – “R” for read only or “RW” for write and read rights
env – environment of the api call: ‘P’ for production, ‘S’ for sandbox
- Returns:
dict with the headers
- property data: Dict | Element | DataFrame | None
Property that get xml data with API call. If not available, make an api call
- Returns:
xml data, dictionary or pandas dataframe
- delete() None
Delete an item
- Returns:
None
- static get_data_from_disk(mms_id: str, holding_id: str, item_id: str, zone: str) XmlData | None
Fetch the data of the described record
It’s useful to restore a record from a backup.
- Parameters:
mms_id – bib record mms_id
holding_id – holding record ID
item_id – numerical ID of the item
zone – zone of the record
- Returns:
almapiwrapper.record.XmlDataor None
- get_holding_id() str
Fetch holding ID
- Returns:
str, holding ID
- get_item_id() str
Fetch the item ID in the xml data of ‘data’ attribute. Useful for creating a new item.
- Returns:
str, item id
- get_mms_id() str
Fetch IZ MMS ID
- Returns:
str, IZ MMS ID
- get_nz_mms_id() str | None
Fetch NZ MMS ID
- Returns:
str, NZ MMS ID
- property holding: Holding | None
Property of the item returning the
almapiwrapper.inventory.Holdingobject related to the item- Returns:
almapiwrapper.inventory.Holding
- property library: str | None
Property of the holding returning the library code
- Returns:
str, library code
- property location: str | None
Property of the holding returning the library code
- Returns:
str, location code
- static parse_data(data: JsonData | XmlData | Dict | str) JsonData | XmlData | None
Parse the data and return a parsed data object or None if an error occurs
- Parameters:
data – data to be parsed
- Returns:
parsed data object or None if an error occurs
- save() Item
Save a record item in the ‘records’ folder. Versioning is supported. A suffix is added to the file path.
Example: records/UBS_9963486250105504/item_22314215800005504_23314215790005504_01.xml
- Returns:
almapiwrapper.inventory.Itemobject
- scan_in(library: str, circ_desk: str) Item
Scan in an item
The scan operation can be used to advance workflows or to return an item.
- Parameters:
library – library code
circ_desk – circulation desk code
- Returns:
Item
- update() Item
Update items data
- Returns:
almapiwrapper.inventory.Itemobject