import type { ApiClient } from "@promobase/sdk-runtime"; import { Cursor } from "@promobase/sdk-runtime"; import { metaPagination } from "../../pagination.ts"; import type { CommentFields } from "./comment.ts"; import type { InsightsResultFields } from "./insights-result.ts"; import type { UserFields } from "./user.ts"; export interface IGMediaForIGOnlyAPIFields { alt_text: string; caption: string; comments_count: number; current_live_viewer_count: number; id: string; is_comment_enabled: boolean; is_shared_to_feed: boolean; like_count: number; media_product_type: string; media_type: string; media_url: string; owner: UserFields; permalink: string; shortcode: string; thumbnail_url: string; timestamp: string; username: string; } export interface IGMediaForIGOnlyAPICreateCommentsParams { message?: string; [key: string]: unknown; } export interface IGMediaForIGOnlyAPIListInsightsParams { breakdown?: string[]; metric: string[]; period?: string[]; [key: string]: unknown; } export interface IGMediaForIGOnlyAPIUpdateParams { comment_enabled?: boolean; [key: string]: unknown; } export function iGMediaForIGOnlyAPINode(client: ApiClient, id: string) { return { __path: id, __brand: undefined as unknown as IGMediaForIGOnlyAPIFields, get: (opts: { fields: F; params?: Record }) => client.get>(`${id}`, opts), update: (params: IGMediaForIGOnlyAPIUpdateParams) => client.post(`${id}`, params as Record), children: )[]>(opts: { fields: F; params?: Record }) => new Cursor, F[number]>>(client, `${id}/children`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), comments: { __path: `${id}/comments`, __brand: undefined as unknown as CommentFields, list: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/comments`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), create: (params: IGMediaForIGOnlyAPICreateCommentsParams) => client.post>(`${id}/comments`, params as Record), }, insights: (opts: { fields: F; params?: IGMediaForIGOnlyAPIListInsightsParams }) => new Cursor>(client, `${id}/insights`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), }; }