using CashLineERP.SharedKernel.IslamicFinance;

namespace CashLineERP.Domain.IslamicFinance.PartnerLenders;

public sealed class IslamicFinancePartnerLenderFundingProfile
{
    public bool SupportsPartnerFunding { get; }
    public bool SupportsCashLineFunding { get; }
    public bool SupportsHybridFunding { get; }

    public IslamicFinancePartnerLenderFundingProfile(
        bool supportsPartnerFunding,
        bool supportsCashLineFunding,
        bool supportsHybridFunding)
    {
        if (!supportsPartnerFunding && !supportsCashLineFunding && !supportsHybridFunding)
        {
            throw new InvalidOperationException("Partner lender funding profile must support at least one funding source mode.");
        }

        SupportsPartnerFunding = supportsPartnerFunding;
        SupportsCashLineFunding = supportsCashLineFunding;
        SupportsHybridFunding = supportsHybridFunding;
    }

    public bool SupportsMode(IslamicFinanceFundingSourceMode fundingSourceMode) => fundingSourceMode switch
    {
        IslamicFinanceFundingSourceMode.Partner => SupportsPartnerFunding,
        IslamicFinanceFundingSourceMode.CashLine => SupportsCashLineFunding,
        IslamicFinanceFundingSourceMode.Hybrid => SupportsHybridFunding,
        _ => false
    };
}
