responses.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. comment: str
  30. class SlotResponse(BaseObjectResponse):
  31. title: str
  32. starting_time: datetime
  33. ending_time: datetime
  34. required_volunteers: int
  35. volunteers_id: list[str] = []
  36. template_id: Optional[str]
  37. class SMSResponse(BaseObjectResponse):
  38. volunteer_id: Optional[str]
  39. content: str
  40. phone_number: str
  41. sending_time: datetime
  42. send_time: Optional[datetime]
  43. class TemplateResponse(BaseObjectResponse):
  44. title: str
  45. description: str
  46. place: str
  47. responsible_contact: str
  48. tags_id: list[str] = []
  49. comment: str
  50. class TagResponse(BaseObjectResponse):
  51. title: str
  52. templates_id: list[str] = []
  53. class ProjectResponse(BaseObjectResponse):
  54. name: str
  55. volunteers: list[VolunteerResponse]
  56. sms: list[SMSResponse]
  57. slots: list[SlotResponse]
  58. tags: list[TagResponse]
  59. templates: list[TemplateResponse]
  60. is_public: bool
  61. class ProjectListResponse(BaseResponse):
  62. id: str
  63. created_at: datetime
  64. updated_at: datetime
  65. name: str
  66. is_public: bool