// 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 Businesses extends APIResource { /** * Retrieve complete details for a specific business including all profile * information, credits balance, campaign statistics, and activity metrics. * * @example * ```ts * const business = await client.admin.businesses.retrieve( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * ); * ``` */ retrieve(id: string, options?: RequestOptions): APIPromise { return this._client.get(path`/admin/businesses/${id}`, options); } /** * Retrieve a paginated list of all businesses registered in the platform. Supports * filtering by search query, status, and various sorting options. Includes * additional metrics like total campaigns and spending. * * @example * ```ts * const businesses = await client.admin.businesses.list(); * ``` */ list( query: BusinessListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get('/admin/businesses', { query, ...options }); } /** * Manually adjust the credits balance for a specific business. This creates a * billing event with paymentId "system" to track the adjustment. Requires admin * privileges and a reason for the adjustment. * * @example * ```ts * const response = * await client.admin.businesses.updateCredits( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * { credits: 0, reason: 'x' }, * ); * ``` */ updateCredits( id: string, body: BusinessUpdateCreditsParams, options?: RequestOptions, ): APIPromise { return this._client.put(path`/admin/businesses/${id}/credits`, { body, ...options }); } } export interface BusinessRetrieveResponse { /** * Business details */ data: BusinessRetrieveResponse.Data; /** * When the response was generated */ generatedAt: string; /** * Whether the request was successful */ success: boolean; } export namespace BusinessRetrieveResponse { /** * Business details */ export interface Data { /** * Unique identifier for the business */ id: string; /** * The billing email address */ billingEmail: string | null; /** * Primary business goal */ brandGoal: string | null; /** * ISO 3166-1 alpha-2 country code */ country: string | null; /** * When the business was created */ createdAt: string; /** * Current credits balance in cents */ credits: number; /** * The industry sector */ industry: string | null; /** * The name of the business */ name: string; /** * Business status */ status: 'active' | 'inactive' | 'pending'; /** * Stripe customer ID */ stripeCustomerId: string | null; /** * Stripe payment method ID */ stripePaymentMethodId: string | null; /** * When the business was last updated */ updatedAt: string; /** * Brand voice guidelines */ voiceGuidelines: string | null; /** * Official website URL */ website: string | null; /** * How they heard about the platform */ whereHearUs: string | null; /** * Last activity timestamp */ lastActivityAt?: string | null; /** * Total number of campaigns */ totalCampaigns?: number; /** * Total amount spent in cents */ totalSpent?: number; } } export interface BusinessListResponse { data: BusinessListResponse.Data; /** * Whether the request was successful */ success: boolean; } export namespace BusinessListResponse { export interface Data { /** * Array of businesses */ businesses: Array; /** * Pagination information */ pagination: Data.Pagination; } export namespace Data { export interface Business { /** * Unique identifier for the business */ id: string; /** * The billing email address */ billingEmail: string | null; /** * Primary business goal */ brandGoal: string | null; /** * ISO 3166-1 alpha-2 country code */ country: string | null; /** * When the business was created */ createdAt: string; /** * Current credits balance in cents */ credits: number; /** * The industry sector */ industry: string | null; /** * The name of the business */ name: string; /** * Business status */ status: 'active' | 'inactive' | 'pending'; /** * Stripe customer ID */ stripeCustomerId: string | null; /** * Stripe payment method ID */ stripePaymentMethodId: string | null; /** * When the business was last updated */ updatedAt: string; /** * Brand voice guidelines */ voiceGuidelines: string | null; /** * Official website URL */ website: string | null; /** * How they heard about the platform */ whereHearUs: string | null; /** * Last activity timestamp */ lastActivityAt?: string | null; /** * Total number of campaigns */ totalCampaigns?: number; /** * Total amount spent in cents */ totalSpent?: number; } /** * 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; } } } export interface BusinessUpdateCreditsResponse { data: BusinessUpdateCreditsResponse.Data; /** * Whether the credit adjustment was successful */ success: boolean; } export namespace BusinessUpdateCreditsResponse { export interface Data { /** * When the adjustment was made */ adjustedAt: string; /** * Credit adjustment amount (can be negative) */ adjustment: number; /** * Business identifier */ businessId: string; /** * New credits amount in cents */ newCredits: number; /** * Previous credits amount in cents */ previousCredits: number; /** * Reason for the adjustment */ reason: string; /** * Admin user who made the adjustment */ adjustedBy?: string; } } export interface BusinessListParams { /** * Number of businesses per page */ limit?: string; /** * Page number for pagination */ page?: string; /** * Search businesses by name or email */ search?: string; /** * Sort businesses by field */ sortBy?: 'name' | 'createdAt' | 'credits' | 'updatedAt'; /** * Sort order */ sortOrder?: 'asc' | 'desc'; /** * Filter by business status */ status?: 'active' | 'inactive' | 'pending'; } export interface BusinessUpdateCreditsParams { /** * New credits amount in cents */ credits: number; /** * Reason for credit adjustment */ reason: string; } export declare namespace Businesses { export { type BusinessRetrieveResponse as BusinessRetrieveResponse, type BusinessListResponse as BusinessListResponse, type BusinessUpdateCreditsResponse as BusinessUpdateCreditsResponse, type BusinessListParams as BusinessListParams, type BusinessUpdateCreditsParams as BusinessUpdateCreditsParams, }; }