lib/DataContext.js
function(iface)
    {
        var hash        = {};
        var collection  = iface.__name__.substring(1);
        var dataContext = this;

        _(typedef.signature(iface)).each(function (info, key) {

            // create the function that calls method call and returns a promise
            hash[key] = function() {
                var args       = [dataContext.apiKey].concat(_(arguments).toArray());
                //http://community.infusionsoft.com/showthread.php/2140-API-vs-Web-Form?p=8853&viewfull=1#post8853
                //There is an issue in the sendTemplate function, it needs to be sendEmail
                if (key == 'sendTemplate') {
                    key = 'sendEmail';
                }
                var methodName = collection + '.' + key;
                var d          = Q.defer();

                dataContext.client.methodCall(methodName, args, d.makeNodeResolver());

                return d.promise;
            };
        });

        // instantiate a version of this class
        this[collection] = new (typedef.class(collection).define(hash))();
    }
function(iface)
    {
        var hash        = {};
        var collection  = iface.__name__.substring(1);
        var dataContext = this;

        _(typedef.signature(iface)).each(function (info, key) {

            // create the function that calls method call and returns a promise
            hash[key] = function() {
                var args       = [dataContext.apiKey].concat(_(arguments).toArray());
                //http://community.infusionsoft.com/showthread.php/2140-API-vs-Web-Form?p=8853&viewfull=1#post8853
                //There is an issue in the sendTemplate function, it needs to be sendEmail
                if (key == 'sendTemplate') {
                    key = 'sendEmail';
                }
                var methodName = collection + '.' + key;
                var d          = Q.defer();

                dataContext.client.methodCall(methodName, args, d.makeNodeResolver());

                return d.promise;
            };
        });

        // instantiate a version of this class
        this[collection] = new (typedef.class(collection).define(hash))();
    }
function ( iface ) { var hash = { } ; var collection = iface . __name__ . substring ( 1 ) ; var dataContext = this ; _ ( typedef . signature ( iface ) ) . each ( function ( info , key ) { // create the function that calls method call and returns a promise hash [ key ] = function ( ) { var args = [ dataContext . apiKey ] . concat ( _ ( arguments ) . toArray ( ) ) ; //http://community.infusionsoft.com/showthread.php/2140-API-vs-Web-Form?p=8853&viewfull=1#post8853 //There is an issue in the sendTemplate function, it needs to be sendEmail if ( key == 'sendTemplate' ) { key = 'sendEmail' ; } var methodName = collection + '.' + key ; var d = Q . defer ( ) ; dataContext . client . methodCall ( methodName , args , d . makeNodeResolver ( ) ) ; return d . promise ; } ; } ) ; // instantiate a version of this class this [ collection ] = new ( typedef . class ( collection ) . define ( hash ) ) ( ) ; }
Given an interface, create and instantiate a class that let's us call all of the methods
Given an interface create and instantiate a class that let s us call all of the methods