public LocationFeed Convert() { if (SourceObject == null) { throw new ArgumentNullException("SourceObject"); } InstaMediaList ConvertMedia(List <InstaMediaItemResponse> mediasResponse) { var medias = new InstaMediaList(); if (mediasResponse == null) { return(medias); } foreach (var instaUserFeedItemResponse in mediasResponse) { if (instaUserFeedItemResponse?.Type != 0) { continue; } var feedItem = InstaConvertersFabric.Instance.GetSingleMediaConverter(instaUserFeedItemResponse) .Convert(); medias.Add(feedItem); } return(medias); } var feed = new LocationFeed { MediaCount = SourceObject.MediaCount, NextMaxId = SourceObject.NextMaxId, Medias = ConvertMedia(SourceObject.Items), RankedMedias = ConvertMedia(SourceObject.RankedItems), Location = InstaConvertersFabric.Instance.GetLocationConverter(SourceObject.Location).Convert(), Story = InstaConvertersFabric.Instance.GetStoryConverter(SourceObject.Story).Convert() }; return(feed); }
private InstaMediaList ConvertMedia(List <InstaMediaItemResponse> mediasResponse) { var medias = new InstaMediaList(); if (mediasResponse == null) { return(medias); } foreach (var instaUserFeedItemResponse in mediasResponse) { if (instaUserFeedItemResponse?.Type != 0) { continue; } var feedItem = ConvertersFabric.Instance.GetSingleMediaConverter(instaUserFeedItemResponse) .Convert(); medias.Add(feedItem); } return(medias); }