using System.Text.Json;

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

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

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

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