using BuildingBlock.Identity.Contracts.Responses;
using Thalos.Domain.Contracts;

namespace Thalos.Domain.Decisions;

/// <summary>
/// Default domain implementation for token issuance fallback semantics.
/// </summary>
public sealed class IdentityTokenDecisionService : IIdentityTokenDecisionService
{
    /// <inheritdoc />
    public IssueIdentityTokenResponse BuildIssuedTokenResponse(IdentityTokenData tokenData)
    {
        if (string.IsNullOrWhiteSpace(tokenData.Token) || !tokenData.ExpiresInSeconds.HasValue)
        {
            return new IssueIdentityTokenResponse(string.Empty, 0);
        }

        return new IssueIdentityTokenResponse(tokenData.Token, tokenData.ExpiresInSeconds.Value);
    }
}
