def put(self, contact_uuid: str): uuid = g.user_info["id"] UserService.add_contact_to_user(uuid, contact_uuid=contact_uuid, uow=current_app.context) contacts = UserService.list_contacts(uuid, uow=current_app.context) return { "message": f"contact {contact_uuid} successfully added from user {uuid}", "data": contacts }, 201
def get(self): return { "data": UserService.get_affairs_by_user_uuid(uuid=g.user_info["id"], uow=current_app.context), "message": "success" }, 200
def add_contact(data: Dict[str, Any], uow: AbstractUnitOfWork) -> Dict[str, Any]: contact: ContactEntity = ContactService.schema().load(data) uuid = contact.uuid with uow: uow.contact.add(contact) contact_position = UserService.build_position_from_group_id_ad_position_id( group_id=contact.group_id, position_id=contact.position_id, group_type=contact.group_type, uow=uow) contact.position = contact_position return ContactService.get_by_uuid(uuid, uow=uow)
def get(self): parser = reqparse.RequestParser() parser.add_argument('query', type=str, required=True) parser.add_argument( 'uuids', type=str, required=False, ) args = parser.parse_args() query: str = args.get("query") uuids: str = args.get("uuids") uuids_list: List[str] = uuids.split(',') if isinstance(uuids_list, str): uuids_list = [uuids_list] users = UserService.search_users(query=query, uuids=uuids_list, uow=current_app.context) return { "data": users, "message": "success", }, 200
def get(self, contact_uuid: str): uuid = g.user_info["id"] contact: Dict[str, Any] = UserService.get_user_contact( uuid, contact_uuid=contact_uuid, uow=current_app.context) return {"data": contact, "user": "******"}, 200
def get(self): uuid = g.user_info["id"] contacts = UserService.list_contacts(uuid, uow=current_app.context) return {"data": contacts, "user": "******"}, 200
def create_user(command: CreateUser, uow: AbstractUnitOfWork): return UserService.add_user(data=command.data, uow=uow)
def get(self, uuid: str): return { "data": UserService.get_by_uuid(uuid, current_app.context), "message": "success" }, 200
def get(self): return { "data": UserService.list_users(current_app.context), "message": "success", }, 200