#nullable enable
using Baya.Application.Contracts.Payments;
using Baya.Domain.Entities.Bnpl;

namespace Baya.Infrastructure.CrossCutting.Seams;

/// <summary>
/// Config-driven <see cref="IBnplProviderResolver"/> — maps every known <c>provider_code</c> to the deterministic
/// <see cref="MockBnplProvider"/> (all four Iranian provider-financed BNPLs share the mock behaviour). A real
/// system registers one concrete adapter per code (<c>SnappPayBnplProvider</c>, <c>DigipayBnplProvider</c>, …)
/// and this resolver returns the right one; swapping is a registration change, <b>never</b> an <c>if (mock)</c>
/// branch in a handler. An unknown code resolves to <c>null</c> so the handler rejects it cleanly.
/// </summary>
public sealed class MockBnplProviderResolver(MockBnplProvider provider) : IBnplProviderResolver
{
    public IBnplProvider? Resolve(string providerCode)
        => BnplProviderCodes.IsKnown(providerCode) ? provider : null;
}
