export type SignupRequest = {email?: string | undefined, full_name?: string | undefined, g_captcha_response?: string | undefined, invite?: string | undefined, personal_info?: {[key: string]: unknown} | undefined}; export type CreateApiSignupArgs = {body: SignupRequest}; export type CreateApiSignupOptions = {baseUrl?: string | undefined, NexlaSessionToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Sign Up * * POST /signup */ export const createApiSignup = async (args: CreateApiSignupArgs, options?: CreateApiSignupOptions) => { const {baseUrl = "https://dataops.nexla.io/nexla-api", fetch: fetchFn = fetch, NexlaSessionToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (NexlaSessionToken !== undefined) headers.set('authorization', `Bearer ${NexlaSessionToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/signup${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 };