export type UploadTranslationKeyScreenshotRequestV2 = {base64: string}; export type CreateApiApiV1TranslationKeysScreenshotsArgs = {key: string, namespace?: string | undefined, body: UploadTranslationKeyScreenshotRequestV2}; export type CreateApiApiV1TranslationKeysScreenshotsOptions = {baseUrl?: string | undefined, ProjectAPIKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload translation key screenshot * * POST /api/v1/translation-keys/screenshots */ export const createApiApiV1TranslationKeysScreenshots = async (args: CreateApiApiV1TranslationKeysScreenshotsArgs, options?: CreateApiApiV1TranslationKeysScreenshotsOptions) => { const {baseUrl = "https://api.simplelocalize.io", fetch: fetchFn = fetch, ProjectAPIKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.key != null) query.append("key", String(args.key)) if (args.namespace != null) query.append("namespace", String(args.namespace)) if (ProjectAPIKey !== undefined) headers.set("X-SimpleLocalize-Token", ProjectAPIKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/translation-keys/screenshots${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 };