export type ApiPreference = {id?: number | undefined, publicName?: (string | null) | undefined, privateName?: (string | null) | undefined, isPreference?: boolean | undefined, order?: (string | null) | undefined, isPublic?: boolean | undefined, categoryId?: number | undefined, preferenceCount?: number | undefined, created?: string | undefined, lastModified?: string | undefined, isOptedIn?: (boolean | null) | undefined, preferences?: (Array | null) | undefined}; export type UpdateApiV2ContactContactIdPreferencesArgs = {contactId: number, body: Array}; export type UpdateApiV2ContactContactIdPreferencesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sets the subscribed preferences for a contact * * PUT /v2/contact/{contactId}/preferences */ export const updateApiV2ContactContactIdPreferences = async (args: UpdateApiV2ContactContactIdPreferencesArgs, options?: UpdateApiV2ContactContactIdPreferencesOptions) => { const {baseUrl = "https://api.dotdigital.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/octet-stream") const url = `${baseUrl.replace(/\/+$/, '')}/v2/contact/${encodeURIComponent(String(args.contactId))}/preferences${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 res.blob() };