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