25 lines
518 B
Python
25 lines
518 B
Python
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
|