using MongoDB.Bson;

namespace adas_core.Domain.Models.Responses;

/// <summary>
/// Represents a response payload for a beacon, encapsulating its color, point-of-contact identifier, and associated unit identifier.
/// </summary>
/// <remarks>
/// Implements <see cref="IEquatable{T}"/> to enable value-based equality comparison between <see cref="BeaconResponse"/> instances.
/// </remarks>
public class BeaconResponse(string color, ObjectId poc, ObjectId unitId) : IEquatable<BeaconResponse>
{
    private string Color { get; } = color;
    private ObjectId PointOfCareId { get; } = poc;

    private ObjectId UnitId { get; } = unitId;

    /// <summary>
    /// Determines whether the specified <see cref="BeaconResponse"/> is equal to the current instance by comparing their <c>PointOfCareId</c> and <c>UnitId</c> values.
    /// </summary>
    /// <param name="other">The <see cref="BeaconResponse"/> to compare with the current instance.</param>
    /// <returns><see langword="true"/> if both <c>PointOfCareId</c> and <c>UnitId</c> match; otherwise, <see langword="false"/>.</returns>
    public bool Equals(BeaconResponse? other)
        {
            return PointOfCareId == other?.PointOfCareId && UnitId == other.UnitId;
        }

    /// <summary>
    /// Returns a string representation of the BeaconResponse, including the point of care identifier, unit (bed) identifier, and color.
    /// </summary>
    /// <returns>A formatted string describing the beacon's point of care, unit, and color.</returns>
    public override string ToString()
        {
            return "BeaconResponse[pointOfCare: " + PointOfCareId + ", bed: " + UnitId + ", color: " + Color + "]";
        }
}