-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathuser.go
75 lines (56 loc) · 1.32 KB
/
user.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package twitter
import (
"errors"
"time"
userpb "github.com/code-payments/code-protobuf-api/generated/go/user/v1"
)
type Record struct {
Id uint64
Username string
Name string
ProfilePicUrl string
VerifiedType userpb.TwitterUser_VerifiedType
FollowerCount uint32
TipAddress string
LastUpdatedAt time.Time
CreatedAt time.Time
}
func (r *Record) Validate() error {
if len(r.Username) == 0 {
return errors.New("username is required")
}
if len(r.Name) == 0 {
return errors.New("name is required")
}
if len(r.ProfilePicUrl) == 0 {
return errors.New("profile pic url is required")
}
if len(r.TipAddress) == 0 {
return errors.New("tip address is required")
}
return nil
}
func (r *Record) Clone() Record {
return Record{
Id: r.Id,
Username: r.Username,
Name: r.Name,
ProfilePicUrl: r.ProfilePicUrl,
VerifiedType: r.VerifiedType,
FollowerCount: r.FollowerCount,
TipAddress: r.TipAddress,
LastUpdatedAt: r.LastUpdatedAt,
CreatedAt: r.CreatedAt,
}
}
func (r *Record) CopyTo(dst *Record) {
dst.Id = r.Id
dst.Username = r.Username
dst.Name = r.Name
dst.ProfilePicUrl = r.ProfilePicUrl
dst.VerifiedType = r.VerifiedType
dst.FollowerCount = r.FollowerCount
dst.TipAddress = r.TipAddress
dst.LastUpdatedAt = r.LastUpdatedAt
dst.CreatedAt = r.CreatedAt
}