responses.py 1.8 KB

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