internal new static RestSelfChannel Create(BaseTwitchClient client, Model model) { var entity = new RestSelfChannel(client, model.Id); entity.Update(model); return(entity); }
// Channels public static async Task <RestSelfChannel> GetCurrentChannelAsync(BaseTwitchClient client, RequestOptions options = null) { var model = await client.ApiClient.GetMyChannelAsync(options).ConfigureAwait(false); if (model != null) { return(RestSelfChannel.Create(client, model)); } return(null); }
public static async Task <RestSelfChannel> GetSelfChannelAsync(BaseRestClient client, ulong channelId) { if (!TokenHelper.TryGetToken(client, channelId, out RestTokenInfo info)) { throw new MissingScopeException("channel_read"); } if (!info.Authorization.Scopes.Contains("channel_read")) { throw new MissingScopeException("channel_read"); } var model = await client.RestClient.GetSelfChannelInternalAsync(info.Token); return(RestSelfChannel.Create(client, model)); }