import type { StorageAdapter, Page, PageOptions, PayLogger, Authorizer, RateProvider } from "../interfaces.js"; import type { ID } from "../types.js"; import type { Wallet, WalletBalance, WalletConstraints } from "../schemas.js"; import { type CreateWalletInput } from "../schemas.js"; /** Wallet management domain — create, inspect, and archive wallets. */ export interface WalletsDomain { /** * Create a new wallet for an owner within the client's tenant. * * @param input - Wallet creation parameters (currency, owner, constraints, etc.) * @returns The newly created wallet. * @throws {AuthorizationError} if the configured authorizer denies `wallet.create`. * * @example * ```ts * const wallet = await pay.wallets.create({ * currency: "NGN", * ownerId: userId, * ownerType: "user", * label: "Main NGN wallet", * }); * ``` */ create(input: CreateWalletInput): Promise; /** * Fetch a wallet by its id. * * @param walletId - The wallet's ULID identifier. * @returns The wallet record. * @throws {WalletNotFoundError} if no wallet with that id exists in this tenant. */ get(walletId: ID): Promise; /** * Retrieve the current (or point-in-time) balance for a wallet. * * When `options.at` is provided, the balance is computed from ledger entries * whose `effectiveAt` ≤ the given timestamp (historical balance query). * * @param walletId - The wallet's ULID identifier. * @param options.at - Optional point-in-time for historical balance lookup. * @returns A {@link WalletBalance} with booked, reserved, available, and pending figures. * @throws {WalletNotFoundError} if the wallet does not exist in this tenant. * * @example * ```ts * const balance = await pay.wallets.getBalance(wallet.id); * console.log(balance.available); // e.g. 95000 kobo * * // Historical balance at a past timestamp * const historical = await pay.wallets.getBalance(wallet.id, { at: new Date("2024-01-01") }); * ``` */ getBalance(walletId: ID, options?: { at?: Date; }): Promise; /** * List all wallets belonging to a given owner within the client's tenant. * * @param ownerId - The owner's identifier. * @param ownerType - The owner's type string (e.g. `"user"`, `"merchant"`). * @param page - Optional pagination cursor and limit. * @returns A paginated list of wallets. */ listByOwner(ownerId: ID, ownerType: string, page?: PageOptions): Promise>; /** * Update mutable wallet properties (label, negative-balance flag, finality mode, * and spending/balance constraints). * * @param walletId - The wallet to update. * @param patch - Fields to update. All keys are optional. * @returns The updated wallet record. * @throws {WalletNotFoundError} if the wallet does not exist. * @throws {AuthorizationError} if the configured authorizer denies `wallet.update`. */ update(walletId: ID, patch: Pick & { constraints?: WalletConstraints; }): Promise; /** * Soft-delete a wallet. Sets `deletedAt` — the wallet remains queryable but * cannot be used for new operations. * * @param walletId - The wallet to archive. * @returns The archived wallet with `deletedAt` set. * @throws {WalletNotFoundError} if the wallet does not exist. * @throws {WalletArchivalError} if the wallet has any ledger entries (non-zero history). * @throws {WalletArchivedError} if the wallet is already archived. * @throws {AuthorizationError} if the configured authorizer denies `wallet.archive`. */ archive(walletId: ID): Promise; /** * Convert a wallet's native-currency balance to a target currency using the * configured {@link RateProvider} and return the result alongside the * original {@link WalletBalance} figures. * * The `convertedAmount` reflects the wallet's `available` balance expressed * in `targetCurrency`. All other WalletBalance fields remain in the wallet's * native currency. A same-currency call is a no-op (`fxRate: "1"`). * * @param walletId - The source wallet. * @param targetCurrency - ISO 4217 target currency code. * @param options.at - Optional point-in-time; balance is computed from ledger * entries whose `effectiveAt` ≤ the given timestamp. * @returns The wallet balance enriched with `convertedAmount` and `fxRate`. * @throws {WalletNotFoundError} if the wallet does not exist. * @throws {FxRateUnavailableError} if no rate provider is configured. * * @example * ```ts * const result = await pay.wallets.getBalanceInCurrency(walletId, "USD"); * console.log(result.convertedAmount); // available balance in USD minor units * console.log(result.fxRate); // e.g. "0.00065" * ``` */ getBalanceInCurrency(walletId: ID, targetCurrency: string, options?: { at?: Date; }): Promise; } export declare function createWalletsDomain(tenantId: ID, storage: StorageAdapter, logger?: PayLogger, authorizer?: Authorizer, rateProvider?: RateProvider): WalletsDomain; //# sourceMappingURL=wallets.d.ts.map