viewpoint
Version:
the exchange email API for nodejs module
71 lines (55 loc) • 1.6 kB
JavaScript
var Attachment, TypeMixin, pascalCase;
pascalCase = require('../ews-util').pascalCase;
TypeMixin = require('./type-mixin');
module.exports = Attachment = (function() {
TypeMixin.includeInto(Attachment);
function Attachment(node) {
this.node = node;
}
Attachment.prototype.attachmentId = function() {
var idNode;
idNode = this.getChildNode('attachmentId');
if (idNode) {
return idNode.attrVal('Id');
}
};
Attachment.prototype.type = function() {
return /^(Item|File)/.exec(this.node.name())[1].toLowerCase();
};
Attachment.prototype.size = function() {
var element;
element = this.getChildNode('size');
if (element) {
return parseInt(element.text());
}
};
Attachment.prototype.lastModifiedTime = function() {
var element;
element = this.getChildNode('lastModifiedTime');
if (element) {
return element.text();
}
};
Attachment.prototype.isInline = function() {
var element;
element = this.getChildNode('isInline');
if (element) {
return element.text() === 'true';
}
};
Attachment.prototype.item = function() {
return this.getChildNode('item');
};
Attachment.prototype.message = function() {
return this.getChildNode('message');
};
Attachment.prototype.content = function() {
var contentNode;
contentNode = this.getChildNode('content');
if (contentNode) {
return new Buffer(contentNode.text(), 'base64');
}
};
Attachment.addTextMethods('name', 'contentType', 'contentId', 'contentLocation');
return Attachment;
})();