import type { ApiClient } from "@promobase/sdk-runtime"; import { Cursor } from "@promobase/sdk-runtime"; import { metaPagination } from "../../pagination.ts"; import type { IGCommentFromUserFields } from "./ig-comment-from-user.ts"; import type { IGMediaFields } from "./ig-media.ts"; import type { IGUserFields } from "./ig-user.ts"; import type { UserFields } from "./user.ts"; export interface IGCommentFields { from: IGCommentFromUserFields; hidden: boolean; id: string; legacy_instagram_comment_id: string; like_count: number; media: IGMediaFields; parent_id: string; text: string; timestamp: string; user: IGUserFields; username: string; } export interface IGCommentCreateRepliesParams { message?: string; [key: string]: unknown; } export interface IGCommentUpdateParams { ad_id?: string; hide?: boolean; [key: string]: unknown; } export function iGCommentNode(client: ApiClient, id: string) { return { __path: id, __brand: undefined as unknown as IGCommentFields, get: (opts: { fields: F; params?: Record }) => client.get>(`${id}`, opts), update: (params: IGCommentUpdateParams) => client.post(`${id}`, params as Record), delete: () => client.delete(`${id}`, {}), replies: { __path: `${id}/replies`, __brand: undefined as unknown as IGCommentFields, list: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/replies`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), create: (params: IGCommentCreateRepliesParams) => client.post(`${id}/replies`, params as Record), }, }; }