export type CreateApiSsoUserArgs = {'api-key': string, 'auth-key': string, body: {firstName: string, middleName?: string | undefined, lastName: string, password: string, username: string, phone: string, email: string, gender?: string | undefined, country: string, idNo: string, idType: string, citizenship: string, usTaxPayer: boolean, dob: string, politicallyExposedNames: string, address1: string, address2?: string | undefined, city: string, state: string, postalCode: string, employmentStatus: string, employmentPosition?: string | undefined, employmentCompany?: string | undefined, employmentType: string, employmentCountry?: string | undefined, isBroker: boolean, directorOf: string, investmentObjectives?: string | undefined, investmentExperience: string, annualIncome: number, networthLiquid: number, networthTotal: number, riskTolerance: string, termsOfUse: boolean, rule14b: boolean, customerAgreement: boolean, marketDataAgreement: boolean, privacyPolicy: boolean, dataSharing: boolean, stockalTermsOfUse: boolean, signedBy: string, partnerCode?: string | undefined, documents: Array, userReferralCode?: string | undefined, partnerToken?: string | undefined}}; export type CreateApiSsoUserOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create User * * POST /sso/user */ export const createApiSsoUser = async (args: CreateApiSsoUserArgs, options?: CreateApiSsoUserOptions) => { const {baseUrl = "https://uatclientapi-v2.stockal.com/client/v2", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['api-key'] != null) headers.set("api-key", String(args['api-key'])) if (args['auth-key'] != null) headers.set("auth-key", String(args['auth-key'])) const url = `${baseUrl.replace(/\/+$/, '')}/sso/user${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 (await res.json()) as unknown };