mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-22 06:21:53 +01:00
fires up ok
This commit is contained in:
parent
9ff1313b0b
commit
ca3b1d7455
4 changed files with 15 additions and 12 deletions
|
@ -1,6 +1,7 @@
|
|||
from typing import NamedTuple
|
||||
from sqlite3 import Row
|
||||
from fastapi.param_functions import Query
|
||||
from pydantic.main import BaseModel
|
||||
|
||||
|
||||
class CreateJukeLinkData(BaseModel):
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/jukebox -H "X-Api-Key: {{
|
||||
g.user.wallets[0].adminkey }}"
|
||||
user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
@ -60,7 +60,7 @@
|
|||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X GET {{ request.url_root }}api/v1/jukebox/<juke_id> -H
|
||||
"X-Api-Key: {{ g.user.wallets[0].adminkey }}"
|
||||
"X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
@ -95,7 +95,7 @@
|
|||
"sp_device": <string, spotify_user_secret>, "sp_playlists":
|
||||
<string, not_required>, "price": <integer, not_required>}'
|
||||
-H "Content-type: application/json" -H "X-Api-Key:
|
||||
{{g.user.wallets[0].adminkey }}"
|
||||
{{user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
@ -117,7 +117,7 @@
|
|||
<h5 class="text-caption q-mt-sm q-mb-none">Curl example</h5>
|
||||
<code
|
||||
>curl -X DELETE {{ request.url_root }}api/v1/jukebox/<juke_id>
|
||||
-H "X-Api-Key: {{ g.user.wallets[0].adminkey }}"
|
||||
-H "X-Api-Key: {{ user.wallets[0].adminkey }}"
|
||||
</code>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
|
|
@ -13,6 +13,7 @@ from starlette.responses import HTMLResponse
|
|||
from lnbits.core.models import User, Payment
|
||||
from .views_api import api_get_jukebox_device_check
|
||||
|
||||
|
||||
templates = Jinja2Templates(directory="templates")
|
||||
|
||||
|
||||
|
@ -49,5 +50,6 @@ async def connect_to_jukebox(request: Request, juke_id):
|
|||
)
|
||||
else:
|
||||
return jukebox_renderer().TemplateResponse(
|
||||
"jukebox/error.html", {"request": request}
|
||||
"jukebox/error.html",
|
||||
{"request": request, "jukebox": jukebox.jukebox(req=request)},
|
||||
)
|
||||
|
|
|
@ -9,13 +9,11 @@ import json
|
|||
from typing import Optional
|
||||
from fastapi.params import Depends
|
||||
from fastapi.param_functions import Query
|
||||
from pydantic.main import BaseModel
|
||||
from .models import CreateJukeLinkData
|
||||
from lnbits.decorators import (
|
||||
check_user_exists,
|
||||
WalletTypeInfo,
|
||||
get_key_type,
|
||||
api_check_wallet_key,
|
||||
api_validate_post_request,
|
||||
)
|
||||
import httpx
|
||||
|
@ -89,17 +87,19 @@ async def api_check_credentials_callbac(
|
|||
|
||||
@jukebox_ext.get("/api/v1/jukebox/{juke_id}", status_code=HTTPStatus.OK)
|
||||
async def api_check_credentials_check(
|
||||
juke_id=None, wallet: WalletTypeInfo = Depends(get_key_type)
|
||||
juke_id: str = Query(None), wallet: WalletTypeInfo = Depends(get_key_type)
|
||||
):
|
||||
print(juke_id)
|
||||
jukebox = await get_jukebox(juke_id)
|
||||
return jukebox._asdict()
|
||||
|
||||
return jukebox
|
||||
|
||||
|
||||
@jukebox_ext.post("/api/v1/jukebox", status_code=HTTPStatus.CREATED)
|
||||
@jukebox_ext.put("/api/v1/jukebox/{juke_id}", status_code=HTTPStatus.OK)
|
||||
async def api_create_update_jukebox(
|
||||
data: CreateJukeLinkData,
|
||||
juke_id=None,
|
||||
juke_id: str = Query(None),
|
||||
wallet: WalletTypeInfo = Depends(get_key_type),
|
||||
):
|
||||
if juke_id:
|
||||
|
@ -107,7 +107,7 @@ async def api_create_update_jukebox(
|
|||
else:
|
||||
jukebox = await create_jukebox(inkey=g.wallet.inkey, **g.data)
|
||||
|
||||
return jukebox._asdict()
|
||||
return jukebox.dict()
|
||||
|
||||
|
||||
@jukebox_ext.delete("/api/v1/jukebox/{juke_id}", status_code=HTTPStatus.OK)
|
||||
|
@ -117,7 +117,7 @@ async def api_delete_item(
|
|||
):
|
||||
await delete_jukebox(juke_id)
|
||||
try:
|
||||
return [{**jukebox._asdict()} for jukebox in await get_jukeboxs(g.wallet.user)]
|
||||
return [{**jukebox.dict()} for jukebox in await get_jukeboxs(g.wallet.user)]
|
||||
except:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NO_CONTENT,
|
||||
|
|
Loading…
Add table
Reference in a new issue