// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as AssetsAPI from './assets'; import { AssetAssociateParams, AssetAssociateResponse, AssetGenerateUploadURLParams, AssetGenerateUploadURLResponse, Assets, } from './assets'; import { APIPromise } from '../../core/api-promise'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class Products extends APIResource { assets: AssetsAPI.Assets = new AssetsAPI.Assets(this._client); /** * Create a new product with complete details including marketing guidelines, * mandatory phrases, and influencer instructions. Products are used in campaigns * to define what influencers will promote. * * @example * ```ts * const product = await client.products.create({ * callToAction: 'Shop Now - Free Shipping', * description: * 'High-quality wireless headphones with noise cancellation, 30-hour battery life, and premium sound quality perfect for music lovers and professionals.', * mandatoryPhrases: [ * 'Premium sound quality', * '30-hour battery life', * 'Noise cancellation technology', * ], * name: 'Premium Wireless Headphones', * url: 'https://store.example.com/products/wireless-headphones', * whatNotToSay: * "Don't compare directly to competitor brands. Avoid making medical claims about hearing protection. Don't mention price comparisons or discounts not currently available.", * whatToSay: * 'Emphasize the superior sound quality, long battery life, and comfortable fit. Mention how these headphones enhance your daily routine whether working from home or commuting.', * }); * ``` */ create(body: ProductCreateParams, options?: RequestOptions): APIPromise { return this._client.post('/products', { body, ...options }); } /** * Retrieve complete details for a specific product including all marketing * guidelines, associated assets, and campaign usage information. * * @example * ```ts * const product = await client.products.retrieve( * '123e4567-e89b-12d3-a456-426614174000', * ); * ``` */ retrieve(id: string, options?: RequestOptions): APIPromise { return this._client.get(path`/products/${id}`, options); } /** * Update product information including marketing guidelines and instructions. All * fields are optional - only provided fields will be updated. Some restrictions * apply for products in active campaigns. * * @example * ```ts * const product = await client.products.update( * '123e4567-e89b-12d3-a456-426614174000', * ); * ``` */ update( id: string, body: ProductUpdateParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.put(path`/products/${id}`, { body, ...options }); } /** * Retrieve a paginated list of products for the authenticated brand. Supports * filtering by search query, category, status, and date range. Results include * product summaries optimized for list views. * * @example * ```ts * const products = await client.products.list(); * ``` */ list( query: ProductListParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { return this._client.get('/products', { query, ...options }); } /** * Delete a product permanently. Products that are currently used in active * campaigns cannot be deleted. This action cannot be undone. * * @example * ```ts * await client.products.delete( * '123e4567-e89b-12d3-a456-426614174000', * ); * ``` */ delete(id: string, options?: RequestOptions): APIPromise { return this._client.delete(path`/products/${id}`, { ...options, headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), }); } } /** * Response schema for creating a new product */ export interface ProductCreateResponse { /** * 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; } /** * Response schema for retrieving a single product's complete details */ export interface ProductRetrieveResponse { /** * 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; } /** * Response schema for updating a product */ export interface ProductUpdateResponse { /** * 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; } /** * Response schema for retrieving a list of products with pagination */ export interface ProductListResponse { /** * Pagination information */ pagination: ProductListResponse.Pagination; /** * List of products */ products: Array; } export namespace ProductListResponse { /** * Pagination information */ export interface Pagination { /** * Number of items per page */ limit: number; /** * Current page number */ page: number; /** * Total number of products */ total: number; /** * Total number of pages */ totalPages: number; } /** * Summarized product information for list views */ export interface Product { /** * Unique identifier for the product */ id: string; /** * Number of assets associated with the product */ assetsCount: number; /** * ISO 8601 timestamp of when the product was created */ createdAt: string; /** * A brief description of the product */ description: string; /** * 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; } } export interface ProductCreateParams { /** * The call-to-action text for the product. Must be between 2 and 100 characters. */ callToAction: string; /** * A detailed description of the product. Must be between 10 and 500 characters. */ description: string; /** * Key phrases that must be included in influencer content. Between 1 and 10 * phrases, each 2-1200 characters. */ mandatoryPhrases: Array; /** * The name of the product. Must be between 2 and 100 characters. */ name: 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. Must be * between 2 and 1200 characters. */ whatNotToSay: string; /** * Guidelines for what influencers should say about the product. Must be between 2 * and 1200 characters. */ whatToSay: string; } export interface ProductUpdateParams { /** * The updated call-to-action text for the product. Must be between 2 and 100 * characters. */ callToAction?: string; /** * The updated description of the product. Must be between 10 and 500 characters. */ description?: string; /** * Updated key phrases that must be included in influencer content. Between 1 and * 10 phrases, each 2-1200 characters. */ mandatoryPhrases?: Array; /** * The updated name of the product. Must be between 2 and 100 characters. */ name?: string; /** * The updated price of the product in the smallest currency unit (e.g., cents). */ price?: number; /** * The updated URL for the product. */ url?: string; /** * Updated guidelines for what influencers should NOT say about the product. Must * be between 2 and 1200 characters. */ whatNotToSay?: string; /** * Updated guidelines for what influencers should say about the product. Must be * between 2 and 1200 characters. */ whatToSay?: string; } export interface ProductListParams { /** * Filter by category */ category?: string; /** * End date for filtering (ISO 8601 format) */ endDate?: string; /** * Number of items per page (default: 10, max: 100) */ limit?: number; /** * Page number (default: 1) */ page?: number; /** * Search query string (1-100 characters) */ q?: string; /** * Start date for filtering (ISO 8601 format) */ startDate?: string; /** * Filter by status */ status?: string; } Products.Assets = Assets; export declare namespace Products { export { type ProductCreateResponse as ProductCreateResponse, type ProductRetrieveResponse as ProductRetrieveResponse, type ProductUpdateResponse as ProductUpdateResponse, type ProductListResponse as ProductListResponse, type ProductCreateParams as ProductCreateParams, type ProductUpdateParams as ProductUpdateParams, type ProductListParams as ProductListParams, }; export { Assets as Assets, type AssetAssociateResponse as AssetAssociateResponse, type AssetGenerateUploadURLResponse as AssetGenerateUploadURLResponse, type AssetAssociateParams as AssetAssociateParams, type AssetGenerateUploadURLParams as AssetGenerateUploadURLParams, }; }