← Public packages
@kentcdodds/wise
Call Wise profiles, balances, quotes, recipients, and transfers with wiseApiToken.
src/list-recipients.ts
56 lines · 1.6 KB · TypeScriptimport { resolveProfileId, wiseRequest, type ProfileRef } from './core.ts'
/**
* List Wise recipients (beneficiary accounts) for a profile.
* Read-only; uses GET /v2/accounts?profile={profileId}.
*
* @param input.profileId - Wise profile id; omit to use profileType.
* @param input.profileType - personal or business when profileId is omitted (default business).
* @param input.seekPosition - Optional pagination cursor.
* @param input.size - Page size (default 20, max 100).
*
* @example
* import listRecipients from 'kody:@kentcdodds/wise/list-recipients'
* const { recipients } = await listRecipients({ profileType: 'business' })
*/
export default async function listRecipients(
input: ProfileRef & { seekPosition?: number | string; size?: number } = {},
) {
const profileId = await resolveProfileId(input)
const size = Math.min(100, Math.max(1, Math.floor(Number(input.size) || 20)))
const raw = (await wiseRequest({
path: '/v2/accounts',
query: {
profile: profileId,
size,
...(input.seekPosition !== undefined
? { seekPosition: input.seekPosition }
: {}),
},
label: 'Wise recipients',
})) as {
content?: Array<{
id?: number
name?: { fullName?: string }
currency?: string
country?: string
type?: string
active?: boolean
}>
seekPositionForNext?: number | null
}
const recipients = (raw?.content || []).map((r) => ({
id: r.id ?? null,
name: r.name?.fullName || null,
currency: r.currency || null,
country: r.country || null,
type: r.type || null,
active: r.active ?? null,
}))
return {
profileId,
recipients,
count: recipients.length,
seekPositionForNext: raw?.seekPositionForNext ?? null,
}
}