Headless CMS and Content Managment Hub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

52 lines
1.6 KiB

// ==========================================================================
// 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
{
/// <summary>
/// The available plans.
/// </summary>
[LocalizedRequired]
public PlanDto[] Plans { get; set; }
/// <summary>
/// The current plan id.
/// </summary>
public string? CurrentPlanId { get; set; }
/// <summary>
/// The plan owner.
/// </summary>
public string? PlanOwner { get; set; }
/// <summary>
/// Indicates if there is a billing portal.
/// </summary>
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;
}
}
}