viewpoint
Version:
the exchange email API for nodejs module
61 lines (46 loc) • 1.66 kB
JavaScript
var HttpRequestPool, Mixin, NtlmAuthFilter, RequestClient, _, globalFilterManager, https,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
HttpRequestPool = require('./http-request-pool');
https = require('https');
_ = require('underscore');
globalFilterManager = require('http-ext').globalFilterManager;
NtlmAuthFilter = require('http-ext-ntlm');
Mixin = require('mixto');
globalFilterManager.use(NtlmAuthFilter);
module.exports = RequestClient = (function(superClass) {
extend(RequestClient, superClass);
function RequestClient(url, options) {
var base;
if (options == null) {
options = {};
}
this.requestPool = new HttpRequestPool;
this.url = url;
this.options = _.clone(options);
this.options.headers = {
'Content-Type': 'text/xml'
};
if ((base = this.options).agent == null) {
base.agent = new https.Agent({
keepAlive: true
});
}
}
RequestClient.prototype.setAuth = function(username, password, domain) {
return this.options.ntlmAuth = {
username: username,
password: password,
domain: domain
};
};
RequestClient.prototype.setUrl = function(url1) {
this.url = url1;
};
RequestClient.prototype.send = function(soapMsg) {
return this.requestPool.post(this.url, _.extend({
body: soapMsg
}, this.options));
};
return RequestClient;
})(Mixin);