d2c4d6671bde02c4f15e2dd6a9d39e59b2761633Dav Glass/*global Y: false, Buffer: false, clearInterval: false, clearTimeout: false, console: false, exports: false, global: false, module: false, process: false, querystring: false, require: false, setInterval: false, setTimeout: false, __filename: false, __dirname: false */
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass * Passthru to the NodeJS <a href="https://github.com/mikeal/request">request</a> module.
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass * This method is return of `require('request')` so you can use it inside NodeJS without
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass * the IO abstraction.
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass * @method request
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass Y.log('Loading NodeJS Request Transport', 'info', 'io');
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass NodeJS IO transport, uses the NodeJS <a href="https://github.com/mikeal/request">request</a>
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass module under the hood to perform all network IO.
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass @method transports.nodejs
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass @returns {Object} This object contains only a `send` method that accepts a
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass `transaction object`, `uri` and the `config object`.
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass method: 'PUT',
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass data: '?foo=bar',
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass //Extra request module config options.
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass maxRedirects: 100,
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass strictSSL: true,
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass multipart: [
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass 'content-type': 'application/json',
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass body: JSON.stringify({
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass _attachments: {
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass follows: true,
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass 'content_type': 'text/plain'
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass body: 'I am an attachment'
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass success: function(id, e) {
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass Y.log(e.responseText);
d2c4d6671bde02c4f15e2dd6a9d39e59b2761633Dav Glass var flatten = function(o) {
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass Y.log('Starting Request Transaction', 'info', 'io');
d2c4d6671bde02c4f15e2dd6a9d39e59b2761633Dav Glass Y.log('Initiating ' + rconf.method + ' request to: ' + rconf.uri, 'info', 'io');
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass Y.log('Request Transaction Complete', 'info', 'io');
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass config.notify(((err.code === 'ETIMEDOUT') ? 'timeout' : 'failure'), transaction, config);
ec16856c3004ac9791cefede79e459e2f4a1d1c0Dav Glass Y.log('Request Transaction Complete', 'info', 'io');
e7a8de4b7486f0890b36c9effa2703630dd6faa5Dav Glass config.notify(((data && (data.statusCode >= 200 && data.statusCode <= 299)) ? 'success' : 'failure'), transaction, config);