using System.Text.Json.Serialization;
namespace Gateway.Models;
///
/// Configuration for a single advertising channel provider.
/// Populated from database (tbChannelConfig) via ChannelConfigService.
/// Drives Gateway routing, wizard behavior, and validation.
///
public sealed class ProviderConfig
{
/// Channel type key (e.g., "google_ads", "meta", "tiktok").
public string ChannelType { get; set; } = "";
/// Display name for UI.
public string DisplayName { get; set; } = "";
/// Short description shown in channel selection.
public string? Description { get; set; }
/// Whether this channel is currently available for new campaigns.
public bool Enabled { get; set; }
/// Provider service endpoint URL (null = stub/disabled).
public string? Endpoint { get; set; }
/// Internal API key for provider service authentication.
public string? InternalKey { get; set; }
/// Whether this is a stub container (test mode).
public bool IsStub { get; set; }
/// Minimum daily budget in USD for this channel.
public decimal MinDailyBudget { get; set; }
/// Minimum monthly budget in USD for this channel.
public decimal MinMonthlyBudget { get; set; }
/// Supported unified objectives (awareness, traffic, conversions, leads, sales).
public List SupportedObjectives { get; set; } = new();
/// Supported creative formats (text, image, video, carousel, etc.).
public List SupportedCreativeFormats { get; set; } = new();
/// Estimated approval time in hours.
public int ApprovalEstimateHours { get; set; }
/// How often to refresh metrics from this provider (minutes).
public int MetricsRefreshIntervalMinutes { get; set; } = 60;
/// Icon identifier for UI (e.g., "google", "meta", "tiktok").
public string? Icon { get; set; }
/// Brand color hex for UI (e.g., "#4285F4").
public string? Color { get; set; }
/// Auth method used by provider (oauth2, api_key, mcc).
public string? AuthMethod { get; set; }
/// Key Vault secret name for provider credentials.
public string? KeyVaultSecretName { get; set; }
///
/// Maps provider-specific status strings to platform statuses.
/// Keys are raw provider values (case-insensitive), values are platform statuses
/// (draft, staged, pending, active, paused, completed, cancelled, error).
///
public Dictionary StatusMappings { get; set; } = new(StringComparer.OrdinalIgnoreCase);
}
///
/// Global allocation and multi-channel settings.
/// Loaded from appsettings.json "MultiChannel:Allocation" section (simple scalars only).
///
public sealed class AllocationSettings
{
public decimal MinMultiChannelMonthlyBudget { get; set; } = 500.00m;
public int MaxChannelsPerInitiative { get; set; } = 5;
public string DefaultAllocationStrategy { get; set; } = "template";
public int PerformanceEvalIntervalDays { get; set; } = 7;
public int PerformanceLookbackDays { get; set; } = 14;
public int PerformanceLearningPeriodDays { get; set; } = 14;
public decimal MaxAllocationShiftPct { get; set; } = 15.00m;
public decimal MinChannelAllocationPct { get; set; } = 10.00m;
public decimal MaxChannelAllocationPct { get; set; } = 80.00m;
}
///
/// Root multi-channel configuration.
/// Channels are populated from DB via ChannelConfigService at startup.
/// Allocation settings loaded from appsettings.json (simple scalars).
///
public sealed class MultiChannelConfig
{
/// Per-provider configurations, keyed by channel type.
public Dictionary Channels { get; set; } = new();
/// Global allocation settings.
public AllocationSettings Allocation { get; set; } = new();
/// Get only enabled providers.
[JsonIgnore]
public IEnumerable EnabledChannels =>
Channels.Values.Where(c => c.Enabled);
/// Look up a provider config by channel type.
public ProviderConfig? GetChannel(string channelType) =>
Channels.TryGetValue(channelType, out var config) ? config : null;
}