forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.go
More file actions
61 lines (49 loc) · 1.13 KB
/
http.go
File metadata and controls
61 lines (49 loc) · 1.13 KB
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
package project
import (
"encoding/json"
"github.com/cli/cli/api"
"github.com/cli/cli/internal/ghrepo"
)
func getProject(client *api.Client, baseRepo ghrepo.Interface, projectID int) (*Project, error) {
data, err := client.GetProject(baseRepo, projectID)
if err != nil {
return nil, err
}
project := &Project{}
err = json.Unmarshal(data, project)
if err != nil {
return nil, err
}
data, err = client.GetProjectColumns(baseRepo, projectID)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &project.Columns)
if err != nil {
return nil, err
}
for _, column := range project.Columns {
data, err := client.GetProjectCards(baseRepo, column.ID)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &column.Cards)
if err != nil {
return nil, err
}
for _, card := range column.Cards {
// hydrate with any linked content
if card.Note == "" {
data, err := client.GetProjectCardContent(card.ContentURL)
if err != nil {
return nil, err
}
err = json.Unmarshal(data, &card.Content)
if err != nil {
return nil, err
}
}
}
}
return project, nil
}