User class

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

Bases: Record

Class representing an Alma user

Variables:
  • primary_id – initial value: primary_id of the user

  • 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.JsonData of the user (useful for new created users)

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_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.Fee objects

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.Loan objects

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.Request objects

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 = '123pw123') 'User'

Set a new password to a user

Parameters:

password – password string, default is ‘123pw123’

Returns:

object almapiwrapper.users.User

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.