mirror of
https://github.com/bitwarden/server.git
synced 2025-07-04 09:32:48 -05:00
[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
This commit is contained in:
49
src/Core/Models/Business/SeatSubscriptionUpdate.cs
Normal file
49
src/Core/Models/Business/SeatSubscriptionUpdate.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using Bit.Core.Entities;
|
||||
using Stripe;
|
||||
|
||||
namespace Bit.Core.Models.Business;
|
||||
|
||||
public class SeatSubscriptionUpdate : SubscriptionUpdate
|
||||
{
|
||||
private readonly int _previousSeats;
|
||||
private readonly StaticStore.Plan _plan;
|
||||
private readonly long? _additionalSeats;
|
||||
protected override List<string> PlanIds => new() { _plan.PasswordManager.StripeSeatPlanId };
|
||||
public SeatSubscriptionUpdate(Organization organization, StaticStore.Plan plan, long? additionalSeats)
|
||||
{
|
||||
_plan = plan;
|
||||
_additionalSeats = additionalSeats;
|
||||
_previousSeats = organization.Seats.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,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user