-
Notifications
You must be signed in to change notification settings - Fork 1
/
user.go
78 lines (59 loc) · 2.12 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
76
77
78
package warrant
import (
"time"
"github.com/pivotal-cf-experimental/warrant/internal/documents"
)
// User is the representation of a user resource within UAA.
type User struct {
// ID is the unique identifier for the user.
ID string
// ExternalID is an identifier for the user as defined by the client that created it.
ExternalID string
// UserName is a human-friendly unique identifier for the user.
UserName string
// FormattedName is the full name, including middle names, of the user.
FormattedName string
// FamilyName is the family name, or last name, of the user.
FamilyName string
// GivenName is the given name, or first name, of the user.
GivenName string
// MiddleName is the middle name(s) of the user.
MiddleName string
// CreatedAt is a timestamp value indicating when the user was created.
CreatedAt time.Time
// UpdatedAt is a timestamp value indicating when the user was last modified.
UpdatedAt time.Time
// Version is an integer value indicating which revision this resource represents.
Version int
// Emails is a list of email addresses for this user.
Emails []string
// Groups is a list of groups to which this user is associated.
Groups []Group
// Active is a boolean value indicating the active status of the user.
Active bool
// Verified is a boolean value indicating whether this user has been verified.
Verified bool
// Origin is a value indicating where this user resource originated.
Origin string
}
func newUserFromResponse(config Config, response documents.UserResponse) User {
var emails []string
for _, email := range response.Emails {
emails = append(emails, email.Value)
}
return User{
ID: response.ID,
ExternalID: response.ExternalID,
UserName: response.UserName,
FormattedName: response.Name.Formatted,
FamilyName: response.Name.FamilyName,
GivenName: response.Name.GivenName,
MiddleName: response.Name.MiddleName,
Emails: emails,
CreatedAt: response.Meta.Created,
UpdatedAt: response.Meta.LastModified,
Active: response.Active,
Verified: response.Verified,
Origin: response.Origin,
}
}