export type ContactCreateRequest = {type: string, region?: string | undefined, data: {[key: string]: Record}, autoValidate: boolean}; export type CreateApiContactTenantLocatorContactsArgs = {tenantLocator: string, body: ContactCreateRequest}; export type CreateApiContactTenantLocatorContactsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * POST /contact/{tenantLocator}/contacts */ export const createApiContactTenantLocatorContacts = async (args: CreateApiContactTenantLocatorContactsArgs, options: CreateApiContactTenantLocatorContactsOptions) => { const {baseUrl, 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(/\/+$/, '')}/contact/${encodeURIComponent(String(args.tenantLocator))}/contacts${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() };