← Public packages
@kentcdodds/wise
Call Wise profiles, balances, quotes, recipients, and transfers with wiseApiToken.
src/list-profiles.ts
36 lines · 1.0 KB · TypeScriptimport { wiseRequest } from './core.ts'
/**
* List Wise profiles available to wiseApiToken (personal and/or business).
* Use for smoke tests and to pick a profileId for balances, quotes, and transfers.
*
* @returns Slim profile list (id, type, display name fields).
*
* @example
* import listProfiles from 'kody:@kentcdodds/wise/list-profiles'
* const { profiles } = await listProfiles()
* // => { profiles: [{ id: 123, type: 'business', name: 'Example Co' }, ...] }
*/
export default async function listProfiles(_input: Record<string, never> = {}) {
const raw = (await wiseRequest({
path: '/v1/profiles',
label: 'Wise profiles',
})) as Array<{
id: number
type?: string
details?: {
firstName?: string
lastName?: string
name?: string
companyName?: string
}
}>
const profiles = (raw || []).map((p) => ({
id: p.id,
type: p.type || null,
firstName: p.details?.firstName || null,
lastName: p.details?.lastName || null,
name: p.details?.name || p.details?.companyName || null,
}))
return { profiles, count: profiles.length }
}