Реализация работы с invoice
This commit is contained in:
+32
-1
@@ -4,7 +4,8 @@ import asyncio
|
||||
from statistics import median
|
||||
|
||||
from db import *
|
||||
from call2api import check_user_token, user_in_db, transfer_coins, get_stats
|
||||
from call2api import check_user_token, user_in_db, transfer_coins, get_stats, create_invoice, delete_invoice, \
|
||||
get_invoice
|
||||
|
||||
|
||||
#------------------------------------------------------------
|
||||
@@ -117,6 +118,36 @@ async def get_stats_api(
|
||||
raise HTTPException(status_code=401, detail='Invalid username or token')
|
||||
return await get_stats(token=SYSTEM_API_TOKEN)
|
||||
|
||||
@app.post('/api/create_invoice/')
|
||||
async def create_invoice_api(
|
||||
username: str = Body(),
|
||||
user_token: str = Body(),
|
||||
amount: float | None = Body(None)
|
||||
):
|
||||
if not token_check(username, user_token):
|
||||
raise HTTPException(status_code=401, detail='Invalid username or token')
|
||||
return await create_invoice(token=SYSTEM_API_TOKEN, dst_username=username, amount=amount)
|
||||
|
||||
@app.post('/api/delete_invoice/')
|
||||
async def delete_invoice_api(
|
||||
username: str = Body(),
|
||||
user_token: str = Body(),
|
||||
id: str = Body()
|
||||
):
|
||||
if not token_check(username, user_token):
|
||||
raise HTTPException(status_code=401, detail='Invalid username or token')
|
||||
return await delete_invoice(token=SYSTEM_API_TOKEN, id=id)
|
||||
|
||||
@app.post('/api/get_invoice/')
|
||||
async def get_invoice_api(
|
||||
username: str = Body(),
|
||||
user_token: str = Body(),
|
||||
id: str = Body()
|
||||
):
|
||||
if not token_check(username, user_token):
|
||||
raise HTTPException(status_code=401, detail='Invalid username or token')
|
||||
return await get_invoice(token=SYSTEM_API_TOKEN, id=id)
|
||||
|
||||
#------------------------- END ------------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user