export type GetApiKycRequirementsArgs = {provider: 'FONBNK' | 'ONRAMP_MONEY' | 'GUARDARIAN' | 'YELLOW_CARD', countryCode: string, fiatCurrency: string}; export type GetApiKycRequirementsOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Inspect configured provider requirements * * GET /kyc/requirements */ export const getApiKycRequirements = async (args: GetApiKycRequirementsArgs, options?: GetApiKycRequirementsOptions) => { 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.countryCode != null) query.append("countryCode", String(args.countryCode)) if (args.fiatCurrency != null) query.append("fiatCurrency", String(args.fiatCurrency)) if (apiKey !== undefined) headers.set('authorization', `Bearer ${apiKey}`) const url = `${baseUrl.replace(/\/+$/, '')}/kyc/requirements${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 };