/// <summary>
        /// Updates the specified OutlookTaskGroup using PATCH.
        /// </summary>
        /// <param name="outlookTaskGroupToUpdate">The OutlookTaskGroup 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 OutlookTaskGroup.</returns>
        public async System.Threading.Tasks.Task <OutlookTaskGroup> UpdateAsync(OutlookTaskGroup outlookTaskGroupToUpdate, CancellationToken cancellationToken)
        {
            if (outlookTaskGroupToUpdate.AdditionalData != null)
            {
                if (outlookTaskGroupToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    outlookTaskGroupToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, outlookTaskGroupToUpdate.GetType().Name)
                    });
                }
            }
            if (outlookTaskGroupToUpdate.AdditionalData != null)
            {
                if (outlookTaskGroupToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
                    outlookTaskGroupToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
                {
                    throw new ClientException(
                              new Error
                    {
                        Code    = GeneratedErrorConstants.Codes.NotAllowed,
                        Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, outlookTaskGroupToUpdate.GetType().Name)
                    });
                }
            }
            this.ContentType = "application/json";
            this.Method      = "PATCH";
            var updatedEntity = await this.SendAsync <OutlookTaskGroup>(outlookTaskGroupToUpdate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
        /// <summary>
        /// Creates the specified OutlookTaskGroup using POST.
        /// </summary>
        /// <param name="outlookTaskGroupToCreate">The OutlookTaskGroup to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created OutlookTaskGroup.</returns>
        public async System.Threading.Tasks.Task <OutlookTaskGroup> CreateAsync(OutlookTaskGroup outlookTaskGroupToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <OutlookTaskGroup>(outlookTaskGroupToCreate, cancellationToken).ConfigureAwait(false);

            this.InitializeCollectionProperties(newEntity);
            return(newEntity);
        }
        /// <summary>
        /// Initializes any collection properties after deserialization, like next requests for paging.
        /// </summary>
        /// <param name="outlookTaskGroupToInitialize">The <see cref="OutlookTaskGroup"/> with the collection properties to initialize.</param>
        private void InitializeCollectionProperties(OutlookTaskGroup outlookTaskGroupToInitialize)
        {
            if (outlookTaskGroupToInitialize != null && outlookTaskGroupToInitialize.AdditionalData != null)
            {
                if (outlookTaskGroupToInitialize.TaskFolders != null && outlookTaskGroupToInitialize.TaskFolders.CurrentPage != null)
                {
                    outlookTaskGroupToInitialize.TaskFolders.AdditionalData = outlookTaskGroupToInitialize.AdditionalData;

                    object nextPageLink;
                    outlookTaskGroupToInitialize.AdditionalData.TryGetValue("*****@*****.**", out nextPageLink);
                    var nextPageLinkString = nextPageLink as string;

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        outlookTaskGroupToInitialize.TaskFolders.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Adds the specified OutlookTaskGroup to the collection via POST.
 /// </summary>
 /// <param name="outlookTaskGroup">The OutlookTaskGroup to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created OutlookTaskGroup.</returns>
 public System.Threading.Tasks.Task <OutlookTaskGroup> AddAsync(OutlookTaskGroup outlookTaskGroup, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <OutlookTaskGroup>(outlookTaskGroup, cancellationToken));
 }
 /// <summary>
 /// Adds the specified OutlookTaskGroup to the collection via POST.
 /// </summary>
 /// <param name="outlookTaskGroup">The OutlookTaskGroup to add.</param>
 /// <returns>The created OutlookTaskGroup.</returns>
 public System.Threading.Tasks.Task <OutlookTaskGroup> AddAsync(OutlookTaskGroup outlookTaskGroup)
 {
     return(this.AddAsync(outlookTaskGroup, CancellationToken.None));
 }
 /// <summary>
 /// Creates the specified OutlookTaskGroup using POST.
 /// </summary>
 /// <param name="outlookTaskGroupToCreate">The OutlookTaskGroup to create.</param>
 /// <returns>The created OutlookTaskGroup.</returns>
 public System.Threading.Tasks.Task <OutlookTaskGroup> CreateAsync(OutlookTaskGroup outlookTaskGroupToCreate)
 {
     return(this.CreateAsync(outlookTaskGroupToCreate, CancellationToken.None));
 }