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

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

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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        synchronizationSchemaToInitialize.Directories.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
 /// <summary>
 /// Creates the specified SynchronizationSchema using POST.
 /// </summary>
 /// <param name="synchronizationSchemaToCreate">The SynchronizationSchema to create.</param>
 /// <returns>The created SynchronizationSchema.</returns>
 public System.Threading.Tasks.Task <SynchronizationSchema> CreateAsync(SynchronizationSchema synchronizationSchemaToCreate)
 {
     return(this.CreateAsync(synchronizationSchemaToCreate, CancellationToken.None));
 }