export type AsmId = {asmOrgId?: number | undefined, asmSecurityId?: number | undefined, asmTradingId?: number | undefined, id?: number | undefined, idType?: ('ASM_SECURITY_ID' | 'ASM_ORGANIZATION_ID' | 'ASM_TRADING_ITEM_ID') | undefined}; export type Percent = {value?: number | undefined}; export type MultiValueObject = {allValues?: {[key: string]: Percent} | undefined, wholeValue?: Record | undefined}; export type MultiSeriesObject = {firstDate?: string | undefined, initialValue?: MultiValueObject | undefined, lastValue?: ({key?: string | undefined, value?: MultiValueObject | undefined}) | undefined, staticValue?: MultiValueObject | undefined, wholeStaticValue?: Record | undefined}; export type ConstituentAttributeJson = {asmId?: AsmId | undefined, asmOrgId?: number | undefined, asmSecurityId?: number | undefined, attributeKey: string, id: number, value?: MultiSeriesObject | undefined}; export type PatchApiConstituentAttributesArgs = {'Addepar-Firm': string, body: ConstituentAttributeJson}; export type PatchApiConstituentAttributesOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Constituent Attributes * * PATCH /constituent_attributes */ export const patchApiConstituentAttributes = async (args: PatchApiConstituentAttributesArgs, options?: PatchApiConstituentAttributesOptions) => { const {baseUrl = "https://examplefirm.addepar.com/api/v1", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.api+json") headers.set('accept', "application/vnd.api+json") if (args['Addepar-Firm'] != null) headers.set("Addepar-Firm", String(args['Addepar-Firm'])) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/constituent_attributes${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 (await res.json()) as unknown };