export type GetApiApiWAFDestinationHoldingIdXmlArgs = {destination: string, holdingId: number, AsOfDate?: string | undefined}; export type GetApiApiWAFDestinationHoldingIdXmlOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Generates an export for a particular holding * * GET /api/WAF/{destination}/{holdingId}.xml */ export const getApiApiWAFDestinationHoldingIdXml = async (args: GetApiApiWAFDestinationHoldingIdXmlArgs, options: GetApiApiWAFDestinationHoldingIdXmlOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.AsOfDate != null) query.append("AsOfDate", String(args.AsOfDate)) const url = `${baseUrl.replace(/\/+$/, '')}/api/WAF/${encodeURIComponent(String(args.destination))}/${encodeURIComponent(String(args.holdingId))}.xml${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 undefined };