#nullable enable using System.Text.Json.Serialization; using Bit.Core.Context; using Bit.Core.Enums; using Bit.Core.Tools.Entities; using Bit.Core.Tools.Enums; namespace Bit.Core.Tools.Models.Business; /// /// Product support monitoring. /// /// /// Do not store secrets in this type. /// public class ReferenceEvent { /// /// Instantiates a . /// public ReferenceEvent() { } /// /// Monitored event type. /// Entity that created the event. /// The conditions in which the event occurred. public ReferenceEvent(ReferenceEventType type, IReferenceable source, ICurrentContext currentContext) { Type = type; if (source != null) { Source = source.IsUser() ? ReferenceEventSource.User : ReferenceEventSource.Organization; Id = source.Id; ReferenceData = source.ReferenceData; } if (currentContext != null) { ClientId = currentContext.ClientId; ClientVersion = currentContext.ClientVersion; } } /// /// Monitored event type. /// [JsonConverter(typeof(JsonStringEnumConverter))] public ReferenceEventType Type { get; set; } /// /// The kind of entity that created the event. /// [JsonConverter(typeof(JsonStringEnumConverter))] public ReferenceEventSource Source { get; set; } /// public Guid Id { get; set; } /// public string? ReferenceData { get; set; } /// /// Moment the event occurred. /// public DateTime EventDate { get; set; } = DateTime.UtcNow; /// /// Number of users sent invitations by an organization. /// /// /// Should contain a value only on events. /// Otherwise the value should be . /// public int? Users { get; set; } /// /// Whether or not a subscription was canceled immediately or at the end of the billing period. /// /// /// when a cancellation occurs immediately. /// when a cancellation occurs at the end of a customer's billing period. /// Should contain a value only on events. /// Otherwise the value should be . /// public bool? EndOfPeriod { get; set; } /// /// Branded name of the subscription. /// /// /// Should contain a value only for subscription management events. /// Otherwise the value should be . /// public string? PlanName { get; set; } /// /// Identifies a subscription. /// /// /// Should contain a value only for subscription management events. /// Otherwise the value should be . /// public PlanType? PlanType { get; set; } /// /// The branded name of the prior plan. /// /// /// Should contain a value only on events /// initiated by organizations. /// Otherwise the value should be . /// public string? OldPlanName { get; set; } /// /// Identifies the prior plan /// /// /// Should contain a value only on events /// initiated by organizations. /// Otherwise the value should be . /// public PlanType? OldPlanType { get; set; } /// /// Seat count when a billable action occurs. When adjusting seats, contains /// the new seat count. /// /// /// Should contain a value only on , /// , , /// and events initiated by organizations. /// Otherwise the value should be . /// public int? Seats { get; set; } /// /// Seat count when a seat adjustment occurs. /// /// /// Should contain a value only on /// events initiated by organizations. /// Otherwise the value should be . /// public int? PreviousSeats { get; set; } /// /// Qty in GB of storage. When adjusting storage, contains the adjusted /// storage qty. Otherwise contains the total storage quantity. /// /// /// Should contain a value only on , /// , , /// and events. /// Otherwise the value should be . /// public short? Storage { get; set; } /// /// The type of send created or accessed. /// /// /// Should contain a value only on /// and events. /// Otherwise the value should be . /// [JsonConverter(typeof(JsonStringEnumConverter))] public SendType? SendType { get; set; } /// /// Whether the send has private notes. /// /// /// when the send has private notes, otherwise . /// Should contain a value only on /// and events. /// Otherwise the value should be . /// public bool? SendHasNotes { get; set; } /// /// The send expires after its access count exceeds this value. /// /// /// This field only contains a value when the send has a max access count /// and is /// or events. /// Otherwise, the value should be . /// public int? MaxAccessCount { get; set; } /// /// Whether the created send has a password. /// /// /// Should contain a value only on /// and events. /// Otherwise the value should be . /// public bool? HasPassword { get; set; } /// /// The administrator that performed the action. /// /// /// Should contain a value only on /// and events. /// Otherwise the value should be . /// public string? EventRaisedByUser { get; set; } /// /// Whether or not an organization's trial period was started by a sales person. /// /// /// Should contain a value only on /// and events. /// Otherwise the value should be . /// public bool? SalesAssistedTrialStarted { get; set; } /// /// The installation id of the application that originated the event. /// /// /// when the event was not originated by an application. /// public string? ClientId { get; set; } /// /// The version of the client application that originated the event. /// /// /// when the event was not originated by an application. /// public Version? ClientVersion { get; set; } }