export type GameDraftState = 'sqa-to-review' | 'video-to-review' | 'video-ready' | 'approved' | 'rejected' | 'published'; export type SetStateDto = {state?: GameDraftState | undefined, version: number, gameIds?: Array | undefined, lock?: number | undefined}; export type CreateApiV2AutogameArticleDraftsIdSetStateArgs = {id: string, body: SetStateDto}; export type CreateApiV2AutogameArticleDraftsIdSetStateOptions = {baseUrl: string, accessToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * POST /v2/autogame/article/drafts/{id}/set_state */ export const createApiV2AutogameArticleDraftsIdSetState = async (args: CreateApiV2AutogameArticleDraftsIdSetStateArgs, options: CreateApiV2AutogameArticleDraftsIdSetStateOptions) => { const {baseUrl, fetch: fetchFn = fetch, accessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (accessToken !== undefined) headers.set('authorization', `Bearer ${accessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/autogame/article/drafts/${encodeURIComponent(String(args.id))}/set_state${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 undefined };