Repository: nicklaw5/helix
Pull request #73 (2021-02-05 17:07:51)

Added "broadcaster_login" and "user_login" field for several API response
Added "broadcaster_login" and "user_login" for API response.
Source : https://dev.twitch.tv/docs/change-log post at 2021‑01‑28 .


Patch:
diff --git a/bits.go b/bits.go
index 1b4c1b5..2738b9b 100644
--- a/bits.go
+++ b/bits.go
@@ -4,10 +4,11 @@ import "time"
 
 // UserBitTotal ...
 type UserBitTotal struct {
-	UserID   string `json:"user_id"`
-	UserName string `json:"user_name"`
-	Rank     int    `json:"rank"`
-	Score    int    `json:"score"`
+	UserID    string `json:"user_id"`
+	UserLogin string `json:"user_login"`
+	UserName  string `json:"user_name"`
+	Rank      int    `json:"rank"`
+	Score     int    `json:"score"`
 }
 
 // ManyUserBitTotals ...
diff --git a/channels.go b/channels.go
index b6cba97..f9c4057 100644
--- a/channels.go
+++ b/channels.go
@@ -16,15 +16,16 @@ type ManySearchChannels struct {
 
 // Channel describes a channel from SearchChannel
 type Channel struct {
-	ID           string   `json:"id"`
-	GameID       string   `json:"game_id"`
-	DisplayName  string   `json:"display_name"`
-	Language     string   `json:"broadcaster_language"`
-	Title        string   `json:"title"`
-	ThumbnailURL string   `json:"thumbnail_url"`
-	IsLive       bool     `json:"is_live"`
-	StartedAt    Time     `json:"started_at"`
-	TagIDs       []string `json:"tag_ids"`
+	ID               string   `json:"id"`
+	GameID           string   `json:"game_id"`
+	BroadcasterLogin string   `json:"broadcaster_login"`
+	DisplayName      string   `json:"display_name"`
+	Language         string   `json:"broadcaster_language"`
+	Title            string   `json:"title"`
+	ThumbnailURL     string   `json:"thumbnail_url"`
+	IsLive           bool     `json:"is_live"`
+	StartedAt        Time     `json:"started_at"`
+	TagIDs           []string `json:"tag_ids"`
 }
 
 // SearchChannelsResponse is the response from SearchChannels
diff --git a/moderation.go b/moderation.go
index ae63cbc..a506497 100644
--- a/moderation.go
+++ b/moderation.go
@@ -4,6 +4,7 @@ package helix
 // ExpiresAt must be parsed manually since an empty string means perma ban
 type Ban struct {
 	UserID    string `json:"user_id"`
+	UserLogin string `json:"user_login"`
 	UserName  string `json:"user_name"`
 	ExpiresAt Time   `json:"expires_at"`
 }
diff --git a/stream_markers.go b/stream_markers.go
index f4b2bfd..a4c41c3 100644
--- a/stream_markers.go
+++ b/stream_markers.go
@@ -17,9 +17,10 @@ type VideoMarker struct {
 
 // StreamMarker ...
 type StreamMarker struct {
-	UserID   string        `json:"user_id"`
-	UserName string        `json:"user_name"`
-	Videos   []VideoMarker `json:"videos"`
+	UserID    string        `json:"user_id"`
+	UserName  string        `json:"user_name"`
+	UserLogin string        `json:"user_login"`
+	Videos    []VideoMarker `json:"videos"`
 }
 
 // ManyStreamMarkers ...
diff --git a/streams.go b/streams.go
index 2b869ad..83f525e 100644
--- a/streams.go
+++ b/streams.go
@@ -6,6 +6,7 @@ import "time"
 type Stream struct {
 	ID           string    `json:"id"`
 	UserID       string    `json:"user_id"`
+	UserLogin    string    `json:"user_login"`
 	UserName     string    `json:"user_name"`
 	GameID       string    `json:"game_id"`
 	TagIDs       []string  `json:"tag_ids"`
diff --git a/users.go b/users.go
index 8870912..38058d2 100644
--- a/users.go
+++ b/users.go
@@ -76,6 +76,7 @@ func (c *Client) UpdateUser(params *UpdateUserParams) (*UsersResponse, error) {
 // UserFollow ...
 type UserFollow struct {
 	FromID     string    `json:"from_id"`
+	FromLogin  string    `json:"from_login"`
 	FromName   string    `json:"from_name"`
 	ToID       string    `json:"to_id"`
 	ToName     string    `json:"to_name"`
diff --git a/videos.go b/videos.go
index d12779c..c909e4f 100644
--- a/videos.go
+++ b/videos.go
@@ -4,6 +4,7 @@ package helix
 type Video struct {
 	ID           string `json:"id"`
 	UserID       string `json:"user_id"`
+	UserLogin    string `json:"user_login"`
 	UserName     string `json:"user_name"`
 	Title        string `json:"title"`
 	Description  string `json:"description"`


Test patch:
diff --git a/bits_test.go b/bits_test.go
index 7bbde5b..241ee0c 100644
--- a/bits_test.go
+++ b/bits_test.go
@@ -31,7 +31,7 @@ func TestClient_GetBitsLeaderboard(t *testing.T) {
 			2,
 			"week",
 			time.Time{},
-			`{"data":[{"user_id":"158010205","user_name":"TundraCowboy","rank":1,"score":12543},{"user_id":"7168163","rank":2,"score":6900}],"date_range":{"started_at":"2018-02-05T08:00:00Z","ended_at":"2018-02-12T08:00:00Z"},"total":2}`,
+			`{"data":[{"user_id":"158010205","user_login":"tundracowboy","user_name":"TundraCowboy","rank":1,"score":12543},{"user_id":"7168163","rank":2,"score":6900}],"date_range":{"started_at":"2018-02-05T08:00:00Z","ended_at":"2018-02-12T08:00:00Z"},"total":2}`,
 		},
 		{
 			http.StatusOK,
diff --git a/channels_test.go b/channels_test.go
index e66f341..f37813e 100644
--- a/channels_test.go
+++ b/channels_test.go
@@ -22,24 +22,26 @@ func TestSearchChannels(t *testing.T) {
 			`{"data":[{"broadcaster_language":"en","display_name":"Ninja","game_id":"33214","id":"27833742640","is_live":false,"tag_ids":[],"thumbnail_url":"https://static-cdn.jtvnw.net/previews-ttv/live_user_ninja-{width}x{height}.jpg","title":"I have lost my voice D: | twitter.com/Ninja","started_at":"2018-03-06T15:07:45Z"},{"broadcaster_language":"en","display_name":"DrDisrespect","game_id":"33214","id":"27834185424","is_live":false,"tag_ids":[],"thumbnail_url":"https://static-cdn.jtvnw.net/previews-ttv/live_user_drdisrespectlive-{width}x{height}.jpg","title":"Turbo Treehouses || @DrDisRespect","started_at":"2018-03-06T16:05:00Z"}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6Mn19"}}`,
 			[]Channel{
 				Channel{
-					ID:           "27833742640",
-					GameID:       "33214",
-					DisplayName:  "Ninja",
-					Language:     "en",
-					Title:        "I have lost my voice D: | twitter.com/Ninja",
-					ThumbnailURL: "https://static-cdn.jtvnw.net/previews-ttv/live_user_ninja-{width}x{height}.jpg",
-					IsLive:       false,
-					TagIDs:       []string{},
+					ID:               "27833742640",
+					GameID:           "33214",
+					BroadcasterLogin: "ninja",
+					DisplayName:      "Ninja",
+					Language:         "en",
+					Title:            "I have lost my voice D: | twitter.com/Ninja",
+					ThumbnailURL:     "https://static-cdn.jtvnw.net/previews-ttv/live_user_ninja-{width}x{height}.jpg",
+					IsLive:           false,
+					TagIDs:           []string{},
 				},
 				Channel{
-					ID:           "27834185424",
-					GameID:       "33214",
-					DisplayName:  "DrDisrespect",
-					Language:     "en",
-					Title:        "Turbo Treehouses || @DrDisRespect",
-					ThumbnailURL: "https://static-cdn.jtvnw.net/previews-ttv/live_user_drdisrespectlive-{width}x{height}.jpg",
-					IsLive:       false,
-					TagIDs:       []string{},
+					ID:               "27834185424",
+					GameID:           "33214",
+					BroadcasterLogin: "drdisrespect",
+					DisplayName:      "DrDisrespect",
+					Language:         "en",
+					Title:            "Turbo Treehouses || @DrDisRespect",
+					ThumbnailURL:     "https://static-cdn.jtvnw.net/previews-ttv/live_user_drdisrespectlive-{width}x{height}.jpg",
+					IsLive:           false,
+					TagIDs:           []string{},
 				},
 			},
 		},
diff --git a/moderation_test.go b/moderation_test.go
index c1b28b5..4ca30d9 100644
--- a/moderation_test.go
+++ b/moderation_test.go
@@ -33,7 +33,7 @@ func TestGetBannedUsers(t *testing.T) {
 			"",
 			"",
 			"",
-			`{"data":[{"expires_at":"","user_id":"54946241","user_name":"chronophylos"},{"expires_at":"2022-03-15T02:00:28Z","user_id":"423374343","user_name":"glowillig"}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6MX19"}}`,
+			`{"data":[{"expires_at":"","user_id":"54946241","user_name":"chronophylos","user_name":"chronophylos"},{"expires_at":"2022-03-15T02:00:28Z","user_id":"423374343","user_name":"glowillig"}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6MX19"}}`,
 		},
 	}
 
diff --git a/stream_markers_test.go b/stream_markers_test.go
index c5cf7d9..0f91d58 100644
--- a/stream_markers_test.go
+++ b/stream_markers_test.go
@@ -22,7 +22,7 @@ func TestGetStreamMarkers(t *testing.T) {
 			"123",
 			1,
 			5,
-			`{"data":[{"user_id":"123","user_name":"DisplayName","videos":[{"video_id":"456","markers":[{"id":"106b8d6243a4f883d25ad75e6cdffdc4","created_at":"2018-08-20T20:10:03Z","description":"hello,thisisamarker!","position_seconds":244,"URL":"https://twitch.tv/videos/456?t=0h4m06s"}]}]}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjoiMjk1MjA0Mzk3OjI1Mzpib29rbWFyazoxMDZiOGQ1Y"}}`},
+			`{"data":[{"user_id":"123","user_name":"displayname","user_name":"DisplayName","videos":[{"video_id":"456","markers":[{"id":"106b8d6243a4f883d25ad75e6cdffdc4","created_at":"2018-08-20T20:10:03Z","description":"hello,thisisamarker!","position_seconds":244,"URL":"https://twitch.tv/videos/456?t=0h4m06s"}]}]}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjoiMjk1MjA0Mzk3OjI1Mzpib29rbWFyazoxMDZiOGQ1Y"}}`},
 		{
 			http.StatusBadRequest,
 			&Options{ClientID: "my-client-id"},
diff --git a/streams_test.go b/streams_test.go
index 17d43c4..d88ade1 100644
--- a/streams_test.go
+++ b/streams_test.go
@@ -18,7 +18,7 @@ func TestGetStreams(t *testing.T) {
 			http.StatusOK,
 			&Options{ClientID: "my-client-id"},
 			2,
-			`{"data":[{"id":"27833742640","user_id":"19571641","user_name":"Ninja","game_id":"33214","tag_ids":[],"type":"live","title":"I have lost my voice D: | twitter.com/Ninja","viewer_count":72124,"started_at":"2018-03-06T15:07:45Z","language":"en","thumbnail_url":"https://static-cdn.jtvnw.net/previews-ttv/live_user_ninja-{width}x{height}.jpg"},{"id":"27834185424","user_id":"17337557","user_name":"DrDisrespect","game_id":"33214","tag_ids":[],"type":"live","title":"Turbo Treehouses || @DrDisRespect","viewer_count":29687,"started_at":"2018-03-06T16:05:00Z","language":"en","thumbnail_url":"https://static-cdn.jtvnw.net/previews-ttv/live_user_drdisrespectlive-{width}x{height}.jpg"}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6Mn19"}}`,
+			`{"data":[{"id":"27833742640","user_id":"19571641","user_login":"ninja","user_name":"Ninja","game_id":"33214","tag_ids":[],"type":"live","title":"I have lost my voice D: | twitter.com/Ninja","viewer_count":72124,"started_at":"2018-03-06T15:07:45Z","language":"en","thumbnail_url":"https://static-cdn.jtvnw.net/previews-ttv/live_user_ninja-{width}x{height}.jpg"},{"id":"27834185424","user_id":"17337557","user_name":"DrDisrespect","game_id":"33214","tag_ids":[],"type":"live","title":"Turbo Treehouses || @DrDisRespect","viewer_count":29687,"started_at":"2018-03-06T16:05:00Z","language":"en","thumbnail_url":"https://static-cdn.jtvnw.net/previews-ttv/live_user_drdisrespectlive-{width}x{height}.jpg"}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6Mn19"}}`,
 		},
 		{
 			http.StatusBadRequest,
diff --git a/videos_test.go b/videos_test.go
index 10fad46..d913994 100644
--- a/videos_test.go
+++ b/videos_test.go
@@ -24,7 +24,7 @@ func TestGetVideos(t *testing.T) {
 			http.StatusOK,
 			&Options{ClientID: "my-client-id"},
 			&VideosParams{GameID: "21779", Period: "month", Type: "highlight", Language: "en", Sort: "views", First: 1},
-			`{"data":[{"id":"224404190","user_id":"30080751","user_name":"Dyrus","title":"jhin mains LUL","description":"LUL","created_at":"2018-01-31T22:35:55Z","published_at":"2018-01-31T22:35:55Z","url":"https://www.twitch.tv/videos/224404190","thumbnail_url":"https://static-cdn.jtvnw.net/s3_vods/427483724d153cb8c673_dyrus_27413838016_782035045//thumb/thumb224404190-%{width}x%{height}.jpg","viewable":"public","view_count":4924,"language":"en","type":"highlight","duration":"50s"}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6MX19"}}`,
+			`{"data":[{"id":"224404190","user_id":"30080751","user_name":"dyrus","user_name":"Dyrus","title":"jhin mains LUL","description":"LUL","created_at":"2018-01-31T22:35:55Z","published_at":"2018-01-31T22:35:55Z","url":"https://www.twitch.tv/videos/224404190","thumbnail_url":"https://static-cdn.jtvnw.net/s3_vods/427483724d153cb8c673_dyrus_27413838016_782035045//thumb/thumb224404190-%{width}x%{height}.jpg","viewable":"public","view_count":4924,"language":"en","type":"highlight","duration":"50s"}],"pagination":{"cursor":"eyJiIjpudWxsLCJhIjp7Ik9mZnNldCI6MX19"}}`,
 		},
 	}