using System.Text.Json;

namespace Inspectron.Epson.PrintServer.Printers.Utils.KitchenReceipt;

public class KitchenReceiptConverterAdapter : IReceiptConverter
{
    private readonly int _lineWidth;
    private readonly int _bigFontLineWidth;

    public KitchenReceiptConverterAdapter(int lineWidth, int bigFontLineWidth)
    {
        _lineWidth = lineWidth;
        _bigFontLineWidth = bigFontLineWidth;
    }

    public List<PrintCommand> Convert(string jsonContent)
    {
        var receipt = JsonSerializer.Deserialize<KitchenReceipt>(jsonContent);
        var converter = new KitchenReceiptConverter(_lineWidth, _bigFontLineWidth);
        return converter.ConvertToPrintCommands(receipt);
    }
}
