lnbits-legend/lnbits/extensions/deezy/views_api.py

66 lines
1.5 KiB
Python
Raw Normal View History

2023-01-05 11:46:01 +01:00
# views_api.py is for you API endpoints that could be hit by another service
# add your dependencies here
# import httpx
# (use httpx just like requests, except instead of response.ok there's only the
# response.is_error that is its inverse)
from . import deezy_ext
from .crud import (
get_btc_to_ln,
2023-01-07 21:59:10 +00:00
get_ln_to_btc,
get_token,
save_btc_to_ln,
2023-01-06 00:34:24 +01:00
save_ln_to_btc,
2023-01-07 21:59:10 +00:00
save_token,
update_ln_to_btc,
2023-01-05 11:46:01 +01:00
)
2023-01-07 21:59:10 +00:00
from .models import BtcToLnSwap, LnToBtcSwap, Token, UpdateLnToBtcSwap
2023-01-05 11:46:01 +01:00
@deezy_ext.get("/api/v1/token")
2023-01-07 22:06:35 +00:00
async def api_deezy_get_token():
2023-01-05 11:46:01 +01:00
rows = await get_token()
return rows
@deezy_ext.get("/api/v1/ln-to-btc")
2023-01-07 22:06:35 +00:00
async def api_deezy_get_ln_to_btc():
rows = await get_ln_to_btc()
return rows
@deezy_ext.get("/api/v1/btc-to-ln")
2023-01-07 22:06:35 +00:00
async def api_deezy_get_btc_to_ln():
rows = await get_btc_to_ln()
return rows
2023-01-05 11:46:01 +01:00
@deezy_ext.post("/api/v1/store-token")
2023-01-07 22:06:35 +00:00
async def api_deezy_save_toke(data: Token):
2023-01-05 11:46:01 +01:00
await save_token(data)
return data.deezy_token
@deezy_ext.post("/api/v1/store-ln-to-btc")
2023-01-07 22:06:35 +00:00
async def api_deezy_save_ln_to_btc(data: LnToBtcSwap):
response = await save_ln_to_btc(data)
return response
2023-01-06 00:34:24 +01:00
@deezy_ext.post("/api/v1/update-ln-to-btc")
2023-01-07 22:06:35 +00:00
async def api_deezy_update_ln_to_btc(data: UpdateLnToBtcSwap):
2023-01-06 00:34:24 +01:00
response = await update_ln_to_btc(data)
return response
@deezy_ext.post("/api/v1/store-btc-to-ln")
2023-01-07 22:06:35 +00:00
async def api_deezy_save_btc_to_ln(data: BtcToLnSwap):
response = await save_btc_to_ln(data)
return response