User

class moco_wrapper.models.User(moco)

Class for handling users.

create(firstname: str, lastname: str, email: str, password: str, unit_id: int, active: bool = None, external: bool = None, language: str = None, mobile_phone: str = None, work_phone: str = None, home_address: str = None, birthday: datetime.date = None, custom_properties: dict = None, info: str = None)

Creates a new user.

Parameters:
  • firstname (str) – First name of the user
  • lastname (str) – Last name of the user
  • email (str) – Email address
  • password (str) – Password to use when creating the user
  • unit_id (int) – Id of the unit/team the user belongs to
  • active (bool) – If the user should be activated or not
  • external (bool) – If the user is an employee or an external employee (his user id will now show up in reports etc.)
  • language (str) – de, de-AT, de-CH, en, it or fr
  • mobile_phone (str) – Mobile phone number
  • work_phone (str) – Work phone number
  • home_address (str) – Phyical home address
  • birthday (datetime.date, str) – Birthday date
  • custom_properties (dict) – Custom fields to add to the user
  • info (str) – Additional information about the user
Returns:

The created user object

delete(user_id: int)

Deletes an existing user.

Parameters:user_id (int) – Id of the user to delete
Returns:Empty response on success
get(user_id: int)

Get a single user.

Parameters:user_id (int) – Id of the user
Returns:Single user object
getlist(include_archived: bool = None, sort_by: str = None, sort_order: str = 'asc', page: int = 1)

Get a list of users.

Parameters:
  • include_archived (bool) – Include archived users in the list
  • sort_by (str) – Sort by key
  • sort_order (str) – asc or desc (default asc)
  • page (int) – Page number (default 1)
Returns:

List of users

update(user_id, firstname: str = None, lastname: str = None, email: str = None, password: str = None, unit_id: int = None, active: bool = None, external: bool = None, language: str = None, mobile_phone: str = None, work_phone: str = None, home_address: str = None, birthday: datetime.date = None, custom_properties: dict = None, info: str = None)

Updates an existing user.

Parameters:
  • user_id (int) – the Id of the user
  • firstname (str) – First name of the user
  • lastname (str) – Last name of the user
  • email (str) – Email address
  • password (str) – Password to use when creating the user
  • unit_id (int) – Id of the unit/team the user belongs to
  • active (bool) – If the user should be activated or not
  • external (bool) – If the user is an employee or an external employee (his user id will now show up in reports etc.)
  • language (str) – de, de-AT, de-CH, en, it or fr
  • mobile_phone (str) – Mobile phone number
  • work_phone (str) – Work phone number
  • home_address (str) – Physical home address
  • birthday (datetime.date, str) – Birthday date
  • custom_properties (dict) – Custom fields to add to the user
  • info (str) – Additional information abotu the user
Returns:

The updated user object