/// <summary> /// Gets all of the available live channels /// </summary> /// <param name="categorySlug">The optional category slug to search for</param> /// <param name="count">The number of channels to return</param> /// <returns>All available channels</returns> public async Task <IEnumerable <ChannelModel> > GetLiveChannels(string categorySlug = null, int count = 1) { string query = $"{{ channels(status: LIVE, first: {count}) {{ {ChannelModel.BasicFieldsWithStreamerEdges} }} }}"; if (!string.IsNullOrEmpty(categorySlug)) { query = $"{{ channels(categorySlug: \"{categorySlug}\", status: LIVE, first: {count}) {{ {ChannelModel.BasicFieldsWithStreamerEdges} }} }}"; } GraphQLEdgeArrayModel <ChannelModel> channels = await this.QueryAsync <GraphQLEdgeArrayModel <ChannelModel> >(query, "channels"); return(channels?.Items); }
/// <summary> /// Gets the user that is following the specified streamer /// </summary> /// <param name="streamer">The user to get the follow for</param> /// <param name="user">The user who is following</param> /// <returns>The set of follows</returns> public async Task <UserFollowModel> GetFollowingUser(UserModel streamer, UserModel user) { GraphQLEdgeArrayModel <UserFollowModel> follows = await this.QueryAsync <GraphQLEdgeArrayModel <UserFollowModel> >($"{{ followers(streamerId: {streamer.id}, userId: {user.id}, first: {1}) {{ {UserFollowModel.AllFieldsEdges} }} }}", "followers"); return((follows?.Items != null) ? follows?.Items.FirstOrDefault() : null); }
/// <summary> /// Gets the channels currently live on the homepage /// </summary> /// <returns>All available channels</returns> public async Task <IEnumerable <ChannelModel> > GetHomepageChannels(int count = 1) { GraphQLEdgeArrayModel <ChannelModel> channels = await this.QueryAsync <GraphQLEdgeArrayModel <ChannelModel> >($"{{ homepageChannels(first: {count}) {{ {ChannelModel.BasicFieldsWithStreamerEdges} }} }}", "homepageChannels"); return(channels?.Items); }
/// <summary> /// Gets the users that are following the specified channel /// </summary> /// <param name="streamer">The user to get follows for</param> /// <param name="count">The maximum number to get</param> /// <returns>The set of follows</returns> public async Task <IEnumerable <UserFollowModel> > GetFollowingUsers(UserModel streamer, int count = 1) { GraphQLEdgeArrayModel <UserFollowModel> follows = await this.QueryAsync <GraphQLEdgeArrayModel <UserFollowModel> >($"{{ followers(streamerId: {streamer.id}, first: {count}) {{ {UserFollowModel.AllFieldsEdges} }} }}", "followers"); return(follows?.Items); }