Loan class
- class almapiwrapper.users.Loan(loan_id: str | None = None, primary_id: str | None = None, zone: str | None = None, env: Literal['P', 'S'] | None = 'P', user: User | None = None, data: JsonData | None = None)
Bases:
RecordClass representing a Users loan
- Variables:
api_base_url_users – url of the user api
loan_id – id of the loan
item –
almapiwrapper.inventory.Itemloaned itemzone – initial value: zone of the fee
env – initial value: environment of the entity: ‘P’ for production and ‘S’ for sandbox
user –
almapiwrapper.users.Usereither primary_id of the user or the user itself must be provideddata –
almapiwrapper.record.JsonDatawith fee data
- 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
- 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
- change_due_date(new_due_date: str, notify_user: bool = False) Loan
Change due date of the loan
- Parameters:
new_due_date – str : new due date in format YYYY-MM-DD
notify_user – bool : whether to notify the user by email about the due date change, default is False
- Returns:
object
almapiwrapper.users.Loan
- 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
- property item: Item | None
Property returning the loaned item
It fetches it in a private attribute if not available in the data property.
- property loan_id: str
Property returning the loan ID
It fetches it in a private attribute if not available in the data property.
- 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
- renew_loan() Loan
Renew the loan
- Returns:
object
almapiwrapper.users.Loan
- save() Loan
Save a user loan record in the ‘records’ folder
When saved, a suffix is added to the file path with the version. Example: records/<primary_id>/loan_<IZ>_<loan_id>_<version>.xml
- Returns:
object
almapiwrapper.users.Fee