export type UserIdentifyId = {identifyId: string}; export type CreateApiV2UserPreferencesArgs = {body: UserIdentifyId}; export type CreateApiV2UserPreferencesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get user preferences. This version of API includes extra property 'trackEmailAnalytics' in the response. (identifyId passed via request body) * * POST /v2/user/preferences */ export const createApiV2UserPreferences = async (args: CreateApiV2UserPreferencesArgs, options?: CreateApiV2UserPreferencesOptions) => { const {baseUrl = "https://app.aptrinsic.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/v2/user/preferences${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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() };