requests.go 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. package common
  2. import "github.com/google/uuid"
  3. // Common Response Types
  4. type ErrorResponse struct {
  5. Error string `json:"error"`
  6. }
  7. type MessageResponse struct {
  8. Message string `json:"message"`
  9. }
  10. // Auth Requests/Responses
  11. type AuthLoginRequest struct {
  12. Email string `json:"email" binding:"required,email"`
  13. Password string `json:"password" binding:"required,password"`
  14. }
  15. type AuthLoginResponse struct {
  16. Token string `json:"token"`
  17. User User `json:"user"`
  18. }
  19. // User Requests/Responses
  20. type UserCreateRequest struct {
  21. Email string `json:"email" binding:"required,email"`
  22. Name string `json:"name" binding:"required,min=2,max=100"`
  23. PhoneNumber string `json:"phone_number" binding:"omitempty,phone"`
  24. Password string `json:"password" binding:"required,password"`
  25. }
  26. type UserCreateResponse struct {
  27. User User `json:"user"`
  28. }
  29. type UserUpdateRequest struct {
  30. Name string `json:"name" binding:"required,min=2,max=100"`
  31. PhoneNumber string `json:"phone_number" binding:"omitempty,phone"`
  32. }
  33. type UserUpdateResponse struct {
  34. User User `json:"user"`
  35. }
  36. type UserResponse struct {
  37. User User `json:"user"`
  38. Workspaces []Workspace `json:"workspaces"`
  39. }
  40. // Workspace Requests/Responses
  41. type WorkspaceCreateRequest struct {
  42. Name string `json:"name" binding:"required,min=2,max=100"`
  43. }
  44. type WorkspaceCreateResponse struct {
  45. ID uuid.UUID `json:"id"`
  46. Name string `json:"name"`
  47. }
  48. type WorkspaceResponse struct {
  49. Workspace Workspace `json:"workspace"`
  50. }
  51. type WorkspaceListResponse struct {
  52. Workspaces []Workspace `json:"workspaces"`
  53. }
  54. type WorkspaceOwnerInitRequest struct {
  55. Email string `json:"email" binding:"required,email"`
  56. Name string `json:"name" binding:"required,min=2,max=100"`
  57. PhoneNumber string `json:"phone_number" binding:"omitempty,phone"`
  58. }
  59. type WorkspaceOwnerInitResponse struct {
  60. User User `json:"user"`
  61. }
  62. type WorkspaceOwnerCreateRequest struct {
  63. Email string `json:"email" binding:"required,email"`
  64. Name string `json:"name" binding:"required,min=2,max=100"`
  65. PhoneNumber string `json:"phone_number" binding:"omitempty,phone"`
  66. Password string `json:"password" binding:"required,password"`
  67. }
  68. type WorkspaceOwnerCreateResponse struct {
  69. User User `json:"user"`
  70. }
  71. type WorkspaceMemberAddRequest struct {
  72. WorkspaceID uuid.UUID `json:"workspace_id" binding:"required,uuid"`
  73. Role string `json:"role" binding:"required,oneof=admin member"`
  74. }
  75. type WorkspaceMemberAddResponse struct {
  76. Message string `json:"message"`
  77. }
  78. // Profile Requests/Responses
  79. type ProfileCreateRequest struct {
  80. Name string `json:"name" binding:"required,min=2,max=100"`
  81. WorkspaceID uuid.UUID `json:"workspace_id" binding:"required,uuid"`
  82. }
  83. type ProfileCreateResponse struct {
  84. Profile Profile `json:"profile"`
  85. }
  86. type ProfileUpdateRequest struct {
  87. Name string `json:"name" binding:"required,min=2,max=100"`
  88. }
  89. type ProfileUpdateResponse struct {
  90. Profile Profile `json:"profile"`
  91. }
  92. type ProfileResponse struct {
  93. Profile Profile `json:"profile"`
  94. }
  95. type ProfileListResponse struct {
  96. Profiles []Profile `json:"profiles"`
  97. }
  98. // Invitation Requests/Responses
  99. type InvitationCreateRequest struct {
  100. Email string `json:"email" binding:"required,email"`
  101. WorkspaceID uuid.UUID `json:"workspace_id" binding:"required,uuid"`
  102. Role string `json:"role" binding:"required,oneof=admin member"`
  103. }
  104. type InvitationCreateResponse struct {
  105. ID uuid.UUID `json:"id"`
  106. Email string `json:"email"`
  107. Status string `json:"status"`
  108. ExpiresAt string `json:"expires_at"`
  109. WorkspaceID uuid.UUID `json:"workspace_id"`
  110. }
  111. type InvitationAcceptRequest struct {
  112. Email string `json:"email" binding:"required,email"`
  113. Name string `json:"name" binding:"required,min=2,max=100"`
  114. PhoneNumber string `json:"phone_number" binding:"omitempty,phone"`
  115. Password string `json:"password" binding:"required,password"`
  116. Token string `json:"token" binding:"required"`
  117. }
  118. type InvitationAcceptResponse struct {
  119. User User `json:"user"`
  120. WorkspaceID uuid.UUID `json:"workspace_id"`
  121. }
  122. type InvitationValidateResponse struct {
  123. Valid bool `json:"valid"`
  124. WorkspaceID uuid.UUID `json:"workspace_id"`
  125. Email string `json:"email"`
  126. Error string `json:"error,omitempty"`
  127. }
  128. type InvitationListResponse struct {
  129. Invitations []Invite `json:"invitations"`
  130. }