NewUser class
- class almapiwrapper.users.NewUser(zone: str, env: Literal['P', 'S'], data: JsonData | dict | str)
Bases:
UserClass used to create new users
- Variables:
zone – initial value: zone where the user should be created
env – initial value: environment of the entity: ‘P’ for production and ‘S’ for sandbox
data – initial value:
almapiwrapper.record.JsonDataof the user to create
- add_synchro_note() 'User'
Add a test synchronization notes
- Returns:
object
almapiwrapper.users.User
- 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
- check_synchro_note() bool
Test if the user has a synchronization test note
- Returns:
True if a synchronization test note is found else False
- create(password: str | None = None) 'NewUser' | User
Create the user with API.
- Parameters:
password – optional string with the password, if not provided, the password will be set at the default value (if not available in the data)
- Returns:
object
almapiwrapper.users.Useror objectalmapiwrapper.users.NewUser(in case of error)
Note
If the record encountered an error, this method will be skipped.
- create_loan(library: str, circ_desk: str, item_barcode: str | None = None, item_id: str | None = None, item: almapiwrapper.inventory.Item | None = None) 'users.Loan' | None
Create a loan for the user
- Parameters:
library – code of the library
circ_desk – code of the circulation desk
item_barcode – barcode of the item
item_id – id of the item
item – object
almapiwrapper.inventory.Item
- Returns:
object
almapiwrapper.users.Loan
Note
If the record encountered an error, this method will be skipped.
- 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
- dedup_notes(self) 'User'
Remove all duplicated notes
Text of note is used to compare notes. If the text is the same, the external note is preferred.
- Returns:
object
almapiwrapper.users.User
- delete()
Delete the user
- Returns:
None
Note
If the record encountered an error, this method will be skipped.
- property fees: List[Fee] | None
Property returning the list of the fees of the user
- Returns:
list of
almapiwrapper.users.Feeobjects
- fetch_requests(self) List['users.Request'] | None
Fetch the list of the requests of the user
- property loans: List[Loan] | None
Property returning the list of the loans of the user
- Returns:
list of
almapiwrapper.users.Loanobjects
- 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
- property primary_id: str
Property returning the primary ID
It fetches it in a private attribute if not available in the data property.
When a new value is set and json data is available, it changes the primary ID at the data level.
- Returns:
primary ID of the user
- remove_synchro_note() 'User'
Remove all test synchronization notes
- Returns:
object
almapiwrapper.users.User
- property requests: List[Request] | None
Property returning the list of the requests of the user
- Returns:
list of
almapiwrapper.users.Requestobjects
- save() 'User'
Save a user record in the ‘records’ folder
When saved, a suffix is added to the file path with the version. Example: records/<primary_id>/user_<IZ>_<primary_id>_<version>.xml
- Returns:
object
almapiwrapper.users.User
- set_password(password: str | None = None) 'NewUser'
Set the password of a new user
- Parameters:
password – string containing the new password.
- Returns:
object
almapiwrapper.users.NewUser
Note
If the record encountered an error, this method will be skipped.
- update() 'User'
Update the user through api
- Parameters:
override – string containing the list of the fields to override
- Returns:
object
almapiwrapper.users.User
Note
If the record encountered an error, this method will be skipped.