export type GetApiAppsGovFrV1EntrySiloEntryIdAgreementArgs = {silo_entry_id: string}; export type GetApiAppsGovFrV1EntrySiloEntryIdAgreementOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download the agreement PDF * * GET /apps/gov-fr/v1/entry/{silo_entry_id}/agreement */ export const getApiAppsGovFrV1EntrySiloEntryIdAgreement = async (args: GetApiAppsGovFrV1EntrySiloEntryIdAgreementArgs, options?: GetApiAppsGovFrV1EntrySiloEntryIdAgreementOptions) => { const {baseUrl = "https://api.invopop.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/pdf") const url = `${baseUrl.replace(/\/+$/, '')}/apps/gov-fr/v1/entry/${encodeURIComponent(String(args.silo_entry_id))}/agreement${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() };