felicity-lims/felicity/apps/client/schemas.py

98 lines
2 KiB
Python
Raw Normal View History

2021-01-06 19:52:14 +08:00
from typing import Optional
2023-04-10 20:23:31 +08:00
from core.uid_gen import FelicityIDType
2021-01-06 19:52:14 +08:00
from pydantic import BaseModel
2023-03-19 23:21:32 +08:00
#
2021-01-06 19:52:14 +08:00
# Client Schemas
#
2021-01-06 19:52:14 +08:00
# Shared properties
2023-04-10 20:23:31 +08:00
2021-01-06 19:52:14 +08:00
class ClientBase(BaseModel):
name: Optional[str] = None
code: Optional[str] = None
2023-03-19 23:21:32 +08:00
district_uid: Optional[FelicityIDType] = None
2021-01-06 19:52:14 +08:00
email: Optional[str] = None
email_cc: Optional[str] = None
2021-03-26 04:22:59 +08:00
consent_email: Optional[bool] = None
2022-11-20 21:20:41 +08:00
phone_mobile: Optional[str] = None
phone_business: Optional[str] = None
2021-03-26 04:22:59 +08:00
consent_sms: Optional[bool] = None
2021-05-30 22:32:13 +08:00
internal_use: Optional[bool] = False
2021-01-06 19:52:14 +08:00
active: Optional[bool] = True
2021-01-06 19:52:14 +08:00
class ClientBaseInDB(ClientBase):
2023-03-19 23:21:32 +08:00
uid: Optional[FelicityIDType] = None
2021-01-06 19:52:14 +08:00
class Config:
orm_mode = True
2021-01-06 19:52:14 +08:00
# Properties to receive via API on creation
class ClientCreate(ClientBase):
2023-03-19 23:21:32 +08:00
district_uid: Optional[FelicityIDType]
2021-01-06 19:52:14 +08:00
2021-01-06 19:52:14 +08:00
# Properties to receive via API on update
class ClientUpdate(ClientBase):
pass
2021-01-06 19:52:14 +08:00
# Properties to return via API
class Client(ClientBaseInDB):
pass
2021-01-06 19:52:14 +08:00
# Properties stored in DB
class ClientInDB(ClientBaseInDB):
pass
2021-03-26 04:22:59 +08:00
2021-03-26 04:22:59 +08:00
#
# Client Contact Schemas
#
# Shared properties
class ClientContactBase(BaseModel):
2023-03-19 23:21:32 +08:00
client_uid: Optional[FelicityIDType] = None
2021-03-26 04:22:59 +08:00
first_name: Optional[str] = None
last_name: Optional[str] = None
email: Optional[str] = None
email_cc: Optional[str] = None
mobile_phone: Optional[str] = None
consent_sms: Optional[bool] = False
business_phone: Optional[str] = None
is_active: Optional[bool] = True
is_superuser: Optional[bool] = False
class ClientContactBaseInDB(ClientContactBase):
2023-03-19 23:21:32 +08:00
uid: Optional[FelicityIDType] = None
2021-03-26 04:22:59 +08:00
class Config:
orm_mode = True
# Properties to receive via API on creation
class ClientContactCreate(ClientContactBase):
2023-03-19 23:21:32 +08:00
client_uid: FelicityIDType
2021-03-26 04:22:59 +08:00
# Properties to receive via API on update
class ClientContactUpdate(ClientContactBase):
pass
# Properties to return via API
class ClientContact(ClientContactBaseInDB):
pass
# Properties stored in DB
class ClientContactInDB(ClientContactBaseInDB):
pass