diff --git a/lnbits/extensions/tpos/crud.py b/lnbits/extensions/tpos/crud.py index 6bfed42..6d11576 100644 --- a/lnbits/extensions/tpos/crud.py +++ b/lnbits/extensions/tpos/crud.py @@ -24,7 +24,7 @@ def get_tpos(tpos_id: str) -> Optional[TPoS]: with open_ext_db("tpos") as db: row = db.fetchone("SELECT * FROM tposs WHERE id = ?", (tpos_id,)) - return TPoS(**row) if row else None + return TPoS.from_row(row) if row else None def get_tposs(wallet_ids: Union[str, List[str]]) -> List[TPoS]: @@ -35,7 +35,7 @@ def get_tposs(wallet_ids: Union[str, List[str]]) -> List[TPoS]: q = ",".join(["?"] * len(wallet_ids)) rows = db.fetchall(f"SELECT * FROM tposs WHERE wallet IN ({q})", (*wallet_ids,)) - return [TPoS(**row) for row in rows] + return [TPoS.from_row(row) for row in rows] def delete_tpos(tpos_id: str) -> None: diff --git a/lnbits/extensions/tpos/models.py b/lnbits/extensions/tpos/models.py index cbe2e8f..e106156 100644 --- a/lnbits/extensions/tpos/models.py +++ b/lnbits/extensions/tpos/models.py @@ -1,3 +1,4 @@ +from sqlite3 import Row from typing import NamedTuple @@ -6,3 +7,7 @@ class TPoS(NamedTuple): wallet: str name: str currency: str + + @classmethod + def from_row(cls, row: Row) -> "TPoS": + return cls(**dict(row)) diff --git a/lnbits/extensions/tpos/templates/tpos/_api_docs.html b/lnbits/extensions/tpos/templates/tpos/_api_docs.html index 895f434..d122a97 100644 --- a/lnbits/extensions/tpos/templates/tpos/_api_docs.html +++ b/lnbits/extensions/tpos/templates/tpos/_api_docs.html @@ -8,21 +8,18 @@ group="api" dense expand-separator - label="List all users TPoS" + label="List TPoS" > - GET /tpos/api/v1/tposs + GET /tpos/api/v1/tposs
Headers
{"X-Api-Key": <invoice_key>}
Body (application/json)
- Returns 201 CREATED (application/json) + Returns 200 OK (application/json)
- {"currency": <string>, "id": <string>, "name": - <string>, "wallet": <string>} + [<tpos_object>, ...]
Curl example
curl -X GET {{ request.url_root }}tpos/api/v1/tposs -H "X-Api-Key: @@ -35,7 +32,7 @@ POST /tpos/api/v1/tpossPOST /tpos/api/v1/tposs
Headers
{"X-Api-Key": <invoice_key>}
@@ -70,12 +67,12 @@ DELETE + >DELETE /tpos/api/v1/tposs/<tpos_id>
Headers
{"X-Api-Key": <admin_key>}
-
Returns 201 NO_CONTENT
+
Returns 204 NO CONTENT
Curl example