namespace MetaApi.Configuration; /// /// Root configuration for Meta Marketing API integration. /// Bind to the "Meta" section in appsettings.json or environment variables. /// /// Meta uses System User tokens for server-to-server auth (no interactive OAuth flow). /// These tokens don't expire if the System User remains active in Business Manager. /// public sealed class MetaConfig { public const string SectionName = "Meta"; /// /// Enable/disable real API calls. When false, the provider returns emulated responses. /// Override via: Meta__EnableRealApi=true /// public bool EnableRealApi { get; set; } = false; /// /// Graph API version (e.g. "v21.0"). /// Meta requires explicit versioning in all API URLs. /// public string ApiVersion { get; set; } = "v21.0"; /// /// Meta App ID from the Developer Portal. /// public string AppId { get; set; } = string.Empty; /// /// Meta App Secret from the Developer Portal. /// Store in Key Vault; inject via environment variable in prod. /// public string AppSecret { get; set; } = string.Empty; /// /// System User Access Token for server-to-server API calls. /// Generated in Business Manager → System Users → Generate Token. /// Unlike OAuth tokens, these don't expire unless revoked. /// Store in Key Vault; inject via environment variable in prod. /// public string SystemUserToken { get; set; } = string.Empty; /// /// USIM's Business Manager ID. /// All client ad accounts are created under this BM. /// Format: numeric string (e.g. "123456789012345") /// public string BusinessManagerId { get; set; } = string.Empty; /// /// Default ad account ID for testing/sandbox. /// Format: act_XXXXXXXXXXXXXXX (with "act_" prefix) /// public string? DefaultAdAccountId { get; set; } /// /// Request timeout in seconds for Graph API calls. /// public int TimeoutSeconds { get; set; } = 60; /// /// Graph API base URL. Override for sandbox/testing if needed. /// public string GraphApiBaseUrl { get; set; } = "https://graph.facebook.com"; } /// /// Per-request Meta API context, populated from request and/or database. /// public sealed class MetaApiContext { /// /// Target Meta ad account ID for this request. /// Format: act_XXXXXXXXXXXXXXX (with "act_" prefix) /// public string AdAccountId { get; set; } = string.Empty; /// /// Business Manager ID that owns this ad account. /// public string? BusinessManagerId { get; set; } /// /// Optional override access token for a specific account. /// If null, the platform System User token from config is used. /// public string? AccessToken { get; set; } }