import { IgApiClient } from './client' ; import { AccountFollowersFeed , AccountFollowingFeed , BestiesFeed , BlockedUsersFeed , DirectInboxFeed , DirectPendingInboxFeed , DirectThreadFeed , DiscoverFeed , PostsInsightsFeed , LocationFeed , MediaCommentsFeed , MusicGenreFeed , MusicMoodFeed , MusicSearchFeed , MusicTrendingFeed , NewsFeed , PendingFriendshipsFeed , ReelsMediaFeed , ReelsTrayFeed , SavedFeed , StoriesInsightsFeed , TagFeed , TagsFeed , TimelineFeed , UserFeed , UsertagsFeed , IgtvBrowseFeed , IgtvChannelFeed , LikedFeed , TopicalExploreFeed , } from '../feeds' ; import { DirectInboxFeedResponseThreadsItem } from '../responses' ; import { plainToClassFromExist } from 'class-transformer' ; import * as Chance from 'chance' ; import { PostsInsightsFeedOptions , TimelineFeedReason , IgAppModule } from '../types' ; import { UserStoryFeed } from '../feeds/user-story.feed' ; import { ListReelMediaViewerFeed } from '../feeds/list-reel-media-viewer.feed' ; import { MediaInlineChildCommentsFeed } from '../feeds/media.inline-child-comments.feed' ; import { MediaStickerResponsesFeed } from '../feeds/media.sticker-responses.feed' ; import { StorySliderVotersFeedResponseResponseRootObject , StorySliderVotersFeedResponseResponseVotersItem , StoryQuestionResponsesFeedResponseRespondersItem , StoryQuestionResponsesFeedResponseRootObject , StoryQuizParticipantsFeedResponseParticipantsItem , StoryQuizParticipantsFeedResponseRootObject , StoryPollVotersFeedResponseRootObject , StoryPollVotersFeedResponseVotersItem , } from '../responses' ; export class FeedFactory { constructor ( private client ) { } public accountFollowers ( options ? ) { return plainToClassFromExist ( new AccountFollowersFeed ( this . client ) , { id : options && typeof options !== 'object' ? options : this . client . state . cookieUserId , ... ( typeof options === 'object' ? options : undefined ) , } ) ; } public accountFollowing ( options ? ) { return plainToClassFromExist ( new AccountFollowingFeed ( this . client ) , { id : options && typeof options !== 'object' ? options : this . client . state . cookieUserId , ... ( typeof options === 'object' ? options : undefined ) , } ) ; } public news ( ) { return new NewsFeed ( this . client ) ; } public discover ( ) { return new DiscoverFeed ( this . client ) ; } public pendingFriendships ( ) { return new PendingFriendshipsFeed ( this . client ) ; } public bestFriendships ( ) { return new BestiesFeed ( this . client ) ; } public blockedUsers ( ) { return new BlockedUsersFeed ( this . client ) ; } public directInbox ( ) { return new DirectInboxFeed ( this . client ) ; } public directPending ( ) { return new DirectPendingInboxFeed ( this . client ) ; } public directThread ( options , seqId ? ) { const feed = new DirectThreadFeed ( this . client ) ; feed . id = options . thread_id ; feed . cursor = options . oldest_cursor ; feed . seqId = seqId ; return feed ; } public user ( id ) { const feed = new UserFeed ( this . client ) ; feed . id = id ; return feed ; } public tag ( tag ) { const feed = new TagFeed ( this . client ) ; feed . tag = tag ; return feed ; } public tags ( tag , tab = 'top' ) { const feed = new TagsFeed ( this . client ) ; feed . tag = tag ; feed . tab = tab ; return feed ; } public location ( id , tab = 'ranked' ) { const feed = new LocationFeed ( this . client ) ; feed . id = id ; feed . tab = tab ; return feed ; } public mediaComments ( id ) { const feed = new MediaCommentsFeed ( this . client ) ; feed . id = id ; return feed ; } public reelsMedia ( options ) { return plainToClassFromExist ( new ReelsMediaFeed ( this . client ) , options ) ; } public userStory ( userId ) { return plainToClassFromExist ( new UserStoryFeed ( this . client ) , { userId } ) ; } public reelsTray ( reason = 'cold_start' ) { return plainToClassFromExist ( new ReelsTrayFeed ( this . client ) , { reason } ) ; } public timeline ( reason ? ) { const feed = new TimelineFeed ( this . client ) ; if ( reason ) { feed . reason = reason ; } return feed ; } public musicTrending ( product = 'story_camera_music_overlay_post_capture' ) { return plainToClassFromExist ( new MusicTrendingFeed ( this . client ) , { product } ) ; } public musicSearch ( query , product = 'story_camera_music_overlay_post_capture' ) { const options = { query , product , searchSessionId : new Chance ( query ) . guid ( ) , } ; return plainToClassFromExist ( new MusicSearchFeed ( this . client ) , options ) ; } public musicGenre ( id , product = 'story_camera_music_overlay_post_capture' ) { return plainToClassFromExist ( new MusicGenreFeed ( this . client ) , { id , product , } ) ; } public musicMood ( id , product = 'story_camera_music_overlay_post_capture' ) { return plainToClassFromExist ( new MusicMoodFeed ( this . client ) , { id , product , } ) ; } public usertags ( id ) { return plainToClassFromExist ( new UsertagsFeed ( this . client ) , { id } ) ; } public postsInsightsFeed ( options ) { return plainToClassFromExist ( new PostsInsightsFeed ( this . client ) , { options } ) ; } public storiesInsights ( timeframe ) { return plainToClassFromExist ( new StoriesInsightsFeed ( this . client ) , { timeframe } ) ; } public saved ( ) { return new SavedFeed ( this . client ) ; } public listReelMediaViewers ( mediaId ) { return plainToClassFromExist ( new ListReelMediaViewerFeed ( this . client ) , { mediaId } ) ; } public mediaInlineChildComments ( mediaId , commentId , minId ? ) { return plainToClassFromExist ( new MediaInlineChildCommentsFeed ( this . client ) , { mediaId , commentId , nextMinId : minId , } ) ; } public igtvBrowse ( isPrefetch ? ) { return plainToClassFromExist ( new IgtvBrowseFeed ( this . client ) , { isPrefetch : ! ! isPrefetch , } ) ; } public storyQuestionResponses ( mediaId , stickerId ) { return plainToClassFromExist ( new MediaStickerResponsesFeed < any , any > ( this . client ) , { mediaId , stickerId , name : 'story_question_responses' , rootName : 'responder_info' , itemName : 'responders' , } ) ; } public storyPollVoters ( mediaId , stickerId ) { return plainToClassFromExist ( new MediaStickerResponsesFeed < any , any > ( this . client ) , { mediaId , stickerId , name : 'story_poll_voters' , rootName : 'voter_info' , itemName : 'voters' , } ) ; } public storyQuizParticipants ( mediaId , stickerId ) { return plainToClassFromExist ( new MediaStickerResponsesFeed < any , any > ( this . client ) , { mediaId , stickerId , name : 'story_quiz_participants' , rootName : 'participant_info' , itemName : 'participants' , } ) ; } public storySliderVoters ( mediaId , stickerId ) { return plainToClassFromExist ( new MediaStickerResponsesFeed < any , any > ( this . client ) , { mediaId , stickerId , name : 'story_slider_voters' , rootName : 'voter_info' , itemName : 'voters' , } ) ; } public igtvChannel ( id ) { if ( /[0-9]/ . test ( id . toString ( ) ) ) { id = `user_${ id }` ; } return plainToClassFromExist ( new IgtvChannelFeed ( this . client ) , { channelId : id , } ) ; } param id public igtvChaining ( id ) { return this . igtvChannel ( `chaining_${ id }` ) ; } public liked ( ) { return new LikedFeed ( this . client ) ; } public topicalExplore ( options = { } ) { return plainToClassFromExist ( new TopicalExploreFeed ( this . client ) , options ) ; } }