namespace TikTokApi.Configuration; /// /// Root configuration for TikTok Marketing API integration. /// Bind to the "TikTok" section in appsettings.json or environment variables. /// /// TikTok auth model: /// - Register as developer → create app → OAuth authorize → get access_token /// - Access tokens do NOT expire unless the advertiser revokes authorization /// - Token is passed via "Access-Token" HTTP header (not query param like Meta) /// /// Agency model: /// - Business Center (BC) is the parent entity (equivalent to Google MCC / Meta BM) /// - BC owns advertiser accounts (ad accounts) created for clients /// - BC API: /bc/advertiser/create, /bc/asset/get, /bc/transfer (fund management) /// public sealed class TikTokConfig { public const string SectionName = "TikTok"; /// /// Enable/disable real API calls. When false, the provider returns emulated responses. /// Override via: TikTok__EnableRealApi=true /// public bool EnableRealApi { get; set; } = false; /// /// TikTok Marketing API version (e.g. "v1.3"). /// Used in URL path: /open_api/v1.3/... /// public string ApiVersion { get; set; } = "v1.3"; /// /// TikTok App ID from the Developer Portal (My Apps). /// public string AppId { get; set; } = string.Empty; /// /// TikTok App Secret from the Developer Portal. /// Store in Key Vault; inject via environment variable in prod. /// public string AppSecret { get; set; } = string.Empty; /// /// Long-lived access token obtained via OAuth authorization flow. /// Does NOT expire unless the advertiser revokes authorization. /// Passed in "Access-Token" header on all API calls. /// Store in Key Vault; inject via environment variable in prod. /// public string AccessToken { get; set; } = string.Empty; /// /// USIM's Business Center ID. /// All client advertiser accounts are created under this BC. /// Format: numeric string (e.g. "7123456789012345678") /// public string BusinessCenterId { get; set; } = string.Empty; /// /// Default advertiser ID for testing/sandbox. /// Format: numeric string (e.g. "7123456789012345678") /// public string? DefaultAdvertiserId { get; set; } /// /// Request timeout in seconds for API calls. /// public int TimeoutSeconds { get; set; } = 60; /// /// TikTok Marketing API base URL. /// Production: https://business-api.tiktok.com /// Sandbox: https://sandbox-ads.tiktok.com /// public string ApiBaseUrl { get; set; } = "https://business-api.tiktok.com"; } /// /// Per-request TikTok API context extracted from ProviderRequest. /// public sealed class TikTokApiContext { /// /// TikTok advertiser (ad account) ID. /// Derived from ProviderRequest.TenantId (accExternalAccountId). /// Format: numeric string. /// public string AdvertiserId { get; set; } = string.Empty; /// /// Business Center ID that owns/manages the advertiser account. /// Falls back to TikTokConfig.BusinessCenterId if not in request. /// public string? BusinessCenterId { get; set; } }