1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

Plan And Price Updates (#859)

* Expanded the Plan model to make plan & product data a bit more dynamic 
* Created a Product enum to track versioned instances of the same plan
* Created and API call and Response model for getting plan & product data from the server
This commit is contained in:
Addison Beck
2020-08-11 14:19:56 -04:00
committed by GitHub
parent 61b11e398b
commit c8220fdfa6
10 changed files with 541 additions and 153 deletions

View File

@ -1,8 +1,9 @@
using System;
using System.Linq;
using Bit.Core.Models.Table;
using System.Collections.Generic;
using Bit.Core.Models.Business;
using Bit.Core.Models.StaticStore;
using System.Linq;
using Bit.Core.Enums;
namespace Bit.Core.Models.Api
{
@ -25,7 +26,7 @@ namespace Bit.Core.Models.Api
BusinessCountry = organization.BusinessCountry;
BusinessTaxNumber = organization.BusinessTaxNumber;
BillingEmail = organization.BillingEmail;
Plan = organization.Plan;
Plan = new PlanResponseModel(Utilities.StaticStore.Plans.FirstOrDefault(plan => plan.Type == organization.PlanType));
PlanType = organization.PlanType;
Seats = organization.Seats;
MaxCollections = organization.MaxCollections;
@ -51,8 +52,8 @@ namespace Bit.Core.Models.Api
public string BusinessCountry { get; set; }
public string BusinessTaxNumber { get; set; }
public string BillingEmail { get; set; }
public string Plan { get; set; }
public Enums.PlanType PlanType { get; set; }
public PlanResponseModel Plan { get; set; }
public PlanType PlanType { get; set; }
public short? Seats { get; set; }
public short? MaxCollections { get; set; }
public short? MaxStorageGb { get; set; }

View File

@ -0,0 +1,100 @@
using System;
using Bit.Core.Enums;
using Bit.Core.Models.StaticStore;
namespace Bit.Core.Models.Api
{
public class PlanResponseModel : ResponseModel
{
public PlanResponseModel(Plan plan, string obj = "plan")
: base(obj)
{
if (plan == null)
{
throw new ArgumentNullException(nameof(plan));
}
Type = plan.Type;
Product = plan.Product;
Name = plan.Name;
IsAnnual = plan.IsAnnual;
NameLocalizationKey = plan.NameLocalizationKey;
DescriptionLocalizationKey = plan.DescriptionLocalizationKey;
CanBeUsedByBusiness = plan.CanBeUsedByBusiness;
BaseSeats = plan.BaseSeats;
BaseStorageGb = plan.BaseStorageGb;
MaxCollections = plan.MaxCollections;
MaxUsers = plan.MaxUsers;
HasAdditionalSeatsOption = plan.HasAdditionalSeatsOption;
HasAdditionalStorageOption = plan.HasAdditionalStorageOption;
MaxAdditionalSeats = plan.MaxAdditionalSeats;
MaxAdditionalStorage = plan.MaxAdditionalStorage;
HasPremiumAccessOption = plan.HasPremiumAccessOption;
TrialPeriodDays = plan.TrialPeriodDays;
HasSelfHost = plan.HasSelfHost;
HasPolicies = plan.HasPolicies;
HasGroups = plan.HasGroups;
HasDirectory = plan.HasDirectory;
HasEvents = plan.HasEvents;
HasTotp = plan.HasTotp;
Has2fa = plan.Has2fa;
HasSso = plan.HasSso;
UsersGetPremium = plan.UsersGetPremium;
UpgradeSortOrder = plan.UpgradeSortOrder;
DisplaySortOrder = plan.DisplaySortOrder;
LegacyYear = plan.LegacyYear;
Disabled = plan.Disabled;
StripePlanId = plan.StripePlanId;
StripeSeatPlanId = plan.StripeSeatPlanId;
StripeStoragePlanId = plan.StripeStoragePlanId;
BasePrice = plan.BasePrice;
SeatPrice = plan.SeatPrice;
AdditionalStoragePricePerGb = plan.AdditionalStoragePricePerGb;
PremiumAccessOptionPrice = plan.PremiumAccessOptionPrice;
}
public PlanType Type { get; set; }
public ProductType Product { get; set; }
public string Name { get; set; }
public bool IsAnnual { get; set; }
public string NameLocalizationKey { get; set; }
public string DescriptionLocalizationKey { get; set; }
public bool CanBeUsedByBusiness { get; set; }
public int BaseSeats { get; set; }
public short? BaseStorageGb { get; set; }
public short? MaxCollections { get; set; }
public short? MaxUsers { get; set; }
public bool HasAdditionalSeatsOption { get; set; }
public short? MaxAdditionalSeats { get; set; }
public bool HasAdditionalStorageOption { get; set; }
public short? MaxAdditionalStorage { get; set; }
public bool HasPremiumAccessOption { get; set; }
public int? TrialPeriodDays { get; set; }
public bool HasSelfHost { get; set; }
public bool HasPolicies { get; set; }
public bool HasGroups { get; set; }
public bool HasDirectory { get; set; }
public bool HasEvents { get; set; }
public bool HasTotp { get; set; }
public bool Has2fa { get; set; }
public bool HasApi { get; set; }
public bool HasSso { get; set; }
public bool UsersGetPremium { get; set; }
public int UpgradeSortOrder { get; set; }
public int DisplaySortOrder { get; set; }
public int? LegacyYear { get; set; }
public bool Disabled { get; set; }
public string StripePlanId { get; set; }
public string StripeSeatPlanId { get; set; }
public string StripeStoragePlanId { get; set; }
public string StripePremiumAccessPlanId { get; set; }
public decimal BasePrice { get; set; }
public decimal SeatPrice { get; set; }
public decimal AdditionalStoragePricePerGb { get; set; }
public decimal PremiumAccessOptionPrice { get; set; }
}
}

View File

@ -235,7 +235,7 @@ namespace Bit.Core.Models.Business
{
valid = organization.UsePolicies == UsePolicies;
}
if (valid && Version >= 7)
{
valid = organization.UseSso == UseSso;

View File

@ -4,32 +4,48 @@ namespace Bit.Core.Models.StaticStore
{
public class Plan
{
public PlanType Type { get; set; }
public ProductType Product { get; set; }
public string Name { get; set; }
public bool IsAnnual { get; set; }
public string NameLocalizationKey { get; set; }
public string DescriptionLocalizationKey { get; set; }
public bool CanBeUsedByBusiness { get; set; }
public int BaseSeats { get; set; }
public short? BaseStorageGb { get; set; }
public short? MaxCollections { get; set; }
public short? MaxUsers { get; set; }
public bool HasAdditionalSeatsOption { get; set; }
public short? MaxAdditionalSeats { get; set; }
public bool HasAdditionalStorageOption { get; set; }
public short? MaxAdditionalStorage { get; set; }
public bool HasPremiumAccessOption { get; set; }
public int? TrialPeriodDays { get; set; }
public bool HasSelfHost { get; set; }
public bool HasPolicies { get; set; }
public bool HasGroups { get; set; }
public bool HasDirectory { get; set; }
public bool HasEvents { get; set; }
public bool HasTotp { get; set; }
public bool Has2fa { get; set; }
public bool HasApi { get; set; }
public bool HasSso { get; set; }
public bool UsersGetPremium { get; set; }
public int UpgradeSortOrder { get; set; }
public int DisplaySortOrder { get; set; }
public int? LegacyYear { get; set; }
public bool Disabled { get; set; }
public string StripePlanId { get; set; }
public string StripeSeatPlanId { get; set; }
public string StripeStoragePlanId { get; set; }
public string StripePremiumAccessPlanId { get; set; }
public PlanType Type { get; set; }
public short BaseSeats { get; set; }
public bool CanBuyAdditionalSeats { get; set; }
public short? MaxAdditionalSeats { get; set; }
public bool CanBuyPremiumAccessAddon { get; set; }
public bool UseGroups { get; set; }
public bool UsePolicies { get; set; }
public bool UseSso { get; set; }
public bool UseDirectory { get; set; }
public bool UseEvents { get; set; }
public bool UseTotp { get; set; }
public bool Use2fa { get; set; }
public bool UseApi { get; set; }
public short? MaxStorageGb { get; set; }
public decimal BasePrice { get; set; }
public decimal SeatPrice { get; set; }
public short? MaxCollections { get; set; }
public int UpgradeSortOrder { get; set; }
public bool Disabled { get; set; }
public int? TrialPeriodDays { get; set; }
public bool SelfHost { get; set; }
public bool UsersGetPremium { get; set; }
public decimal AdditionalStoragePricePerGb { get; set; }
public decimal PremiumAccessOptionPrice { get; set; }
}
}