using System.Text.Json;

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

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

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

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