export type UpdateTranslationRequestV2 = {key: string, language: string, text: string, customerId?: string | undefined, namespace?: string | undefined, reviewStatus?: ('REVIEWED' | 'NOT_REVIEWED' | '') | undefined}; export type PatchApiApiV2TranslationsArgs = {body: UpdateTranslationRequestV2}; export type PatchApiApiV2TranslationsOptions = {baseUrl?: string | undefined, ProjectAPIKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update single translation * * PATCH /api/v2/translations */ export const patchApiApiV2Translations = async (args: PatchApiApiV2TranslationsArgs, options?: PatchApiApiV2TranslationsOptions) => { 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 (ProjectAPIKey !== undefined) headers.set("X-SimpleLocalize-Token", ProjectAPIKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/translations${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };