// UserIdsFor converts user names into a comma delimited string of user ids
UserIdsFor converts user names into a comma delimited string of user ids
// UserIdsFor converts user names into a comma delimited string of user ids
func (t *twitch) UserIdsFor(userNames []string) ([]string, error) {
	userIds := []string{}
	if len(userNames) == 0 {
		return userIds, errors.New("UserNames is Length: 0")
	}
	request, err := http.NewRequest(http.MethodGet, getUserConversionUrl(userNames), nil)
	if nil != err {
		return userIds, err
	}
	request.Header.Set(httputil.HttpAcceptHeader, TwitchV5)
	request.Header.Set(httputil.HttpClientIdHeader, t.clientId)
	httpClient := &http.Client{}
	resp, err := httpClient.Do(request)
	if nil != err {
		return userIds, err
	}
	var payload TwitchUsersPayload
	e := httputil.DecodeJson(resp.Body, &payload)
	if nil != e {
		return userIds, e
	}
	for _, twitchUser := range payload.Users {
		userIds = append(userIds, twitchUser.UserId)
		t.userNameCache[twitchUser.UserId] = twitchUser.DisplayName
	}
	return userIds, nil
}
func ( t * twitch ) UserIdsFor ( userNames [ ] string ) ( [ ] string , error ) { userIds := [ ] string { } if len ( userNames ) == 0 { return userIds , errors . New ( " " ) } request , err := http . NewRequest ( http . MethodGet , getUserConversionUrl ( userNames ) , nil ) if nil != err { return userIds , err } request . Header . Set ( httputil . HttpAcceptHeader , TwitchV5 ) request . Header . Set ( httputil . HttpClientIdHeader , t . clientId ) httpClient := & http . Client { } resp , err := httpClient . Do ( request ) if nil != err { return userIds , err } var payload TwitchUsersPayload e := httputil . DecodeJson ( resp . Body , & payload ) if nil != e { return userIds , e } for _ , twitchUser := range payload . Users { userIds = append ( userIds , twitchUser . UserId ) t . userNameCache [ twitchUser . UserId ] = twitchUser . DisplayName } return userIds , nil }
UserIdsFor converts user names into a comma delimited string of user ids
UserIdsFor converts user names into a comma delimited string of user ids
// Cache Display Name for User Id