// 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 Payouts extends APIResource { /** * Get a paginated list of payout requests with filtering capabilities by status, * creator, payment method, and date range. Includes creator information, campaign * details, and masked payment method details for security. * * @example * ```ts * const payouts = await client.admin.payouts.list(); * ``` */ list( query: PayoutListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get('/admin/payouts', { query, ...options }); } /** * Retry a failed payout request by resetting its status to pending. This allows * the payout processing system to attempt the payout again. * * @example * ```ts * const response = await client.admin.payouts.retry( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * ); * ``` */ retry(id: string, options?: RequestOptions): APIPromise { return this._client.post(path`/admin/payouts/${id}/retry`, options); } /** * Update the status of a payout request. Valid transitions include: pending → * processing → paid, pending → rejected, processing → failed. Creates financial * movement records for successful payouts. * * @example * ```ts * const response = await client.admin.payouts.updateStatus( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { status: 'pending' }, * ); * ``` */ updateStatus( id: string, body: PayoutUpdateStatusParams, options?: RequestOptions, ): APIPromise { return this._client.put(path`/admin/payouts/${id}/status`, { body, ...options }); } } export interface PayoutListResponse { data: Array; pagination: PayoutListResponse.Pagination; } export namespace PayoutListResponse { export interface Data { id: string; amount: number; createdAt: string; currency: string; depositAccountId: string; status: 'pending' | 'processing' | 'paid' | 'failed' | 'rejected'; updatedAt: string; creator?: Data.Creator; destinationAccount?: Data.DestinationAccount; failureReason?: string; financialMovementId?: string; name?: string; processedAt?: string; } export namespace Data { export interface Creator { id: string; email: string; handle: string; name: string; country?: string; } export interface DestinationAccount { accountNumber: string; accountType: 'wire'; bank: string; name: string; } } export interface Pagination { limit: number; page: number; total: number; totalPages: number; } } export interface PayoutRetryResponse { data: PayoutRetryResponse.Data; } export namespace PayoutRetryResponse { export interface Data { id: string; amount: number; createdAt: string; currency: string; depositAccountId: string; status: 'pending' | 'processing' | 'paid' | 'failed' | 'rejected'; updatedAt: string; creator?: Data.Creator; destinationAccount?: Data.DestinationAccount; failureReason?: string; financialMovementId?: string; name?: string; processedAt?: string; } export namespace Data { export interface Creator { id: string; email: string; handle: string; name: string; country?: string; } export interface DestinationAccount { accountNumber: string; accountType: 'wire'; bank: string; name: string; } } } export interface PayoutUpdateStatusResponse { data: PayoutUpdateStatusResponse.Data; } export namespace PayoutUpdateStatusResponse { export interface Data { id: string; amount: number; createdAt: string; currency: string; depositAccountId: string; status: 'pending' | 'processing' | 'paid' | 'failed' | 'rejected'; updatedAt: string; creator?: Data.Creator; destinationAccount?: Data.DestinationAccount; failureReason?: string; financialMovementId?: string; name?: string; processedAt?: string; } export namespace Data { export interface Creator { id: string; email: string; handle: string; name: string; country?: string; } export interface DestinationAccount { accountNumber: string; accountType: 'wire'; bank: string; name: string; } } } export interface PayoutListParams { creatorId?: string; dateFrom?: string; dateTo?: string; limit?: number; method?: 'western_union' | 'mercury_wire' | 'bind_api' | 'crypto'; page?: number; status?: 'pending' | 'processing' | 'paid' | 'failed' | 'rejected'; } export interface PayoutUpdateStatusParams { status: 'pending' | 'processing' | 'paid' | 'failed' | 'rejected'; reason?: string; } export declare namespace Payouts { export { type PayoutListResponse as PayoutListResponse, type PayoutRetryResponse as PayoutRetryResponse, type PayoutUpdateStatusResponse as PayoutUpdateStatusResponse, type PayoutListParams as PayoutListParams, type PayoutUpdateStatusParams as PayoutUpdateStatusParams, }; }