From a9ab41701f955b380c03369818841880eabf725f Mon Sep 17 00:00:00 2001 From: Tiago vasconcelos Date: Sun, 22 Aug 2021 11:35:08 +0100 Subject: [PATCH] usemanager syntax error --- lnbits/extensions/usermanager/views_api.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/lnbits/extensions/usermanager/views_api.py b/lnbits/extensions/usermanager/views_api.py index 1bf47d6b..78217589 100644 --- a/lnbits/extensions/usermanager/views_api.py +++ b/lnbits/extensions/usermanager/views_api.py @@ -1,11 +1,15 @@ from typing import Optional -from pydantic.main import BaseModel from quart import g, jsonify from http import HTTPStatus from lnbits.core.crud import get_user from lnbits.decorators import api_check_wallet_key, api_validate_post_request +from fastapi import FastAPI, Query +from fastapi.encoders import jsonable_encoder +from fastapi.responses import JSONResponse +from pydantic import BaseModel + from . import usermanager_ext from .crud import ( create_usermanager_user, @@ -34,7 +38,7 @@ async def api_usermanager_users(): ) -@usermanager_ext.get("/api/v1/users/") +@usermanager_ext.get("/api/v1/users/{user_id}") @api_check_wallet_key(key_type="invoice") async def api_usermanager_user(user_id): user = await get_usermanager_user(user_id) @@ -58,12 +62,12 @@ async def api_usermanager_users_create(data: CreateUsersData): return jsonify(full), HTTPStatus.CREATED -@usermanager_ext.delete("/api/v1/users/") +@usermanager_ext.delete("/api/v1/users/{user_id}") @api_check_wallet_key(key_type="invoice") async def api_usermanager_users_delete(user_id): user = await get_usermanager_user(user_id) if not user: - return jsonify({"message": "User does not exist."}), HTTPStatus.NOT_FOUND + return {"message": "User does not exist."}, HTTPStatus.NOT_FOUND await delete_usermanager_user(user_id) return "", HTTPStatus.NO_CONTENT @@ -114,13 +118,13 @@ async def api_usermanager_wallets(): ) -@usermanager_ext.get("/api/v1/wallets") +@usermanager_ext.get("/api/v1/wallets/{wallet_id}") @api_check_wallet_key(key_type="invoice") async def api_usermanager_wallet_transactions(wallet_id): return await get_usermanager_wallet_transactions(wallet_id), HTTPStatus.OK -@usermanager_ext.get("/api/v1/wallets/") +@usermanager_ext.get("/api/v1/wallets/{user_id}") @api_check_wallet_key(key_type="invoice") async def api_usermanager_users_wallets(user_id): wallet = await get_usermanager_users_wallets(user_id) @@ -133,7 +137,7 @@ async def api_usermanager_users_wallets(user_id): ) -@usermanager_ext.delete("/api/v1/wallets/") +@usermanager_ext.delete("/api/v1/wallets/{wallet_id}") @api_check_wallet_key(key_type="invoice") async def api_usermanager_wallets_delete(wallet_id): wallet = await get_usermanager_wallet(wallet_id)