using System;
using Interop.QBFC16; // Ensure this matches your DLL version

public class QuickBooksConnector
{
    public string ProcessQBXML(string qbxmlRequest)
    {
        try
        {
            QBSessionManager sessionManager = new QBSessionManager();
            sessionManager.OpenConnection("", "YourAppName");
            sessionManager.BeginSession("", ENOpenMode.omDontCare);

            IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 13, 0);
            requestMsgSet.AppendXML(qbxmlRequest);

            IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
            string qbxmlResponse = responseMsgSet.ToXMLString();

            sessionManager.EndSession();
            sessionManager.CloseConnection();

            return qbxmlResponse;
        }
        catch (Exception ex)
        {
            return $"Error: {ex.Message}";
        }
    }
}