export type SubmitRampKycDto = {provider: 'FONBNK' | 'ONRAMP_MONEY' | 'GUARDARIAN' | 'YELLOW_CARD', userEmail: string, countryCode: string, fiatCurrency: string, fields?: Record | undefined, callbackUrl?: string | undefined, cryptoAmount?: number | undefined}; export type CreateApiRampKycArgs = {body: SubmitRampKycDto}; export type CreateApiRampKycOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Submit KYC information * * POST /ramp/kyc */ export const createApiRampKyc = async (args: CreateApiRampKycArgs, options?: CreateApiRampKycOptions) => { const {baseUrl = "https://api.chainrails.io/api/v1", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/ramp/kyc${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 };