import type { ApiClient } from "@promobase/sdk-runtime"; import { Cursor } from "@promobase/sdk-runtime"; import { metaPagination } from "../../pagination.ts"; import type { BrandedContentShadowIGUserIDFields } from "./branded-content-shadow-ig-user-id.ts"; import type { IGBoostMediaAdFields } from "./ig-boost-media-ad.ts"; import type { IGCommentFields } from "./ig-comment.ts"; import type { IGMediaBoostEligibilityInfoFields } from "./ig-media-boost-eligibility-info.ts"; import type { IGUserFields } from "./ig-user.ts"; import type { IGVideoCopyrightCheckMatchesInformationFields } from "./ig-video-copyright-check-matches-information.ts"; import type { InstagramInsightsResultFields } from "./instagram-insights-result.ts"; import type { ShadowIGMediaCollaboratorsFields } from "./shadow-ig-media-collaborators.ts"; import type { ShadowIGMediaProductTagsFields } from "./shadow-ig-media-product-tags.ts"; import type { UserFields } from "./user.ts"; export interface IGMediaFields { alt_text: string; boost_eligibility_info: IGMediaBoostEligibilityInfoFields; caption: string; comments_count: number; copyright_check_information: IGVideoCopyrightCheckMatchesInformationFields; current_live_viewer_count: number; has_poll: boolean; has_slider: boolean; id: string; ig_id: string; is_comment_enabled: boolean; is_shared_to_feed: boolean; legacy_instagram_media_id: string; like_count: number; media_product_type: string; media_type: string; media_url: string; owner: IGUserFields; permalink: string; shortcode: string; thumbnail_url: string; timestamp: string; username: string; video_title: string; view_count: number; } export interface IGMediaCreateBrandedContentPartnerPromoteParams { permission: boolean; sponsor_id: number; [key: string]: unknown; } export interface IGMediaCreateCommentsParams { ad_id?: string; message?: string; [key: string]: unknown; } export interface IGMediaListInsightsParams { breakdown?: string[]; metric: string[]; period?: string[]; [key: string]: unknown; } export interface IGMediaCreateProductTagsParams { child_index?: number; updated_tags: Record[]; [key: string]: unknown; } export interface IGMediaUpdateParams { comment_enabled?: boolean; [key: string]: unknown; } export function iGMediaNode(client: ApiClient, id: string) { return { __path: id, __brand: undefined as unknown as IGMediaFields, get: (opts: { fields: F; params?: Record }) => client.get>(`${id}`, opts), update: (params: IGMediaUpdateParams) => client.post(`${id}`, params as Record), delete: () => client.delete(`${id}`, {}), boostAdsList: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/boost_ads_list`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), brandedContentPartnerPromote: { __path: `${id}/branded_content_partner_promote`, __brand: undefined as unknown as BrandedContentShadowIGUserIDFields, list: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/branded_content_partner_promote`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), create: (params: IGMediaCreateBrandedContentPartnerPromoteParams) => client.post(`${id}/branded_content_partner_promote`, params as Record), }, children: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/children`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), collaborators: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/collaborators`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), comments: { __path: `${id}/comments`, __brand: undefined as unknown as IGCommentFields, list: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/comments`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), create: (params: IGMediaCreateCommentsParams) => client.post(`${id}/comments`, params as Record), }, insights: (opts: { fields: F; params?: IGMediaListInsightsParams }) => new Cursor>(client, `${id}/insights`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), partnershipAdCode: { __path: `${id}/partnership_ad_code`, __brand: undefined as unknown as Record, create: (params: Record) => client.post>(`${id}/partnership_ad_code`, params as Record), delete: (params?: Record) => client.delete(`${id}/partnership_ad_code`, params as Record ?? {}), }, productTags: { __path: `${id}/product_tags`, __brand: undefined as unknown as ShadowIGMediaProductTagsFields, list: (opts: { fields: F; params?: Record }) => new Cursor>(client, `${id}/product_tags`, opts as { fields: readonly string[]; params?: Record }, metaPagination()), create: (params: IGMediaCreateProductTagsParams) => client.post(`${id}/product_tags`, params as Record), }, }; }