export type WalletActionType = 'TERMINATE' | 'BLOCK' | 'UNBLOCK'; export type WalletActionRequest = {action: WalletActionType, comment: 'COMPLIANCE' | 'OPERATION' | 'OFFBOARDING' | 'CLIENT_REQUEST' | 'OTHER'}; export type CreateApiLedgerV2WalletsIdActionsArgs = {id: string, body: WalletActionRequest}; export type CreateApiLedgerV2WalletsIdActionsOptions = {baseUrl?: string | undefined, Hawk?: string | undefined, fetch?: typeof fetch | undefined}; /** * Execute wallet action * * POST /ledger/v2/wallets/{id}/actions */ export const createApiLedgerV2WalletsIdActions = async (args: CreateApiLedgerV2WalletsIdActionsArgs, options?: CreateApiLedgerV2WalletsIdActionsOptions) => { const {baseUrl = "https://api.sandbox.bvnk.com", fetch: fetchFn = fetch, Hawk} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Hawk !== undefined) headers.set("Authorization", Hawk) const url = `${baseUrl.replace(/\/+$/, '')}/ledger/v2/wallets/${encodeURIComponent(String(args.id))}/actions${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };