export type AddChildDomain = {domain?: string | undefined}; export type CreateApiResellerChildrenChildIdentifierDomainsArgs = {childIdentifier: string, body: AddChildDomain}; export type CreateApiResellerChildrenChildIdentifierDomainsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a domain for a child account * * POST /reseller/children/{childIdentifier}/domains * * Also accepts auth: partner-key */ export const createApiResellerChildrenChildIdentifierDomains = async (args: CreateApiResellerChildrenChildIdentifierDomainsArgs, options?: CreateApiResellerChildrenChildIdentifierDomainsOptions) => { const {baseUrl = "https://api.brevo.com/v3", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("api-key", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/reseller/children/${encodeURIComponent(String(args.childIdentifier))}/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 undefined };