export type GetApiContributionsTargetObjectIdTargetObjectIdArgs = {targetObjectId: number, status?: string | undefined, contributionType?: string | undefined, targetPageNum?: number | undefined}; export type GetApiContributionsTargetObjectIdTargetObjectIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get contribution data by target object id directly from the database. * * GET /contributions/targetObjectId/{targetObjectId} */ export const getApiContributionsTargetObjectIdTargetObjectId = async (args: GetApiContributionsTargetObjectIdTargetObjectIdArgs, options?: GetApiContributionsTargetObjectIdTargetObjectIdOptions) => { const {baseUrl = "https://catalog.archives.gov/api/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.status != null) query.append("status", String(args.status)) if (args.contributionType != null) query.append("contributionType", String(args.contributionType)) if (args.targetPageNum != null) query.append("targetPageNum", String(args.targetPageNum)) const url = `${baseUrl.replace(/\/+$/, '')}/contributions/targetObjectId/${encodeURIComponent(String(args.targetObjectId))}${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 };