forked from dvsnin/yandex-tracker-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.go
113 lines (86 loc) · 2.54 KB
/
users.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package tracker
import (
"github.com/go-resty/resty/v2"
)
type BasicUsers []BasicUser
// User
// Basic user structure in Yandex.Tracker
type BasicUser struct {
Self string `json:"self"`
ID string `json:"id"`
Display string `json:"display"`
}
// Id
// Get user id
func (u *BasicUser) Id() string {
if u != nil {
return u.ID
}
return ""
}
// Name
// Get username
func (u *BasicUser) Name() string {
if u != nil {
return u.Display
}
return ""
}
type Users []User
// User structure in Yandex.Tracker
// https://cloud.yandex.ru/en/docs/tracker/get-user-info
type User struct {
// Address of the API resource with information about the user account
Self string `json:"self"`
// Unique ID of the user Tracker account
UID int `json:"uid"`
// User's login
Login string `json:"login"`
// Unique ID of the user Tracker account
TrackerUid int `json:"trackerUid"`
// Unique ID of the user account in the Yandex 360 for Business organization and Yandex ID
PassportUid int `json:"passportUid"`
// User unique ID in Yandex Cloud Organization
CloudUid string `json:"cloudUid"`
// User's first name
FirstName string `json:"firstName"`
// User's last name
LastName string `json:"lastName"`
// Displayed user name
Display string `json:"display"`
// User email address
Email string `json:"email"`
// Service parameter
External bool `json:"external"`
// Flag indicating whether the user has full access to Tracker:
// true: Full access
// false: Read-only access
HasLicense bool `json:"hasLicense"`
// User status in the organization:
// true: User is dismissed
// false: User is a current employee
Dismissed bool `json:"dismissed"`
// Service parameter
UseNewFilters bool `json:"useNewFilters"`
// Flag indicating whether user notifications are forced disabled:
// true: Disabled
// false: Enabled
DisableNotifications bool `json:"disableNotifications"`
// Date and time of the user's first authentication, in the YYYY-MM-DDThh:mm:ss.sss±hhmm format
FirstLoginDate string `json:"firstLoginDate"`
// Date and time of the user's last authentication, in the YYYY-MM-DDThh:mm:ss.sss±hhmm format
LastLoginDate string `json:"lastLoginDate"`
// Method of adding a user:
// true: By sending an invitation by email
// false: By other means
WelcomeMailSent bool `json:"welcomeMailSent"`
}
func (t *trackerClient) Myself() (*User, *resty.Response, error) {
req := t.NewRequest(resty.MethodGet, "/v2/myself", nil)
result := new(User)
resp, err := t.Do(req, result)
if err != nil {
return nil, nil, err
}
return result, resp, nil
}