export type CreateApiCompaniesArgs = {check_duplicate: boolean, body: {name: string, owner_id: number, website?: string | undefined, phones?: Array | undefined, address?: ({street?: string | undefined, city?: string | undefined, state?: string | undefined, postal_code?: string | undefined}) | undefined, country_code?: string | undefined, entered_by_id?: number | undefined, social_media_urls?: Array | undefined, notes?: string | undefined, is_hot?: boolean | undefined, key_technologies?: string | undefined, billing_contact_id?: number | undefined, custom_fields?: Array | undefined, user_groups?: Array | undefined}}; export type CreateApiCompaniesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a company * * POST /companies */ export const createApiCompanies = async (args: CreateApiCompaniesArgs, options?: CreateApiCompaniesOptions) => { const {baseUrl = "https://api.catsone.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.check_duplicate != null) query.append("check_duplicate", String(args.check_duplicate)) const url = `${baseUrl.replace(/\/+$/, '')}/companies${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 undefined };