feat: init merchant
This commit is contained in:
parent
2832ee928c
commit
99492b36c8
6 changed files with 164 additions and 8 deletions
25
models.py
Normal file
25
models.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import json
|
||||
from sqlite3 import Row
|
||||
from typing import Optional
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class MerchantConfig(BaseModel):
|
||||
name: Optional[str]
|
||||
|
||||
|
||||
class PartialMerchant(BaseModel):
|
||||
private_key: str
|
||||
public_key: str
|
||||
config: MerchantConfig = MerchantConfig()
|
||||
|
||||
|
||||
class Merchant(PartialMerchant):
|
||||
id: str
|
||||
|
||||
@classmethod
|
||||
def from_row(cls, row: Row) -> "Merchant":
|
||||
merchant = cls(**dict(row))
|
||||
merchant.config = MerchantConfig(**json.loads(row["meta"]))
|
||||
return merchant
|
||||
Loading…
Add table
Add a link
Reference in a new issue