-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprojectPermission.go
126 lines (114 loc) · 3.75 KB
/
projectPermission.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
114
115
116
117
118
119
120
121
122
123
124
125
126
package ganboard
// GetProjectUsers https://docs.kanboard.org/en/latest/api/project_permission_procedures.html#getprojectusers
func (c *Client) GetProjectUsers(projectID int) (map[int]string, error) {
query := request{
Client: c,
Method: "getProjectUsers",
Params: map[string]int{
"project_id": projectID,
},
}
response, err := query.decodeMapIntString()
return response, err
}
// GetAssignableUsers https://docs.kanboard.org/en/latest/api/project_permission_procedures.html#getassignableusers
func (c *Client) GetAssignableUsers(params AssignableUsersParams) (map[int]string, error) {
query := request{
Client: c,
Method: "getAssignableUsers",
Params: params,
}
response, err := query.decodeMapIntString()
return response, err
}
// AddProjectUser https://docs.kanboard.org/en/latest/api/project_permission_procedures.html#addprojectuser
func (c *Client) AddProjectUser(params ProjectUserParams) (bool, error) {
query := request{
Client: c,
Method: "addProjectUser",
Params: params,
}
response, err := query.decodeBoolean()
return response, err
}
// AddProjectGroup https://docs.kanboard.org/en/latest/api/project_permission_procedures.html#addprojectgroup
func (c *Client) AddProjectGroup(params ProjectGroupParams) (bool, error) {
query := request{
Client: c,
Method: "addProjectGroup",
Params: params,
}
response, err := query.decodeBoolean()
return response, err
}
// RemoveProjectUser https://docs.kanboard.org/en/latest/api/project_permission_procedures.html#removeprojectuser
func (c *Client) RemoveProjectUser(params ProjectUserParams) (bool, error) {
query := request{
Client: c,
Method: "removeProjectUser",
Params: params,
}
response, err := query.decodeBoolean()
return response, err
}
// RemoveProjectGroup https://docs.kanboard.org/en/latest/api/project_permission_procedures.html#removeprojectgroup
func (c *Client) RemoveProjectGroup(params ProjectGroupParams) (bool, error) {
query := request{
Client: c,
Method: "removeProjectGroup",
ID: 1,
Params: params,
}
response, err := query.decodeBoolean()
return response, err
}
// ChangeProjectUserRole https://docs.kanboard.org/en/latest/api/project_permission_procedures.html#changeprojectuserrole
func (c *Client) ChangeProjectUserRole(params ProjectUserParams) (bool, error) {
query := request{
Client: c,
Method: "changeProjectUserRole",
Params: params,
}
response, err := query.decodeBoolean()
return response, err
}
// ChangeProjectGroupRole https://docs.kanboard.org/en/latest/api/project_permission_procedures.html#changeprojectgrouprole
func (c *Client) ChangeProjectGroupRole(params ProjectUserParams) (bool, error) {
query := request{
Client: c,
Method: "changeProjectGroupRole",
Params: params,
}
response, err := query.decodeBoolean()
return response, err
}
// GetProjectUserRole https://docs.kanboard.org/en/latest/api/project_permission_procedures.html#getprojectuserrole
func (c *Client) GetProjectUserRole(projectID int, userID int) (string, error) {
query := request{
Client: c,
Method: "getProjectUserRole",
Params: map[string]int{
"project_id": projectID,
"user_id": userID,
},
}
response, err := query.decodeString()
return response, err
}
// AssignableUsersParams input for GetAssignableUsers
type AssignableUsersParams struct {
ProjectID int `json:"project_id"`
PreprendUnassigned bool `json:"preprend_unasssigned,omitempty"`
}
// ProjectUserParams input for AddProjectUser
type ProjectUserParams struct {
ProjectID int `json:"project_id"`
UserID int `json:"user_id"`
Role string `json:"role,omitempty"`
}
// ProjectGroupParams input for AddProjectGroup
type ProjectGroupParams struct {
ProjectID int `json:"project_id"`
GroupID int `json:"group_id"`
Role string `json:"role,omitempty"`
}