export type AgreementSubmit = {data: string}; export type CreateApiAppsGovFrV1EntrySiloEntryIdAgreementArgs = {silo_entry_id: string, body: AgreementSubmit}; export type CreateApiAppsGovFrV1EntrySiloEntryIdAgreementOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Upload a pre-signed agreement * * POST /apps/gov-fr/v1/entry/{silo_entry_id}/agreement */ export const createApiAppsGovFrV1EntrySiloEntryIdAgreement = async (args: CreateApiAppsGovFrV1EntrySiloEntryIdAgreementArgs, options?: CreateApiAppsGovFrV1EntrySiloEntryIdAgreementOptions) => { const {baseUrl = "https://api.invopop.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") 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: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };