示例#1
0
        public InstaTagFeed Convert()
        {
            if (SourceObject?.Medias == null)
            {
                throw new ArgumentNullException("InstaFeedResponse or its media list");
            }
            var feed = new InstaTagFeed();

            List <InstaMedia> ConvertMedia(List <InstaMediaItemResponse> mediasResponse)
            {
                var medias = new List <InstaMedia>();

                foreach (var instaUserFeedItemResponse in mediasResponse)
                {
                    if (instaUserFeedItemResponse?.Type != 0)
                    {
                        continue;
                    }
                    var feedItem = ConvertersFabric.GetSingleMediaConverter(instaUserFeedItemResponse).Convert();
                    medias.Add(feedItem);
                }
                return(medias);
            }

            feed.RankedMedias.AddRange(ConvertMedia(SourceObject.RankedItems));
            feed.Medias.AddRange(ConvertMedia(SourceObject.Medias));
            feed.Medias.PageSize = feed.Medias.Count;
            foreach (var story in SourceObject.Stories)
            {
                var feedItem = ConvertersFabric.GetStoryConverter(story).Convert();
                feed.Stories.Add(feedItem);
            }
            return(feed);
        }
        public InstaStoryTray Convert()
        {
            if (SourceObject == null)
            {
                throw new ArgumentNullException($"Source object");
            }
            var storyTray = new InstaStoryTray
            {
                Id         = SourceObject.Id,
                IsPortrait = SourceObject.IsPortrait,
                TopLive    = ConvertersFabric.GetTopLiveConverter(SourceObject.TopLive).Convert()
            };

            foreach (var item in SourceObject.Tray)
            {
                var story = ConvertersFabric.GetStoryConverter(item).Convert();
                storyTray.Tray.Add(story);
            }
            return(storyTray);
        }
示例#3
0
        public InstaStoryTray Convert()
        {
            if (SourceObject == null)
            {
                throw new ArgumentNullException($"Source object");
            }

            var storyTray = new InstaStoryTray
            {
                Status            = SourceObject.Status,
                StickerVersion    = SourceObject.StickerVersion,
                StoryRankingToken = SourceObject.StoryRankingToken
            };

            if (SourceObject.Tray.Count > 0)
            {
                foreach (var story in SourceObject.Tray)
                {
                    storyTray.Tray.Add(ConvertersFabric.GetStoryConverter(story).Convert());
                }
            }

            return(storyTray);
        }