lnbits-legend/lnbits/extensions/scrub/models.py

30 lines
786 B
Python
Raw Normal View History

2022-05-17 20:27:52 +01:00
import json
from urllib.parse import urlparse, urlunparse, parse_qs, urlencode, ParseResult
from starlette.requests import Request
from fastapi.param_functions import Query
from typing import Optional, Dict
from lnbits.lnurl import encode as lnurl_encode # type: ignore
from sqlite3 import Row
from pydantic import BaseModel
2022-06-07 11:04:34 +01:00
class CreateScrubLink(BaseModel):
wallet: str
description: str
payoraddress: str
2022-05-17 20:27:52 +01:00
class ScrubLink(BaseModel):
id: int
wallet: str
description: str
2022-05-19 11:39:59 +01:00
payoraddress: str
2022-05-17 20:27:52 +01:00
@classmethod
def from_row(cls, row: Row) -> "ScrubLink":
data = dict(row)
return cls(**data)
def lnurl(self, req: Request) -> str:
url = req.url_for("scrub.api_lnurl_response", link_id=self.id)
2022-06-07 11:04:34 +01:00
return lnurl_encode(url)