public static async Task ModifyChannelAsync(RestSimpleChannel channel, Action <ModifyChannelParams> options) { if (!TokenHelper.TryGetToken(channel.Client, channel.Id, out RestTokenInfo info)) { throw new MissingScopeException("channel_editor"); } if (!info.Authorization.Scopes.Contains("channel_editor")) { throw new MissingScopeException("channel_editor"); } var changes = new ModifyChannel(); options.Invoke(changes.Parameters); var model = await channel.Client.RestClient.ModifyChannelInternalAsync(info.Token, channel.Id, changes); channel.Update(model); if (channel is RestChannel rc) { await rc.UpdateAsync(); } if (channel is RestSelfChannel rsc) { await rsc.UpdateAsync(); } }
internal override void Update(Model model) { base.Update(model); Channel = new RestSimpleChannel(Client, model.Channel.Id); Channel.Update(model.Channel); BroadcastId = model.BroadcastId; BroadcastType = model.BroadcastType; CreatedAt = model.CreatedAt; Description = model.Description; DescriptionHtml = model.Description; Qualities = model.Fps; Game = model.Game; Language = model.Language; Length = model.Length; MutedSegments = model.MutedSegments.ToArray(); Previews = model.PreviewImages; PublishedAt = model.PublishedAt; Resolutions = model.Resolutions; Status = model.Status; Tags = model.Tags.Split(' '); Thumbnails = model.Thumbnails; Title = model.Title; Viewable = model.Viewable; ViewableAt = model.ViewableAt; Views = model.Views; }
internal static RestSimpleChannel Create(BaseRestClient client, Model model) { var entity = new RestSimpleChannel(client, model.Id); entity.Update(model); return(entity); }
// Channel public static async Task ModifyAsync(RestSimpleChannel channel, Action <ModifyChannelParams> changes, RequestOptions options = null) { var filledParams = new ModifyChannelParams(); changes.Invoke(filledParams); var model = await channel.Client.ApiClient.ModifyChannelAsync(channel.Id, filledParams, options).ConfigureAwait(false); if (model != null) { channel.Update(model); } }