Initial import into Gitea
This commit is contained in:
109
Gateway/Models/MultiChannelConfig.cs
Normal file
109
Gateway/Models/MultiChannelConfig.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Gateway.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for a single advertising channel provider.
|
||||
/// Populated from database (tbChannelConfig) via ChannelConfigService.
|
||||
/// Drives Gateway routing, wizard behavior, and validation.
|
||||
/// </summary>
|
||||
public sealed class ProviderConfig
|
||||
{
|
||||
/// <summary>Channel type key (e.g., "google_ads", "meta", "tiktok").</summary>
|
||||
public string ChannelType { get; set; } = "";
|
||||
|
||||
/// <summary>Display name for UI.</summary>
|
||||
public string DisplayName { get; set; } = "";
|
||||
|
||||
/// <summary>Short description shown in channel selection.</summary>
|
||||
public string? Description { get; set; }
|
||||
|
||||
/// <summary>Whether this channel is currently available for new campaigns.</summary>
|
||||
public bool Enabled { get; set; }
|
||||
|
||||
/// <summary>Provider service endpoint URL (null = stub/disabled).</summary>
|
||||
public string? Endpoint { get; set; }
|
||||
|
||||
/// <summary>Internal API key for provider service authentication.</summary>
|
||||
public string? InternalKey { get; set; }
|
||||
|
||||
/// <summary>Whether this is a stub container (test mode).</summary>
|
||||
public bool IsStub { get; set; }
|
||||
|
||||
/// <summary>Minimum daily budget in USD for this channel.</summary>
|
||||
public decimal MinDailyBudget { get; set; }
|
||||
|
||||
/// <summary>Minimum monthly budget in USD for this channel.</summary>
|
||||
public decimal MinMonthlyBudget { get; set; }
|
||||
|
||||
/// <summary>Supported unified objectives (awareness, traffic, conversions, leads, sales).</summary>
|
||||
public List<string> SupportedObjectives { get; set; } = new();
|
||||
|
||||
/// <summary>Supported creative formats (text, image, video, carousel, etc.).</summary>
|
||||
public List<string> SupportedCreativeFormats { get; set; } = new();
|
||||
|
||||
/// <summary>Estimated approval time in hours.</summary>
|
||||
public int ApprovalEstimateHours { get; set; }
|
||||
|
||||
/// <summary>How often to refresh metrics from this provider (minutes).</summary>
|
||||
public int MetricsRefreshIntervalMinutes { get; set; } = 60;
|
||||
|
||||
/// <summary>Icon identifier for UI (e.g., "google", "meta", "tiktok").</summary>
|
||||
public string? Icon { get; set; }
|
||||
|
||||
/// <summary>Brand color hex for UI (e.g., "#4285F4").</summary>
|
||||
public string? Color { get; set; }
|
||||
|
||||
/// <summary>Auth method used by provider (oauth2, api_key, mcc).</summary>
|
||||
public string? AuthMethod { get; set; }
|
||||
|
||||
/// <summary>Key Vault secret name for provider credentials.</summary>
|
||||
public string? KeyVaultSecretName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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).
|
||||
/// </summary>
|
||||
public Dictionary<string, string> StatusMappings { get; set; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Global allocation and multi-channel settings.
|
||||
/// Loaded from appsettings.json "MultiChannel:Allocation" section (simple scalars only).
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Root multi-channel configuration.
|
||||
/// Channels are populated from DB via ChannelConfigService at startup.
|
||||
/// Allocation settings loaded from appsettings.json (simple scalars).
|
||||
/// </summary>
|
||||
public sealed class MultiChannelConfig
|
||||
{
|
||||
/// <summary>Per-provider configurations, keyed by channel type.</summary>
|
||||
public Dictionary<string, ProviderConfig> Channels { get; set; } = new();
|
||||
|
||||
/// <summary>Global allocation settings.</summary>
|
||||
public AllocationSettings Allocation { get; set; } = new();
|
||||
|
||||
/// <summary>Get only enabled providers.</summary>
|
||||
[JsonIgnore]
|
||||
public IEnumerable<ProviderConfig> EnabledChannels =>
|
||||
Channels.Values.Where(c => c.Enabled);
|
||||
|
||||
/// <summary>Look up a provider config by channel type.</summary>
|
||||
public ProviderConfig? GetChannel(string channelType) =>
|
||||
Channels.TryGetValue(channelType, out var config) ? config : null;
|
||||
}
|
||||
Reference in New Issue
Block a user