export type MediaDataEntryReference = {type: 'diary' | 'fnol' | 'inquiry' | 'policy' | 'producer' | 'producerAppointment' | 'producerCode' | 'producerLicense' | 'quote' | 'task' | 'transaction' | 'userAssociation', locator: unknown}; export type CreateApiAuxdataTenantLocatorMediadataArgs = {tenantLocator: string, filename: string, mimeType: string, title?: string | undefined, tag?: string | undefined, references: Array, body: BodyInit}; export type CreateApiAuxdataTenantLocatorMediadataOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /auxdata/{tenantLocator}/mediadata */ export const createApiAuxdataTenantLocatorMediadata = async (args: CreateApiAuxdataTenantLocatorMediadataArgs, options: CreateApiAuxdataTenantLocatorMediadataOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") if (args.filename != null) query.append("filename", String(args.filename)) if (args.mimeType != null) query.append("mimeType", String(args.mimeType)) if (args.title != null) query.append("title", String(args.title)) if (args.tag != null) query.append("tag", String(args.tag)) for (const item of args.references ?? []) query.append("references", String(item)) const url = `${baseUrl.replace(/\/+$/, '')}/auxdata/${encodeURIComponent(String(args.tenantLocator))}/mediadata${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };