ews javascript api

ServiceObject

function
 ServiceObject() 

Option name Type Description
service ExchangeService

EWS service to which this object belongs.

Internal constructor.

function ServiceObject(service) {
    //EwsUtilities.ValidateParam(service, "service");
    //EwsUtilities.ValidateServiceObjectVersion(this, service.RequestedServerVersion);
    this.lockObject = {};

OnChange

property
 this.OnChange 

Defines an event that is triggered when the service object changes.

this.OnChange = [];
this.Service = service;
this.propertyBag = new PropertyBag_1.PropertyBag(this);
    }
    Object.defineProperty(ServiceObject.prototype, "PropertyBag", {

get

method
 get() 

The property bag holding property values for this object.

get: function () { return this.propertyBag; },
enumerable: true,
configurable: true
    });
    Object.defineProperty(ServiceObject.prototype, "Schema", {

get

method
 get() 

Gets the schema associated with this type of object.

get: function () { return this.GetSchema(); },
enumerable: true,
configurable: true
    });
    Object.defineProperty(ServiceObject.prototype, "IsNew", {

get

method
 get() 

Indicates whether this object is a real store item, or if it's a local object that has yet to be saved.

get: function () {
    var id = this.GetId();
    return id == null ? true : !id.IsValid;
},
enumerable: true,
configurable: true
    });
    Object.defineProperty(ServiceObject.prototype, "IsDirty", {

get

method
 get() 

Gets a value indicating whether the object has been modified and should be saved.

get: function () {
    return this.PropertyBag.IsDirty;
},
enumerable: true,
configurable: true
    });

_getItem

method
 ServiceObject.prototype._getItem() 

Option name Type Description
propertyDefinition PropertyDefinitionBase

Definition of the property to get.

Gets the value of specified property in this instance.
This Indexer of c#

ServiceObject.prototype._getItem = function (propertyDefinition) {
    var propertyValue;
    var propDef = propertyDefinition;
    if (propDef != null) {
        //todo: check for propertydefinitionbase type or child type;
        return this.PropertyBag._getItem(propDef);
    }
    else {
        var extendedPropDef = propertyDefinition;
        if (extendedPropDef != null) {
            if (this.TryGetExtendedProperty(extendedPropDef, propertyValue)) {
                return propertyValue;
            }
            else {
                throw new ServiceObjectPropertyException_1.ServiceObjectPropertyException(Strings_1.Strings.MustLoadOrAssignPropertyBeforeAccess, propertyDefinition);
            }
        }
        else {
            // Other subclasses of PropertyDefinitionBase are not supported.
            throw new Error(ExtensionMethods_1.StringHelper.Format("not supported for property definition type: {0}", propertyDefinition.constructor));
        }
    }
};

Changed

method
 ServiceObject.prototype.Changed() 

Triggers dispatch of the change event.

ServiceObject.prototype.Changed = function () {
    if (this.OnChange != null) {
        for (var _i = 0, _a = this.OnChange; _i < _a.length; _i++) {
            var changeDelegate = _a[_i];
            changeDelegate(this);
        }
    }
};

ClearChangeLog

method
 ServiceObject.prototype.ClearChangeLog() 

Clears the object's change log.

ServiceObject.prototype.ClearChangeLog = function () { this.PropertyBag.ClearChangeLog(); };

GetChangeXmlElementName

method
 ServiceObject.prototype.GetChangeXmlElementName() 

Gets the name of the change XML element.

ServiceObject.prototype.GetChangeXmlElementName = function () { return XmlElementNames_1.XmlElementNames.ItemChange; };

GetDeleteFieldXmlElementName

method
 ServiceObject.prototype.GetDeleteFieldXmlElementName() 

Gets the name of the delete field XML element.

ServiceObject.prototype.GetDeleteFieldXmlElementName = function () { return XmlElementNames_1.XmlElementNames.DeleteItemField; };

GetExtendedProperties

method
 ServiceObject.prototype.GetExtendedProperties() 

Gets the extended properties collection.

ServiceObject.prototype.GetExtendedProperties = function () { return null; };

GetId

method
 ServiceObject.prototype.GetId() 

The unique Id of this object.

ServiceObject.prototype.GetId = function () {
    var idPropertyDefinition = this.GetIdPropertyDefinition();
    var serviceId = { outValue: null };
    if (idPropertyDefinition != null) {
        this.PropertyBag.TryGetValue(idPropertyDefinition, serviceId);
    }
    return serviceId.outValue;
};

GetIdPropertyDefinition

method
 ServiceObject.prototype.GetIdPropertyDefinition() 

The property definition for the Id of this object.

ServiceObject.prototype.GetIdPropertyDefinition = function () { return null; };

GetIsCustomDateTimeScopingRequired

method
 ServiceObject.prototype.GetIsCustomDateTimeScopingRequired() 

Determines whether properties defined with ScopedDateTimePropertyDefinition require custom time zone scoping.

ServiceObject.prototype.GetIsCustomDateTimeScopingRequired = function () { return false; };

GetIsTimeZoneHeaderRequired

method
 ServiceObject.prototype.GetIsTimeZoneHeaderRequired() 

Option name Type Description
isUpdateOperation boolean

Indicates whether the operation being petrformed is an update operation.

return boolean

true if a time zone SOAP header should be emitted; otherwise, false.

Gets a value indicating whether a time zone SOAP header should be emitted in a CreateItem or UpdateItem request so this item can be property saved or updated.

ServiceObject.prototype.GetIsTimeZoneHeaderRequired = function (isUpdateOperation) { return false; };

GetLoadedPropertyDefinitions

method
 ServiceObject.prototype.GetLoadedPropertyDefinitions() 

Gets the collection of loaded property definitions.

ServiceObject.prototype.GetLoadedPropertyDefinitions = function () {
    var propDefs = [];
    for (var _i = 0, _a = this.PropertyBag.Properties.Keys; _i < _a.length; _i++) {
        var propDef = _a[_i];
        propDefs.push(propDef);
    }
    if (this.GetExtendedProperties() != null) {
        for (var _b = 0, _c = this.GetExtendedProperties().Items; _b < _c.length; _b++) {
            var extProp = _c[_b];
            propDefs.push(extProp.PropertyDefinition);
        }
    }
    return propDefs;
};

GetMinimumRequiredServerVersion

method
 ServiceObject.prototype.GetMinimumRequiredServerVersion() 

Gets the minimum required server version.

ServiceObject.prototype.GetMinimumRequiredServerVersion = function () { throw new Error("abstract method, must implement"); };

GetSchema

method
 ServiceObject.prototype.GetSchema() 

Internal method to return the schema associated with this type of object.

ServiceObject.prototype.GetSchema = function () { throw new Error("abstract method, must implement"); };

GetSetFieldXmlElementName

method
 ServiceObject.prototype.GetSetFieldXmlElementName() 

Gets the name of the set field XML element.

ServiceObject.prototype.GetSetFieldXmlElementName = function () { return XmlElementNames_1.XmlElementNames.SetItemField; };

GetXmlElementName

method
 ServiceObject.prototype.GetXmlElementName() 

GetXmlElementName retrieves the XmlElementName of this type based on the EwsObjectDefinition attribute that decorates it, if present.

ServiceObject.prototype.GetXmlElementName = function () {
    throw new Error("ServiceObject.ts - GetXmlElementName -  this must be overridden by derived class - can not use reflection to get class attribute in javascript");
    if (ExtensionMethods_1.StringHelper.IsNullOrEmpty(this.xmlElementName)) {
        this.xmlElementName = this.GetXmlElementNameOverride();
        EwsLogging_1.EwsLogging.Assert(!ExtensionMethods_1.StringHelper.IsNullOrEmpty(this.xmlElementName), "EwsObject.GetXmlElementName", ExtensionMethods_1.StringHelper.Format("The class {0} does not have an associated XML element name.", "unknown decendent of ServiceObject - in serviceObject.GetXmlElementname"));
    }
    return this.xmlElementName;
};

