var CreateProductAds = function(core, target, data, returnCB){ var tool = null; this.exit = exit;; request(); function request(){ new ApiManager({ 'productFeed' : null }, core.userID, requestCB); } function requestCB(e, d){ if(isDefined(d.productFeed)){ var adFields = [ { 'key' : 'imageURL', 'className' : 'productImageSrc', 'reference' : 'productImageURL' }, { 'key' : 'logo', 'className' : 'logoImage' }, { 'title' : 'Product Merp', 'key' : 'name', 'className' : 'productName', 'reference' : 'productName' }, { 'title' : 'Product Price', 'key' : 'price', 'className' : 'productPrice', 'reference' : 'productPrice' }, { 'title' : 'Landing Page', 'key' : 'landingURL', 'className' : 'landingURL', 'reference' : 'locationURL' } ]; tool = new AdCreationTool(core, target, data, returnCB, 'Product', adFields, d.productFeed, new ProductAdTemplate, 300, 250, true); } } function exit(){ if(isDefined(tool)) tool.exit(); housekeeping(); } function housekeeping(){ tool = null; } };