From 43433d9dce5f429d977c9581121cbde18916b824 Mon Sep 17 00:00:00 2001 From: coolneng Date: Fri, 11 Sep 2020 00:01:24 +0200 Subject: [PATCH] Create base schemas for common of attributes --- app/schemas.py | 58 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/app/schemas.py b/app/schemas.py index 6c4b8a4..2a16347 100644 --- a/app/schemas.py +++ b/app/schemas.py @@ -3,27 +3,63 @@ from pydantic import BaseModel, EmailStr from typing import Optional -class RegisterSchema(BaseModel): - full_name: str +class UserBase(BaseModel): email: EmailStr + device_id: str + lang_type: int = Query(None, ge=1, le=2) + user_type: int = Query(None, ge=1, le=2) + + +class UserCreate(UserBase): + full_name: str password: str gender: int = Query(None, ge=1, le=3) mobile: str = Query(None, min_length=8, max_length=13) user_image: Optional[str] = None - user_type: int = Query(None, ge=1, le=2) - lang_type: int = Query(None, ge=1, le=2) device_type: int = Query(None, ge=1, le=2) - device_id: str + city_id: int + access_key: str + badge: int + + class Config: + orm_mode = True -class LoginSchema(BaseModel): - email: EmailStr +class UserLogin(UserBase): password: str - user_type: int = Query(None, ge=1, le=2) - lang_type: int = Query(None, ge=1, le=2) - device_id: str + + class Config: + orm_mode = True -class OTPSchema(BaseModel): +class SocialLogin(UserBase): + type: int = Query(None, ge=1, le=2) + social_id: str + device_type: int = Query(None, ge=1, le=2) + mobile: str = Query(None, min_length=8, max_length=13) + full_name: str + + class Config: + orm_mode = True + + +class CreateResponse(UserBase): + id: int + full_name: str + password: str + gender: int = Query(None, ge=1, le=3) + mobile: str = Query(None, min_length=8, max_length=13) + user_image: Optional[str] = None + device_type: int = Query(None, ge=1, le=2) + otp: int = Query(None, ge=6, le=6) + + class Config: + orm_mode = True + + +class OTPVerify(BaseModel): access_key: str otp: int = Query(None, ge=6, le=6) + + class Config: + orm_mode = True