viewpoint
Version:
the exchange email API for nodejs module
89 lines (67 loc) • 2.69 kB
JavaScript
var Item, Mailbox, Message, NAMESPACES, TypeMixin, camelCase, pascalCase, ref,
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,
slice = [].slice;
ref = require('../ews-util'), pascalCase = ref.pascalCase, camelCase = ref.camelCase;
Item = require('./item');
TypeMixin = require('./type-mixin');
NAMESPACES = require('../ews-ns').NAMESPACES;
Mailbox = (function() {
TypeMixin.includeInto(Mailbox);
function Mailbox(node1) {
this.node = node1;
}
Mailbox.addTextMethods('name', 'emailAddress', 'routingType', 'mailboxType');
Mailbox.addAttrMethods('itemId');
return Mailbox;
})();
module.exports = Message = (function(superClass) {
extend(Message, superClass);
function Message(node) {
Message.__super__.constructor.call(this, node);
}
Message.prototype.getMailboxList = function(methodName) {
var element, i, len, node, ref1, results;
element = this.getChildNode(methodName);
if (element) {
ref1 = element.childNodes();
results = [];
for (i = 0, len = ref1.length; i < len; i++) {
node = ref1[i];
results.push(new Mailbox(node));
}
return results;
}
};
Message.addMailboxMethods = function() {
var methods;
methods = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return methods.forEach((function(_this) {
return function(methodName) {
return _this.prototype[methodName] = function() {
var element;
element = this.getChildNode(methodName);
if (element) {
return new Mailbox(element.child(0));
}
};
};
})(this));
};
Message.addMailboxListMethods = function() {
var methods;
methods = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return methods.forEach((function(_this) {
return function(methodName) {
return _this.prototype[methodName] = function() {
return this.getMailboxList(methodName);
};
};
})(this));
};
Message.addMailboxMethods('sender', 'from', 'receivedBy');
Message.addMailboxListMethods('toRecipients', 'ccRecipients', 'bccRecipients', 'replyTo');
Message.addTextMethods('conversationTopic', 'conversationIndex', 'internetMessageId', 'references', 'dateTimeSent');
Message.addBoolTextMethods('isReadReceiptRequested', 'isDeliveryReceiptRequested', 'isRead', 'isResponseRequested');
return Message;
})(Item);