export type GetApiReaderDownloadBooksBookIdArgs = {book_id: string}; export type GetApiReaderDownloadBooksBookIdOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download book * * GET /reader/download/books/{book_id} */ export const getApiReaderDownloadBooksBookId = async (args: GetApiReaderDownloadBooksBookIdArgs, options: GetApiReaderDownloadBooksBookIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (BearerAuth !== undefined) headers.set("Authorization", BearerAuth) const url = `${baseUrl.replace(/\/+$/, '')}/reader/download/books/${encodeURIComponent(String(args.book_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };