feat: manage shipping zones
This commit is contained in:
parent
dcda99830e
commit
31c5a82cb9
8 changed files with 444 additions and 20 deletions
22
models.py
22
models.py
|
|
@ -1,10 +1,12 @@
|
|||
import json
|
||||
from sqlite3 import Row
|
||||
from typing import Optional
|
||||
from typing import List, Optional
|
||||
|
||||
from fastapi import Query
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
######################################## MERCHANT ########################################
|
||||
class MerchantConfig(BaseModel):
|
||||
name: Optional[str]
|
||||
|
||||
|
|
@ -23,3 +25,21 @@ class Merchant(PartialMerchant):
|
|||
merchant = cls(**dict(row))
|
||||
merchant.config = MerchantConfig(**json.loads(row["meta"]))
|
||||
return merchant
|
||||
|
||||
|
||||
######################################## ZONES ########################################
|
||||
class PartialZone(BaseModel):
|
||||
name: Optional[str]
|
||||
currency: str
|
||||
cost: float
|
||||
countries: List[str] = []
|
||||
|
||||
|
||||
class Zone(PartialZone):
|
||||
id: str
|
||||
|
||||
@classmethod
|
||||
def from_row(cls, row: Row) -> "Zone":
|
||||
zone = cls(**dict(row))
|
||||
zone.countries = json.loads(row["regions"])
|
||||
return zone
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue