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

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

                    if (!string.IsNullOrEmpty(nextPageLinkString))
                    {
                        windows10PkcsCertificateProfileToInitialize.ManagedDeviceCertificateStates.InitializeNextPageRequest(
                            this.Client,
                            nextPageLinkString);
                    }
                }
            }
        }
        /// <summary>
        /// Creates the specified Windows10PkcsCertificateProfile using POST.
        /// </summary>
        /// <param name="windows10PkcsCertificateProfileToCreate">The Windows10PkcsCertificateProfile to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created Windows10PkcsCertificateProfile.</returns>
        public async System.Threading.Tasks.Task <Windows10PkcsCertificateProfile> CreateAsync(Windows10PkcsCertificateProfile windows10PkcsCertificateProfileToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <Windows10PkcsCertificateProfile>(windows10PkcsCertificateProfileToCreate, cancellationToken).ConfigureAwait(false);

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }