ews javascript api

__extends

declaration
 __extends 

var __extends = this.__extends || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    __.prototype = b.prototype;
    d.prototype = new __();
};
var PropertyException_1 = require("../../../Exceptions/PropertyException");
var Strings_1 = require("../../../Strings");
var PropertySet_1 = require("../../PropertySet");
var ExchangeVersion_1 = require("../../../Enumerations/ExchangeVersion");
var EnumToExchangeVersionMappingHelper_1 = require("../../../Enumerations/EnumToExchangeVersionMappingHelper");
var EwsUtilities_1 = require("../../EwsUtilities");
var ItemAttachment_1 = require("../../../ComplexProperties/ItemAttachment");
var XmlElementNames_1 = require("../../XmlElementNames");
var ContactSchema_1 = require("../Schemas/ContactSchema");
var Item_1 = require("./Item");
var Contact = (function (_super) {
    __extends(Contact, _super);
    function Contact(serviceOrParentAttachment) {
        _super.call(this, serviceOrParentAttachment instanceof ItemAttachment_1.ItemAttachment ? serviceOrParentAttachment.Service : serviceOrParentAttachment); //todo:fix -can not user instanceof with exchangeservice, creates circular loop with ewsutility 
    }
    Object.defineProperty(Contact.prototype, "FileAs", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.FileAs);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.FileAs, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "FileAsMapping", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.FileAsMapping);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.FileAsMapping, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "DisplayName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.DisplayName);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.DisplayName, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "GivenName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.GivenName);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.GivenName, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Initials", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Initials);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Initials, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "MiddleName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.MiddleName);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.MiddleName, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "NickName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.NickName);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.NickName, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "CompleteName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.CompleteName);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "CompanyName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.CompanyName);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.CompanyName, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "EmailAddresses", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.EmailAddresses);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "PhysicalAddresses", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.PhysicalAddresses);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "PhoneNumbers", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.PhoneNumbers);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "AssistantName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.AssistantName);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.AssistantName, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Birthday", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Birthday);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Birthday, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "BusinessHomePage", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.BusinessHomePage);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.BusinessHomePage, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Children", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Children);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Children, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Companies", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Companies);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Companies, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "ContactSource", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.ContactSource);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Department", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Department);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Department, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Generation", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Generation);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Generation, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "ImAddresses", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.ImAddresses);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "JobTitle", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.JobTitle);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.JobTitle, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Manager", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Manager);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Manager, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Mileage", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Mileage);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Mileage, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "OfficeLocation", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.OfficeLocation);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.OfficeLocation, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "PostalAddressIndex", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.PostalAddressIndex);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.PostalAddressIndex, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Profession", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Profession);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Profession, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "SpouseName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.SpouseName);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.SpouseName, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Surname", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Surname);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.Surname, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "WeddingAnniversary", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.WeddingAnniversary);
        },
        set: function (value) {
            this.PropertyBag._setItem(ContactSchema_1.ContactSchema.WeddingAnniversary, value);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "HasPicture", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.HasPicture);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "PhoneticFullName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.PhoneticFullName);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "PhoneticFirstName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.PhoneticFirstName);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "PhoneticLastName", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.PhoneticLastName);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Alias", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Alias);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "Notes", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Notes);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "DirectoryPhoto", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.Photo);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "UserSMIMECertificate", {
        get: function () {
            var byteArrayArray = this.PropertyBag._getItem(ContactSchema_1.ContactSchema.UserSMIMECertificate);
            return byteArrayArray.Content;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "MSExchangeCertificate", {
        get: function () {
            var byteArrayArray = this.PropertyBag._getItem(ContactSchema_1.ContactSchema.MSExchangeCertificate);
            return byteArrayArray.Content;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "DirectoryId", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.DirectoryId);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "ManagerMailbox", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.ManagerMailbox);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Contact.prototype, "DirectReports", {
        get: function () {
            return this.PropertyBag._getItem(ContactSchema_1.ContactSchema.DirectReports);
        },
        enumerable: true,
        configurable: true
    });
    Contact.prototype.Bind = function (service, id, propertySet) {
        if (propertySet === void 0) { propertySet = PropertySet_1.PropertySet.FirstClassProperties; }
        return Contact.Bind(service, id, propertySet);
    };
    Contact.Bind = function (service, id, propertySet) {
        if (propertySet === void 0) { propertySet = PropertySet_1.PropertySet.FirstClassProperties; }
        return service.BindToItem(id, propertySet, Contact);
    };
    Contact.prototype.GetContactPictureAttachment = function () {
        EwsUtilities_1.EwsUtilities.ValidateMethodVersion(this.Service, ExchangeVersion_1.ExchangeVersion.Exchange2010, "GetContactPictureAttachment");
        if (!this.PropertyBag.IsPropertyLoaded(ContactSchema_1.ContactSchema.Attachments)) {
            throw new PropertyException_1.PropertyException(Strings_1.Strings.AttachmentCollectionNotLoaded);
        }
        for (var _i = 0, _a = this.Attachments.Items; _i < _a.length; _i++) {
            var attachment = _a[_i];
            //todo: implement typecasting
            var fileAttachment = attachment;
            if (fileAttachment.IsContactPhoto) {
                return fileAttachment;
            }
        }
        return null;
    };
    Contact.prototype.GetMinimumRequiredServerVersion = function () { return ExchangeVersion_1.ExchangeVersion.Exchange2007_SP1; };
    Contact.prototype.GetSchema = function () { return ContactSchema_1.ContactSchema.Instance; };
    Contact.prototype.GetXmlElementName = function () { return XmlElementNames_1.XmlElementNames.Contact; };
    Contact.prototype.InternalRemoveContactPicture = function () {
        // Iterates in reverse order to remove file attachments that have IsContactPhoto set to true.
        for (var index = this.Attachments.Count - 1; index >= 0; index--) {
            //todo: implement safe typecasting
            var fileAttachment = this.Attachments.__thisIndexer(index);
            if (fileAttachment != null) {
                if (fileAttachment.IsContactPhoto) {
                    this.Attachments.Remove(fileAttachment);
                }
            }
        }
    };
    Contact.prototype.RemoveContactPicture = function () {
        EwsUtilities_1.EwsUtilities.ValidateMethodVersion(this.Service, ExchangeVersion_1.ExchangeVersion.Exchange2010, "RemoveContactPicture");
        if (!this.PropertyBag.IsPropertyLoaded(ContactSchema_1.ContactSchema.Attachments)) {
            throw new PropertyException_1.PropertyException(Strings_1.Strings.AttachmentCollectionNotLoaded);
        }
        this.InternalRemoveContactPicture();
    };
    //SetContactPicture(contentStream: any /*System.IO.Stream*/): any { throw new Error("Contact.ts - SetContactPicture : Not implemented."); }
    //SetContactPicture(content: number[] /*System.Byte[]*/): any { throw new Error("Contact.ts - SetContactPicture : Not implemented."); }
    //SetContactPicture(fileName: string): any { throw new Error("Contact.ts - SetContactPicture : Not implemented."); }
    Contact.prototype.SetContactPicture = function (fileNameOrContent) { throw new Error("Contact.ts - SetContactPicture : Not implemented."); };
    Contact.prototype.Validate = function () {
        _super.prototype.Validate.call(this);
        var fileAsMapping = { outValue: null };
        if (this.TryGetProperty(ContactSchema_1.ContactSchema.FileAsMapping, fileAsMapping)) {
            // FileAsMapping is extended by 5 new values in 2010 mode. Validate that they are used according the version.
            EwsUtilities_1.EwsUtilities.ValidateEnumVersionValue(EnumToExchangeVersionMappingHelper_1.EnumToExchangeVersionMappingHelper.FileAsMapping, fileAsMapping.outValue, this.Service.RequestedServerVersion);
        }
    };
    Contact.ContactPictureName = "ContactPicture.jpg";
    return Contact;
})(Item_1.Item);
exports.Contact = Contact;