public InstaExploreFeed Convert()
        {
            if (SourceObject == null)
            {
                throw new ArgumentNullException("SourceObject");
            }

            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);
            }

            var feed = new InstaExploreFeed
            {
                StoryTray = ConvertersFabric.GetStoryTrayConverter(SourceObject.Items.StoryTray).Convert(),
                Channel   = ConvertersFabric.GetChannelConverter(SourceObject.Items.Channel).Convert()
            };

            feed.Medias.AddRange(ConvertMedia(SourceObject.Items.Medias));
            feed.Medias.PageSize = feed.Medias.Count;

            return(feed);
        }
Exemple #2
0
        public InstaDirectInboxItem Convert()
        {
            var threadItem = new InstaDirectInboxItem
            {
                ClientContext = SourceObject.ClientContext,
                ItemId        = SourceObject.ItemId
            };

            switch (SourceObject.ItemType)
            {
            case "text":
                threadItem.ItemType = InstaDirectThreadItemType.Text;
                break;

            case "media_share":
                threadItem.ItemType = InstaDirectThreadItemType.MediaShare;
                break;
            }
            threadItem.Text      = SourceObject.Text;
            threadItem.TimeStamp = DateTimeHelper.UnixTimestampMilisecondsToDateTime(SourceObject.TimeStamp);
            threadItem.UserId    = SourceObject.UserId;
            if (SourceObject.MediaShare == null)
            {
                return(threadItem);
            }
            var converter = ConvertersFabric.GetSingleMediaConverter(SourceObject.MediaShare);

            threadItem.MediaShare = converter.Convert();
            return(threadItem);
        }
Exemple #3
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 InstaFeed Convert()
        {
            var feed = new InstaFeed();

            foreach (var instaUserFeedItemResponse in SourceObject.Items)
            {
                if (instaUserFeedItemResponse?.Type != 0)
                {
                    continue;
                }
                var feedItem = ConvertersFabric.GetSingleMediaConverter(instaUserFeedItemResponse).Convert();
                feed.Medias.Add(feedItem);
            }
            return(feed);
        }
        public InstaChannel Convert()
        {
            if (SourceObject == null)
            {
                throw new ArgumentNullException($"Source object");
            }
            var channel = new InstaChannel
            {
                ChannelId   = SourceObject.ChannelId,
                ChannelType = SourceObject.ChannelType,
                Context     = SourceObject.Context,
                Header      = SourceObject.Header,
                Title       = SourceObject.Title,
                Media       = ConvertersFabric.GetSingleMediaConverter(SourceObject.Media).Convert()
            };

            return(channel);
        }
Exemple #6
0
        public InstaFeed Convert()
        {
            if (SourceObject?.Items == null)
            {
                throw new ArgumentNullException("InstaFeedResponse or its Items");
            }
            var feed = new InstaFeed();

            foreach (var instaUserFeedItemResponse in SourceObject.Items)
            {
                if (instaUserFeedItemResponse?.Type != 0)
                {
                    continue;
                }
                var feedItem = ConvertersFabric.GetSingleMediaConverter(instaUserFeedItemResponse).Convert();
                feed.Medias.Add(feedItem);
            }
            feed.Medias.PageSize = SourceObject.Items.Count;
            return(feed);
        }