// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import { APIPromise } from '../../../core/api-promise'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; export class OnHold extends APIResource { /** * Retrieve a paginated list of all on-hold balances in the system. Shows funds * that are held against campaigns including their status, amounts, and associated * campaign information. Supports filtering by status, brand, campaign, and sorting * options. Includes summary statistics for dashboard views. * * @example * ```ts * const response = * await client.admin.balances.onHold.retrieveOnHold(); * ``` */ retrieveOnHold( query: OnHoldRetrieveOnHoldParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get('/admin/balances/on-hold', { query, ...options }); } /** * Revert an on-hold balance charge and restore the funds to the brand's credits. * This operation changes the status to "reverted", updates the brand's credits * balance, and creates a billing event record for audit purposes. Can only be * performed on balances with "held" status. * * @example * ```ts * const response = await client.admin.balances.onHold.revert( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { reason: 'x' }, * ); * ``` */ revert( chargeID: string, body: OnHoldRevertParams, options?: RequestOptions, ): APIPromise { return this._client.post(path`/admin/balances/on-hold/${chargeID}/revert`, { body, ...options }); } } export interface OnHoldRetrieveOnHoldResponse { data: OnHoldRetrieveOnHoldResponse.Data; /** * Whether the request was successful */ success: boolean; } export namespace OnHoldRetrieveOnHoldResponse { export interface Data { /** * Array of on-hold balances */ onHoldBalances: Array; /** * Pagination information */ pagination: Data.Pagination; /** * Summary statistics */ summary: Data.Summary; } export namespace Data { export interface OnHoldBalance { /** * Unique identifier for the on-hold balance */ id: string; /** * Amount held in cents */ amount: number; /** * Associated campaign data */ campaign: OnHoldBalance.Campaign; /** * Campaign identifier */ campaignId: string; /** * When the balance was placed on hold */ createdAt: string; /** * When the balance was released */ releasedAt: string | null; /** * When the balance was reverted */ revertedAt: string | null; /** * Status of the on-hold balance */ status: 'held' | 'released' | 'reverted'; /** * When the balance was last updated */ updatedAt: string; /** * Brand user identifier who owns the balance */ userId: string; } export namespace OnHoldBalance { /** * Associated campaign data */ export interface Campaign { /** * Campaign identifier */ id: string; /** * Brand identifier */ brandId: string; /** * Brand name */ brandName: string; /** * Campaign name */ name: string; /** * Campaign status */ status: string; } } /** * Pagination information */ export interface Pagination { /** * Whether there are more pages */ hasNext: boolean; /** * Whether there are previous pages */ hasPrev: boolean; /** * Number of items per page */ limit: number; /** * Current page number */ page: number; /** * Total number of businesses */ total: number; /** * Total number of pages */ totalPages: number; } /** * Summary statistics */ export interface Summary { /** * Total amount on hold in cents */ totalAmount: number; /** * Number of held balances */ totalHeld: number; /** * Number of released balances */ totalReleased: number; /** * Number of reverted balances */ totalReverted: number; } } } export interface OnHoldRevertResponse { data: OnHoldRevertResponse.Data; /** * Whether the revert was successful */ success: boolean; } export namespace OnHoldRevertResponse { export interface Data { /** * Amount reverted in cents */ amount: number; /** * Brand identifier */ brandId: string; /** * Brand name */ brandName: string; /** * Campaign identifier */ campaignId: string; /** * Campaign name */ campaignName: string; /** * On-hold balance identifier */ chargeId: string; /** * Revert confirmation message */ message: string; /** * New balance status */ newStatus: string; /** * Previous balance status */ previousStatus: string; /** * Reason for the revert */ reason: string; /** * When the revert was processed */ revertedAt: string; /** * Admin user who reverted the charge */ revertedBy?: string; } } export interface OnHoldRetrieveOnHoldParams { /** * Filter by brand ID */ brandId?: string; /** * Filter by campaign ID */ campaignId?: string; /** * Number of on-hold balances per page */ limit?: string; /** * Page number for pagination */ page?: string; /** * Sort on-hold balances by field */ sortBy?: 'amount' | 'createdAt' | 'updatedAt'; /** * Sort order */ sortOrder?: 'asc' | 'desc'; /** * Filter by on-hold balance status */ status?: 'held' | 'released' | 'reverted'; } export interface OnHoldRevertParams { /** * Reason for reverting the charge */ reason: string; /** * Admin user who reverted the charge */ revertedBy?: string; } export declare namespace OnHold { export { type OnHoldRetrieveOnHoldResponse as OnHoldRetrieveOnHoldResponse, type OnHoldRevertResponse as OnHoldRevertResponse, type OnHoldRetrieveOnHoldParams as OnHoldRetrieveOnHoldParams, type OnHoldRevertParams as OnHoldRevertParams, }; }