mirror of
https://github.com/lnbits/lnbits.git
synced 2025-10-09 20:12:34 +02:00
fix: syntax errors
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
from pydantic.types import constr
|
||||||
import trio
|
import trio
|
||||||
import json
|
import json
|
||||||
import httpx
|
import httpx
|
||||||
@@ -5,15 +6,13 @@ import hashlib
|
|||||||
from urllib.parse import urlparse, urlunparse, urlencode, parse_qs, ParseResult
|
from urllib.parse import urlparse, urlunparse, urlencode, parse_qs, ParseResult
|
||||||
from quart import g, current_app, make_response, url_for
|
from quart import g, current_app, make_response, url_for
|
||||||
|
|
||||||
from fastapi import FastAPI
|
from fastapi import Query
|
||||||
from fastapi.encoders import jsonable_encoder
|
from fastapi.encoders import jsonable_encoder
|
||||||
from fastapi.responses import JSONResponse
|
|
||||||
from pydantic import BaseModel
|
|
||||||
|
|
||||||
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
from typing import Dict, Union
|
from typing import Dict, List, Optional, Union
|
||||||
|
|
||||||
from lnbits import bolt11, lnurl
|
from lnbits import bolt11, lnurl
|
||||||
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
||||||
@@ -95,15 +94,7 @@ async def api_payments():
|
|||||||
# async def api_payments_create_invoice(amount: List[str] = Query([type: str = Query(None)])):
|
# async def api_payments_create_invoice(amount: List[str] = Query([type: str = Query(None)])):
|
||||||
|
|
||||||
|
|
||||||
class Memo(BaseModel):
|
async def api_payments_create_invoice(memo: Union[None, constr(min_length=1)], amount: int):
|
||||||
type: str
|
|
||||||
empty: bool
|
|
||||||
required: bool
|
|
||||||
excludes: bool
|
|
||||||
excludes: bool = Query("description_hash")
|
|
||||||
|
|
||||||
|
|
||||||
async def api_payments_create_invoice(amount: int = Query(...), memo: Memo ):
|
|
||||||
if "description_hash" in g.data:
|
if "description_hash" in g.data:
|
||||||
description_hash = unhexlify(g.data["description_hash"])
|
description_hash = unhexlify(g.data["description_hash"])
|
||||||
memo = ""
|
memo = ""
|
||||||
|
@@ -5,6 +5,8 @@ from lnbits.core.crud import get_user, get_wallet
|
|||||||
from lnbits.core.services import create_invoice, check_invoice_status
|
from lnbits.core.services import create_invoice, check_invoice_status
|
||||||
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
||||||
from fastapi.encoders import jsonable_encoder
|
from fastapi.encoders import jsonable_encoder
|
||||||
|
from fastapi import Query
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
from . import events_ext
|
from . import events_ext
|
||||||
from .crud import (
|
from .crud import (
|
||||||
@@ -41,14 +43,14 @@ async def api_events():
|
|||||||
)
|
)
|
||||||
|
|
||||||
class CreateData(BaseModel):
|
class CreateData(BaseModel):
|
||||||
wallet: str = Query(...),
|
wallet: str = Query(...)
|
||||||
name: str = Query(...),
|
name: str = Query(...)
|
||||||
info: str = Query(...),
|
info: str = Query(...)
|
||||||
closing_date: str = Query(...),
|
closing_date: str = Query(...)
|
||||||
event_start_date: str = Query(...),
|
event_start_date: str = Query(...)
|
||||||
event_end_date: str = Query(...),
|
event_end_date: str = Query(...)
|
||||||
amount_tickets: int = Query(..., ge=0),
|
amount_tickets: int = Query(..., ge=0)
|
||||||
price_per_ticket: int = Query(..., ge=0),
|
price_per_ticket: int = Query(..., ge=0)
|
||||||
|
|
||||||
@events_ext.post("/api/v1/events")
|
@events_ext.post("/api/v1/events")
|
||||||
@events_ext.put("/api/v1/events/<event_id>")
|
@events_ext.put("/api/v1/events/<event_id>")
|
||||||
@@ -100,7 +102,7 @@ async def api_tickets():
|
|||||||
)
|
)
|
||||||
|
|
||||||
class CreateTicketData(BaseModel):
|
class CreateTicketData(BaseModel):
|
||||||
name: str = Query(...),
|
name: str = Query(...)
|
||||||
email: str
|
email: str
|
||||||
|
|
||||||
@events_ext.post("/api/v1/tickets/<event_id>/<sats>")
|
@events_ext.post("/api/v1/tickets/<event_id>/<sats>")
|
||||||
|
@@ -4,6 +4,9 @@ import base64
|
|||||||
from lnbits.core.crud import get_wallet
|
from lnbits.core.crud import get_wallet
|
||||||
from lnbits.core.services import create_invoice, check_invoice_status
|
from lnbits.core.services import create_invoice, check_invoice_status
|
||||||
import json
|
import json
|
||||||
|
from typing import Optional
|
||||||
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
|
||||||
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
|
||||||
import httpx
|
import httpx
|
||||||
@@ -74,16 +77,16 @@ async def api_check_credentials_check(juke_id):
|
|||||||
|
|
||||||
|
|
||||||
class CreateData(BaseModel):
|
class CreateData(BaseModel):
|
||||||
user: str = None,
|
user: str = None
|
||||||
title: str = None,
|
title: str = None
|
||||||
wallet: str = None,
|
wallet: str = None
|
||||||
sp_user: str = None,
|
sp_user: str = None
|
||||||
sp_secret: str = None,
|
sp_secret: str = None
|
||||||
sp_access_token: Optional[str] = None,
|
sp_access_token: Optional[str] = None
|
||||||
sp_refresh_token: Optional[str] = None,
|
sp_refresh_token: Optional[str] = None
|
||||||
sp_device: Optional[str] = None,
|
sp_device: Optional[str] = None
|
||||||
sp_playlists: Optional[str] = None,
|
sp_playlists: Optional[str] = None
|
||||||
price: Optional[str] = None,
|
price: Optional[str] = None
|
||||||
|
|
||||||
@jukebox_ext.post("/api/v1/jukebox/")
|
@jukebox_ext.post("/api/v1/jukebox/")
|
||||||
@jukebox_ext.put("/api/v1/jukebox/<juke_id>")
|
@jukebox_ext.put("/api/v1/jukebox/<juke_id>")
|
||||||
|
@@ -27,10 +27,10 @@ async def api_paywalls():
|
|||||||
|
|
||||||
|
|
||||||
class CreateData(BaseModel):
|
class CreateData(BaseModel):
|
||||||
url: Optional[str] = Query(...),
|
url: Optional[str] = Query(...)
|
||||||
memo: Optional[str] = Query(...),
|
memo: Optional[str] = Query(...)
|
||||||
description: str = Query(None),
|
description: str = Query(None)
|
||||||
amount: int = Query(None),
|
amount: int = Query(None)
|
||||||
remembers: bool = Query(None)
|
remembers: bool = Query(None)
|
||||||
|
|
||||||
@paywall_ext.post("/api/v1/paywalls")
|
@paywall_ext.post("/api/v1/paywalls")
|
||||||
|
@@ -17,7 +17,7 @@ from .models import TPoS
|
|||||||
|
|
||||||
@tpos_ext.get("/api/v1/tposs")
|
@tpos_ext.get("/api/v1/tposs")
|
||||||
@api_check_wallet_key("invoice")
|
@api_check_wallet_key("invoice")
|
||||||
async def api_tposs(all_wallets: boolean = Query(None)):
|
async def api_tposs(all_wallets: bool = Query(None)):
|
||||||
wallet_ids = [g.wallet.id]
|
wallet_ids = [g.wallet.id]
|
||||||
if all_wallets:
|
if all_wallets:
|
||||||
wallet_ids = wallet_ids = (await get_user(g.wallet.user)).wallet_ids(await get_user(g.wallet.user)).wallet_ids
|
wallet_ids = wallet_ids = (await get_user(g.wallet.user)).wallet_ids(await get_user(g.wallet.user)).wallet_ids
|
||||||
@@ -60,7 +60,7 @@ async def api_tpos_delete(tpos_id: str):
|
|||||||
# @api_validate_post_request(
|
# @api_validate_post_request(
|
||||||
# schema={"amount": {"type": "integer", "min": 1, "required": True}}
|
# schema={"amount": {"type": "integer", "min": 1, "required": True}}
|
||||||
# )
|
# )
|
||||||
async def api_tpos_create_invoice(amount: int = Query(..., ge=1), tpos_id: str):
|
async def api_tpos_create_invoice(tpos_id: str, amount: int = Query(..., ge=1)):
|
||||||
tpos = await get_tpos(tpos_id)
|
tpos = await get_tpos(tpos_id)
|
||||||
|
|
||||||
if not tpos:
|
if not tpos:
|
||||||
@@ -76,7 +76,7 @@ async def api_tpos_create_invoice(amount: int = Query(..., ge=1), tpos_id: str):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
return {"message": str(e)}, HTTPStatus.INTERNAL_SERVER_ERROR
|
return {"message": str(e)}, HTTPStatus.INTERNAL_SERVER_ERROR
|
||||||
|
|
||||||
return {"payment_hash": payment_hash, "payment_request": payment_request}), HTTPStatus.CREATED
|
return {"payment_hash": payment_hash, "payment_request": payment_request}, HTTPStatus.CREATED
|
||||||
|
|
||||||
|
|
||||||
@tpos_ext.get("/api/v1/tposs/{tpos_id}/invoices/{payment_hash}")
|
@tpos_ext.get("/api/v1/tposs/{tpos_id}/invoices/{payment_hash}")
|
||||||
|
@@ -68,11 +68,11 @@ async def api_link_retrieve(link_id):
|
|||||||
return jsonable_encoder({**link, **{"lnurl": link.lnurl}}), HTTPStatus.OK
|
return jsonable_encoder({**link, **{"lnurl": link.lnurl}}), HTTPStatus.OK
|
||||||
|
|
||||||
class CreateData(BaseModel):
|
class CreateData(BaseModel):
|
||||||
title: str = Query(...),
|
title: str = Query(...)
|
||||||
min_withdrawable: int = Query(..., ge=1),
|
min_withdrawable: int = Query(..., ge=1)
|
||||||
max_withdrawable: int = Query(..., ge=1),
|
max_withdrawable: int = Query(..., ge=1)
|
||||||
uses: int = Query(..., ge=1),
|
uses: int = Query(..., ge=1)
|
||||||
wait_time: int = Query(..., ge=1),
|
wait_time: int = Query(..., ge=1)
|
||||||
is_unique: bool
|
is_unique: bool
|
||||||
|
|
||||||
@withdraw_ext.post("/api/v1/links")
|
@withdraw_ext.post("/api/v1/links")
|
||||||
|
Reference in New Issue
Block a user