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

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

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

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

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