This repository has been archived by the owner on Jun 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
user_struct.go
59 lines (52 loc) · 2.19 KB
/
user_struct.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
package zendesk
import (
"github.com/ttacon/libphonenumber"
"strings"
)
type ManyUsers struct {
Users []User
}
type User struct {
Id int`json:"id,omitempty"`
Url string `json:"url,omitempty"`
Name string `json:"name,omitempty"`
ExternalId string `json:"external_id,omitempty"`
Alias string `json:"alias,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
UpdatedAt string `json:"updated_at,omitempty"`
Active bool `json:"active,omitempty"`
Verified bool `json:"verified,omitempty"`
Shared bool `json:"shared,omitempty"`
SharedAgent bool `json:"shared_agent,omitempty"`
Locale string `json:"locale,omitempty"`
LocaleId int `json:"locale_id,omitempty"`
TimeZone string `json:"time_zone,omitempty"`
LastLoginAt string `json:"last_login_at,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
Signature string `json:"signature,omitempty"`
Details string `json:"details,omitempty"`
Notes string `json:"notes,omitempty"`
OrganizationId int `json:"organization_id,omitempty"`
Role string `json:"role,omitempty"`
CustomRoleId string `json:"custom_role_id,omitempty"`
Moderator bool `json:"moderator,omitempty"`
TicketRestriction string `json:"ticket_restriction,omitempty"`
OnlyPrivateComments bool `json:"only_private_comments,omitempty"`
Tags []string `json:"tags,omitempty"`
Suspended bool `json:"suspended,omitempty"`
RestrictedAgent bool `json:"restricted_agent,omitempty"`
Photo *Attachment `json:"photo,omitempty"`
UserFields map[string]interface{} `json:"user_fields,omitempty"`
}
type Attachment struct{}
func (u *User) FormatPhone(country string) {
if u.Phone != "" {
num, _ := libphonenumber.Parse(u.Phone, strings.ToUpper(country))
u.Phone = libphonenumber.Format(num, libphonenumber.E164)
}
}
func (users *ManyUsers) AppendUsers(user User) []User {
users.Users = append(users.Users, user)
return users.Users
}