Letter class

class almapiwrapper.config.Letter(code: str, zone: str, env: Literal['P', 'S'] | None = 'P', data: JsonData | XmlData | dict | str | None = None)

Bases: Record

Class representing a configurable Alma letter.

Parameters:
  • code – Alma letter code

  • zone – institutional zone

  • env – environment (‘P’ for production, ‘S’ for sandbox)

  • data – optional payload (JsonData, XmlData, dict, xml/json string)

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

property code: str | None

Return the letter code :return: letter code

property data: Dict | Element | DataFrame | JsonData | XmlData | None

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

Returns:

xml data, dictionary or pandas dataframe

property enabled: bool
Returns:

boolean indicating if letter configuration is enabled

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

save() Letter

Save one letter configuration in Alma.

update() Letter

Update one letter configuration in Alma.