export type PurchaseDomainMailboxDto = {firstname: string, lastname: string, email: string, profilePicId: number}; export type PurchaseDomainItemDto = {name: string, redirectUrl: string, mailboxes: Array}; export type PurchaseDomainDto = {domainOwnerFirstname: string, domainOwnerLastname: string, companyName: string, address: string, city?: string | undefined, state?: string | undefined, country: string, zipcode: string, phoneNumber: string, emailServiceProvider: 'Google' | 'Microsoft' | 'Azure', planType?: ('quarterly' | 'annualFlexi' | 'annualFixed') | undefined, domains: Array, isReplacement?: boolean | undefined, isFreeOrder?: boolean | undefined}; export type CreateApiV1DomainArgs = {body: PurchaseDomainDto}; export type CreateApiV1DomainOptions = {baseUrl: string, xApiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Purchase domains and mailboxes as managed email-sending infrastructure * * POST /v1/domain */ export const createApiV1Domain = async (args: CreateApiV1DomainArgs, options: CreateApiV1DomainOptions) => { const {baseUrl, fetch: fetchFn = fetch, xApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (xApiKey !== undefined) headers.set("x-api-key", xApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v1/domain${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 };