export type CreateApiAccountsArgs = {update_if_exists?: boolean | undefined, body: {owner?: number | undefined, name?: string | undefined, domain?: string | undefined, picture?: string | undefined, size?: number | undefined, website?: string | undefined, description?: string | undefined, address?: Record | undefined, addresses?: (Array<{city?: string | undefined, country?: string | undefined, region?: string | undefined, state_region?: string | undefined, street?: string | undefined, zip?: string | undefined, _dirty?: boolean | undefined}>) | undefined, email?: string | undefined, email_addresses?: (Array<{email: string, _dirty?: boolean | undefined}>) | undefined, phone_number?: string | undefined, phone_numbers?: (Array<{number: string, type?: string | undefined, _dirty?: boolean | undefined}>) | undefined, social_profiles?: Array | undefined, tags?: Array | undefined, links?: string | undefined, customers?: (Array<{id: number, email?: string | undefined, name?: string | undefined}>) | undefined, _dirty?: boolean | undefined, parent_account?: number | undefined, custom?: Record | undefined}}; export type CreateApiAccountsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create an account * * POST /accounts */ export const createApiAccounts = async (args: CreateApiAccountsArgs, options?: CreateApiAccountsOptions) => { const {baseUrl = "https://api.salesflare.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (args.update_if_exists != null) query.append("update_if_exists", String(args.update_if_exists)) const url = `${baseUrl.replace(/\/+$/, '')}/accounts${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() };