import SocialPostsRoute from "../routes/SocialPostsRoute"; import Requests from "../util/Requests"; import Response from "../util/Response"; import { AxiosPromise } from "axios"; class SocialPosts { /** * List all the Posts. * * @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList * * @returns promise */ public static list(params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.getPosts, undefined, undefined, params); } /** * Give a tip to another user * * @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin * * @returns A promise */ public static create(data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.createPost, data, {}, params); } /** * Retrieve the information for a single post. * * @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage * * @param post_id The id fo the post to retrieve. * * @returns promise */ public static view(post_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.retrievePost, {}, { post_id: post_id }, params); } /** * Update the informationa bout a post, as long as it hasn't been posted. * * @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage * * @param post_id The id fo the post to retrieve. * * @returns promise */ public static update(post_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.updatePost, data, { post_id: post_id }, params); } /** * Deletes a post. * * @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage * * @param post_id The id of the post to delete. * @returns promise */ public static delete(post_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.deletePost, {}, { post_id: post_id }, params); } /** * Dispute a post as being fraudulent.,s * * @see https://api.glitch.fun/api/documentation#/Social%20Media%20Posts/disputePost * * @param post_id The id fo the post to retrieve. * * @returns promise */ public static dispute(post_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.dispute, data, { post_id: post_id }, params); } /** * Get the change of the post metrics over a period of time. * * @see https://api.glitch.fun/api/documentation#/Social%20Media%20Posts/getSocialMediaPostHistory * * @param post_id The id fo the post to retrieve. * * @returns promise */ public static history(post_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.history, {}, { post_id: post_id }, params); } /** * Get the change progression of a social media post over period of time. * * @see https://api.glitch.fun/api/documentation#/Social%20Media%20Posts/getSocialMediaPostHistory * * @param post_id The id fo the post to retrieve. * * @returns promise */ public static progression(params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.progression, {}, {}, params); } /** * Add media to a social media post. * * @see https://api.glitch.fun/api/documentation#/Social%20Media%20Posts/addMediaToSocialMediaPost * * @param post_id The ID of the social media post. * @param data The data to be sent in the request body. * * @returns promise */ public static addMedia(post_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.addMedia, data, { post_id: post_id }, params); } /** * Remove media from a social media post. * * @see https://api.glitch.fun/api/documentation#/Social%20Media%20Posts/removeMediaFromSocialMediaPost * * @param post_id The ID of the social media post. * @param media_id The ID of the media to remove. * * @returns promise */ public static removeMedia(post_id: string, media_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.removeMedia, {}, { post_id: post_id, media_id: media_id }, params); } /** * Reschedule a post that has failed. * * @see https://api.glitch.fun/api/documentation#/Social%20Media%20Posts/addMediaToSocialMediaPost * * @param post_id The ID of the social media post. * @param data The data to be sent in the request body. * * @returns promise */ public static reschedule(post_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.reschedule, data, { post_id: post_id }, params); } /** * Get the reports for a social media post * * @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList * * @returns promise */ public static reports(post_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.reports, undefined, { post_id }, params); } /** * Update the information about a post impressions, for posts who API do not give view counts. * * @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage * * @param post_id The id fo the post to retrieve. * * @returns promise */ public static updatePostImpressions(post_id: string, data?: object, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.updatePostImpressions, data, { post_id: post_id }, params); } /** * Get reports on all the the short links * * @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList * * @returns promise */ public static shortLinkReports(params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.shortLinkReports, undefined, undefined, params); } /** * List comments for a social media post. * * @param post_id The ID of the social media post. * @param params Optional query parameters for filtering and sorting. * @returns A promise */ public static listComments(post_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.listComments, undefined, { post_id }, params); } /** * Sync comments from the social media platform for a specific post. * * @param post_id The ID of the social media post. * @param params Optional query parameters (e.g., limit). * @returns A promise */ public static syncComments(post_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.syncComments, undefined, { post_id }, params); } /** * Get a list of all comments that are pending a response. * * @param params Optional query parameters for filtering. * @returns A promise */ public static listPendingResponses(params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.listPendingResponses, undefined, undefined, params); } /** * Retrieve a single comment by its ID. * * @param comment_id The ID of the comment. * @param params Optional query parameters (e.g., include_thread). * @returns A promise */ public static viewComment(comment_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.viewComment, undefined, { comment_id }, params); } /** * Post a reply to a comment. * * @param comment_id The ID of the comment to reply to. * @param data The content of the reply. * @returns A promise */ public static replyToComment(comment_id: string, data: object): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.replyToComment, data, { comment_id }); } /** * Moderate a comment (approve, reject, spam, hide, show). * * @param comment_id The ID of the comment to moderate. * @param data The moderation action and optional reason. * @returns A promise */ public static moderateComment(comment_id: string, data: object): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.moderateComment, data, { comment_id }); } /** * Mark a comment as needing a response. * * @param comment_id The ID of the comment. * @returns A promise */ public static markCommentForResponse(comment_id: string): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.markCommentForResponse, undefined, { comment_id }); } /** * Get the full thread for a given comment. * * @param comment_id The ID of a comment within the thread. * @returns A promise */ public static getCommentThread(comment_id: string): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.getCommentThread, undefined, { comment_id }); } /** * Trigger a manual update of a comment's metrics from its platform. * * @param comment_id The ID of the comment to update. * @returns A promise */ public static updateCommentMetrics(comment_id: string): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.updateCommentMetrics, undefined, { comment_id }); } /** * Create a new top-level comment on a post. * * @param post_id The ID of the social media post to comment on. * @param data The content of the comment. * @returns A promise */ public static createComment(post_id: string, data: object): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.createComment, data, { post_id }); } /** * Get game install attribution data for a specific social media post. * * @param post_id The ID of the social media post. * @param params Optional query parameters (start_date, end_date, confidence_threshold). * @returns A promise */ public static getPostAttribution(post_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.getPostAttribution, undefined, { post_id }, params); } /** * Get a report of all social media posts for a title that are converting to game installs. * * @param params Query parameters (title_id, start_date, end_date, confidence_threshold). * @returns A promise */ public static getSocialPostAttributionReport(params: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.getSocialPostAttributionReport, undefined, undefined, params); } /** * Get a summary of clicks for each short link in a post. * * @param post_id The ID of the social media post. * @returns A promise */ public static getLinkSummary(post_id: string): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.getLinkSummary, undefined, { post_id }); } /** * Trigger a historical sync for a specific platform for the current user. * * @see https://api.glitch.fun/api/documentation#/Social%20Media%20Posts/syncHistory * * @param platform The platform to sync (e.g., 'twitter', 'youtube', 'bluesky'). * * @returns promise */ public static syncHistory(platform: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.syncHistory, {}, { platform }, params); } /** * Perform a social action (Like, Repost, Vote) on a post. * * @param post_id The ID of the social media post. * @param action The action to perform. * @returns promise */ public static performAction(post_id: string, action: 'like' | 'unlike' | 'repost' | 'unrepost' | 'vote_up' | 'vote_down' | 'unvote'): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.performAction, { action }, { post_id }); } /** * Perform a social action (Like, Repost, Vote) on a comment. * * @param comment_id The ID of the comment. * @param action The action to perform. * @returns promise */ public static performCommentAction(comment_id: string, action: 'like' | 'unlike' | 'repost' | 'unrepost' | 'vote_up' | 'vote_down' | 'unvote'): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.performCommentAction, { action }, { comment_id }); } /** * Get ad creative performance matrix. */ public static creativePerformance(params: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.creativePerformance, {}, {}, params); } /** * List social media conversations. * * @see https://api.glitch.fun/api/documentation#/Social%20Messaging/listSocialConversations * * @param params Query parameters (scheduler_id, platform, page, per_page). * @returns promise */ public static listConversations(params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.listConversations, undefined, undefined, params); } /** * Sync conversations from external platform. * * @see https://api.glitch.fun/api/documentation#/Social%20Messaging/syncSocialConversations * * @param data Body parameters (platform, scheduler_id). * @returns promise */ public static syncConversations(data: object): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.syncConversations, data); } /** * Get a specific conversation. * * @see https://api.glitch.fun/api/documentation#/Social%20Messaging/getSocialConversation * * @param conversation_id The ID of the conversation. * @returns promise */ public static getConversation(conversation_id: string): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.getConversation, undefined, { conversation_id }); } /** * List messages in a conversation. * * @see https://api.glitch.fun/api/documentation#/Social%20Messaging/listSocialMessages * * @param conversation_id The ID of the conversation. * @param params Query parameters (sync, page, per_page). * @returns promise */ public static getConversationMessages(conversation_id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.getConversationMessages, undefined, { conversation_id }, params); } /** * Send a Direct Message. * * @see https://api.glitch.fun/api/documentation#/Social%20Messaging/sendSocialMessage * * @param data Body parameters (message, conversation_id, recipient_id, platform, scheduler_id, media_ids). * @returns promise */ public static sendSocialMessage(data: object): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.sendSocialMessage, data); } /** * Reply to a high-intent TikTok comment via Direct Message. * * @param comment_id The ID of the comment. * @param data { message: string } */ public static replyViaDm(comment_id: string, data: { message: string }): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.replyViaDm, data, { comment_id }); } /** * List all discovered Reddit questions (Admin Only). * * @param params Query parameters: status, subreddit, is_question. */ public static listRedditQuestions(params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.listRedditQuestions, undefined, undefined, params); } /** * Retrieve details for a specific discovered Reddit question (Admin Only). * * @param id The UUID of the question. */ public static viewRedditQuestion(id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.viewRedditQuestion, {}, { id }, params); } /** * Update a Reddit question's status or metadata (Admin Only). * * @param id The UUID of the question. * @param data { status: 'pending'|'answered'|'ignored', metadata?: object } */ public static updateRedditQuestion(id: string, data: object, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.updateRedditQuestion, data, { id }, params); } /** * Delete a discovered Reddit question (Admin Only). * * @param id The UUID of the question. */ public static deleteRedditQuestion(id: string, params?: Record): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.deleteRedditQuestion, {}, { id }, params); } /** * Optimize a Reddit post for a specific subreddit using the AI engine (Admin Only). * * @param data { subreddit: string, content: string, title_id: string } */ public static optimizeRedditPost(data: { subreddit: string, content: string, title_id: string }): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.optimizeRedditPost, data); } /** * Get a report attributing game installs, wishlists, and purchases to specific social media posts. * * @param params Filter object: * - title_id: string (Required) * - start_date?: string (YYYY-MM-DD) * - end_date?: string (YYYY-MM-DD) * - confidence_threshold?: number (0-100) */ public static getSocialPostAttribution(params: { title_id: string, start_date?: string, end_date?: string, confidence_threshold?: number }): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.socialPostAttribution, {}, undefined, params); } /** * Get a report attributing game installs and revenue to specific UTM sources and campaigns. * * @param params Filter object: * - title_id: string (Required) * - start_date?: string (YYYY-MM-DD) * - end_date?: string (YYYY-MM-DD) * - confidence_threshold?: number (0-100) */ public static getUtmAttribution(params: { title_id: string, start_date?: string, end_date?: string, confidence_threshold?: number }): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.utmAttribution, {}, undefined, params); } public static getInfluencerAttribution(params: { title_id: string, start_date?: string, end_date?: string, confidence_threshold?: number }): AxiosPromise> { return Requests.processRoute(SocialPostsRoute.routes.influencerAttribution, {}, undefined, params); } } export default SocialPosts;