export type CreateApiHdDesksDeskIdAuthLogoutArgs = {desk_id: string, 'X-SV-Client': 'help-desk-portal', body: {refresh_token?: string | undefined}}; export type CreateApiHdDesksDeskIdAuthLogoutOptions = {baseUrl?: string | undefined, HelpDeskCustomerToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sign the customer out * * POST /hd/desks/{desk_id}/auth/logout */ export const createApiHdDesksDeskIdAuthLogout = async (args: CreateApiHdDesksDeskIdAuthLogoutArgs, options?: CreateApiHdDesksDeskIdAuthLogoutOptions) => { const {baseUrl = "https://api.sparkvault.com/v1", fetch: fetchFn = fetch, HelpDeskCustomerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['X-SV-Client'] != null) headers.set("X-SV-Client", String(args['X-SV-Client'])) if (HelpDeskCustomerToken !== undefined) headers.set('authorization', `Bearer ${HelpDeskCustomerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/hd/desks/${encodeURIComponent(String(args.desk_id))}/auth/logout${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 };