// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as ConfigsAPI from './configs'; import { ConfigListResponse, ConfigRetrieveResponse, ConfigUpdateParams, ConfigUpdateResponse, Configs, } from './configs'; import { APIPromise } from '../../../core/api-promise'; import { RequestOptions } from '../../../internal/request-options'; export class TakeRate extends APIResource { configs: ConfigsAPI.Configs = new ConfigsAPI.Configs(this._client); /** * Administrative endpoint to create or update the global flat take-rate * configuration. This admin-only endpoint manages the single flat commission rate * used across all campaigns. * * @example * ```ts * const response = await client.admin.takeRate.config({ * percentage: 15, * }); * ``` */ config(body: TakeRateConfigParams, options?: RequestOptions): APIPromise { return this._client.post('/admin/take-rate/config', { body, ...options }); } /** * Administrative endpoint to validate that an offer amount meets the minimum * commission requirements. This admin-only endpoint checks if the proposed offer * amount will generate at least the $10 minimum commission when the 15% take-rate * is applied. It returns validation status and the minimum required offer amount * if the current amount is insufficient. * * @example * ```ts * const response = await client.admin.takeRate.validateOffer({ * offerAmount: 1, * }); * ``` */ validateOffer( body: TakeRateValidateOfferParams, options?: RequestOptions, ): APIPromise { return this._client.post('/admin/take-rate/validate-offer', { body, ...options }); } } export interface TakeRateConfigResponse { data: TakeRateConfigResponse.Data; message: string; success: boolean; } export namespace TakeRateConfigResponse { export interface Data { id: string; createdAt: string; isActive: boolean; maxAmount: number | null; minAmount: number | null; name: string; percentage: number; updatedAt: string; } } export interface TakeRateValidateOfferResponse { data: TakeRateValidateOfferResponse.Data; success: boolean; } export namespace TakeRateValidateOfferResponse { export interface Data { isValid: boolean; message: string; minimumRequired?: number; takeRateAmount?: number; } } export interface TakeRateConfigParams { /** * Take-rate percentage (0-25%) */ percentage: number; /** * Maximum commission amount in USD */ maxAmount?: number; /** * Minimum commission amount in USD */ minAmount?: number; } export interface TakeRateValidateOfferParams { offerAmount: number; } TakeRate.Configs = Configs; export declare namespace TakeRate { export { type TakeRateConfigResponse as TakeRateConfigResponse, type TakeRateValidateOfferResponse as TakeRateValidateOfferResponse, type TakeRateConfigParams as TakeRateConfigParams, type TakeRateValidateOfferParams as TakeRateValidateOfferParams, }; export { Configs as Configs, type ConfigRetrieveResponse as ConfigRetrieveResponse, type ConfigUpdateResponse as ConfigUpdateResponse, type ConfigListResponse as ConfigListResponse, type ConfigUpdateParams as ConfigUpdateParams, }; }