Example #1
0
        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();
            }
        }
Example #2
0
        internal static RestSimpleChannel Create(BaseRestClient client, Model model)
        {
            var entity = new RestSimpleChannel(client, model.Id);

            entity.Update(model);
            return(entity);
        }
Example #3
0
 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;
 }
Example #4
0
        internal override void Update(Model model)
        {
            base.Update(model);

            Title              = model.Title;
            Description        = model.Description;
            DescriptionHtml    = model.Description;
            BroadcastId        = model.BroadcastId;
            BroadcastType      = model.BroadcastType;
            Status             = model.Status;
            Tags               = model.Tags.Split(' ');
            Language           = model.Language;
            Game               = model.Game;
            Length             = model.Length;
            Views              = model.Views;
            Viewable           = model.Viewable;
            ViewableAt         = model.ViewableAt;
            CreatedAt          = model.CreatedAt;
            PublishedAt        = model.PublishedAt;
            RecordedAt         = model.RecordedAt;
            AnimatedPreviewUrl = model.AnimatedPreviewUrl;
            Qualities          = model.Fps;
            Resolutions        = model.Resolutions;

            Channel = RestChannel.Create(Client, model.Channel);

            //Preview = model.Preview;
            //Thumbnail = model.Thumbnails;
        }
Example #5
0
        // 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);
            }
        }