Loan class

class almapiwrapper.users.Loan(loan_id: Optional[str] = None, primary_id: Optional[str] = None, zone: Optional[str] = None, env: Optional[Literal['P', 'S']] = 'P', user: Optional[User] = None, data: Optional[JsonData] = None)

Bases: Record

Class representing a Users loan

Variables
  • api_base_url_users – url of the user api

  • loan_id – id of the fee

  • itemalmapiwrapper.inventory.Item loaned item

  • zone – initial value: zone of the fee

  • env – initial value: environment of the entity: ‘P’ for production and ‘S’ for sandbox

  • useralmapiwrapper.users.User either primary_id of the user or the user itself must be provided

  • dataalmapiwrapper.record.JsonData with fee data

static build_headers(data_format: Literal['json', 'xml'], zone: str, area: str, rights: Literal['R', 'RW'] = 'RW', env: Optional[Literal['P', 'S']] = '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: Optional[Union[Dict, Element, DataFrame]]

Property that get xml data with API call. If not available, make an api call

Returns

xml data, dictionary or pandas dataframe

property item: Optional[Item]

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.

save(**kwargs)

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