export type CreateApiApiV2CompaniesIdDomainsArgs = {id: number, body: {Domain: string, Importance?: ('Low' | 'Medium' | 'High' | 'Critical' | 'Urgent') | undefined}}; export type CreateApiApiV2CompaniesIdDomainsOptions = {baseUrl?: string | undefined, OAuthv2?: string | undefined, fetch?: typeof fetch | undefined}; /** * A new secondary top level domain (TLD) is added to the given company. * * POST /api/v2/companies/{id}/domains */ export const createApiApiV2CompaniesIdDomains = async (args: CreateApiApiV2CompaniesIdDomainsArgs, options?: CreateApiApiV2CompaniesIdDomainsOptions) => { const {baseUrl = "https://app.blackkitetech.com", fetch: fetchFn = fetch, OAuthv2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/plain") if (OAuthv2 !== undefined) headers.set('authorization', `Bearer ${OAuthv2}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/companies/${encodeURIComponent(String(args.id))}/domains${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.text() };