Skip to content

structs/users.py

structs.users

User Structs

PolicySigned

Bases: BaseModel

Policy Signed struct

Attributes:

Name Type Description
uid str

user id.

type PolicyType

type of PolicyType.

sign_at datetime

datetime.

Source code in structs/users.py
class PolicySigned(BaseModel):
    ''' Policy Signed struct

    Attributes:
        uid: user id.
        type: type of [PolicyType](PolicyType).
        sign_at: datetime.

    '''
    uid: str = Field(description='user id')
    type: PolicyType = Field(description='Policy type')
    sign_at: datetime = Field(
        description='The policy signed at', default_factory=datetime.now)

    class Config:  # pylint: disable=too-few-public-methods
        ''' Config'''
        use_enum_values = True

Config

Config

Source code in structs/users.py
class Config:  # pylint: disable=too-few-public-methods
    ''' Config'''
    use_enum_values = True

PolicyType

Bases: str, Enum

Policy Type

Source code in structs/users.py
class PolicyType(str, Enum):
    ''' Policy Type '''
    COC = 'coc'
    SECURITY_GUARD = 'security_guard'

User

Bases: BaseModel

User struct

Attributes:

Name Type Description
id str

user id. (alias: _id)

created_at int

timestamp.

mail EmailStr

mail.

profile Optional[UserProfle]

profile info.

profile_real Optional[UserProfleReal]

real profile info.

Todo

Need to convert the int type to datetime of created_at.

Source code in structs/users.py
class User(BaseModel):
    ''' User struct

    Attributes:
        id: user id. *(alias: `_id`)*
        created_at: timestamp.
        mail: mail.
        profile: profile info.
        profile_real: real profile info.

    !!! TODO

        Need to convert the `int` type to `datetime` of `created_at`.

    '''
    id: str = Field(..., alias='_id')
    created_at: int = Field(default_factory=lambda: int(time()))
    mail: EmailStr = Field(..., description="User's mail")
    profile: Optional[UserProfle]
    profile_real: Optional[UserProfleReal]

    class Config:  # pylint: disable=too-few-public-methods
        ''' Config

        Attributes:
            anystr_strip_whitespace: `True`

        '''
        anystr_strip_whitespace: bool = True

Config

Config

Attributes:

Name Type Description
anystr_strip_whitespace bool

True

Source code in structs/users.py
class Config:  # pylint: disable=too-few-public-methods
    ''' Config

    Attributes:
        anystr_strip_whitespace: `True`

    '''
    anystr_strip_whitespace: bool = True

UserAddress

Bases: BaseModel

User Address

Attributes:

Name Type Description
code str

postal code.

receiver str

receiver name.

address str

address.

Source code in structs/users.py
class UserAddress(BaseModel):
    ''' User Address

    Attributes:
        code: postal code.
        receiver: receiver name.
        address: address.

    '''
    code: str = Field(default='')
    receiver: str = Field(default='')
    address: str = Field(default='')

    class Config:  # pylint: disable=too-few-public-methods
        ''' Config

        Attributes:
            anystr_strip_whitespace: `True`

        '''
        anystr_strip_whitespace: bool = True

Config

Config

Attributes:

Name Type Description
anystr_strip_whitespace bool

True

Source code in structs/users.py
class Config:  # pylint: disable=too-few-public-methods
    ''' Config

    Attributes:
        anystr_strip_whitespace: `True`

    '''
    anystr_strip_whitespace: bool = True

UserBank

Bases: BaseModel

User Bank info

Attributes:

Name Type Description
code str

bank code.

no str

bank account numbers.

branch str

bank branch name.

name str

bank account name.

Source code in structs/users.py
class UserBank(BaseModel):
    ''' User Bank info

    Attributes:
        code: bank code.
        no: bank account numbers.
        branch: bank branch name.
        name: bank account name.

    '''
    code: str = Field(default='', description='bank code')
    no: str = Field(default='', description='bank account numbers')
    branch: str = Field(default='', description='bank branch name')
    name: str = Field(default='', description='bank account name')

    class Config:  # pylint: disable=too-few-public-methods
        ''' Config

        Attributes:
            anystr_strip_whitespace: `True`

        '''
        anystr_strip_whitespace: bool = True

