export type CreateApiV2AuthenticationLogoutArgs = {'x-tenant-id': string, 'x-challengecode': string}; export type CreateApiV2AuthenticationLogoutOptions = {baseUrl?: string | undefined, oauth2AuthorizationCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Logout * * POST /v2/authentication/logout * * Also accepts auth: oauth2-client-credentials */ export const createApiV2AuthenticationLogout = async (args: CreateApiV2AuthenticationLogoutArgs, options?: CreateApiV2AuthenticationLogoutOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, oauth2AuthorizationCode} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['x-tenant-id'] != null) headers.set("x-tenant-id", String(args['x-tenant-id'])) if (args['x-challengecode'] != null) headers.set("x-challengecode", String(args['x-challengecode'])) if (oauth2AuthorizationCode !== undefined) headers.set('authorization', `Bearer ${oauth2AuthorizationCode}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/authentication/logout${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };