export type ThemeColor = {id?: string | undefined, type?: ('COLOR' | 'GRADIENT') | undefined, value?: string | undefined}; export type ThemeCustomFont = {fontFamily?: string | undefined, fontSrc?: string | undefined, fontWeights?: Array | undefined, id?: string | undefined, importSrc?: string | undefined}; export type ThemeSelectedFont = {id?: string | undefined, type?: ('DEFAULT' | 'CUSTOM') | undefined}; export type Theme = {colors?: Array | undefined, components?: Array | undefined, creationDate?: string | undefined, customFonts?: Array | undefined, dateModified?: string | undefined, description?: string | undefined, id?: number | undefined, name?: string | undefined, projectIds: Array, selectedFonts?: Array | undefined, status?: ('ACTIVE' | 'DRAFT' | 'PAUSED') | undefined, tags?: Array | undefined, widgetIds?: Array | undefined}; export type CreateApiThemesArgs = {body: Theme}; export type CreateApiThemesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a new theme * * POST /themes */ export const createApiThemes = async (args: CreateApiThemesArgs, options?: CreateApiThemesOptions) => { const {baseUrl = "https://api.kameleoon.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/themes${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 res.blob() };