Loading events.go +28 −0 Changes for events.go: 28 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -72,9 +72,31 @@ type ContributionEvent struct { PushData ContributionEventPushData `json:"push_data"` Note *Note `json:"note"` Author BasicUser `json:"author"` WikiPage *EventWikiPage `json:"wiki_page"` Imported bool `json:"imported"` // ImportedFrom is the literal string "none" when the event was not // imported, never the empty string, so a caller must compare against // "none" rather than test for emptiness. ImportedFrom string `json:"imported_from"` AuthorUsername string `json:"author_username"` } // EventWikiPage represents the wiki page an event happened to. It is sent // only on an event whose target is a wiki page. // // GitLab API docs: // https://docs.gitlab.com/api/events/#get-user-contribution-events type EventWikiPage struct { Format string `json:"format"` Slug string `json:"slug"` Title string `json:"title"` WikiPageMetaID int64 `json:"wiki_page_meta_id"` } func (w EventWikiPage) String() string { return Stringify(w) } // ContributionEventPushData represents a user's contribution push data. // // GitLab API docs: Loading Loading @@ -140,6 +162,12 @@ type ProjectEvent struct { TargetTitle string `json:"target_title"` CreatedAt string `json:"created_at"` Author BasicUser `json:"author"` WikiPage *EventWikiPage `json:"wiki_page"` Imported bool `json:"imported"` // ImportedFrom is the literal string "none" when the event was not // imported, never the empty string, so a caller must compare against // "none" rather than test for emptiness. ImportedFrom string `json:"imported_from"` AuthorUsername string `json:"author_username"` Data ProjectEventData `json:"data"` Note ProjectEventNote `json:"note"` Loading events_test.go +108 −7 Changes for events_test.go: 108 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -33,12 +33,48 @@ func TestUsersService_ListUserContributionEvents(t *testing.T) { "avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", "web_url": "http://localhost:3000/venky333" }, "imported": true, "imported_from": "github", "author_username": "venky333" }, { "id": 4, "project_id": 15, "action_name": "created", "target_id": 123, "target_type": "WikiPage::Meta", "author_id": 1, "target_title": "Deploy", "author": { "name": "Venkatesh Thalluri", "username": "venky333", "id": 1, "state": "active", "avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", "web_url": "http://localhost:3000/venky333" }, "wiki_page": { "format": "markdown", "slug": "deploy", "title": "Deploy", "wiki_page_meta_id": 123 }, "imported": false, "imported_from": "none", "author_username": "venky333" } ] `) }) author := BasicUser{ Name: "Venkatesh Thalluri", Username: "venky333", ID: 1, State: "active", AvatarURL: "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", WebURL: "http://localhost:3000/venky333", } want := []*ContributionEvent{ { ID: 3, Loading @@ -51,14 +87,27 @@ func TestUsersService_ListUserContributionEvents(t *testing.T) { AuthorID: 1, TargetTitle: "Public project search field", Note: nil, Author: BasicUser{ Name: "Venkatesh Thalluri", Username: "venky333", ID: 1, State: "active", AvatarURL: "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", WebURL: "http://localhost:3000/venky333", Author: author, Imported: true, ImportedFrom: "github", AuthorUsername: "venky333", }, { ID: 4, ProjectID: 15, ActionName: "created", TargetID: 123, TargetType: "WikiPage::Meta", AuthorID: 1, TargetTitle: "Deploy", Author: author, WikiPage: &EventWikiPage{ Format: "markdown", Slug: "deploy", Title: "Deploy", WikiPageMetaID: 123, }, ImportedFrom: "none", AuthorUsername: "venky333", }, } Loading Loading @@ -219,6 +268,32 @@ func TestEventsService_ListProjectVisibleEvents(t *testing.T) { "commit_title": "Add simple search to projects in public area" }, "target_title": null }, { "id": 5, "project_id": 15, "action_name": "created", "target_id": 123, "target_type": "WikiPage::Meta", "author_id": 1, "target_title": "Deploy", "author": { "name": "Venkatesh Thalluri", "username": "venky333", "id": 1, "state": "active", "avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", "web_url": "http://localhost:3000/venky333" }, "wiki_page": { "format": "markdown", "slug": "deploy", "title": "Deploy", "wiki_page_meta_id": 123 }, "imported": true, "imported_from": "github", "author_username": "venky333" } ] `) Loading Loading @@ -276,6 +351,32 @@ func TestEventsService_ListProjectVisibleEvents(t *testing.T) { CommitTitle: "Add simple search to projects in public area", }, }, { ID: 5, ProjectID: 15, ActionName: "created", TargetID: 123, TargetType: "WikiPage::Meta", AuthorID: 1, TargetTitle: "Deploy", Author: BasicUser{ Name: "Venkatesh Thalluri", Username: "venky333", ID: 1, State: "active", AvatarURL: "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", WebURL: "http://localhost:3000/venky333", }, WikiPage: &EventWikiPage{ Format: "markdown", Slug: "deploy", Title: "Deploy", WikiPageMetaID: 123, }, Imported: true, ImportedFrom: "github", AuthorUsername: "venky333", }, } ces, resp, err := client.Events.ListProjectVisibleEvents(15, nil, nil) Loading Loading
events.go +28 −0 Changes for events.go: 28 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -72,9 +72,31 @@ type ContributionEvent struct { PushData ContributionEventPushData `json:"push_data"` Note *Note `json:"note"` Author BasicUser `json:"author"` WikiPage *EventWikiPage `json:"wiki_page"` Imported bool `json:"imported"` // ImportedFrom is the literal string "none" when the event was not // imported, never the empty string, so a caller must compare against // "none" rather than test for emptiness. ImportedFrom string `json:"imported_from"` AuthorUsername string `json:"author_username"` } // EventWikiPage represents the wiki page an event happened to. It is sent // only on an event whose target is a wiki page. // // GitLab API docs: // https://docs.gitlab.com/api/events/#get-user-contribution-events type EventWikiPage struct { Format string `json:"format"` Slug string `json:"slug"` Title string `json:"title"` WikiPageMetaID int64 `json:"wiki_page_meta_id"` } func (w EventWikiPage) String() string { return Stringify(w) } // ContributionEventPushData represents a user's contribution push data. // // GitLab API docs: Loading Loading @@ -140,6 +162,12 @@ type ProjectEvent struct { TargetTitle string `json:"target_title"` CreatedAt string `json:"created_at"` Author BasicUser `json:"author"` WikiPage *EventWikiPage `json:"wiki_page"` Imported bool `json:"imported"` // ImportedFrom is the literal string "none" when the event was not // imported, never the empty string, so a caller must compare against // "none" rather than test for emptiness. ImportedFrom string `json:"imported_from"` AuthorUsername string `json:"author_username"` Data ProjectEventData `json:"data"` Note ProjectEventNote `json:"note"` Loading
events_test.go +108 −7 Changes for events_test.go: 108 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -33,12 +33,48 @@ func TestUsersService_ListUserContributionEvents(t *testing.T) { "avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", "web_url": "http://localhost:3000/venky333" }, "imported": true, "imported_from": "github", "author_username": "venky333" }, { "id": 4, "project_id": 15, "action_name": "created", "target_id": 123, "target_type": "WikiPage::Meta", "author_id": 1, "target_title": "Deploy", "author": { "name": "Venkatesh Thalluri", "username": "venky333", "id": 1, "state": "active", "avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", "web_url": "http://localhost:3000/venky333" }, "wiki_page": { "format": "markdown", "slug": "deploy", "title": "Deploy", "wiki_page_meta_id": 123 }, "imported": false, "imported_from": "none", "author_username": "venky333" } ] `) }) author := BasicUser{ Name: "Venkatesh Thalluri", Username: "venky333", ID: 1, State: "active", AvatarURL: "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", WebURL: "http://localhost:3000/venky333", } want := []*ContributionEvent{ { ID: 3, Loading @@ -51,14 +87,27 @@ func TestUsersService_ListUserContributionEvents(t *testing.T) { AuthorID: 1, TargetTitle: "Public project search field", Note: nil, Author: BasicUser{ Name: "Venkatesh Thalluri", Username: "venky333", ID: 1, State: "active", AvatarURL: "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", WebURL: "http://localhost:3000/venky333", Author: author, Imported: true, ImportedFrom: "github", AuthorUsername: "venky333", }, { ID: 4, ProjectID: 15, ActionName: "created", TargetID: 123, TargetType: "WikiPage::Meta", AuthorID: 1, TargetTitle: "Deploy", Author: author, WikiPage: &EventWikiPage{ Format: "markdown", Slug: "deploy", Title: "Deploy", WikiPageMetaID: 123, }, ImportedFrom: "none", AuthorUsername: "venky333", }, } Loading Loading @@ -219,6 +268,32 @@ func TestEventsService_ListProjectVisibleEvents(t *testing.T) { "commit_title": "Add simple search to projects in public area" }, "target_title": null }, { "id": 5, "project_id": 15, "action_name": "created", "target_id": 123, "target_type": "WikiPage::Meta", "author_id": 1, "target_title": "Deploy", "author": { "name": "Venkatesh Thalluri", "username": "venky333", "id": 1, "state": "active", "avatar_url": "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", "web_url": "http://localhost:3000/venky333" }, "wiki_page": { "format": "markdown", "slug": "deploy", "title": "Deploy", "wiki_page_meta_id": 123 }, "imported": true, "imported_from": "github", "author_username": "venky333" } ] `) Loading Loading @@ -276,6 +351,32 @@ func TestEventsService_ListProjectVisibleEvents(t *testing.T) { CommitTitle: "Add simple search to projects in public area", }, }, { ID: 5, ProjectID: 15, ActionName: "created", TargetID: 123, TargetType: "WikiPage::Meta", AuthorID: 1, TargetTitle: "Deploy", Author: BasicUser{ Name: "Venkatesh Thalluri", Username: "venky333", ID: 1, State: "active", AvatarURL: "http://localhost:3000/uploads/user/avatar/1/fox_avatar.png", WebURL: "http://localhost:3000/venky333", }, WikiPage: &EventWikiPage{ Format: "markdown", Slug: "deploy", Title: "Deploy", WikiPageMetaID: 123, }, Imported: true, ImportedFrom: "github", AuthorUsername: "venky333", }, } ces, resp, err := client.Events.ListProjectVisibleEvents(15, nil, nil) Loading