Skip to content
← Public packages

@kentcdodds/wise

Call Wise profiles, balances, quotes, recipients, and transfers with wiseApiToken.

src/smoke-test.ts

27 lines · 918 B · TypeScript
import listBalances from './list-balances.ts'
import listProfiles from './list-profiles.ts'

/**
 * Read-only Wise auth smoke test: list profiles and business balances.
 * Use after saving wiseApiToken (and host approval for api.wise.com).
 *
 * @example
 * import smokeTest from 'kody:@kentcdodds/wise/smoke-test'
 * const result = await smokeTest()
 * // => { ok: true, profileCount: 2, balanceCount: 3, ... }
 */
export default async function smokeTest(_input: Record<string, never> = {}) {
	const { profiles, count } = await listProfiles()
	const business = profiles.find((p) => p.type === 'business')
	const balances = business
		? await listBalances({ profileId: business.id })
		: { profileId: null, balances: [], count: 0 }
	return {
		ok: true,
		profileCount: count,
		profiles,
		businessProfileId: business?.id ?? null,
		balanceCount: balances.count,
		balancesSample: balances.balances.slice(0, 5),
	}
}