export type UpdateApiApiV2CallbackSettingsArgs = {body: {outUrl: string | null, inUrl: string | null, format: 'm' | 'u' | 'j'}}; export type UpdateApiApiV2CallbackSettingsOptions = {baseUrl?: string | undefined, BasicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Update callback URL settings * * PUT /api/v2/callback/settings */ export const updateApiApiV2CallbackSettings = async (args: UpdateApiApiV2CallbackSettingsArgs, options?: UpdateApiApiV2CallbackSettingsOptions) => { const {baseUrl = "https://rest.textmagic.com", fetch: fetchFn = fetch, BasicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BasicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${BasicAuth.username}:${BasicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/callback/settings${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };