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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        todoTaskListToInitialize.Extensions.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }

                if (todoTaskListToInitialize.Tasks != null && todoTaskListToInitialize.Tasks.CurrentPage != null)
                {
                    todoTaskListToInitialize.Tasks.AdditionalData = todoTaskListToInitialize.AdditionalData;

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

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