-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresponseModels.go
More file actions
43 lines (37 loc) · 1.05 KB
/
responseModels.go
File metadata and controls
43 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"time"
"github.com/google/uuid"
"github.com/mikarwacki/chirpy/internal/database"
)
type responseChirp struct {
ID uuid.UUID `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Body string `json:"body"`
UserID uuid.UUID `json:"user_id"`
}
type responseUser struct {
ID uuid.UUID `json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
Email string `json:"email"`
IsChirpyRed bool `json:"is_chirpy_red"`
Token string `json:"token"`
RefreshToken string `json:"refresh_token"`
}
func NewResponseUser(user database.User, token string, refreshToken string) *responseUser {
return &responseUser{
ID: user.ID,
CreatedAt: user.CreatedAt,
UpdatedAt: user.UpdatedAt,
Email: user.Email,
IsChirpyRed: user.IsChirpyRed,
Token: token,
RefreshToken: refreshToken,
}
}
type requestUser struct {
Email string `json:"email"`
Password string `json:"password"`
}