export type GetApiV1MediaIdSignedUrlWriteArgs = {id: string}; export type GetApiV1MediaIdSignedUrlWriteOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Generate signing-url for write file in to google storage * * GET /v1/media/{id}/signed-url/write */ export const getApiV1MediaIdSignedUrlWrite = async (args: GetApiV1MediaIdSignedUrlWriteArgs, options?: GetApiV1MediaIdSignedUrlWriteOptions) => { const {baseUrl = "https://api.truepill.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/media/${encodeURIComponent(String(args.id))}/signed-url/write${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() };