import {z} from 'zod' export type FireAntApiModelsPostsPostImage = {imageID?: number | undefined, base64Image?: string | undefined, imageUrl?: string | undefined}; export type FireAntApiModelsPostsPostFile = {fileID?: number | undefined, fileName?: string | undefined, fileExtension?: string | undefined, base64Content?: string | undefined, fileContentUrl?: string | undefined}; export type FireAntApiModelsPostsPostChangeRequest = {approved?: boolean | undefined, date?: string | undefined, title?: string | undefined, description?: string | undefined, type?: number | undefined, videoUrl?: string | undefined, videoThumbnailUrl?: string | undefined, videoWidth?: number | undefined, videoHeight?: number | undefined, language?: string | undefined, expertUserID?: string | undefined, postGroupID?: number | undefined, postSourceID?: number | undefined, isSourceContentFull?: boolean | undefined, postSourceUrl?: string | undefined, isTop?: boolean | undefined, content?: string | undefined, link?: string | undefined, linkTitle?: string | undefined, linkDescription?: string | undefined, linkImage?: string | undefined, roomID?: number | undefined, referToPostID?: number | undefined, replyToPostID?: number | undefined, sentiment?: number | undefined, images?: Array | undefined, files?: Array | undefined, symbols?: Array | undefined, individuals?: Array | undefined, hashTags?: Array | undefined, users?: Array | undefined, videoType?: number | undefined, isVideo?: boolean | undefined, isEmagazine?: boolean | undefined, isInfographic?: boolean | undefined, newsType?: number | undefined, summary?: string | undefined, isLivestream?: boolean | undefined, streamingUrl?: string | undefined, streamingKey?: string | undefined, youtubeStreamingUrl?: string | undefined, youtubeStreamingKey?: string | undefined, facebookStreamingUrl?: string | undefined, facebookStreamingKey?: string | undefined, livestreamAction?: boolean | undefined, livestreamActionTitle?: string | undefined, livestreamActionUrl?: string | undefined, livestreamActionRoute?: string | undefined, repliesDisabled?: boolean | undefined, repliesModerationRequired?: boolean | undefined, pendingApproval?: boolean | undefined, isAIGenerated?: boolean | undefined, contentURL?: string | undefined, hasSummary?: boolean | undefined}; export type FireAntApiModelsAlertsAdminNewsRequest = {userName?: string | undefined, post?: FireAntApiModelsPostsPostChangeRequest | undefined}; export type DeleteApiAdminNewsPostIdArgs = {postId: number, body: FireAntApiModelsAlertsAdminNewsRequest}; export type DeleteApiAdminNewsPostIdOptions = {baseUrl?: string | undefined, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; export const deleteApiAdminNewsPostIdResponse = z.number().int(); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Xóa tin tức * * DELETE /admin/news/{postId} */ export const deleteApiAdminNewsPostId = async (args: DeleteApiAdminNewsPostIdArgs, options?: DeleteApiAdminNewsPostIdOptions) => { const {baseUrl = "https://api.fireant.vn", fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/admin/news/${encodeURIComponent(String(args.postId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(deleteApiAdminNewsPostIdResponse, await res.json()) };