feat: keep customer profiles up to date

This commit is contained in:
Vlad Stan 2023-03-27 17:19:51 +03:00
parent e7b16dd17f
commit 89f46fff35
7 changed files with 175 additions and 5 deletions

View file

@ -427,3 +427,24 @@ class DirectMessage(PartialDirectMessage):
def from_row(cls, row: Row) -> "DirectMessage":
dm = cls(**dict(row))
return dm
######################################## CUSTOMERS ########################################
class CustomerProfile(BaseModel):
name: Optional[str]
about: Optional[str]
class Customer(BaseModel):
merchant_id: str
public_key: str
event_created_at: Optional[int]
profile: Optional[CustomerProfile]
@classmethod
def from_row(cls, row: Row) -> "Customer":
customer = cls(**dict(row))
customer.profile = CustomerProfile(**json.loads(row["meta"]))
return customer