Config

Config

Attributes:

Name Type Description
anystr_strip_whitespace bool

True

Source code in structs/users.py
class Config:  # pylint: disable=too-few-public-methods
    ''' Config

    Attributes:
        anystr_strip_whitespace: `True`

    '''
    anystr_strip_whitespace: bool = True

UserProfle

Bases: BaseModel

User Profile struct

Attributes:

Name Type Description
badge_name str

Badge name.

intro str

introduction.

Source code in structs/users.py
class UserProfle(BaseModel):
    ''' User Profile struct

    Attributes:
        badge_name: Badge name.
        intro: introduction.

    '''
    badge_name: str = Field(default='', example='Badge Name')
    intro: str = Field(default='', description='Markdown format')

    class Config:  # pylint: disable=too-few-public-methods
        ''' Config

        Attributes:
            anystr_strip_whitespace: `True`

        '''
        anystr_strip_whitespace: bool = True

Config

Config

Attributes:

Name Type Description
anystr_strip_whitespace bool

True

Source code in structs/users.py
class Config:  # pylint: disable=too-few-public-methods
    ''' Config

    Attributes:
        anystr_strip_whitespace: `True`

    '''
    anystr_strip_whitespace: bool = True

UserProfleReal

Bases: UserProfleRealBase

User Profile Real struct

Attributes:

Name Type Description
birthday Optional[datetime]

(optional) birthday.

bank Optional[UserBank]

(optional) bank info.

address Optional[UserAddress]

(optional) address info.

dietary_habit Optional[list[DietaryHabitItemsValue]]

(optional) dietary habit info.

Source code in structs/users.py
class UserProfleReal(UserProfleRealBase):
    ''' User Profile Real struct

    Attributes:
        birthday: *(optional)* birthday.
        bank: *(optional)* bank info.
        address: *(optional)* address info.
        dietary_habit: *(optional)* dietary habit info.

    '''
    birthday: Optional[datetime] = Field(default=None)
    bank: Optional[UserBank] = Field(default_factory=UserBank)
    address: Optional[UserAddress] = Field(default_factory=UserAddress)
    dietary_habit: Optional[list[DietaryHabitItemsValue]] = Field(
        default_factory=list)

    class Config:  # pylint: disable=too-few-public-methods
        ''' Config

        Attributes:
            anystr_strip_whitespace: `True`
            use_enum_values: `True`

        '''
        anystr_strip_whitespace: bool = True
        use_enum_values: bool = True

Config

Config

Attributes:

Name Type Description
anystr_strip_whitespace bool

True

use_enum_values bool

True

Source code in structs/users.py
class Config:  # pylint: disable=too-few-public-methods
    ''' Config

    Attributes:
        anystr_strip_whitespace: `True`
        use_enum_values: `True`

    '''
    anystr_strip_whitespace: bool = True
    use_enum_values: bool = True

UserProfleRealBase

Bases: BaseModel

User Profile Real Base struct

Attributes:

Name Type Description
name str

name.

phone str

phone numbers.

roc_id str

user national id.

company str

company or school name.

Source code in structs/users.py
class UserProfleRealBase(BaseModel):
    ''' User Profile Real Base struct

    Attributes:
        name: name.
        phone: phone numbers.
        roc_id: user national id.
        company: company or school name.

    '''
    name: str = Field(default='')
    phone: str = Field(default='')
    roc_id: str = Field(default='')
    company: str = Field(default='')

    class Config:  # pylint: disable=too-few-public-methods
        ''' Config

        Attributes:
            anystr_strip_whitespace: `True`

        '''
        anystr_strip_whitespace: bool = True

Config

Config

Attributes:

Name Type Description
anystr_strip_whitespace bool

True

Source code in structs/users.py
class Config:  # pylint: disable=too-few-public-methods
    ''' Config

    Attributes:
        anystr_strip_whitespace: `True`

    '''
    anystr_strip_whitespace: bool = True