// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as MiscAPI from '../../misc'; import * as WalletsAPI from './wallets'; import { APIPromise } from '../../../core/api-promise'; import { DefaultPageNumberPagination, type DefaultPageNumberPaginationParams, PagePromise, } from '../../../core/pagination'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; export class LedgerEntries extends APIResource { /** * @example * ```ts * // Automatically fetches more pages as needed. * for await (const customerWalletTransaction of client.customers.wallets.ledgerEntries.list( * 'cus_TV52uJWWXt2yIoBBxpjaa', * )) { * // ... * } * ``` */ list( customerID: string, query: LedgerEntryListParams | null | undefined = {}, options?: RequestOptions, ): PagePromise { return this._client.getAPIList( path`/customers/${customerID}/wallets/ledger-entries`, DefaultPageNumberPagination, { query, ...options }, ); } /** * @example * ```ts * const customerWallet = * await client.customers.wallets.ledgerEntries.create( * 'cus_TV52uJWWXt2yIoBBxpjaa', * { * amount: 0, * currency: 'AED', * entry_type: 'credit', * }, * ); * ``` */ create( customerID: string, body: LedgerEntryCreateParams, options?: RequestOptions, ): APIPromise { return this._client.post(path`/customers/${customerID}/wallets/ledger-entries`, { body, ...options }); } } export type CustomerWalletTransactionsDefaultPageNumberPagination = DefaultPageNumberPagination; export interface CustomerWalletTransaction { id: string; after_balance: number; amount: number; before_balance: number; business_id: string; created_at: string; currency: MiscAPI.Currency; customer_id: string; event_type: | 'payment' | 'payment_reversal' | 'refund' | 'refund_reversal' | 'dispute' | 'dispute_reversal' | 'merchant_adjustment'; is_credit: boolean; reason?: string | null; reference_object_id?: string | null; } export interface LedgerEntryListParams extends DefaultPageNumberPaginationParams { /** * Optional currency filter */ currency?: MiscAPI.Currency; } export interface LedgerEntryCreateParams { amount: number; /** * Currency of the wallet to adjust */ currency: MiscAPI.Currency; /** * Type of ledger entry - credit or debit */ entry_type: 'credit' | 'debit'; /** * Optional idempotency key to prevent duplicate entries */ idempotency_key?: string | null; reason?: string | null; } export declare namespace LedgerEntries { export { type CustomerWalletTransaction as CustomerWalletTransaction, type CustomerWalletTransactionsDefaultPageNumberPagination as CustomerWalletTransactionsDefaultPageNumberPagination, type LedgerEntryListParams as LedgerEntryListParams, type LedgerEntryCreateParams as LedgerEntryCreateParams, }; }