export type GetApiRampKycArgs = {provider: 'FONBNK' | 'ONRAMP_MONEY' | 'GUARDARIAN' | 'YELLOW_CARD', userEmail: string, countryCode: string, fiatCurrency: string, cryptoAmount?: number | undefined}; export type GetApiRampKycOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get user KYC state * * GET /ramp/kyc */ export const getApiRampKyc = async (args: GetApiRampKycArgs, options?: GetApiRampKycOptions) => { const {baseUrl = "https://api.chainrails.io/api/v1", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.provider != null) query.append("provider", String(args.provider)) if (args.userEmail != null) query.append("userEmail", String(args.userEmail)) if (args.countryCode != null) query.append("countryCode", String(args.countryCode)) if (args.fiatCurrency != null) query.append("fiatCurrency", String(args.fiatCurrency)) if (args.cryptoAmount != null) query.append("cryptoAmount", String(args.cryptoAmount)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/ramp/kyc${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };