/// <summary> /// Updates the specified MessageRule using PATCH. /// </summary> /// <param name="messageRuleToUpdate">The MessageRule to update.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception> /// <returns>The updated MessageRule.</returns> public async System.Threading.Tasks.Task <MessageRule> UpdateAsync(MessageRule messageRuleToUpdate, CancellationToken cancellationToken) { if (messageRuleToUpdate.AdditionalData != null) { if (messageRuleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || messageRuleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, messageRuleToUpdate.GetType().Name) }); } } if (messageRuleToUpdate.AdditionalData != null) { if (messageRuleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) || messageRuleToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode)) { throw new ClientException( new Error { Code = GeneratedErrorConstants.Codes.NotAllowed, Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, messageRuleToUpdate.GetType().Name) }); } } this.ContentType = "application/json"; this.Method = "PATCH"; var updatedEntity = await this.SendAsync <MessageRule>(messageRuleToUpdate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(updatedEntity); return(updatedEntity); }
/// <summary> /// Save message rule. /// </summary> /// <returns></returns> public void Save() { this.PreValidateSave(); MessageRule rule = this.Service.CreateInboxRule(this); this.propertyBag = rule.propertyBag; this.MailboxId = rule.MailboxId; }
/// <summary> /// Creates the specified MessageRule using POST. /// </summary> /// <param name="messageRuleToCreate">The MessageRule to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created MessageRule.</returns> public async System.Threading.Tasks.Task <MessageRule> CreateAsync(MessageRule messageRuleToCreate, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; var newEntity = await this.SendAsync <MessageRule>(messageRuleToCreate, cancellationToken).ConfigureAwait(false); this.InitializeCollectionProperties(newEntity); return(newEntity); }
/// <summary> /// Creates the specified MessageRule using POST. /// </summary> /// <param name="messageRuleToCreate">The MessageRule to create.</param> /// <returns>The created MessageRule.</returns> public System.Threading.Tasks.Task <MessageRule> CreateAsync(MessageRule messageRuleToCreate) { return(this.CreateAsync(messageRuleToCreate, CancellationToken.None)); }
/// <summary> /// Initializes any collection properties after deserialization, like next requests for paging. /// </summary> /// <param name="messageRuleToInitialize">The <see cref="MessageRule"/> with the collection properties to initialize.</param> private void InitializeCollectionProperties(MessageRule messageRuleToInitialize) { }
/// <summary> /// Adds the specified MessageRule to the collection via POST. /// </summary> /// <param name="messageRule">The MessageRule to add.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <returns>The created MessageRule.</returns> public System.Threading.Tasks.Task <MessageRule> AddAsync(MessageRule messageRule, CancellationToken cancellationToken) { this.ContentType = "application/json"; this.Method = "POST"; return(this.SendAsync <MessageRule>(messageRule, cancellationToken)); }
/// <summary> /// Adds the specified MessageRule to the collection via POST. /// </summary> /// <param name="messageRule">The MessageRule to add.</param> /// <returns>The created MessageRule.</returns> public System.Threading.Tasks.Task <MessageRule> AddAsync(MessageRule messageRule) { return(this.AddAsync(messageRule, CancellationToken.None)); }