def METHOD_NAME(api_user):
    """ update user profile from work weixin
    use for work weixin departments, login, profile bind
    """
    # update additional user info
    username = api_user.get('username')
    nickname = api_user.get('name')
    contact_email = api_user.get('contact_email')
    headimgurl = api_user.get('avatar')
    # make sure the contact_email is unique
    if contact_email and Profile.objects.get_profile_by_contact_email(contact_email):
        logger.warning('contact email %s already exists' % contact_email)
        contact_email = ''
    profile_kwargs = {}
    if nickname:
        profile_kwargs['nickname'] = nickname
    if contact_email:
        profile_kwargs['contact_email'] = contact_email
    if profile_kwargs:
        try:
            Profile.objects.add_or_update(username, **profile_kwargs)
        except Exception as e:
            logger.error(e)
    # avatar
    try:
        image_name = 'work_weixin_avatar'
        image_file = requests.get(headimgurl).content
        avatar = Avatar.objects.filter(emailuser=username, primary=True).first()
        avatar = avatar or Avatar(emailuser=username, primary=True)
        avatar_file = ContentFile(image_file)
        avatar_file.name = image_name
        avatar.avatar = avatar_file
        avatar.save()
    except Exception as e:
        logger.error(e)