Last active
December 27, 2015 11:49
-
-
Save jamescarr/7321326 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function parseThatXML(content, rootElement) { | |
| var result = {}, $el = $(content).find(rootElement); | |
| $el.children().each(function() { | |
| result[this.nodeName] = $(this).text(); | |
| }); | |
| return result; | |
| } | |
| var Zap = { | |
| customers_post_poll:function(bundle, cb) { | |
| var customers = $.parseXML(bundle.response.content).getElementsByTagName('Customer'); | |
| var lookupCustomers = _.map($(customers), function(element) { | |
| var CustomerID = $(element).find('CustomerID').text(); | |
| var req = bundle.request; | |
| req.url = req.url + '/'+ CustomerID | |
| return function(next) { | |
| z.request(req, function(err, response) { | |
| var customer = parseThatXML($.parseXML(response.content), 'Customer') | |
| next(err, customer); | |
| }); | |
| } | |
| }); | |
| async.parallel(lookupCustomers, function(err, results) { | |
| cb(err, results); | |
| }) | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment