forked from plouc/go-gitlab-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.go
72 lines (57 loc) · 1.73 KB
/
events.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
package gogitlab
import (
"encoding/xml"
"fmt"
"time"
)
type Person struct {
Name string `xml:"name" json:"name"`
Email string `xml:"email" json:"email"`
}
type Link struct {
Rel string `xml:"rel,attr,omitempty" json:"rel"`
Href string `xml:"href,attr" json:"href"`
}
type ActivityFeed struct {
Title string `xml:"title" json:"title"`
Id string `xml:"id" json:"id"`
Link []Link `xml:"link" json:"link"`
Updated time.Time `xml:"updated,attr" json:"updated"`
Entries []*FeedCommit `xml:"entry" json:"entries"`
}
type FeedCommit struct {
Id string `xml:"id" json:"id"`
Title string `xml:"title" json:"title"`
Link []Link `xml:"link" json:"link"`
Updated time.Time `xml:"updated" json:"updated"`
Author Person `xml:"author" json:"author"`
Summary string `xml:"summary" json:"summary"`
//<media:thumbnail width="40" height="40" url="https://secure.gravatar.com/avatar/7070eab7c6206530d3b7820362227fec?s=40&d=mm"/>
}
func (g *Gitlab) Activity() (ActivityFeed, error) {
url := g.BaseUrl + dashboardFeedPath + "?private_token=" + g.Token
fmt.Println(url)
contents, err := g.buildAndExecRequest("GET", url, nil)
if err != nil {
fmt.Printf("%s\n", err.Error())
}
var activity ActivityFeed
err = xml.Unmarshal(contents, &activity)
if err != nil {
fmt.Printf("%s\n", err.Error())
}
return activity, err
}
func (g *Gitlab) RepoActivityFeed(feedPath string) ActivityFeed {
url := g.BaseUrl + g.RepoFeedPath + "?private_token=" + g.Token
contents, err := g.buildAndExecRequest("GET", url, nil)
if err != nil {
fmt.Printf("%s\n", err)
}
var activity ActivityFeed
err = xml.Unmarshal(contents, &activity)
if err != nil {
fmt.Printf("%s\n", err)
}
return activity
}