Request class
- class almapiwrapper.users.Request(request_id: str | None = None, user_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 request
- Variables:
api_base_url – url of the user api
request_id – id of the request
zone – initial value: zone of the request
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 request 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
- cancel(self, reason: str | None = 'Cancelled by patron', note: str | None = None, notify_user: bool | None = True) None
Cancel the request
- Parameters:
reason – str : reason for the cancellation
note – str : note for the cancellation
notify_user – bool : notify the user about the cancellation
- Returns:
None
- create(self) 'userslib.Request'
Create a new request
Requests are created only at title level. MMS ID is required in request data to create a request.
- Returns:
object
almapiwrapper.users.Request
- 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
- 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 request_id: str
Property returning the loan ID
It fetches it in a private attribute if not available in the data property.
- save() Request
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>/request_<IZ>_<request_id>_<version>.xml
- Returns:
object
almapiwrapper.users.Request
- update() Request
Update a request :return: object
almapiwrapper.users.Request