/// <summary>
 /// Adds the specified UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion to the collection via POST.
 /// </summary>
 /// <param name="userExperienceAnalyticsAppHealthAppPerformanceByOSVersion">The UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion to add.</param>
 /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
 /// <returns>The created UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion.</returns>
 public System.Threading.Tasks.Task <UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion> AddAsync(UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion userExperienceAnalyticsAppHealthAppPerformanceByOSVersion, CancellationToken cancellationToken)
 {
     this.ContentType = "application/json";
     this.Method      = "POST";
     return(this.SendAsync <UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion>(userExperienceAnalyticsAppHealthAppPerformanceByOSVersion, cancellationToken));
 }
 /// <summary>
 /// Adds the specified UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion to the collection via POST.
 /// </summary>
 /// <param name="userExperienceAnalyticsAppHealthAppPerformanceByOSVersion">The UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion to add.</param>
 /// <returns>The created UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion.</returns>
 public System.Threading.Tasks.Task <UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion> AddAsync(UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion userExperienceAnalyticsAppHealthAppPerformanceByOSVersion)
 {
     return(this.AddAsync(userExperienceAnalyticsAppHealthAppPerformanceByOSVersion, CancellationToken.None));
 }
 /// <summary>
 /// Initializes any collection properties after deserialization, like next requests for paging.
 /// </summary>
 /// <param name="userExperienceAnalyticsAppHealthAppPerformanceByOSVersionToInitialize">The <see cref="UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion"/> with the collection properties to initialize.</param>
 private void InitializeCollectionProperties(UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion userExperienceAnalyticsAppHealthAppPerformanceByOSVersionToInitialize)
 {
 }
        /// <summary>
        /// Creates the specified UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion using POST.
        /// </summary>
        /// <param name="userExperienceAnalyticsAppHealthAppPerformanceByOSVersionToCreate">The UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion to create.</param>
        /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
        /// <returns>The created UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion.</returns>
        public async System.Threading.Tasks.Task <UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion> CreateAsync(UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion userExperienceAnalyticsAppHealthAppPerformanceByOSVersionToCreate, CancellationToken cancellationToken)
        {
            this.ContentType = "application/json";
            this.Method      = "POST";
            var newEntity = await this.SendAsync <UserExperienceAnalyticsAppHealthAppPerformanceByOSVersion>(userExperienceAnalyticsAppHealthAppPerformanceByOSVersionToCreate, cancellationToken).ConfigureAwait(false);

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

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