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

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

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

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

            this.InitializeCollectionProperties(updatedEntity);
            return(updatedEntity);
        }
 /// <summary>
 /// Adds the specified DeviceManagementTemplateSettingCategory to the collection via POST.
 /// </summary>
 /// <param name="deviceManagementTemplateSettingCategory">The DeviceManagementTemplateSettingCategory to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created DeviceManagementTemplateSettingCategory.</returns>
 public System.Threading.Tasks.Task <DeviceManagementTemplateSettingCategory> AddAsync(DeviceManagementTemplateSettingCategory deviceManagementTemplateSettingCategory, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <DeviceManagementTemplateSettingCategory>(deviceManagementTemplateSettingCategory, cancellationToken));
 }