def put(self, uid):
        """
        Update an user. API KEY
        """

        parser = ak_parser.copy()
        parser.add_argument('lang', type=lang_parser)
        parser.add_argument('height', type=float)
        parser.add_argument('age', type=int)
        parser.add_argument('weight', type=float)
        parser.add_argument('gender', type=gender_parser)
        parser.add_argument('inclination', type=inclination_parser)
        args = parser.parse_args(strict=True)
        valid_fields = frozenset(
            ['lang', 'height', 'weight', 'gender', 'inclination', 'age'])
        print args
        user_query = db_session.query(UserModel).filter(
            UserModel.apikey == args['apikey'])
        user = user_query.one()

        for key, value in args.iteritems():
            if key in valid_fields and value is not None:
                setattr(user, key, value)
        user = db_session.merge(user, load=True)
        db_session.commit()
        return user.to_dict(), 200
    def post(self):
        """
        Authenticate as a user
        """
        parser = reqparse.RequestParser()
        parser.add_argument('username', type=str, required=True)
        parser.add_argument('password', type=str, required=True)
        args = parser.parse_args(strict=True)

        query = db_session.query(UserModel).filter(
            UserModel.username == args['username'])
        if query.count() > 0:
            user = query.one()
            if user.password == args['password']:
                user.apikey = generate_apikey(user.username)
                db_session.merge(user)
                db_session.commit()
                return {'apikey': user.apikey}, 200
        return {"message": {"pass": "******",
                        "user": "******", }}, 400
    def post(self):
        """
        Authenticate as a user
        """
        parser = reqparse.RequestParser()
        parser.add_argument('username', type=str, required=True)
        parser.add_argument('password', type=str, required=True)
        args = parser.parse_args(strict=True)

        query = db_session.query(UserModel).filter(
            UserModel.username == args['username'])
        if query.count() > 0:
            user = query.one()
            if user.password == args['password']:
                user.apikey = generate_apikey(user.username)
                db_session.merge(user)
                db_session.commit()
                return {'apikey': user.apikey}, 200
        return {
            "message": {
                "pass": "******",
                "user": "******",
            }
        }, 400
    def put(self, uid):
        """
        Update an user. API KEY
        """

        parser = ak_parser.copy()
        parser.add_argument('lang', type=lang_parser)
        parser.add_argument('height', type=float)
        parser.add_argument('age', type=int)
        parser.add_argument('weight', type=float)
        parser.add_argument('gender', type=gender_parser)
        parser.add_argument('inclination', type=inclination_parser)
        args = parser.parse_args(strict=True)
        valid_fields = frozenset(['lang', 'height', 'weight', 'gender', 'inclination', 'age'])
        print args
        user_query = db_session.query(UserModel).filter(UserModel.apikey == args['apikey'])
        user = user_query.one()

        for key, value in args.iteritems():
            if key in valid_fields and value is not None:
                setattr(user, key, value)
        user = db_session.merge(user, load=True)
        db_session.commit()
        return user.to_dict(), 200