GetXmlElementNameOverride

method
 ServiceObject.prototype.GetXmlElementNameOverride() 

This methods lets subclasses of ServiceObject override the default mechanism by which the XML element name associated with their type is retrieved.

ServiceObject.prototype.GetXmlElementNameOverride = function () { return null; };

InternalDelete

method
 ServiceObject.prototype.InternalDelete() 

Option name Type Description
deleteMode DeleteMode

The deletion mode.

sendCancellationsMode SendCancellationsMode

Indicates whether meeting cancellation messages should be sent.

affectedTaskOccurrences AffectedTaskOccurrence

Indicate which occurrence of a recurring task should be deleted.

Deletes the object.

ServiceObject.prototype.InternalDelete = function (deleteMode, sendCancellationsMode, affectedTaskOccurrences) {
    throw new Error("abstract method, must implement");
};

InternalLoad

method
 ServiceObject.prototype.InternalLoad() 

Option name Type Description
propertySet PropertySet

The properties to load.

Loads the specified set of properties on the object.

ServiceObject.prototype.InternalLoad = function (propertySet) { throw new Error("abstract method, must implement"); };
ServiceObject.prototype.Load = function (propertySet) {
    return this.InternalLoad(propertySet || PropertySet_1.PropertySet.FirstClassProperties);
};
//LoadFromJson(jsonObject: JsonObject, service: ExchangeService, clearPropertyBag: boolean): any { throw new Error("ServiceObject.ts - LoadFromJson : Not implemented."); }
//LoadFromJson(jsonServiceObject: JsonObject, service: ExchangeService, clearPropertyBag: boolean, requestedPropertySet: PropertySet, summaryPropertiesOnly: boolean): any { throw new Error("ServiceObject.ts - LoadFromJson : Not implemented."); }

LoadFromXmlJsObject

method
 ServiceObject.prototype.LoadFromXmlJsObject() 

Option name Type Description
jsObject any

Jason Object converted from XML.

service ExchangeService

The service.

clearPropertyBag boolean

if set to true [clear property bag].

requestedPropertySet PropertySet

The property set.

summaryPropertiesOnly boolean

if set to true [summary props only].

Loads service object from XML.

ServiceObject.prototype.LoadFromXmlJsObject = function (jsObject, service, clearPropertyBag, requestedPropertySet, summaryPropertiesOnly) {
    if (requestedPropertySet === void 0) { requestedPropertySet = null; }
    if (summaryPropertiesOnly === void 0) { summaryPropertiesOnly = false; }
    this.PropertyBag.LoadFromXmlJsObject(jsObject, service, clearPropertyBag, requestedPropertySet, summaryPropertiesOnly);
};

ThrowIfThisIsNew

method
 ServiceObject.prototype.ThrowIfThisIsNew() 

Throws exception if this is a new service object.

ServiceObject.prototype.ThrowIfThisIsNew = function () {
    if (this.IsNew) {
        throw new Error("service object does not have id"); //InvalidOperationException(Strings.ServiceObjectDoesNotHaveId);
    }
};

ThrowIfThisIsNotNew

method
 ServiceObject.prototype.ThrowIfThisIsNotNew() 

Throws exception if this is not a new service object.

ServiceObject.prototype.ThrowIfThisIsNotNew = function () {
    if (!this.IsNew) {
        throw new Error("service object already have id"); //InvalidOperationException(Strings.ServiceObjectAlreadyHasId);
    }
};
//ToJson(service: ExchangeService, isUpdateOperation: boolean): any { return this.PropertyBag.ToJson(service, isUpdateOperation);}

TryGetExtendedProperty

method
 ServiceObject.prototype.TryGetExtendedProperty() 

Option name Type Description
propertyDefinition ExtendedPropertyDefinition

The property definition.

propertyValue IOutParam.<T>

The property value.

return boolean

True if property retrieved, false otherwise.

Try to get the value of a specified extended property in this instance.

ServiceObject.prototype.TryGetExtendedProperty = function (propertyDefinition, propertyValue) {
    var propertyCollection = this.GetExtendedProperties();
    if ((propertyCollection != null) &&
        propertyCollection.TryGetValue(propertyDefinition, propertyValue)) {
        return true;
    }
    else {
        propertyValue.outValue = null; //default(T);
        return false;
    }
};
//todo:fix - implement type casting on specific type request version. 
//TryGetProperty<T>(propertyDefinition: PropertyDefinitionBase, propertyValue: any): boolean { throw new Error("Need implementation."); }
//TryGetProperty(propertyDefinition: PropertyDefinitionBase, propertyValue: any): boolean { throw new Error("ServiceObject.ts - TryGetProperty : Not implemented."); }

TryGetProperty

method
 ServiceObject.prototype.TryGetProperty() 

Option name Type Description
propertyDefinition PropertyDefinitionBase

The property definition.

propertyValue IOutParam.<T>

The property value.

return boolean

True if property retrieved, false otherwise.

Try to get the value of a specified property in this instance.

ServiceObject.prototype.TryGetProperty = function (propertyDefinition, propertyValue) {
    var propDef = propertyDefinition; // as PropertyDefinition;
    debugger; //todo: fix for compatibility checking, if this is propertydefinition or propertydefinitionbase
    if (propDef != null) {
        return this.PropertyBag.TryGetPropertyAs(propDef, propertyValue);
    }
    else {
        debugger; //todo: check for compatibility of extendedpropertydefition or propertydefition.
        var extPropDef = propertyDefinition; // as ExtendedPropertyDefinition;
        if (extPropDef != null) {
            return this.TryGetExtendedProperty(extPropDef, propertyValue);
        }
        else {
            // Other subclasses of PropertyDefinitionBase are not supported.
            throw new Error(ExtensionMethods_1.StringHelper.Format(Strings_1.Strings.OperationNotSupportedForPropertyDefinitionType, propertyDefinition.Type)); //NotSupportedException
        }
    }
};

Validate

method
 ServiceObject.prototype.Validate() 

Validates this instance.

ServiceObject.prototype.Validate = function () { this.PropertyBag.Validate(); };
//WriteToJsonForUpdate(service: ExchangeService): any { throw new Error("ServiceObject.ts - WriteToJsonForUpdate : Not implemented."); }

WriteToXml

method
 ServiceObject.prototype.WriteToXml() 

Option name Type Description
writer EwsServiceXmlWriter

The writer.

Writes service object as XML.

ServiceObject.prototype.WriteToXml = function (writer) { this.PropertyBag.WriteToXml(writer); };

WriteToXmlForUpdate

method
 ServiceObject.prototype.WriteToXmlForUpdate() 

Option name Type Description
writer EwsServiceXmlWriter

The writer.

Writes service object for update as XML.

ServiceObject.prototype.WriteToXmlForUpdate = function (writer) { this.PropertyBag.WriteToXmlForUpdate(writer); };
Object.defineProperty(ServiceObject.prototype, "InstanceType", {

get

method
 get() 

created this to help find serviceobject type, ServiceObjectInstance instanceof Item/Folder/Attachment fails by creating circular dependency in javascript/typescript

get: function () { return "ServiceObject"; },
enumerable: true,
configurable: true
    });
    Object.defineProperty(ServiceObject.prototype, "IsAttachment", {

get

method
 get() 

created this to keep item and folder object away from here. modularization would fail and create a larger file

get: function () { return false; } //only item instance would return true.
,
enumerable: true,
configurable: true
    });
    return ServiceObject;
})();
exports.ServiceObject = ServiceObject;