// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as BonusesAPI from './bonuses'; import { BonusCancelParams, BonusCancelResponse, BonusListResponse, BonusRetrieveStatsResponse, Bonuses, } from './bonuses'; import * as DeliverablesAPI from './deliverables'; import { DeliverableApproveParams, DeliverableApproveResponse, DeliverableListResponse, DeliverableRejectParams, DeliverableRejectResponse, Deliverables, } from './deliverables'; import * as MetricsAPI from './metrics'; import { MetricBulkParams, MetricBulkResponse, MetricListResponse, MetricSyncResponse, Metrics, } from './metrics'; import * as TakeRateAPI from './take-rate'; import { TakeRate, TakeRateRetrieveRevenueResponse } from './take-rate'; import * as LeadsAPI from './leads/leads'; import { LeadApproveAllResponse, LeadDeleteLeadResponse, LeadListResponse, LeadRetrieveBonusesParams, LeadRetrieveBonusesResponse, Leads, } from './leads/leads'; import { APIPromise } from '../../../core/api-promise'; import { RequestOptions } from '../../../internal/request-options'; import { path } from '../../../internal/utils/path'; export class Campaigns extends APIResource { leads: LeadsAPI.Leads = new LeadsAPI.Leads(this._client); deliverables: DeliverablesAPI.Deliverables = new DeliverablesAPI.Deliverables(this._client); takeRate: TakeRateAPI.TakeRate = new TakeRateAPI.TakeRate(this._client); metrics: MetricsAPI.Metrics = new MetricsAPI.Metrics(this._client); bonuses: BonusesAPI.Bonuses = new BonusesAPI.Bonuses(this._client); /** * Retrieve complete details for a specific campaign including all configuration, * metrics, lead counts, deliverable statistics, and performance data. * * @example * ```ts * const campaign = await client.admin.campaigns.retrieve( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * ); * ``` */ retrieve(id: string, options?: RequestOptions): APIPromise { return this._client.get(path`/admin/campaigns/${id}`, options); } /** * Retrieve a paginated list of all campaigns in the platform. Supports filtering * by search query, status, brand, and various sorting options. Includes campaign * statistics and metrics for admin overview. * * @example * ```ts * const campaigns = await client.admin.campaigns.list(); * ``` */ list( query: CampaignListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get('/admin/campaigns', { query, ...options }); } /** * Manually approve a campaign and change its status to active. This allows the * campaign to start accepting influencer applications and begin the marketing * process. Only campaigns in draft or pending status can be approved. * * @example * ```ts * const response = await client.admin.campaigns.approve( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * ); * ``` */ approve(id: string, options?: RequestOptions): APIPromise { return this._client.post(path`/admin/campaigns/${id}/approve`, options); } /** * Force complete a campaign regardless of its current state (except cancelled). * This immediately changes the campaign status to completed and stops all ongoing * activities. * * @example * ```ts * const response = await client.admin.campaigns.forceComplete( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * ); * ``` */ forceComplete(id: string, options?: RequestOptions): APIPromise { return this._client.post(path`/admin/campaigns/${id}/force-complete`, options); } /** * Retrieve all products associated with a specific campaign. Includes complete * product information such as descriptions, pricing, images, marketing guidelines, * mandatory phrases, and delivery instructions. * * @example * ```ts * const response = * await client.admin.campaigns.retrieveProducts( * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e', * ); * ``` */ retrieveProducts(id: string, options?: RequestOptions): APIPromise { return this._client.get(path`/admin/campaigns/${id}/products`, options); } } export interface CampaignRetrieveResponse { /** * Campaign details */ data: CampaignRetrieveResponse.Data; /** * When the response was generated */ generatedAt: string; /** * Whether the request was successful */ success: boolean; } export namespace CampaignRetrieveResponse { /** * Campaign details */ export interface Data { /** * Unique identifier for the campaign */ id: string; /** * Additional requirements for influencers */ additionalRequests: string; /** * Whether deliverables are automatically approved */ autoApproveDeliverables: boolean; /** * Unique identifier of the brand that owns the campaign */ brandId: string; /** * Campaign budget configuration */ budget: Data.Budget; /** * ISO 8601 timestamp of when the campaign was created */ createdAt: string; /** * Unique identifier of the user who created the campaign */ createdBy: string; /** * Campaign deadline (ISO 8601 format) */ deadline: string | null; /** * Campaign description */ description: string | null; /** * Campaign goal */ goal: string; /** * Growth period for selecting an influencer */ growthPeriod: 'day' | 'week' | 'month' | 'year'; /** * URLs of similar content or competitors for reference */ lookALikeUrls: Array; /** * Campaign name */ name: string; /** * Products associated with the campaign */ productIds: Array; /** * Reference URLs for inspiration */ referenceUrls: Array; /** * Current campaign status */ status: string; /** * Campaign targeting configuration with enhanced targeting options */ targeting: Data.Targeting; /** * Campaign type */ type: string; /** * ISO 8601 timestamp of when the campaign was last updated */ updatedAt: string; /** * Average views per post range [from, to] */ avgViews?: Array; /** * Average engagement rate per post */ engagementRate?: number; /** * Follower count range for influencer targeting [from, to] */ followerSegmentation?: Array; /** * Average growth rate per post */ growthRate?: number; } export namespace Data { /** * Campaign budget configuration */ export interface Budget { /** * Budget amount in smallest currency unit (e.g., cents) */ amount: number; /** * Budget type: monthly or lifetime */ type: string; /** * Whether the budget renews automatically (monthly budgets only) */ renewAutomatically?: boolean; } /** * Campaign targeting configuration with enhanced targeting options */ export interface Targeting { /** * Target age range [min, max] */ ageRange: Array; /** * Target countries (ISO 3166-1 alpha-2 codes) */ country: Array; /** * Target gender demographics */ gender: Array; /** * Target interests for audience */ interests: Array; /** * Target keywords for content creation */ keywords: Array; /** * Target languages (ISO 639-1 codes) */ languages: Array; /** * Target social media platforms */ platform: Array; } } } export interface CampaignListResponse { data: CampaignListResponse.Data; /** * When the response was generated */ generatedAt: string; /** * Whether the request was successful */ success: boolean; } export namespace CampaignListResponse { export interface Data { /** * Array of campaigns */ campaigns: Array; /** * Pagination information */ pagination: Data.Pagination; } export namespace Data { /** * Complete campaign information including targeting, products, and status */ export interface Campaign { /** * Unique identifier for the campaign */ id: string; /** * Additional requirements for influencers */ additionalRequests: string; /** * Whether deliverables are automatically approved */ autoApproveDeliverables: boolean; /** * Unique identifier of the brand that owns the campaign */ brandId: string; /** * Campaign budget configuration */ budget: Campaign.Budget; /** * ISO 8601 timestamp of when the campaign was created */ createdAt: string; /** * Unique identifier of the user who created the campaign */ createdBy: string; /** * Campaign deadline (ISO 8601 format) */ deadline: string | null; /** * Campaign description */ description: string | null; /** * Campaign goal */ goal: string; /** * Growth period for selecting an influencer */ growthPeriod: 'day' | 'week' | 'month' | 'year'; /** * URLs of similar content or competitors for reference */ lookALikeUrls: Array; /** * Campaign name */ name: string; /** * Products associated with the campaign */ productIds: Array; /** * Reference URLs for inspiration */ referenceUrls: Array; /** * Current campaign status */ status: string; /** * Campaign targeting configuration with enhanced targeting options */ targeting: Campaign.Targeting; /** * Campaign type */ type: string; /** * ISO 8601 timestamp of when the campaign was last updated */ updatedAt: string; /** * Average views per post range [from, to] */ avgViews?: Array; /** * Average engagement rate per post */ engagementRate?: number; /** * Follower count range for influencer targeting [from, to] */ followerSegmentation?: Array; /** * Average growth rate per post */ growthRate?: number; } export namespace Campaign { /** * Campaign budget configuration */ export interface Budget { /** * Budget amount in smallest currency unit (e.g., cents) */ amount: number; /** * Budget type: monthly or lifetime */ type: string; /** * Whether the budget renews automatically (monthly budgets only) */ renewAutomatically?: boolean; } /** * Campaign targeting configuration with enhanced targeting options */ export interface Targeting { /** * Target age range [min, max] */ ageRange: Array; /** * Target countries (ISO 3166-1 alpha-2 codes) */ country: Array; /** * Target gender demographics */ gender: Array; /** * Target interests for audience */ interests: Array; /** * Target keywords for content creation */ keywords: Array; /** * Target languages (ISO 639-1 codes) */ languages: Array; /** * Target social media platforms */ platform: Array; } } /** * 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 CampaignApproveResponse { data: CampaignApproveResponse.Data; /** * Whether the campaign approval was successful */ success: boolean; } export namespace CampaignApproveResponse { export interface Data { /** * When the campaign was approved */ approvedAt: string; /** * Admin user who approved the campaign */ approvedBy: string; /** * Campaign identifier */ campaignId: string; /** * Campaign name */ campaignName: string; /** * Approval message */ message: string; /** * New campaign status */ newStatus: string; /** * Previous campaign status */ previousStatus: string; } } export interface CampaignForceCompleteResponse { data: CampaignForceCompleteResponse.Data; /** * Whether the force completion was successful */ success: boolean; } export namespace CampaignForceCompleteResponse { export interface Data { /** * Campaign identifier */ campaignId: string; /** * Campaign name */ campaignName: string; /** * When the campaign was force completed */ completedAt: string; /** * Admin user who completed the campaign */ completedBy: string; /** * Completion message */ message: string; /** * New campaign status */ newStatus: string; /** * Previous campaign status */ previousStatus: string; } } export interface CampaignRetrieveProductsResponse { data: CampaignRetrieveProductsResponse.Data; /** * Whether the request was successful */ success: boolean; } export namespace CampaignRetrieveProductsResponse { export interface Data { /** * Campaign identifier */ campaignId: string; /** * Campaign name */ campaignName: string; /** * Array of campaign products */ products: Array; /** * Total number of products */ totalProducts: number; } export namespace Data { /** * Response schema for retrieving a single product's complete details */ export interface Product { /** * Unique identifier for the product */ id: string; /** * List of assets associated with the product */ assets: Array; /** * Unique identifier of the brand that owns the product */ brandId: string; /** * The call-to-action text for the product */ callToAction: string; /** * ISO 8601 timestamp of when the product was created */ createdAt: string; /** * A detailed description of the product */ description: string; /** * Key phrases that must be included in influencer content */ mandatoryPhrases: Array; /** * The name of the product */ name: string; /** * ISO 8601 timestamp of when the product was last updated */ updatedAt: string; /** * The URL where customers can purchase or learn more about the product */ url: string; /** * Guidelines for what influencers should NOT say about the product */ whatNotToSay: string; /** * Guidelines for what influencers should say about the product */ whatToSay: string; } } } export interface CampaignListParams { /** * Filter by brand ID */ brandId?: string; /** * Number of campaigns per page */ limit?: string; /** * Page number for pagination */ page?: string; /** * Search campaigns by name or description */ search?: string; /** * Sort campaigns by field */ sortBy?: 'name' | 'createdAt' | 'budget' | 'updatedAt' | 'startDate'; /** * Sort order */ sortOrder?: 'asc' | 'desc'; /** * Filter by campaign status */ status?: 'draft' | 'active' | 'paused' | 'completed' | 'cancelled'; } Campaigns.Leads = Leads; Campaigns.Deliverables = Deliverables; Campaigns.TakeRate = TakeRate; Campaigns.Metrics = Metrics; Campaigns.Bonuses = Bonuses; export declare namespace Campaigns { export { type CampaignRetrieveResponse as CampaignRetrieveResponse, type CampaignListResponse as CampaignListResponse, type CampaignApproveResponse as CampaignApproveResponse, type CampaignForceCompleteResponse as CampaignForceCompleteResponse, type CampaignRetrieveProductsResponse as CampaignRetrieveProductsResponse, type CampaignListParams as CampaignListParams, }; export { Leads as Leads, type LeadListResponse as LeadListResponse, type LeadApproveAllResponse as LeadApproveAllResponse, type LeadDeleteLeadResponse as LeadDeleteLeadResponse, type LeadRetrieveBonusesResponse as LeadRetrieveBonusesResponse, type LeadRetrieveBonusesParams as LeadRetrieveBonusesParams, }; export { Deliverables as Deliverables, type DeliverableListResponse as DeliverableListResponse, type DeliverableApproveResponse as DeliverableApproveResponse, type DeliverableRejectResponse as DeliverableRejectResponse, type DeliverableApproveParams as DeliverableApproveParams, type DeliverableRejectParams as DeliverableRejectParams, }; export { TakeRate as TakeRate, type TakeRateRetrieveRevenueResponse as TakeRateRetrieveRevenueResponse }; export { Metrics as Metrics, type MetricListResponse as MetricListResponse, type MetricBulkResponse as MetricBulkResponse, type MetricSyncResponse as MetricSyncResponse, type MetricBulkParams as MetricBulkParams, }; export { Bonuses as Bonuses, type BonusListResponse as BonusListResponse, type BonusCancelResponse as BonusCancelResponse, type BonusRetrieveStatsResponse as BonusRetrieveStatsResponse, type BonusCancelParams as BonusCancelParams, }; }