public InstaMedia Convert()
        {
            if (SourceObject == null)
            {
                throw new ArgumentNullException("Source object");
            }
            var media = new InstaMedia
            {
                CaptionIsEdited = SourceObject.CaptionIsEdited,
                Code            = SourceObject.Code,
                Date            = DateTimeHelper.UnixTimestampToDateTime(double.Parse(SourceObject.Date)),
                Dimensions      =
                    new Dimensions {
                    Height = SourceObject.Dimensions.Height, Width = SourceObject.Dimensions.Width
                },
                ImageSourceLink = SourceObject.ImageSourceLink,
                InstaIdentifier = SourceObject.InstaIdentifier,
                IsAdvertisement = SourceObject.IsAdvertisement,
                IsVideo         = SourceObject.IsVideo,
                Location        = SourceObject.Location
            };

            var userConverter = ConvertersFabric.GetUserConverter(SourceObject.Owner);

            media.Owner = userConverter.Convert();
            return(media);
        }
Example #2
0
        public InstaUserFeed Convert()
        {
            var feed = new InstaUserFeed();

            if (SourceObject?.SuggestedUsers != null)
            {
                foreach (var user in SourceObject.SuggestedUsers.Users)
                {
                    var userConverter = ConvertersFabric.GetUserConverter(user);
                    feed.SuggestedUsers.Add(userConverter.Convert());
                }
            }
            if (SourceObject != null)
            {
                foreach (var media in SourceObject.Feed.Media.Nodes)
                {
                    var mediaConverter = ConvertersFabric.GetSingleMediaConverter(media);
                    feed.FeedMedia.Add(mediaConverter.Convert());
                }
                feed.FeedPageInfo = new InstaFeedPageInfo
                {
                    EndCursor   = SourceObject.Feed.Media.PageInfo.EndCursor,
                    StartCursor = SourceObject.Feed.Media.PageInfo.StartCursor,
                    HasNextPage = SourceObject.Feed.Media.PageInfo.HasNextPage,
                    HasPrevPage = SourceObject.Feed.Media.PageInfo.HasPrevPage
                };
            }
            return(feed);
        }
        public InstaPost Convert()
        {
            if (SourceObject == null)
            {
                throw new ArgumentNullException("Source object");
            }
            var post = new InstaPost
            {
                Link           = SourceObject.Link,
                CanViewComment = SourceObject.CanViewComment,
                Code           = SourceObject.Code,
                CreatedTime    = SourceObject.CreatedTimeConverted,
                Localtion      = SourceObject.Location,
                Images         = new Images(),
                Likes          = new Likes()
            };

            post.Images.LowResolution = new Image(SourceObject.Images.LowResolution.Url,
                                                  SourceObject.Images.LowResolution.Width, SourceObject.Images.LowResolution.Height);
            post.Images.Thumbnail = new Image(SourceObject.Images.Thumbnail.Url, SourceObject.Images.Thumbnail.Width,
                                              SourceObject.Images.Thumbnail.Height);
            post.Images.StandartResolution = new Image(SourceObject.Images.StandartResolution.Url,
                                                       SourceObject.Images.StandartResolution.Width, SourceObject.Images.StandartResolution.Height);
            post.Likes.Count = SourceObject.LikesCount;
            var userConverter = ConvertersFabric.GetUserConverter(SourceObject.User);

            post.User = userConverter.Convert();
            post.Likes.VisibleLikedUsers = new InstaUserList();
            foreach (var userLike in SourceObject.Likes.Users)
            {
                var userLikeConverter = ConvertersFabric.GetUserConverter(userLike);
                post.Likes.VisibleLikedUsers.Add(userLikeConverter.Convert());
            }
            return(post);
        }