""" User. A user in the analytics service is a simple namedtuple that contains an id and the account type. Since those information are coming from trusted sources ( grass, no need to validate them.) """ from collections import namedtuple from oto import response as oto_response User = namedtuple( 'User', ['id', 'type']) LOCAL_USER_TYPES = dict( subaccount='S', vendor='L') def create_user(id, type): """Create a user. Args: id (int): the user id. type (str): the user type (subaccount or label). Returns: User: the user. """ type = type.lower() if type not in LOCAL_USER_TYPES.keys(): return oto_response.Response( errors={'type': 'The account type is not recognized.'}) return oto_response.Response( message=User(id=int(id), type=LOCAL_USER_TYPES.get(type)))