Skip to content

Asynchronous Support? #6

@mattmorgis

Description

@mattmorgis

I first off wanted to thank you for open sourcing this 👍 I have been working a project that required integrating with the Quickbooks Web Connector and I was up and running within an hour with this module and it acted as a fantastic resource to understand the qbwc implementation!

I started to integrate your work with my project. I'm simply running all orders processed by an e-commerce site through Quickbooks and only using two commands - CustomerAdd and InvoiceAdd.

Each time an order comes through, I save the qbXML needed to create the customer and invoice in a MySQL database. Each time the QBWC comes around polling for any commands to run, I want to replace the buildRequest() call with something like externalModule.fetchRequests(callback) and make it asynchronous since it is impossible to have a synchronous call to MySQL.

What are your thoughts on asynchronous support? Is it even possible? It would effectively make the method look like this:

qbws.QBWebConnectorSvc.QBWebConnectorSvcSoap.authenticate =
function (args) {
    var authReturn = [];

    announceMethod('authenticate', args);

    // Code below uses a random GUID to use as a session ticket
    // An example of a GUID is {85B41BEE-5CD9-427a-A61B-83964F1EB426}
    authReturn[0] = uuid.v1();

    // For simplicity of sample, a hardcoded username/password is used.
    // In real world, you should handle authentication in using a standard way.
    // For example, you could validate the username/password against an LDAP
    // or a directory server
    // TODO: This shouldn't be hard coded
    serviceLog('    Password locally stored = ' + password);

    if (args.strUserName.trim() === username && args.strPassword.trim() === password) {
        qbwcManager.fetchRequests(function(err, requests) {
            req = requests;
            if (req.length === 0) {
                authReturn[1] = 'NONE';
            } else {
                // An empty string for authReturn[1] means asking QBWebConnector
                // to connect to the company file that is currently opened in QB
                authReturn[1] = companyFile;
            }
         } else {
            authReturn[1] = 'nvu';
        }

        serviceLog('    Return values: ');
        serviceLog('        string[] authReturn[0] = ' + authReturn[0]);
        serviceLog('        string[] authReturn[1] = ' + authReturn[1]);

        return {
            authenticateResult: { 'string': [authReturn[0], authReturn[1]] }
         };
    });
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions