export type DeleteApiApiV1UsersUserIdEventsSleepSleepIdArgs = {user_id: string, sleep_id: string, 'X-Open-Wearables-API-Key'?: (string | null) | undefined}; export type DeleteApiApiV1UsersUserIdEventsSleepSleepIdOptions = {baseUrl: string, OAuth2PasswordBearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Delete Sleep Session * * DELETE /api/v1/users/{user_id}/events/sleep/{sleep_id} */ export const deleteApiApiV1UsersUserIdEventsSleepSleepId = async (args: DeleteApiApiV1UsersUserIdEventsSleepSleepIdArgs, options: DeleteApiApiV1UsersUserIdEventsSleepSleepIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, OAuth2PasswordBearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['X-Open-Wearables-API-Key'] != null) headers.set("X-Open-Wearables-API-Key", String(args['X-Open-Wearables-API-Key'])) if (OAuth2PasswordBearer !== undefined) headers.set('authorization', `Bearer ${OAuth2PasswordBearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/users/${encodeURIComponent(String(args.user_id))}/events/sleep/${encodeURIComponent(String(args.sleep_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };