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

The created user object

delete(id: int)

Deletes an existing user.

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

Get a single user.

Parameters:id – 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 – Include archived users in the list
  • sort_by – Sort by key
  • sort_order – asc or desc (default asc)
  • page – Page number (default 1)
Returns:

List of users

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

The updated user object