mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
APIs for premium. Billing helpers.
This commit is contained in:
@ -7,7 +7,7 @@ using System.Linq;
|
||||
|
||||
namespace Bit.Core.Models.Table
|
||||
{
|
||||
public class User : IDataObject<Guid>
|
||||
public class User : IDataObject<Guid>, ISubscriber, IStorable, IStorableSubscriber, IRevisable
|
||||
{
|
||||
private Dictionary<TwoFactorProviderType, TwoFactorProvider> _twoFactorProviders;
|
||||
|
||||
@ -30,6 +30,8 @@ namespace Bit.Core.Models.Table
|
||||
public bool Premium { get; set; }
|
||||
public long? Storage { get; set; }
|
||||
public short? MaxStorageGb { get; set; }
|
||||
public string StripeCustomerId { get; set; }
|
||||
public string StripeSubscriptionId { get; set; }
|
||||
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
|
||||
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
|
||||
|
||||
@ -38,6 +40,16 @@ namespace Bit.Core.Models.Table
|
||||
Id = CoreHelpers.GenerateComb();
|
||||
}
|
||||
|
||||
public string BillingEmailAddress()
|
||||
{
|
||||
return Email;
|
||||
}
|
||||
|
||||
public string BillingName()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
|
||||
public Dictionary<TwoFactorProviderType, TwoFactorProvider> GetTwoFactorProviders()
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(TwoFactorProviders))
|
||||
@ -110,7 +122,12 @@ namespace Bit.Core.Models.Table
|
||||
return 0;
|
||||
}
|
||||
|
||||
var maxStorageBytes = MaxStorageGb.Value * 1073741824L;
|
||||
return StorageBytesRemaining(MaxStorageGb.Value);
|
||||
}
|
||||
|
||||
public long StorageBytesRemaining(short maxStorageGb)
|
||||
{
|
||||
var maxStorageBytes = maxStorageGb * 1073741824L;
|
||||
if(!Storage.HasValue)
|
||||
{
|
||||
return maxStorageBytes;
|
||||
|
Reference in New Issue
Block a user