1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-23 04:21:05 -05:00
bitwarden/src/Core/Models/Business/SmSeatSubscriptionUpdate.cs
cyprain-okeke d7c544a116
[AC 1536] Breakdown The SubscriptionUpdate.cs into multiple files (#3356)
* Move sub-subscription classes to a separate files

* Refactor the sub-class to a separate files

* format whitespace

* remove directive that is unnecessary

* Remove the baseSeat class
2023-10-23 11:28:13 +01:00

51 lines
1.6 KiB
C#

using Bit.Core.Entities;
using Stripe;
namespace Bit.Core.Models.Business;
public class SmSeatSubscriptionUpdate : SubscriptionUpdate
{
private readonly int _previousSeats;
private readonly StaticStore.Plan _plan;
private readonly long? _additionalSeats;
protected override List<string> PlanIds => new() { _plan.SecretsManager.StripeSeatPlanId };
public SmSeatSubscriptionUpdate(Organization organization, StaticStore.Plan plan, long? additionalSeats)
{
_plan = plan;
_additionalSeats = additionalSeats;
_previousSeats = organization.SmSeats.GetValueOrDefault();
}
public override List<SubscriptionItemOptions> UpgradeItemsOptions(Subscription subscription)
{
var item = SubscriptionItem(subscription, PlanIds.Single());
return new()
{
new SubscriptionItemOptions
{
Id = item?.Id,
Plan = PlanIds.Single(),
Quantity = _additionalSeats,
Deleted = (item?.Id != null && _additionalSeats == 0) ? true : (bool?)null,
}
};
}
public override List<SubscriptionItemOptions> RevertItemsOptions(Subscription subscription)
{
var item = SubscriptionItem(subscription, PlanIds.Single());
return new()
{
new SubscriptionItemOptions
{
Id = item?.Id,
Plan = PlanIds.Single(),
Quantity = _previousSeats,
Deleted = _previousSeats == 0 ? true : (bool?)null,
}
};
}
}