// ========================================================================== // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex UG (haftungsbeschraenkt) // All rights reserved. Licensed under the MIT license. // ========================================================================== using Squidex.Domain.Apps.Entities.Apps; using Squidex.Domain.Apps.Entities.Apps.Plans; using Squidex.Infrastructure.Validation; namespace Squidex.Areas.Api.Controllers.Plans.Models { public sealed class AppPlansDto { /// /// The available plans. /// [LocalizedRequired] public PlanDto[] Plans { get; set; } /// /// The current plan id. /// public string? CurrentPlanId { get; set; } /// /// The plan owner. /// public string? PlanOwner { get; set; } /// /// Indicates if there is a billing portal. /// public bool HasPortal { get; set; } public static AppPlansDto FromDomain(IAppEntity app, IAppPlansProvider plans, bool hasPortal) { var (_, planId) = plans.GetPlanForApp(app); var result = new AppPlansDto { CurrentPlanId = planId, Plans = plans.GetAvailablePlans().Select(PlanDto.FromDomain).ToArray(), PlanOwner = app.Plan?.Owner.Identifier, HasPortal = hasPortal }; return result; } } }