responses.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. from datetime import datetime
  2. from typing import Optional
  3. from pydantic import BaseModel, ConfigDict, EmailStr
  4. class BaseResponse(BaseModel):
  5. # may define additional fields or config shared across responses
  6. model_config = ConfigDict(from_attributes=True)
  7. class BaseObjectResponse(BaseResponse):
  8. id: str
  9. created_at: datetime
  10. updated_at: datetime
  11. class AccessTokenResponse(BaseResponse):
  12. token_type: str
  13. access_token: str
  14. expires_at: int
  15. issued_at: int
  16. refresh_token: str
  17. refresh_token_expires_at: int
  18. refresh_token_issued_at: int
  19. class UserResponse(BaseResponse):
  20. id: str
  21. email: EmailStr
  22. class VolunteerResponse(BaseObjectResponse):
  23. name: str
  24. surname: str
  25. email: str
  26. phone_number: str
  27. automatic_sms: bool
  28. slots_id: list[str] = []
  29. class SlotResponse(BaseObjectResponse):
  30. title: str
  31. starting_time: datetime
  32. ending_time: datetime
  33. required_volunteers: int
  34. volunteers_id: list[str] = []
  35. template_id: Optional[str]
  36. class SMSResponse(BaseObjectResponse):
  37. volunteer_id: Optional[str]
  38. content: str
  39. phone_number: str
  40. sending_time: datetime
  41. send_time: Optional[datetime]
  42. class TemplateResponse(BaseObjectResponse):
  43. title: str
  44. description: str
  45. place: str
  46. responsible_contact: str
  47. tags_id: list[str] = []
  48. class TagResponse(BaseObjectResponse):
  49. title: str
  50. templates_id: list[str] = []
  51. class ProjectResponse(BaseObjectResponse):
  52. name: str
  53. volunteers: list[VolunteerResponse]
  54. sms: list[SMSResponse]
  55. slots: list[SlotResponse]
  56. tags: list[TagResponse]
  57. templates: list[TemplateResponse]
  58. is_public: bool
  59. class ProjectListResponse(BaseResponse):
  60. id: str
  61. created_at: datetime
  62. updated_at: datetime
  63. name: str
  64. is_public: bool