-
Notifications
You must be signed in to change notification settings - Fork 3
/
shared_hierarchy.go
129 lines (123 loc) · 4.04 KB
/
shared_hierarchy.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
127
128
129
package clickup
import (
"context"
"fmt"
"net/http"
)
type SharedHierarchyResponse struct {
Shared struct {
Tasks []struct {
ID string `json:"id"`
CustomID struct {
} `json:"custom_id"`
Name string `json:"name"`
Status struct {
Status string `json:"status"`
Color string `json:"color"`
Type string `json:"type"`
Orderindex int `json:"-"`
} `json:"status"`
Orderindex string `json:"-"`
DateCreated string `json:"date_created"`
DateUpdated string `json:"date_updated"`
DateClosed string `json:"date_closed"`
Archived bool `json:"archived"`
Creator struct {
ID int `json:"id"`
Username string `json:"username"`
Color string `json:"color"`
Email string `json:"email"`
ProfilePicture string `json:"profilePicture"`
} `json:"creator"`
Assignees []struct {
ID int `json:"id"`
Username string `json:"username"`
Color string `json:"color"`
Initials string `json:"initials"`
Email string `json:"email"`
ProfilePicture string `json:"profilePicture"`
} `json:"assignees"`
Parent struct {
} `json:"parent"`
Priority struct {
} `json:"priority"`
DueDate struct {
} `json:"due_date"`
StartDate struct {
} `json:"start_date"`
Points struct {
} `json:"points"`
TimeEstimate struct {
} `json:"time_estimate"`
CustomFields []struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
TypeConfig struct {
NewDropDown bool `json:"new_drop_down"`
Options []struct {
ID string `json:"id"`
Name string `json:"name"`
Color string `json:"color"`
Orderindex int `json:"-"`
} `json:"options"`
} `json:"type_config"`
DateCreated string `json:"date_created"`
HideFromGuests bool `json:"hide_from_guests"`
Required bool `json:"required"`
} `json:"custom_fields"`
TeamID string `json:"team_id"`
URL string `json:"url"`
PermissionLevel string `json:"permission_level"`
List struct {
ID string `json:"id"`
Name string `json:"name"`
Access bool `json:"access"`
} `json:"list"`
Project struct {
ID string `json:"id"`
Name string `json:"name"`
Hidden bool `json:"hidden"`
Access bool `json:"access"`
} `json:"project"`
Folder struct {
ID string `json:"id"`
Name string `json:"name"`
Hidden bool `json:"hidden"`
Access bool `json:"access"`
} `json:"folder"`
Space struct {
ID string `json:"id"`
} `json:"space"`
} `json:"tasks"`
Lists []struct {
ID string `json:"id"`
Name string `json:"name"`
Orderindex int `json:"-"`
TaskCount string `json:"task_count"`
Archived bool `json:"archived"`
} `json:"lists"`
Folders []struct {
ID string `json:"id"`
Name string `json:"name"`
Orderindex int `json:"-"`
TaskCount string `json:"task_count"`
Archived bool `json:"archived"`
} `json:"folders"`
} `json:"shared"`
}
// SharedHierarchy returns resources that the authenticated user has access to, but not to its parent.
// From the ClickUp documentation:
// "Returns all resources you have access to where you don't have access to its parent. For example,
// if you have a access to a shared task, but don't have access to its parent list, it will come back in this request."
func (c *Client) SharedHierarchy(ctx context.Context, workspaceID string) (*SharedHierarchyResponse, error) {
if workspaceID == "" {
return nil, fmt.Errorf("must provide a workspace id to query shared hierarchy: %w", ErrValidation)
}
endpoint := fmt.Sprintf("/team/%s/shared", workspaceID)
var sharedHierarchyResponse SharedHierarchyResponse
if err := c.call(ctx, http.MethodGet, endpoint, nil, &sharedHierarchyResponse); err != nil {
return nil, fmt.Errorf("failed to make clickup request: %w", err)
}
return &sharedHierarchyResponse, nil
}